open-vault/ui/app/models/oidc/assignment.js
claire bontempo fcf6467cbf
UI: OIDC config cleanup (#17105)
* cleanup infotableitemarray, add render name option to component

* wait until items fetched before rendering child component

* update test

* finish tests for info table item array

* remove unused capability checks

* remove unnecessary path alias

* fix info table row arg

* fix wildcards getting info tooltip
2022-09-13 09:06:19 -07:00

42 lines
1.1 KiB
JavaScript

import Model, { attr } from '@ember-data/model';
import lazyCapabilities, { apiPath } from 'vault/macros/lazy-capabilities';
import { withModelValidations } from 'vault/decorators/model-validations';
import { isPresent } from '@ember/utils';
const validations = {
name: [
{ type: 'presence', message: 'Name is required.' },
{
type: 'containsWhiteSpace',
message: 'Name cannot contain whitespace.',
},
],
targets: [
{
validator(model) {
return isPresent(model.entityIds) || isPresent(model.groupIds);
},
message: 'At least one entity or group is required.',
},
],
};
@withModelValidations(validations)
export default class OidcAssignmentModel extends Model {
@attr('string') name;
@attr('array') entityIds;
@attr('array') groupIds;
// CAPABILITIES
@lazyCapabilities(apiPath`identity/oidc/assignment/${'name'}`, 'name') assignmentPath;
get canRead() {
return this.assignmentPath.get('canRead');
}
get canEdit() {
return this.assignmentPath.get('canUpdate');
}
get canDelete() {
return this.assignmentPath.get('canDelete');
}
}