2020-11-09 17:29:12 +00:00
|
|
|
import Model, { attr } from '@ember-data/model';
|
2020-09-18 10:14:06 +00:00
|
|
|
import { computed } from '@ember/object';
|
|
|
|
import { fragmentArray } from 'ember-data-model-fragments/attributes';
|
2021-01-27 10:41:24 +00:00
|
|
|
import { nullValue } from 'consul-ui/decorators/replace';
|
2018-05-22 15:03:45 +00:00
|
|
|
|
|
|
|
export const PRIMARY_KEY = 'uid';
|
|
|
|
export const SLUG_KEY = 'ID';
|
2020-09-18 10:14:06 +00:00
|
|
|
|
2020-11-09 17:29:12 +00:00
|
|
|
export default class Intention extends Model {
|
|
|
|
@attr('string') uid;
|
|
|
|
@attr('string') ID;
|
|
|
|
|
|
|
|
@attr('string') Datacenter;
|
|
|
|
@attr('string') Description;
|
|
|
|
@attr('string', { defaultValue: () => 'default' }) SourceNS;
|
|
|
|
@attr('string', { defaultValue: () => '*' }) SourceName;
|
|
|
|
@attr('string', { defaultValue: () => 'default' }) DestinationNS;
|
|
|
|
@attr('string', { defaultValue: () => '*' }) DestinationName;
|
|
|
|
@attr('number') Precedence;
|
|
|
|
@attr('string', { defaultValue: () => 'consul' }) SourceType;
|
2021-01-27 10:41:24 +00:00
|
|
|
@nullValue(undefined) @attr('string') Action;
|
2020-11-09 17:29:12 +00:00
|
|
|
@attr('string') LegacyID;
|
|
|
|
@attr('boolean', { defaultValue: () => true }) Legacy;
|
|
|
|
@attr('number') SyncTime;
|
|
|
|
@attr('date') CreatedAt;
|
|
|
|
@attr('date') UpdatedAt;
|
|
|
|
@attr('number') CreateIndex;
|
|
|
|
@attr('number') ModifyIndex;
|
|
|
|
@attr() Meta; // {}
|
|
|
|
@fragmentArray('intention-permission') Permissions;
|
|
|
|
|
|
|
|
@computed('Meta')
|
|
|
|
get IsManagedByCRD() {
|
2020-09-18 10:14:06 +00:00
|
|
|
const meta = Object.entries(this.Meta || {}).find(
|
|
|
|
([key, value]) => key === 'external-source' && value === 'kubernetes'
|
|
|
|
);
|
|
|
|
return typeof meta !== 'undefined';
|
2020-11-09 17:29:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@computed('IsManagedByCRD')
|
|
|
|
get IsEditable() {
|
2020-09-30 11:33:01 +00:00
|
|
|
return !this.IsManagedByCRD;
|
2020-11-09 17:29:12 +00:00
|
|
|
}
|
|
|
|
}
|