2019-06-21 21:05:45 +00:00
|
|
|
import DS from 'ember-data';
|
|
|
|
import { computed } from '@ember/object';
|
2019-06-25 20:57:50 +00:00
|
|
|
import { expandAttributeMeta } from 'vault/utils/field-to-attrs';
|
|
|
|
import fieldToAttrs from 'vault/utils/field-to-attrs';
|
2019-06-28 21:07:45 +00:00
|
|
|
import apiPath from 'vault/utils/api-path';
|
|
|
|
import attachCapabilities from 'vault/lib/attach-capabilities';
|
2019-06-21 21:05:45 +00:00
|
|
|
|
|
|
|
const { attr } = DS;
|
2019-06-28 21:07:45 +00:00
|
|
|
const Model = DS.Model.extend({
|
2019-06-21 21:05:45 +00:00
|
|
|
useOpenAPI: true,
|
|
|
|
backend: attr({ readOnly: true }),
|
|
|
|
scope: attr({ readOnly: true }),
|
|
|
|
getHelpUrl(path) {
|
|
|
|
return `/v1/${path}/scope/example/role/example?help=1`;
|
|
|
|
},
|
|
|
|
|
2019-06-25 20:57:50 +00:00
|
|
|
name: attr({ readOnly: true }),
|
2019-06-21 21:05:45 +00:00
|
|
|
fieldGroups: computed(function() {
|
|
|
|
let fields = this.newFields.without('role');
|
2019-06-25 20:57:50 +00:00
|
|
|
const groups = [{ 'Allowed Operations': fields }];
|
2019-06-21 21:05:45 +00:00
|
|
|
return fieldToAttrs(this, groups);
|
|
|
|
}),
|
2019-06-25 20:57:50 +00:00
|
|
|
|
|
|
|
fields: computed(function() {
|
|
|
|
let fields = this.newFields.removeObjects(['role', 'operationAll', 'operationNone']);
|
|
|
|
return expandAttributeMeta(this, fields);
|
|
|
|
}),
|
2019-06-21 21:05:45 +00:00
|
|
|
});
|
2019-06-28 21:07:45 +00:00
|
|
|
|
|
|
|
export default attachCapabilities(Model, {
|
|
|
|
updatePath: apiPath`${'backend'}/scope/${'scope'}/role/${'id'}`,
|
|
|
|
});
|