Icu 9418 hide play button if session recording is still in progress (#281)

* 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
This commit is contained in:
Cameron Perera authored and GitHub committed 2023-05-24 12:46:32 -05:00
1 parent 7e2af27453
commit 2659163b37
4 files changed
+40 -7

No files matched your search

@@ -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}
@@ -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');
@@ -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
@@ -94,13 +94,15 @@
</Copyable>
</B.Td>
<B.Td align='right'>
<Hds::Button
@icon='play'
@color='secondary'
@text='Play'
@route='scopes.scope.session-recordings.session-recording.channels-by-connection.channel'
@model={{B.data.id}}
/>
{{#if @model.sessionRecording.isAvailable}}
<Hds::Button
@icon='play'
@color='secondary'
@text={{t 'actions.play'}}
@route='scopes.scope.session-recordings.session-recording.channels-by-connection.channel'
@model={{B.data.id}}
/>
{{/if}}
</B.Td>
</B.Tr>
</:body>