chore: 🤖 PR feedback

This commit is contained in:
Randall Morey committed 2021-02-11 10:44:48 -05:00
1 parent 0b8550c136
commit 8e43f3aef6
4 files changed
+26 -15

No files matched your search

@@ -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),
];
}
-11
View File
@@ -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);
// }
// }
}
+16 -2
View File
@@ -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
@@ -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;