Files
threshold-ui/ui/admin/app/abilities/scope.js
T
Dharini Jeeva 01a986e08b chore: 🤖 new routes for storage policy (#2056)
chore: 🤖 new routes for storage policy (#2056)
2024-01-03 12:05:23 -08:00

51 lines
1.1 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':
case 'policies':
return (
this.features.isEnabled('ssh-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':
case 'policies':
return (
this.features.isEnabled('ssh-session-recording') && super.canList
);
default:
return super.canList;
}
}
}