chore: 🤖 Update session recording API (#243)
* chore: 🤖 Update session recording API * chore: 🤖 Update usage of scope id for targets * chore: 🤖 Update scope id usage for user in session recordings
This commit is contained in:
1 parent
308a393202
commit
0dee7b5a02
11 files changed
+89
-51
No files matched your search
@@ -19,16 +19,11 @@ export default class GeneratedSessionRecordingModel extends BaseModel {
|
||||
type;
|
||||
|
||||
@attr({
|
||||
description: 'The user who created the session.',
|
||||
description:
|
||||
'Contains the values of related fields at the time this Session Recording was created',
|
||||
readOnly: true,
|
||||
})
|
||||
user;
|
||||
|
||||
@attr({
|
||||
description: 'The target the session connected to.',
|
||||
readOnly: true,
|
||||
})
|
||||
target;
|
||||
create_time_values;
|
||||
|
||||
@attr('string', {
|
||||
description: 'The ID of the Session which this Session Recording recorded.',
|
||||
@@ -36,6 +31,13 @@ export default class GeneratedSessionRecordingModel extends BaseModel {
|
||||
})
|
||||
session_id;
|
||||
|
||||
@attr('string', {
|
||||
description:
|
||||
'The ID of the Storage Bucket for the Target of this Session Recording',
|
||||
readOnly: true,
|
||||
})
|
||||
storage_bucket_id;
|
||||
|
||||
@attr('string', {
|
||||
description:
|
||||
'The total number of bytes uploaded from the client in the Session.',
|
||||
|
||||
@@ -38,7 +38,10 @@ export default class SessionRecordingModel extends GeneratedSessionRecordingMode
|
||||
* @type {string}
|
||||
*/
|
||||
get targetScopeDisplayName() {
|
||||
return this.target?.scope?.name || this.target?.scope?.id;
|
||||
return (
|
||||
this.create_time_values?.target?.scope?.name ||
|
||||
this.create_time_values?.target?.scope?.id
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -46,6 +49,8 @@ export default class SessionRecordingModel extends GeneratedSessionRecordingMode
|
||||
* @type {string}
|
||||
*/
|
||||
get userDisplayName() {
|
||||
return this.user?.name || this.user?.id;
|
||||
return (
|
||||
this.create_time_values?.user?.name || this.create_time_values?.user?.id
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -36,9 +36,12 @@ export default factory.extend({
|
||||
target.id = 'deleted_target';
|
||||
|
||||
sessionRecording.update({
|
||||
user: user.attrs,
|
||||
target: target.attrs,
|
||||
sessionId: session.id,
|
||||
storage_bucket_id: target.storage_bucket_id,
|
||||
create_time_values: {
|
||||
user: user.attrs,
|
||||
target: target.attrs,
|
||||
},
|
||||
});
|
||||
},
|
||||
}),
|
||||
@@ -52,9 +55,12 @@ export default factory.extend({
|
||||
);
|
||||
|
||||
sessionRecording.update({
|
||||
user: user.attrs,
|
||||
target: target.attrs,
|
||||
sessionId: session.id,
|
||||
storage_bucket_id: target.storage_bucket_id,
|
||||
create_time_values: {
|
||||
user: user.attrs,
|
||||
target: target.attrs,
|
||||
},
|
||||
});
|
||||
},
|
||||
}),
|
||||
|
||||
@@ -26,18 +26,19 @@ export default ApplicationSerializer.extend({
|
||||
);
|
||||
});
|
||||
}
|
||||
if (model.user?.scopeId) {
|
||||
const scope = scopes.find(model.user.scopeId);
|
||||
json.user.scope = ScopeSerializer.prototype._hashForModel.apply(this, [
|
||||
scope,
|
||||
]);
|
||||
const userScopeId = model.create_time_values?.user?.scopeId;
|
||||
if (userScopeId) {
|
||||
const scope = scopes.find(userScopeId);
|
||||
json.create_time_values.user.scope =
|
||||
ScopeSerializer.prototype._hashForModel.apply(this, [scope]);
|
||||
}
|
||||
if (model.target?.scopeId) {
|
||||
const scope = scopes.find(model.target.scopeId);
|
||||
json.target.scope = ScopeSerializer.prototype._hashForModel.apply(this, [
|
||||
scope,
|
||||
]);
|
||||
const targetScopeId = model.create_time_values?.target?.scopeId;
|
||||
if (targetScopeId) {
|
||||
const scope = scopes.find(targetScopeId);
|
||||
json.create_time_values.target.scope =
|
||||
ScopeSerializer.prototype._hashForModel.apply(this, [scope]);
|
||||
}
|
||||
delete json.create_time_values?.target?.storage_bucket_id;
|
||||
|
||||
json.session_id = model.sessionId;
|
||||
return json;
|
||||
|
||||
@@ -84,13 +84,22 @@ module('Unit | Model | session-recording', function (hooks) {
|
||||
const fakeId = 's_123456789';
|
||||
|
||||
const modelA = store.createRecord('session-recording', {
|
||||
target: {
|
||||
scope: { name: fakeName, id: fakeId },
|
||||
create_time_values: {
|
||||
target: {
|
||||
scope: {
|
||||
name: fakeName,
|
||||
id: fakeId,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
const modelB = store.createRecord('session-recording', {
|
||||
target: {
|
||||
scope: { id: fakeId },
|
||||
create_time_values: {
|
||||
target: {
|
||||
scope: {
|
||||
id: fakeId,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
@@ -105,11 +114,20 @@ module('Unit | Model | session-recording', function (hooks) {
|
||||
const fakeUserId = 'userid';
|
||||
|
||||
const userModelA = store.createRecord('session-recording', {
|
||||
user: { name: fakeUserName, id: fakeUserId },
|
||||
create_time_values: {
|
||||
user: {
|
||||
name: fakeUserName,
|
||||
id: fakeUserId,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const userModelB = store.createRecord('session-recording', {
|
||||
user: { id: fakeUserId },
|
||||
create_time_values: {
|
||||
user: {
|
||||
id: fakeUserId,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
assert.strictEqual(userModelA.userDisplayName, fakeUserName);
|
||||
|
||||
+2
-2
@@ -27,8 +27,8 @@ export default class ScopesScopeSessionRecordingsSessionRecordingChannelsByConne
|
||||
);
|
||||
|
||||
try {
|
||||
if (sessionRecording.target?.storage_bucket_id) {
|
||||
const { storage_bucket_id } = sessionRecording.target;
|
||||
if (sessionRecording.storage_bucket_id) {
|
||||
const { storage_bucket_id } = sessionRecording;
|
||||
storageBucket = await this.store.findRecord(
|
||||
'storage-bucket',
|
||||
storage_bucket_id
|
||||
|
||||
@@ -46,7 +46,7 @@
|
||||
>
|
||||
<span>
|
||||
<FlightIcon @name='target' />
|
||||
{{B.data.target.name}}
|
||||
{{B.data.create_time_values.target.name}}
|
||||
</span>
|
||||
<span>
|
||||
<Hds::Badge
|
||||
|
||||
+7
-7
@@ -110,29 +110,29 @@
|
||||
<h2>{{t 'resources.session-recording.related'}}</h2>
|
||||
<LinkListPanel as |list|>
|
||||
{{! User name }}
|
||||
{{#if @model.sessionRecording.user}}
|
||||
{{#if @model.sessionRecording.create_time_values.user}}
|
||||
<list.Item
|
||||
@icon='user'
|
||||
@color='boundary'
|
||||
@route='scopes.scope.users.user'
|
||||
@model={{array
|
||||
@model.sessionRecording.user.scopeId
|
||||
@model.sessionRecording.user.id
|
||||
@model.sessionRecording.create_time_values.user.scope.id
|
||||
@model.sessionRecording.create_time_values.user.id
|
||||
}}
|
||||
@text={{@model.sessionRecording.userDisplayName}}
|
||||
/>
|
||||
{{/if}}
|
||||
{{! Target name }}
|
||||
{{#if @model.sessionRecording.target}}
|
||||
{{#if @model.sessionRecording.create_time_values.target}}
|
||||
<list.Item
|
||||
@icon='target'
|
||||
@color='boundary'
|
||||
@route='scopes.scope.targets.target'
|
||||
@model={{array
|
||||
@model.sessionRecording.target.scopeId
|
||||
@model.sessionRecording.target.id
|
||||
@model.sessionRecording.create_time_values.target.scope.id
|
||||
@model.sessionRecording.create_time_values.target.id
|
||||
}}
|
||||
@text={{@model.sessionRecording.target.name}}
|
||||
@text={{@model.sessionRecording.create_time_values.target.name}}
|
||||
>
|
||||
{{#if @model.sessionRecording.target.type}}
|
||||
<Hds::Badge @text={{@model.sessionRecording.target.type}} />
|
||||
|
||||
+11
-9
@@ -150,32 +150,34 @@
|
||||
<h2>{{t 'resources.session-recording.related'}}</h2>
|
||||
<LinkListPanel as |list|>
|
||||
{{! User name }}
|
||||
{{#if @model.sessionRecording.user}}
|
||||
{{#if @model.sessionRecording.create_time_values.user}}
|
||||
<list.Item
|
||||
@icon='user'
|
||||
@color='boundary'
|
||||
@route='scopes.scope.users.user'
|
||||
@model={{array
|
||||
@model.sessionRecording.user.scopeId
|
||||
@model.sessionRecording.user.id
|
||||
@model.sessionRecording.create_time_values.user.scope.id
|
||||
@model.sessionRecording.create_time_values.user.id
|
||||
}}
|
||||
@text={{@model.sessionRecording.userDisplayName}}
|
||||
/>
|
||||
{{/if}}
|
||||
{{! Target name }}
|
||||
{{#if @model.sessionRecording.target}}
|
||||
{{#if @model.sessionRecording.create_time_values.target}}
|
||||
<list.Item
|
||||
@icon='target'
|
||||
@color='boundary'
|
||||
@route='scopes.scope.targets.target'
|
||||
@model={{array
|
||||
@model.sessionRecording.target.scopeId
|
||||
@model.sessionRecording.target.id
|
||||
@model.sessionRecording.create_time_values.target.scope.id
|
||||
@model.sessionRecording.create_time_values.target.id
|
||||
}}
|
||||
@text={{@model.sessionRecording.target.name}}
|
||||
@text={{@model.sessionRecording.create_time_values.target.name}}
|
||||
>
|
||||
{{#if @model.sessionRecording.target.type}}
|
||||
<Hds::Badge @text={{@model.sessionRecording.target.type}} />
|
||||
{{#if @model.sessionRecording.create_time_values.target.type}}
|
||||
<Hds::Badge
|
||||
@text={{@model.sessionRecording.create_time_values.target.type}}
|
||||
/>
|
||||
{{/if}}
|
||||
</list.Item>
|
||||
{{/if}}
|
||||
|
||||
@@ -38,7 +38,9 @@ module('Acceptance | session recordings | list', function (hooks) {
|
||||
scope: instances.scopes.global,
|
||||
});
|
||||
instances.sessionRecording = this.server.create('session-recording', {
|
||||
target: instances.scopes.targetModel.attrs,
|
||||
create_time_values: {
|
||||
target: instances.scopes.targetModel.attrs,
|
||||
},
|
||||
});
|
||||
urls.globalScope = `/scopes/global`;
|
||||
urls.sessionRecordings = `${urls.globalScope}/session-recordings`;
|
||||
|
||||
@@ -44,7 +44,9 @@ module('Acceptance | session recordings | read', function (hooks) {
|
||||
});
|
||||
instances.sessionRecording = this.server.create('session-recording', {
|
||||
scope: instances.scopes.global,
|
||||
target: instances.target.attrs,
|
||||
create_time_values: {
|
||||
target: instances.target.attrs,
|
||||
},
|
||||
});
|
||||
instances.connectionRecording = this.server.create('connection-recording', {
|
||||
session_recording: instances.sessionRecording,
|
||||
|
||||
Reference in new issue
Block a user