Files
threshold-ui/ui/admin/app/abilities/scope.js
T
Randall Morey 1afe8af15a Session recording and storage bucket abilities cleanup (#256)
* refactor: 💡 cleanup session recording abilities

* refactor: 💡 use super call instead of duplicating check

* refactor: 💡 cleanup storage bucket abilities
2023-05-17 12:24:31 -07:00

45 lines
1.0 KiB
JavaScript

/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: MPL-2.0
*/
import OverrideModelAbility from './model';
import { inject as service } from '@ember/service';
export default class OverrideScopeAbility extends OverrideModelAbility {
// =services
@service features;
// =attributes
/**
* Creating a resource is allowed only if a create grant is present
* and collection-specific criteria are met.
* @type {boolean}
*/
get canCreate() {
switch (this.collection) {
case 'storage-buckets':
return this.features.isEnabled('session-recording') && super.canCreate;
default:
return super.canCreate;
}
}
/**
* Listing a resource is allowed only if a list grant is present
* and collection-specific criteria are met.
* @type {boolean}
*/
get canList() {
switch (this.collection) {
case 'session-recordings':
case 'storage-buckets':
return this.features.isEnabled('session-recording') && super.canList;
default:
return super.canList;
}
}
}