From 4c9811739cb1c2897ed9ed172d4c8c15a6af9174 Mon Sep 17 00:00:00 2001 From: Zhihe Li Date: Wed, 19 Apr 2023 12:34:31 -0400 Subject: [PATCH] =?UTF-8?q?refactor:=20=F0=9F=92=A1=20Update=20list=20sess?= =?UTF-8?q?ion=20recording=20API=20(#203)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * refactor: 💡 Update list session recording API --- addons/api/mirage/config.js | 13 ++++++++++++- .../app/routes/scopes/scope/session-recordings.js | 6 +++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/addons/api/mirage/config.js b/addons/api/mirage/config.js index 8a42d9662..25be61159 100644 --- a/addons/api/mirage/config.js +++ b/addons/api/mirage/config.js @@ -706,7 +706,18 @@ function routes() { ); // session recordings - this.get('/session-recordings'); + this.get( + '/session-recordings', + ( + { sessionRecordings }, + { queryParams: { scope_id: scopeId, recursive } } + ) => { + if (recursive && scopeId === 'global') { + return sessionRecordings.all(); + } + return sessionRecordings.where({ scopeId }); + } + ); this.get( '/session-recordings/:idMethod', async ({ sessionRecordings }, { params: { idMethod } }) => { diff --git a/ui/admin/app/routes/scopes/scope/session-recordings.js b/ui/admin/app/routes/scopes/scope/session-recordings.js index 9b121c822..e18a61020 100644 --- a/ui/admin/app/routes/scopes/scope/session-recordings.js +++ b/ui/admin/app/routes/scopes/scope/session-recordings.js @@ -26,7 +26,11 @@ export default class ScopesScopeSessionRecordingsRoute extends Route { const scope = this.modelFor('scopes.scope'); // if (this.can.can('list session-recording', scope, { collection: 'session-recordings' })) { const { id: scope_id } = scope; - const sessionRecordings = await this.store.findAll('session-recording'); + + const sessionRecordings = await this.store.query('session-recording', { + scope_id, + recursive: true, + }); const storageBuckets = await this.store.query('storage-bucket', { scope_id, recursive: true,