Files
threshold-ui/ui/desktop/app/controllers/scopes/scope/projects/sessions/index.js
T
hashicorp-copywrite[bot]andCameron Perera 3d610427d0 [COMPLIANCE] Add Copyright and License Headers (#1617)
* [COMPLIANCE] Add Copyright and License Headers

* chore: 🤖 update Copyright headers to satisfy our lint rules

---------

Co-authored-by: hashicorp-copywrite[bot] <110428419+hashicorp-copywrite[bot]@users.noreply.github.com>
Co-authored-by: Cameron Perera <cameron.perera@hashicorp.com>
2023-03-01 09:39:41 -06:00

30 lines
786 B
JavaScript

/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: MPL-2.0
*/
import Controller from '@ember/controller';
export default class ScopesScopeProjectsSessionsIndexController extends Controller {
// =attributes
/**
* A list of sessions filtered to the current user and sorted by created time,
* and active/pending.
* @type {SessionModel[]}
*/
get sorted() {
const sessions = this.model;
const sortedSessions = sessions
// sort by created time
.sortBy('session.created_time')
.reverse();
return [
// then move active sessions to the top
...sortedSessions.filter((session) => session.isCancelable),
// and all others to the end
...sortedSessions.filter((session) => !session.isCancelable),
];
}
}