mirror of https://github.com/status-im/consul.git
ui: peer permission handling (#13724)
* Request peering permissions when peerings is active * Update peering ability to use peering resource * fix canDelete peer permission to check write permission * use super call in abilities.peer#canDelete
This commit is contained in:
parent
a6634db4a5
commit
75768a2039
|
@ -4,7 +4,7 @@ import { inject as service } from '@ember/service';
|
|||
export default class PeerAbility extends BaseAbility {
|
||||
@service('env') env;
|
||||
|
||||
resource = 'operator';
|
||||
resource = 'peering';
|
||||
segmented = false;
|
||||
|
||||
get isLinkable() {
|
||||
|
@ -12,7 +12,7 @@ export default class PeerAbility extends BaseAbility {
|
|||
}
|
||||
get canDelete() {
|
||||
// TODO: Need to confirm these states
|
||||
return !['DELETING', 'TERMINATED', 'UNDEFINED'].includes(this.item.State);
|
||||
return !['DELETING', 'TERMINATED', 'UNDEFINED'].includes(this.item.State) && super.canDelete;
|
||||
}
|
||||
|
||||
get canUse() {
|
||||
|
|
|
@ -57,6 +57,16 @@ const REQUIRED_PERMISSIONS = [
|
|||
Access: 'write',
|
||||
},
|
||||
];
|
||||
const PEERING_PERMISSIONS = [
|
||||
{
|
||||
Resource: 'peering',
|
||||
Access: 'read',
|
||||
},
|
||||
{
|
||||
Resource: 'peering',
|
||||
Access: 'write',
|
||||
},
|
||||
];
|
||||
export default class PermissionService extends RepositoryService {
|
||||
@service('env') env;
|
||||
@service('abilities') _can;
|
||||
|
@ -146,7 +156,7 @@ export default class PermissionService extends RepositoryService {
|
|||
|
||||
@dataSource('/:partition/:nspace/:dc/permissions')
|
||||
async findAll(params) {
|
||||
params.resources = REQUIRED_PERMISSIONS;
|
||||
params.resources = this.permissionsToRequest;
|
||||
this.permissions = await this.findByPermissions(params);
|
||||
/**/
|
||||
// Temporarily revert to pre-1.10 UI functionality by overwriting frontend
|
||||
|
@ -162,4 +172,12 @@ export default class PermissionService extends RepositoryService {
|
|||
/**/
|
||||
return this.permissions;
|
||||
}
|
||||
|
||||
get permissionsToRequest() {
|
||||
if (this._can.can('use peers')) {
|
||||
return [...REQUIRED_PERMISSIONS, ...PEERING_PERMISSIONS];
|
||||
} else {
|
||||
return REQUIRED_PERMISSIONS;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue