* refactor: 💡 session isCancelable to isAvailable * refactor: 💡 check for target info for showing target details * refactor: 💡 add fallback for session data from connect command * refactor: 💡 remove extra divs * refactor: 💡 remove await from peekRecord of a session * test: 💍 add test for no read permission for sessions * test: 💍 reset global qunit after test is done
41 lines
910 B
JavaScript
41 lines
910 B
JavaScript
/**
|
|
* Copyright (c) HashiCorp, Inc.
|
|
* SPDX-License-Identifier: MPL-2.0
|
|
*/
|
|
|
|
import Route from '@ember/routing/route';
|
|
import { inject as service } from '@ember/service';
|
|
|
|
export default class ScopesScopeProjectsSessionsSessionRoute extends Route {
|
|
// =services
|
|
|
|
@service store;
|
|
|
|
// =methods
|
|
|
|
/**
|
|
* Load a session
|
|
* @param {object} params
|
|
* @param {string} params.session_id
|
|
* @return {SessionModel}
|
|
*/
|
|
async model({ session_id }) {
|
|
const session = await this.store.findRecord('session', session_id);
|
|
|
|
/**
|
|
* If the session has a host_id and the user has grants,
|
|
* we retrieve the host and aggregate it to the session model.
|
|
*/
|
|
if (session.host_id) {
|
|
try {
|
|
const host = await this.store.findRecord('host', session.host_id);
|
|
session.addHost(host);
|
|
} catch (error) {
|
|
// no operation
|
|
}
|
|
}
|
|
|
|
return session;
|
|
}
|
|
}
|