From 64e568bd723b57c1791e4e04a6eb0eec0a837ed7 Mon Sep 17 00:00:00 2001 From: Lisbet Alvarez <107949262+lisbet-alvarez@users.noreply.github.com> Date: Fri, 4 Oct 2024 08:14:30 -0700 Subject: [PATCH] =?UTF-8?q?fix:=20=F0=9F=90=9B=20deleting=20session=20reco?= =?UTF-8?q?rding=20causes=20error=20(#2510)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 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 --- addons/core/translations/resources/en-us.yaml | 3 +- .../channels-by-connection/index.js | 4 +-- .../scopes/scope/session-recordings/index.js | 29 ++++++++++++++++++- 3 files changed, 31 insertions(+), 5 deletions(-) diff --git a/addons/core/translations/resources/en-us.yaml b/addons/core/translations/resources/en-us.yaml index eaad618a7..c4d47c686 100644 --- a/addons/core/translations/resources/en-us.yaml +++ b/addons/core/translations/resources/en-us.yaml @@ -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. @@ -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: diff --git a/ui/admin/app/controllers/scopes/scope/session-recordings/session-recording/channels-by-connection/index.js b/ui/admin/app/controllers/scopes/scope/session-recordings/session-recording/channels-by-connection/index.js index 8706e63d9..fd774c8ff 100644 --- a/ui/admin/app/controllers/scopes/scope/session-recordings/session-recording/channels-by-connection/index.js +++ b/ui/admin/app/controllers/scopes/scope/session-recordings/session-recording/channels-by-connection/index.js @@ -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); } @@ -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(); } } diff --git a/ui/admin/app/routes/scopes/scope/session-recordings/index.js b/ui/admin/app/routes/scopes/scope/session-recordings/index.js index 1b3bcf23b..3e918da80 100644 --- a/ui/admin/app/routes/scopes/scope/session-recordings/index.js +++ b/ui/admin/app/routes/scopes/scope/session-recordings/index.js @@ -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 { @@ -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} + */ + 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