mirror of https://github.com/status-im/consul.git
ui: Add unique slug key id to proxy (#8479)
This commit is contained in:
parent
102b7e55da
commit
2d30d864ce
|
@ -2,10 +2,10 @@ import Model from 'ember-data/model';
|
|||
import attr from 'ember-data/attr';
|
||||
|
||||
export const PRIMARY_KEY = 'uid';
|
||||
export const SLUG_KEY = 'ID';
|
||||
export const SLUG_KEY = 'Node,ServiceID';
|
||||
export default Model.extend({
|
||||
[PRIMARY_KEY]: attr('string'),
|
||||
[SLUG_KEY]: attr('string'),
|
||||
ID: attr('string'),
|
||||
ServiceName: attr('string'),
|
||||
ServiceID: attr('string'),
|
||||
Node: attr('string'),
|
||||
|
|
|
@ -4,16 +4,20 @@ export default function(foreignKey, nspaceKey, hash = JSON.stringify) {
|
|||
throw new Error('Unable to create fingerprint, missing foreignKey value');
|
||||
}
|
||||
return function(item) {
|
||||
if (item[slugKey] == null || item[slugKey].length < 1) {
|
||||
throw new Error('Unable to create fingerprint, missing slug');
|
||||
}
|
||||
const slugKeys = slugKey.split(',');
|
||||
const slugValues = slugKeys.map(function(slugKey) {
|
||||
if (item[slugKey] == null || item[slugKey].length < 1) {
|
||||
throw new Error('Unable to create fingerprint, missing slug');
|
||||
}
|
||||
return item[slugKey];
|
||||
});
|
||||
const nspaceValue = item[nspaceKey] || 'default';
|
||||
return {
|
||||
...item,
|
||||
...{
|
||||
[nspaceKey]: nspaceValue,
|
||||
[foreignKey]: foreignKeyValue,
|
||||
[primaryKey]: hash([nspaceValue, foreignKeyValue, item[slugKey]]),
|
||||
[primaryKey]: hash([nspaceValue, foreignKeyValue].concat(slugValues)),
|
||||
},
|
||||
};
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue