* 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
64 lines
1.7 KiB
JavaScript
64 lines
1.7 KiB
JavaScript
import GeneratedSessionRecordingModel from '../generated/models/session-recording';
|
|
import { hasMany } from '@ember-data/model';
|
|
import { inject as service } from '@ember/service';
|
|
|
|
export const TYPE_SESSION_RECORDING_SSH = 'ssh';
|
|
export const TYPES_SESSION_RECORDING = Object.freeze([
|
|
TYPE_SESSION_RECORDING_SSH,
|
|
]);
|
|
|
|
export const STATE_SESSION_RECORDING_STARTED = 'started';
|
|
export const STATE_SESSION_RECORDING_AVAILABLE = 'available';
|
|
export const STATE_SESSION_RECORDING_UNKNOWN = 'unknown';
|
|
|
|
export default class SessionRecordingModel extends GeneratedSessionRecordingModel {
|
|
@hasMany('connection-recording', { async: false }) connection_recordings;
|
|
|
|
@service store;
|
|
|
|
/**
|
|
* True if the session recording type is `ssh`.
|
|
* @type {boolean}
|
|
*/
|
|
get isSSH() {
|
|
return this.type === TYPE_SESSION_RECORDING_SSH;
|
|
}
|
|
|
|
/**
|
|
* True if the session recording is an unknown type.
|
|
* @type {boolean}
|
|
*/
|
|
get isUnknown() {
|
|
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}
|
|
*/
|
|
get targetScopeDisplayName() {
|
|
return (
|
|
this.create_time_values?.target?.scope?.name ||
|
|
this.create_time_values?.target?.scope?.id
|
|
);
|
|
}
|
|
|
|
/**
|
|
* Returns the user name or user id that belongs to the session recording.
|
|
* @type {string}
|
|
*/
|
|
get userDisplayName() {
|
|
return (
|
|
this.create_time_values?.user?.name || this.create_time_values?.user?.id
|
|
);
|
|
}
|
|
}
|