diff --git a/ui/desktop/app/controllers/scopes/scope/projects/sessions/index.js b/ui/desktop/app/controllers/scopes/scope/projects/sessions/index.js index dc54b63f0..babe28f5f 100644 --- a/ui/desktop/app/controllers/scopes/scope/projects/sessions/index.js +++ b/ui/desktop/app/controllers/scopes/scope/projects/sessions/index.js @@ -10,16 +10,24 @@ export default class ScopesScopeProjectsSessionsIndexController extends Controll // =attributes + /** + * A list of sessions filtered to the current user and sorted by created time, + * and active/pending. + * @type {SessionModel[]} + */ @computed('model.@each.{created_time,active}', 'session.data.authenticated.user_id') get sorted() { const userId = this.session.data.authenticated.user_id; const sessions = this.model; const sortedSessions = sessions + // filter sessions by current user .filter(session => session.user_id === userId) + // sort by created time .sortBy('session.created_time').reverse(); - // Then move active sessions to the top... return [ + // then move active sessions to the top ...sortedSessions.filter((session) => session.isCancelable), + // and all others to the end ...sortedSessions.filter((session) => !session.isCancelable), ]; } diff --git a/ui/desktop/app/routes/scopes/scope.js b/ui/desktop/app/routes/scopes/scope.js index 14e36f5e1..a0b817037 100644 --- a/ui/desktop/app/routes/scopes/scope.js +++ b/ui/desktop/app/routes/scopes/scope.js @@ -88,15 +88,4 @@ export default class ScopesScopeRoute extends Route { outlet: 'header-nav', }); } - - // /** - // * In global scope, redirect to first org on authentication. - // */ - // redirect(model) { - // const { isAuthenticated } = this.session; - // const { isGlobal } = model; - // if (isAuthenticated && isGlobal && this.scopes.orgs?.length) { - // this.replaceWith('scopes.scope', this.scopes.orgs.firstObject.id); - // } - // } } diff --git a/ui/desktop/app/routes/scopes/scope/projects.js b/ui/desktop/app/routes/scopes/scope/projects.js index b1aacf256..e579d7efb 100644 --- a/ui/desktop/app/routes/scopes/scope/projects.js +++ b/ui/desktop/app/routes/scopes/scope/projects.js @@ -1,6 +1,20 @@ import Route from '@ember/routing/route'; import { inject as service } from '@ember/service'; +/** + * TODO: This route is now vestigial. Desktop does not provide project-based + * navigation. This route formerly provided a way to aggregate + * all project scopes, which was necessary to then aggregate targets and + * sessions under those projects. Since the API now provides recursive listing, + * it's possible to load all targets and sessions with a single call, no client- + * side aggregation required. + * + * However, it _is_ necessary to prime the store with all project scopes. + * This allows the UI to display project names on associated resources. + * + * The priming function of this route could be moved to scopes or scopes/scope. + * It no longer makes sense as a dedicated route. + */ export default class ScopesScopeProjectsRoute extends Route { // =services @@ -16,8 +30,8 @@ export default class ScopesScopeProjectsRoute extends Route { } /** - * Loads project scopes for the current scope. - * @return {Promise + * Primes the store with _all project scopes_ under global. + * @return {Promise{ScopeModel}} */ model() { return this.store diff --git a/ui/desktop/app/routes/scopes/scope/projects/targets.js b/ui/desktop/app/routes/scopes/scope/projects/targets.js index 32a804074..867011648 100644 --- a/ui/desktop/app/routes/scopes/scope/projects/targets.js +++ b/ui/desktop/app/routes/scopes/scope/projects/targets.js @@ -32,7 +32,7 @@ export default class ScopesScopeProjectsTargetsRoute extends Route { @task(function * () { while(true) { yield timeout(POLL_TIMEOUT_SECONDS * 1000); - //yield this.refreshSessions(); + yield this.refreshSessions(); } }).drop() poller;