Files
threshold-ui/addons/api/addon/abilities/user.js
T
lisbet-alvarez 379f317d8b Refactor account and user abilities (#1694)
* refactor: 💡 add abilities to user and remove from account
2023-05-22 11:16:48 -07:00

44 lines
793 B
JavaScript

/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: MPL-2.0
*/
import ModelAbility from './model';
/**
* Provides abilities for users.
*/
export default class UserAbility extends ModelAbility {
// =permissions
/**
* @type {boolean}
*/
get canAddAccounts() {
return this.hasAuthorizedAction('add-accounts');
}
/**
* @type {boolean}
*/
get canRemoveAccounts() {
return this.hasAuthorizedAction('remove-accounts');
}
/**
* @type {boolean}
*/
get canAddAccount() {
const { account, canAddAccounts } = this;
return canAddAccounts && !account.isUnknown;
}
/**
* @type {boolean}
*/
get canRemoveAccount() {
const { account, canRemoveAccounts } = this;
return canRemoveAccounts && !account.isUnknown;
}
}