feat: 🎸 Add abilities for session recordings (#120)
* feat: 🎸 Add abilities for session recordings ✅ Closes: ICU-8079
This commit is contained in:
1 parent
5992829fa2
commit
bf2029eb54
8 files changed
+324
-27
No files matched your search
@@ -0,0 +1,34 @@
|
||||
/**
|
||||
* Copyright (c) HashiCorp, Inc.
|
||||
* SPDX-License-Identifier: MPL-2.0
|
||||
*/
|
||||
|
||||
import ModelAbility from './model';
|
||||
|
||||
/**
|
||||
* Provides abilities for session recordings.
|
||||
*/
|
||||
export default class RecordingAbility extends ModelAbility {
|
||||
// =services
|
||||
|
||||
// =permissions
|
||||
|
||||
/**
|
||||
* Only "known" session recording types may be read.
|
||||
* @type {boolean}
|
||||
*/
|
||||
get canRead() {
|
||||
return !this.model.isUnknown && this.hasAuthorizedAction('read');
|
||||
}
|
||||
|
||||
get canList() {
|
||||
return (
|
||||
this.hasAuthorizedCollectionAction('list') &&
|
||||
(this.model.isGlobal || this.model.isOrg)
|
||||
);
|
||||
}
|
||||
|
||||
get canDownloadAsciiCast() {
|
||||
return this.model.isSSH && this.hasAuthorizedAction('download');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
import { Ability } from 'ember-can';
|
||||
|
||||
export default class extends Ability {}
|
||||
@@ -18,7 +18,11 @@ export default factory.extend({
|
||||
type: (i) => types[i % types.length],
|
||||
|
||||
authorized_actions: () =>
|
||||
permissions.authorizedActionsFor('recording') || ['no-op', 'read', 'list'],
|
||||
permissions.authorizedActionsFor('recording') || [
|
||||
'no-op',
|
||||
'read',
|
||||
'download',
|
||||
],
|
||||
|
||||
withNonExistingUserAndTarget: trait({
|
||||
afterCreate(recording, server) {
|
||||
|
||||
@@ -37,8 +37,10 @@ export default factory.extend({
|
||||
collectionActions.workers = ['create:worker-led', 'list'];
|
||||
}
|
||||
|
||||
// Session recording resources are only available on global or org scope
|
||||
if (this.type === 'global' || this.type === 'org') {
|
||||
collectionActions['storage-buckets'] = ['create', 'list'];
|
||||
collectionActions.recordings = ['list'];
|
||||
}
|
||||
|
||||
return collectionActions;
|
||||
|
||||
Reference in new issue
Block a user