fix: 🐛 Fix active session display in targets table (#2321)

✅ Closes: https://hashicorp.atlassian.net/browse/ICU-13981
This commit is contained in:
Zhihe Li authored and GitHub committed 2024-06-10 17:14:40 -04:00
1 parent 8d217aab2b
commit fc82980d68
1 file changed
+8
@@ -10,6 +10,7 @@ import {
STATUS_SESSION_PENDING, STATUS_SESSION_PENDING,
} from 'api/models/session'; } from 'api/models/session';
import { action } from '@ember/object'; import { action } from '@ember/object';
import { run } from '@ember/runloop';
export default class ScopesScopeProjectsTargetsIndexRoute extends Route { export default class ScopesScopeProjectsTargetsIndexRoute extends Route {
// =services // =services
@@ -72,6 +73,13 @@ export default class ScopesScopeProjectsTargetsIndexRoute extends Route {
*/ */
beforeModel() { beforeModel() {
if (!this.session.isAuthenticated) this.router.transitionTo('index'); if (!this.session.isAuthenticated) this.router.transitionTo('index');
// Unload all sessions from the store as we might have sessions still in store
// if they were canceled outside of the desktop client
// Not wrapping it an ember run seems to cause a test to fail as well as an error
// if you switch between orgs due to a similar issue as this
// https://github.com/emberjs/data/issues/5447#issuecomment-845672812
run(() => this.store.unloadAll('session'));
} }
/** /**