From 2659163b37edd7e78247746e3f467949ea2a65bd Mon Sep 17 00:00:00 2001 From: Cameron Perera Date: Wed, 24 May 2023 12:46:32 -0500 Subject: [PATCH] Icu 9418 hide play button if session recording is still in progress (#281) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: 🎸 add isAvailable method to session recording model ✅ Closes: ICU-9418 * feat: 🎸 hide play button if session recording in-progress * refactor: 💡 use translation for channel list play button * refactor: 💡 move Play translation to actions from resources --- addons/api/addon/models/session-recording.js | 8 +++++++ .../unit/models/session-recording-test.js | 22 +++++++++++++++++++ addons/core/translations/actions/en-us.yaml | 1 + .../channels-by-connection/index.hbs | 16 ++++++++------ 4 files changed, 40 insertions(+), 7 deletions(-) diff --git a/addons/api/addon/models/session-recording.js b/addons/api/addon/models/session-recording.js index 093a5a398..85dece5e9 100644 --- a/addons/api/addon/models/session-recording.js +++ b/addons/api/addon/models/session-recording.js @@ -32,6 +32,14 @@ export default class SessionRecordingModel extends GeneratedSessionRecordingMode return !TYPES_SESSION_RECORDING.includes(this.type); } + /** + * True if the session recording is in an available state. + * @type {boolean} + */ + get isAvailable() { + return this.state === STATE_SESSION_RECORDING_AVAILABLE; + } + /** * Returns scope name or scope id from the target that belongs to the session recording. * @type {string} diff --git a/addons/api/tests/unit/models/session-recording-test.js b/addons/api/tests/unit/models/session-recording-test.js index 8a88bb1b3..1751792b0 100644 --- a/addons/api/tests/unit/models/session-recording-test.js +++ b/addons/api/tests/unit/models/session-recording-test.js @@ -2,6 +2,11 @@ import { module, test } from 'qunit'; import { setupTest } from 'ember-qunit'; import { TYPE_SESSION_RECORDING_SSH } from 'api/models/session-recording'; import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; +import { + STATE_SESSION_RECORDING_AVAILABLE, + STATE_SESSION_RECORDING_STARTED, + STATE_SESSION_RECORDING_UNKNOWN, +} from 'api/models/session-recording'; module('Unit | Model | session-recording', function (hooks) { setupTest(hooks); @@ -39,6 +44,23 @@ module('Unit | Model | session-recording', function (hooks) { assert.false(modelB.isSSH); }); + test('it has isAvailable property and returns the expected values', async function (assert) { + assert.expect(3); + const store = this.owner.lookup('service:store'); + const modelA = store.createRecord('session-recording', { + state: STATE_SESSION_RECORDING_AVAILABLE, + }); + const modelB = store.createRecord('session-recording', { + state: STATE_SESSION_RECORDING_STARTED, + }); + const modelC = store.createRecord('session-recording', { + state: STATE_SESSION_RECORDING_UNKNOWN, + }); + assert.true(modelA.isAvailable); + assert.false(modelB.isAvailable); + assert.false(modelC.isAvailable); + }); + test('it has connections as a relationship', async function (assert) { assert.expect(1); const store = this.owner.lookup('service:store'); diff --git a/addons/core/translations/actions/en-us.yaml b/addons/core/translations/actions/en-us.yaml index 3198dc1bf..8b0a726fc 100644 --- a/addons/core/translations/actions/en-us.yaml +++ b/addons/core/translations/actions/en-us.yaml @@ -21,6 +21,7 @@ next: Next back: Back view: View retry: Retry +play: Play get-topic-help: Get help for this topic copy-to-clipboard: Copy to Clipboard copy-error-detail-to-clipboard: Copy error detail to clipboard diff --git a/ui/admin/app/templates/scopes/scope/session-recordings/session-recording/channels-by-connection/index.hbs b/ui/admin/app/templates/scopes/scope/session-recordings/session-recording/channels-by-connection/index.hbs index 1e4c2ee65..0bfb54bb7 100644 --- a/ui/admin/app/templates/scopes/scope/session-recordings/session-recording/channels-by-connection/index.hbs +++ b/ui/admin/app/templates/scopes/scope/session-recordings/session-recording/channels-by-connection/index.hbs @@ -94,13 +94,15 @@ - + {{#if @model.sessionRecording.isAvailable}} + + {{/if}}