John Cowen c8e40ee0de
ui: Move ember-data classes to use native JS classes/decorators (#9136)
* ui: Upgrade ember-data models to use native classes/decorators

* ui: Update remaining ember-data imports

* ui: Move ember-data Adapters to use native classes

* ui: Upgrade serializers to native classes/decorators

* ui: remove meta from roles, they never had it to start with
2020-11-09 17:29:12 +00:00

33 lines
1.0 KiB
JavaScript

import Model, { attr } from '@ember-data/model';
import { computed } from '@ember/object';
import isFolder from 'consul-ui/utils/isFolder';
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;
// TODO: Consider defaulting all strings to '' because `typeof null !==
// 'string'` look into what other transformers do with `null` also
// preferably removeNull would be done in this layer also as if a property
// is `null` default Values don't kick in, which also explains `Tags`
// elsewhere
@attr('string') Value; //, {defaultValue: function() {return '';}}
@attr('number') CreateIndex;
@attr('number') ModifyIndex;
@attr('string') Session;
@computed('Key')
get isFolder() {
return isFolder(this.Key || '');
}
}