Icu 9415 remove sorted computed value for connections channels (#276)

* refactor: 💡 remove sorted connections from session recording

Removed from session recording model and respective templates

✅ Closes: ICU-9415

* refactor: 💡 remove sorted channels from connections model

and removed from the appropriate templates and breadcrumb
This commit is contained in:
Cameron Perera authored and GitHub committed 2023-05-23 16:10:39 -05:00
1 parent 7cb9ae9f3b
commit a63776e76f
7 files changed
+6 -62

No files matched your search

@@ -1,12 +1,7 @@
import GeneratedConnectionRecordingModel from '../generated/models/connection-recording';
import { belongsTo, hasMany } from '@ember-data/model';
import { sort } from '@ember/object/computed';
export default class ConnectionRecordingModel extends GeneratedConnectionRecordingModel {
@belongsTo('session-recording', { async: false }) session_recording;
@hasMany('channel-recording', { async: false }) channel_recordings;
startTimeSortingDesc = ['start_time:desc'];
@sort('channel_recordings', 'startTimeSortingDesc')
sortedChannelsByStartTimeDesc;
}
@@ -1,7 +1,6 @@
import GeneratedSessionRecordingModel from '../generated/models/session-recording';
import { hasMany } from '@ember-data/model';
import { inject as service } from '@ember/service';
import { sort } from '@ember/object/computed';
export const TYPE_SESSION_RECORDING_SSH = 'ssh';
export const TYPES_SESSION_RECORDING = Object.freeze([
@@ -17,10 +16,6 @@ export default class SessionRecordingModel extends GeneratedSessionRecordingMode
@service store;
startTimeSortingDesc = ['start_time:desc'];
@sort('connection_recordings', 'startTimeSortingDesc')
sortedConnectionsByStartTimeDesc;
/**
* True if the session recording type is `ssh`.
* @type {boolean}
@@ -20,23 +20,4 @@ module('Unit | Model | connection-recording', function (hooks) {
const channel_recordings = await model.channel_recordings;
assert.strictEqual(channel_recordings.length, 1);
});
test('it has sortedChannelsByStartTimeDesc property and returns the expected values', async function (assert) {
assert.expect(3);
const store = this.owner.lookup('service:store');
const newestChannel = store.createRecord('channel-recording', {
start_time: new Date('2023-01-02T00:00:00.999Z'),
});
const oldestChannel = store.createRecord('channel-recording', {
start_time: new Date('2023-01-01T00:00:00.999Z'),
});
const model = store.createRecord('connection-recording', {
channel_recordings: [oldestChannel, newestChannel],
});
const sortedChannels = await model.sortedChannelsByStartTimeDesc;
assert.strictEqual(sortedChannels.length, 2);
assert.strictEqual(sortedChannels[0].start_time, newestChannel.start_time);
assert.strictEqual(sortedChannels[1].start_time, oldestChannel.start_time);
});
});
@@ -51,32 +51,6 @@ module('Unit | Model | session-recording', function (hooks) {
assert.strictEqual(connection_recordings.length, 1);
});
test('it has sortedConnectionsByStartTimeDesc property and returns the expected values', async function (assert) {
assert.expect(3);
const store = this.owner.lookup('service:store');
const newestConnection = store.createRecord('connection-recording', {
start_time: new Date('2023-01-02T00:00:00.999Z'),
});
const oldestConnection = store.createRecord('connection-recording', {
start_time: new Date('2023-01-01T00:00:00.999Z'),
});
const model = store.createRecord('session-recording', {
type: TYPE_SESSION_RECORDING_SSH,
connection_recordings: [oldestConnection, newestConnection],
});
const sortedConnections = await model.sortedConnectionsByStartTimeDesc;
assert.strictEqual(sortedConnections.length, 2);
assert.strictEqual(
sortedConnections[0].start_time,
newestConnection.start_time
);
assert.strictEqual(
sortedConnections[1].start_time,
oldestConnection.start_time
);
});
test('it has targetScopeDisplayName and returns the expected values', async function (assert) {
assert.expect(2);
const store = this.owner.lookup('service:store');
@@ -14,8 +14,7 @@ export default class ScopesScopeSessionRecordingsSessionRecordingChannelsByConne
return indexedDisplayName(
this.intl,
'resources.session-recording.channel.title_index',
this.model.channelRecording.connection_recording
.sortedChannelsByStartTimeDesc,
this.model.channelRecording.connection_recording.channel_recordings,
this.model.channelRecording
);
}
@@ -9,7 +9,7 @@
<h2>
{{indexed-display-name
'resources.session-recording.channel.title_index'
@model.channelRecording.connection_recording.sortedChannelsByStartTimeDesc
@model.channelRecording.connection_recording.channel_recordings
@model.channelRecording
}}
</h2>
@@ -12,14 +12,14 @@
<Layout::Sidebar as |sb|>
<sb.Body>
{{#each
@model.sessionRecording.sortedConnectionsByStartTimeDesc
@model.sessionRecording.connection_recordings
as |connection|
}}
<div class='channels-by-connection-connection-header'>
<p class='hds-typography-display-300 hds-font-weight-semibold'>
{{indexed-display-name
'resources.session-recording.connection.title_index'
@model.sessionRecording.sortedConnectionsByStartTimeDesc
@model.sessionRecording.connection_recordings
connection
}}
</p>
@@ -32,7 +32,7 @@
</Copyable>
</div>
<Hds::Table
@model={{connection.sortedChannelsByStartTimeDesc}}
@model={{connection.channel_recordings}}
@density='tall'
@columns={{array
(hash
@@ -55,7 +55,7 @@
<span>
{{indexed-display-name
'resources.session-recording.channel.title_index'
connection.sortedChannelsByStartTimeDesc
connection.channel_recordings
B.data
}}
</span>