ddf8c20219
* add menu-loader component to show menu loading button when the model relationship isPending * list what keys we've got in api-path error * fix spacing issue on error flash * add an action on list-controller that bubbles to the list-route mixin to refresh the route * empty store when creating scopes * don't delete _requestQuery in the loop, do it after * add scope deletion from the scope list * add deleteRecord to kmip adapters * add model-wrap component * delete role from detail page and list * add revoke credentials functionality * fix comment * treat all operations fields specially on kmip roles * adjust kmip role edit form for new fields * fix api-path test * update document blocks for menu-loader and model-wrap components
49 lines
1.7 KiB
JavaScript
49 lines
1.7 KiB
JavaScript
import DS from 'ember-data';
|
|
import { computed } from '@ember/object';
|
|
import { expandAttributeMeta } from 'vault/utils/field-to-attrs';
|
|
import fieldToAttrs from 'vault/utils/field-to-attrs';
|
|
import apiPath from 'vault/utils/api-path';
|
|
import attachCapabilities from 'vault/lib/attach-capabilities';
|
|
|
|
const { attr } = DS;
|
|
export const COMPUTEDS = {
|
|
operationFields: computed('newFields', function() {
|
|
return this.newFields.filter(key => key.startsWith('operation'));
|
|
}),
|
|
|
|
operationFieldsWithoutSpecial: computed('operationFields', function() {
|
|
return this.operationFields.slice().removeObjects(['operationAll', 'operationNone']);
|
|
}),
|
|
|
|
nonOperationFields: computed('operationFields', function() {
|
|
let excludeFields = ['role'].concat(this.operationFields);
|
|
return this.newFields.slice().removeObjects(excludeFields);
|
|
}),
|
|
};
|
|
|
|
const Model = DS.Model.extend(COMPUTEDS, {
|
|
useOpenAPI: true,
|
|
backend: attr({ readOnly: true }),
|
|
scope: attr({ readOnly: true }),
|
|
name: attr({ readOnly: true }),
|
|
getHelpUrl(path) {
|
|
return `/v1/${path}/scope/example/role/example?help=1`;
|
|
},
|
|
fieldGroups: computed('fields', 'nonOperationFields', function() {
|
|
const groups = [{ default: this.nonOperationFields }, { 'Allowed Operations': this.operationFields }];
|
|
let ret = fieldToAttrs(this, groups);
|
|
return ret;
|
|
}),
|
|
|
|
operationFormFields: computed('operationFieldsWithoutSpecial', function() {
|
|
return expandAttributeMeta(this, this.operationFieldsWithoutSpecial);
|
|
}),
|
|
fields: computed('nonOperationFields', function() {
|
|
return expandAttributeMeta(this, this.nonOperationFields);
|
|
}),
|
|
});
|
|
|
|
export default attachCapabilities(Model, {
|
|
updatePath: apiPath`${'backend'}/scope/${'scope'}/role/${'id'}`,
|
|
});
|