Skip to content

Commit

Permalink
fix: πŸ› deleting session recording causes error (#2510)
Browse files Browse the repository at this point in the history
* fix: πŸ› deleting session recording causes error

βœ… Closes: https://hashicorp.atlassian.net/browse/ICU-15236

* fix: πŸ› remove scope filter & remove unused translation

βœ… Closes: https://hashicorp.atlassian.net/browse/ICU-15236
  • Loading branch information
lisbet-alvarez authored Oct 4, 2024
1 parent 401ff35 commit 64e568b
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 5 deletions.
3 changes: 1 addition & 2 deletions addons/core/translations/resources/en-us.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,6 @@ storage-bucket:
help_org: This storage bucket will be available for use with targets within this org.
provider:
label: Provider
help: Boundary currently only supports Amazon S3 storage.
endpoint_url:
label: Endpoint URL
help: Cannot be changed later.
Expand Down Expand Up @@ -706,7 +705,7 @@ target:
help: The local proxy port on which to listen by default when a session is started on a client.
sidebar:
label: Session Recording
help: Record SSH sessions on this target and save them to an Amazon S3 bucket.
help: Record SSH sessions on this target and save them to a storage bucket.
link: Session Recording settings
questions:
delete-host-sources:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export default class ScopesScopeSessionRecordingsSessionRecordingChannelsByConne
try {
await sessionRecording.reapplyStoragePolicy();
} catch (e) {
await this.router.replaceWith('scopes.scope.session-recordings');
this.router.replaceWith('scopes.scope.session-recordings');
this.router.refresh();
throw new Error(e);
}
Expand All @@ -79,7 +79,7 @@ export default class ScopesScopeSessionRecordingsSessionRecordingChannelsByConne
@notifySuccess('notifications.delete-success')
async delete(sessionRecording) {
await sessionRecording.destroyRecord();
await this.router.replaceWith('scopes.scope.session-recordings');
this.router.replaceWith('scopes.scope.session-recordings');
this.router.refresh();
}
}
29 changes: 28 additions & 1 deletion ui/admin/app/routes/scopes/scope/session-recordings/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,10 @@ export default class ScopesScopeSessionRecordingsIndexRoute extends Route {
if (!this.allSessionRecordings) {
await this.getAllSessionRecordings(scope_id);
}
doSessionRecordingsExist = Boolean(this.allSessionRecordings.length);
doSessionRecordingsExist = await this.getDoSessionRecordingsExist(
scope_id,
totalItems,
);
doStorageBucketsExist = await this.getDoStorageBucketsExist(scope_id);

return {
Expand Down Expand Up @@ -125,6 +128,30 @@ export default class ScopesScopeSessionRecordingsIndexRoute extends Route {
);
}

/**
* Sets doSessionRecordingsExist to true if there are any session recordings.
* @param {string} scope_id
* @param {number} totalItems
* @returns {Promise<boolean>}
*/
async getDoSessionRecordingsExist(scope_id, totalItems) {
if (totalItems > 0) {
return true;
}
const options = { pushToStore: false, peekIndexedDB: true };
const sessionRecordings = await this.store.query(
'session-recording',
{
scope_id,
page: 1,
pageSize: 1,
recursive: true,
},
options,
);
return sessionRecordings.length > 0;
}

/**
* Returns true if any storage buckets exist.
* @param {string} scope_id
Expand Down

0 comments on commit 64e568b

Please sign in to comment.