open-consul/ui/packages/consul-ui/app/models/kv.js
John Cowen dc183b1786
ui: Restrict the viewing/editing of certain UI elements based on the users ACLs (#9687)
This commit use the internal authorize endpoint along wiht ember-can to further restrict user access to certain UI features and navigational elements depending on the users ACL token
2021-02-19 16:42:16 +00:00

35 lines
915 B
JavaScript

import Model, { attr } from '@ember-data/model';
import { computed } from '@ember/object';
import isFolder from 'consul-ui/utils/isFolder';
import { nullValue } from 'consul-ui/decorators/replace';
export const PRIMARY_KEY = 'uid';
// not really a slug as it contains slashes but all intents and purposes its
// my 'slug'
export const SLUG_KEY = 'Key';
export default class Kv extends Model {
@attr('string') uid;
@attr('string') Key;
@attr('string') Datacenter;
@attr('string') Namespace;
@attr('number') LockIndex;
@attr('number') Flags;
@nullValue(undefined) @attr('string') Value;
@attr('number') CreateIndex;
@attr('number') ModifyIndex;
@attr('string') Session;
@attr({ defaultValue: () => [] }) Resources; // []
@computed('isFolder')
get Kind() {
return this.isFolder ? 'folder' : 'key';
}
@computed('Key')
get isFolder() {
return isFolder(this.Key || '');
}
}