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