refactor: 💡 migrate to router.transitionTo due to deprecations

This commit is contained in:
Randall Morey committed 2022-01-03 12:35:48 -05:00
1 parent 7e354df44c
commit 8bfa454df5
31 files changed
+117 -69

No files matched your search

+2 -1
View File
@@ -5,6 +5,7 @@ export default class AccountRoute extends Route {
// =services
@service session;
@service router;
// =methods
@@ -12,6 +13,6 @@ export default class AccountRoute extends Route {
* If arriving here unauthenticated, redirect to index for further processing.
*/
beforeModel() {
if (!this.session.isAuthenticated) this.transitionTo('index');
if (!this.session.isAuthenticated) this.router.transitionTo('index');
}
}
+6 -1
View File
@@ -1,12 +1,17 @@
import Route from '@ember/routing/route';
import { inject as service } from '@ember/service';
export default class IndexRoute extends Route {
// =services
@service router;
// =methods
/**
* Redirects to scopes route for further processing.
*/
redirect() {
this.transitionTo('scopes');
this.router.transitionTo('scopes');
}
}
+3 -2
View File
@@ -6,6 +6,7 @@ export default class ScopesIndexRoute extends Route {
// =services
@service session;
@service router;
// =methods
@@ -21,9 +22,9 @@ export default class ScopesIndexRoute extends Route {
'data.authenticated.scope.id'
);
if (authenticatedScopeID) {
this.transitionTo('scopes.scope', authenticatedScopeID);
this.router.transitionTo('scopes.scope', authenticatedScopeID);
} else {
this.transitionTo('scopes.scope', 'global');
this.router.transitionTo('scopes.scope', 'global');
}
}
}
+2 -2
View File
@@ -117,7 +117,7 @@ export default class ScopesScopeRoute extends Route {
cancel(scope) {
const { isNew } = scope;
scope.rollbackAttributes();
if (isNew) this.transitionTo('scopes.scope');
if (isNew) this.router.transitionTo('scopes.scope');
}
/**
@@ -134,7 +134,7 @@ export default class ScopesScopeRoute extends Route {
async save(scope) {
const { isNew } = scope;
await scope.save();
await this.transitionTo('scopes.scope.edit', scope);
await this.router.transitionTo('scopes.scope.edit', scope);
if (isNew) this.refresh();
}
@@ -26,7 +26,7 @@ export default class ScopesScopeAuthMethodsRoute extends Route {
* If arriving here unauthenticated, redirect to index for further processing.
*/
beforeModel() {
if (!this.session.isAuthenticated) this.transitionTo('index');
if (!this.session.isAuthenticated) this.router.transitionTo('index');
}
/**
@@ -57,7 +57,7 @@ export default class ScopesScopeAuthMethodsRoute extends Route {
cancel(authMethod) {
const { isNew } = authMethod;
authMethod.rollbackAttributes();
if (isNew) this.transitionTo('scopes.scope.auth-methods');
if (isNew) this.router.transitionTo('scopes.scope.auth-methods');
}
/**
@@ -73,12 +73,12 @@ export default class ScopesScopeAuthMethodsRoute extends Route {
async save(authMethod) {
await authMethod.save();
if (this.can.can('read model', authMethod)) {
await this.transitionTo(
await this.router.transitionTo(
'scopes.scope.auth-methods.auth-method',
authMethod
);
} else {
await this.transitionTo('scopes.scope.auth-methods');
await this.router.transitionTo('scopes.scope.auth-methods');
}
this.refresh();
}
@@ -42,7 +42,9 @@ export default class ScopesScopeAuthMethodsAuthMethodAccountsRoute extends Route
const { isNew } = account;
account.rollbackAttributes();
if (isNew)
this.transitionTo('scopes.scope.auth-methods.auth-method.accounts');
this.router.transitionTo(
'scopes.scope.auth-methods.auth-method.accounts'
);
}
/**
@@ -63,12 +65,14 @@ export default class ScopesScopeAuthMethodsAuthMethodAccountsRoute extends Route
}
await account.save({ adapterOptions });
if (this.can.can('read model', account)) {
await this.transitionTo(
await this.router.transitionTo(
'scopes.scope.auth-methods.auth-method.accounts.account',
account
);
} else {
await this.transitionTo('scopes.scope.auth-methods.auth-method.accounts');
await this.router.transitionTo(
'scopes.scope.auth-methods.auth-method.accounts'
);
}
this.refresh();
}
@@ -41,7 +41,9 @@ export default class ScopesScopeAuthMethodsAuthMethodManagedGroupsRoute extends
const { isNew } = managedGroup;
managedGroup.rollbackAttributes();
if (isNew) {
this.transitionTo('scopes.scope.auth-methods.auth-method.managed-groups');
this.router.transitionTo(
'scopes.scope.auth-methods.auth-method.managed-groups'
);
}
}
@@ -58,12 +60,12 @@ export default class ScopesScopeAuthMethodsAuthMethodManagedGroupsRoute extends
async save(managedGroup) {
await managedGroup.save();
if (this.can.can('read model', managedGroup)) {
await this.transitionTo(
await this.router.transitionTo(
'scopes.scope.auth-methods.auth-method.managed-groups.managed-group',
managedGroup
);
} else {
await this.transitionTo(
await this.router.transitionTo(
'scopes.scope.auth-methods.auth-method.managed-groups'
);
}
@@ -6,11 +6,13 @@ export default class ScopesScopeAuthenticateRoute extends Route {
// =services
@service session;
@service router;
// =methods
beforeModel() {
if (this.session.isAuthenticated) this.transitionTo('scopes.scope.index');
if (this.session.isAuthenticated)
this.router.transitionTo('scopes.scope.index');
}
/**
@@ -1,6 +1,11 @@
import Route from '@ember/routing/route';
import { inject as service } from '@ember/service';
export default class ScopesScopeAuthenticateIndexRoute extends Route {
// =services
@service router;
// =methods
/**
@@ -12,7 +17,10 @@ export default class ScopesScopeAuthenticateIndexRoute extends Route {
redirect({ authMethods }) {
const firstAuthMethod = authMethods.firstObject;
if (firstAuthMethod) {
this.transitionTo('scopes.scope.authenticate.method', firstAuthMethod);
this.router.transitionTo(
'scopes.scope.authenticate.method',
firstAuthMethod
);
}
}
}
@@ -12,6 +12,7 @@ export default class ScopesScopeAuthenticateMethodRoute extends Route {
@service notify;
@service intl;
@service windowManager;
@service router;
// =methods
@@ -60,14 +61,14 @@ export default class ScopesScopeAuthenticateMethodRoute extends Route {
requestCookies,
{ scope, authMethod }
);
this.transitionTo('index');
this.router.transitionTo('index');
break;
case 'oidc':
await this.startOIDCAuthentication(authenticatorName, {
scope,
authMethod,
});
this.transitionTo('scopes.scope.authenticate.method.oidc');
this.router.transitionTo('scopes.scope.authenticate.method.oidc');
break;
}
}
@@ -13,6 +13,7 @@ export default class ScopesScopeAuthenticateMethodOidcRoute extends Route {
@service session;
@service windowManager;
@service router;
// =methods
@@ -47,7 +48,7 @@ export default class ScopesScopeAuthenticateMethodOidcRoute extends Route {
@action
@notifyError(() => 'errors.authentication-failed.title', { catch: true })
error(e) {
this.transitionTo('scopes.scope.authenticate.method.index');
this.router.transitionTo('scopes.scope.authenticate.method.index');
// rethrow the error to activate the notifyError decorator
throw e;
}
@@ -6,10 +6,13 @@ import { confirm } from 'core/decorators/confirm';
import { notifySuccess, notifyError } from 'core/decorators/notify';
export default class ScopesScopeCredentialStoresRoute extends Route {
// =methods
// =services
@service can;
@service router;
// =methods
/**
* Load all credential stores under current scope
* @returns {Promise[CredentialStoreModel]}
@@ -38,7 +41,7 @@ export default class ScopesScopeCredentialStoresRoute extends Route {
@notifySuccess('notifications.save-success')
async save(credentialStore) {
await credentialStore.save();
await this.transitionTo(
await this.router.transitionTo(
'scopes.scope.credential-stores.credential-store',
credentialStore
);
@@ -53,7 +56,7 @@ export default class ScopesScopeCredentialStoresRoute extends Route {
cancel(credentialStore) {
const { isNew } = credentialStore;
credentialStore.rollbackAttributes();
if (isNew) this.transitionTo('scopes.scope.credential-stores');
if (isNew) this.router.transitionTo('scopes.scope.credential-stores');
}
/**
@@ -6,10 +6,13 @@ import { notifySuccess, notifyError } from 'core/decorators/notify';
import { inject as service } from '@ember/service';
export default class ScopesScopeCredentialStoresCredentialStoreCredentialLibrariesRoute extends Route {
// =methods
// =services
@service can;
@service router;
// =methods
/**
* Loads all credential libraries under the current credential store.
* @return {Promise{[CredentialLibraryModel]}}
@@ -39,7 +42,7 @@ export default class ScopesScopeCredentialStoresCredentialStoreCredentialLibrari
const { isNew } = credentialLibrary;
credentialLibrary.rollbackAttributes();
if (isNew)
this.transitionTo(
this.router.transitionTo(
'scopes.scope.credential-stores.credential-store.credential-libraries'
);
}
@@ -57,12 +60,12 @@ export default class ScopesScopeCredentialStoresCredentialStoreCredentialLibrari
async save(credentialLibrary) {
await credentialLibrary.save();
if (this.can.can('read model', credentialLibrary)) {
await this.transitionTo(
await this.router.transitionTo(
'scopes.scope.credential-stores.credential-store.credential-libraries.credential-library',
credentialLibrary
);
} else {
await this.transitionTo(
await this.router.transitionTo(
'scopes.scope.credential-stores.credential-store.credential-libraries'
);
}
+2 -1
View File
@@ -5,6 +5,7 @@ export default class ScopesScopeEditRoute extends Route {
// =services
@service session;
@service router;
// =methods
@@ -12,6 +13,6 @@ export default class ScopesScopeEditRoute extends Route {
* If arriving here unauthenticated, redirect to index for further processing.
*/
beforeModel() {
if (!this.session.isAuthenticated) this.transitionTo('index');
if (!this.session.isAuthenticated) this.router.transitionTo('index');
}
}
+4 -4
View File
@@ -20,7 +20,7 @@ export default class ScopesScopeGroupsRoute extends Route {
* If arriving here unauthenticated, redirect to index for further processing.
*/
beforeModel() {
if (!this.session.isAuthenticated) this.transitionTo('index');
if (!this.session.isAuthenticated) this.router.transitionTo('index');
}
/**
@@ -44,7 +44,7 @@ export default class ScopesScopeGroupsRoute extends Route {
cancel(group) {
const { isNew } = group;
group.rollbackAttributes();
if (isNew) this.transitionTo('scopes.scope.groups');
if (isNew) this.router.transitionTo('scopes.scope.groups');
}
/**
@@ -60,9 +60,9 @@ export default class ScopesScopeGroupsRoute extends Route {
async save(group) {
await group.save();
if (this.can.can('read model', group)) {
await this.transitionTo('scopes.scope.groups.group', group);
await this.router.transitionTo('scopes.scope.groups.group', group);
} else {
await this.transitionTo('scopes.scope.groups');
await this.router.transitionTo('scopes.scope.groups');
}
this.refresh();
}
@@ -20,7 +20,7 @@ export default class ScopesScopeHostCatalogsRoute extends Route {
* If arriving here unauthenticated, redirect to index for further processing.
*/
beforeModel() {
if (!this.session.isAuthenticated) this.transitionTo('index');
if (!this.session.isAuthenticated) this.router.transitionTo('index');
}
/**
@@ -47,7 +47,7 @@ export default class ScopesScopeHostCatalogsRoute extends Route {
cancel(hostCatalog) {
const { isNew } = hostCatalog;
hostCatalog.rollbackAttributes();
if (isNew) this.transitionTo('scopes.scope.host-catalogs');
if (isNew) this.router.transitionTo('scopes.scope.host-catalogs');
}
/**
@@ -63,7 +63,7 @@ export default class ScopesScopeHostCatalogsRoute extends Route {
)
async save(hostCatalog) {
await hostCatalog.save();
await this.transitionTo(
await this.router.transitionTo(
'scopes.scope.host-catalogs.host-catalog',
hostCatalog
);
@@ -45,7 +45,9 @@ export default class ScopesScopeHostCatalogsHostCatalogHostSetsRoute extends Rou
const { isNew } = hostSet;
hostSet.rollbackAttributes();
if (isNew)
this.transitionTo('scopes.scope.host-catalogs.host-catalog.host-sets');
this.router.transitionTo(
'scopes.scope.host-catalogs.host-catalog.host-sets'
);
}
/**
@@ -62,12 +64,12 @@ export default class ScopesScopeHostCatalogsHostCatalogHostSetsRoute extends Rou
async save(hostSet) {
await hostSet.save();
if (this.can.can('read model', hostSet)) {
await this.transitionTo(
await this.router.transitionTo(
'scopes.scope.host-catalogs.host-catalog.host-sets.host-set',
hostSet
);
} else {
await this.transitionTo(
await this.router.transitionTo(
'scopes.scope.host-catalogs.host-catalog.host-sets'
);
}
@@ -44,7 +44,7 @@ export default class ScopesScopeHostCatalogsHostCatalogHostsRoute extends Route
const { isNew } = host;
host.rollbackAttributes();
if (isNew)
this.transitionTo('scopes.scope.host-catalogs.host-catalog.hosts');
this.router.transitionTo('scopes.scope.host-catalogs.host-catalog.hosts');
}
/**
@@ -61,12 +61,14 @@ export default class ScopesScopeHostCatalogsHostCatalogHostsRoute extends Route
async save(host) {
await host.save();
if (this.can.can('read model', host)) {
await this.transitionTo(
await this.router.transitionTo(
'scopes.scope.host-catalogs.host-catalog.hosts.host',
host
);
} else {
await this.transitionTo('scopes.scope.host-catalogs.host-catalog.hosts');
await this.router.transitionTo(
'scopes.scope.host-catalogs.host-catalog.hosts'
);
}
this.refresh();
}
+4 -3
View File
@@ -5,6 +5,7 @@ export default class ScopesScopeIndexRoute extends Route {
// =services
@service session;
@service router;
// =methods
@@ -15,11 +16,11 @@ export default class ScopesScopeIndexRoute extends Route {
*/
redirect(model) {
if (!this.session.isAuthenticated) {
this.transitionTo('scopes.scope.authenticate');
this.router.transitionTo('scopes.scope.authenticate');
} else if (model.isProject) {
this.transitionTo('scopes.scope.edit');
this.router.transitionTo('scopes.scope.edit');
} else {
this.transitionTo('scopes.scope.scopes');
this.router.transitionTo('scopes.scope.scopes');
}
}
}
+2 -1
View File
@@ -5,6 +5,7 @@ export default class ScopesScopeNewRoute extends Route {
// =services
@service session;
@service router;
// =methods
@@ -12,7 +13,7 @@ export default class ScopesScopeNewRoute extends Route {
* If arriving here unauthenticated, redirect to index for further processing.
*/
beforeModel() {
if (!this.session.isAuthenticated) this.transitionTo('index');
if (!this.session.isAuthenticated) this.router.transitionTo('index');
}
/**
+4 -4
View File
@@ -20,7 +20,7 @@ export default class ScopesScopeRolesRoute extends Route {
* If arriving here unauthenticated, redirect to index for further processing.
*/
beforeModel() {
if (!this.session.isAuthenticated) this.transitionTo('index');
if (!this.session.isAuthenticated) this.router.transitionTo('index');
}
/**
@@ -44,7 +44,7 @@ export default class ScopesScopeRolesRoute extends Route {
cancel(role) {
const { isNew } = role;
role.rollbackAttributes();
if (isNew) this.transitionTo('scopes.scope.roles');
if (isNew) this.router.transitionTo('scopes.scope.roles');
}
/**
@@ -60,9 +60,9 @@ export default class ScopesScopeRolesRoute extends Route {
async save(role) {
await role.save();
if (this.can.can('read model', role)) {
await this.transitionTo('scopes.scope.roles.role', role);
await this.router.transitionTo('scopes.scope.roles.role', role);
} else {
await this.transitionTo('scopes.scope.roles');
await this.router.transitionTo('scopes.scope.roles');
}
this.refresh();
}
+2 -1
View File
@@ -10,6 +10,7 @@ export default class ScopesScopeScopesRoute extends Route {
// =services
@service session;
@service router;
// =methods
@@ -17,7 +18,7 @@ export default class ScopesScopeScopesRoute extends Route {
* If arriving here unauthenticated, redirect to index for further processing.
*/
beforeModel() {
if (!this.session.isAuthenticated) this.transitionTo('index');
if (!this.session.isAuthenticated) this.router.transitionTo('index');
}
/**
+2 -1
View File
@@ -17,6 +17,7 @@ export default class ScopesScopeSessionsRoute extends Route {
@service notify;
@service session;
@service resourceFilterStore;
@service router;
// =attributes
@@ -37,7 +38,7 @@ export default class ScopesScopeSessionsRoute extends Route {
* If arriving here unauthenticated, redirect to index for further processing.
*/
beforeModel() {
if (!this.session.isAuthenticated) this.transitionTo('index');
if (!this.session.isAuthenticated) this.router.transitionTo('index');
}
/**
+4 -4
View File
@@ -20,7 +20,7 @@ export default class ScopesScopeTargetsRoute extends Route {
* If arriving here unauthenticated, redirect to index for further processing.
*/
beforeModel() {
if (!this.session.isAuthenticated) this.transitionTo('index');
if (!this.session.isAuthenticated) this.router.transitionTo('index');
}
/**
@@ -45,7 +45,7 @@ export default class ScopesScopeTargetsRoute extends Route {
cancel(target) {
const { isNew } = target;
target.rollbackAttributes();
if (isNew) this.transitionTo('scopes.scope.targets');
if (isNew) this.router.transitionTo('scopes.scope.targets');
}
/**
@@ -62,9 +62,9 @@ export default class ScopesScopeTargetsRoute extends Route {
async save(target) {
await target.save();
if (this.can.can('read model', target)) {
await this.transitionTo('scopes.scope.targets.target', target);
await this.router.transitionTo('scopes.scope.targets.target', target);
} else {
await this.transitionTo('scopes.scope.targets');
await this.router.transitionTo('scopes.scope.targets');
}
this.refresh();
}
+4 -4
View File
@@ -20,7 +20,7 @@ export default class ScopesScopeUsersRoute extends Route {
* If arriving here unauthenticated, redirect to index for further processing.
*/
beforeModel() {
if (!this.session.isAuthenticated) this.transitionTo('index');
if (!this.session.isAuthenticated) this.router.transitionTo('index');
}
/**
@@ -44,7 +44,7 @@ export default class ScopesScopeUsersRoute extends Route {
cancel(user) {
const { isNew } = user;
user.rollbackAttributes();
if (isNew) this.transitionTo('scopes.scope.users');
if (isNew) this.router.transitionTo('scopes.scope.users');
}
/**
@@ -61,9 +61,9 @@ export default class ScopesScopeUsersRoute extends Route {
async save(user) {
await user.save();
if (this.can.can('read model', user)) {
await this.transitionTo('scopes.scope.users.user', user);
await this.router.transitionTo('scopes.scope.users.user', user);
} else {
await this.transitionTo('scopes.scope.users');
await this.router.transitionTo('scopes.scope.users');
}
this.refresh();
}
@@ -12,6 +12,7 @@ export default class ScopesScopeAuthenticateMethodRoute extends Route {
@service notify;
@service ipc;
@service intl;
@service router;
// =methods
@@ -67,14 +68,14 @@ export default class ScopesScopeAuthenticateMethodRoute extends Route {
requestCookies,
{ scope, authMethod }
);
this.transitionTo('index');
this.router.transitionTo('index');
break;
case 'oidc':
await this.startOIDCAuthentication(authenticatorName, {
scope,
authMethod,
});
this.transitionTo('scopes.scope.authenticate.method.oidc');
this.router.transitionTo('scopes.scope.authenticate.method.oidc');
break;
}
}
@@ -12,8 +12,7 @@ export default class ScopesScopeAuthenticateMethodOidcRoute extends Route {
// =services
@service session;
// =attributes
@service router;
// =methods
@@ -39,7 +38,7 @@ export default class ScopesScopeAuthenticateMethodOidcRoute extends Route {
@action
@notifyError(() => 'errors.authentication-failed.title', { catch: true })
error(e) {
this.transitionTo('scopes.scope.authenticate.method.index');
this.router.transitionTo('scopes.scope.authenticate.method.index');
// rethrow the error to activate the notifyError decorator
throw e;
}
@@ -20,6 +20,7 @@ export default class ScopesScopeProjectsRoute extends Route {
@service session;
@service resourceFilterStore;
@service router;
// =methods
@@ -27,7 +28,7 @@ export default class ScopesScopeProjectsRoute extends Route {
* If arriving here unauthenticated, redirect to index for further processing.
*/
beforeModel() {
if (!this.session.isAuthenticated) this.transitionTo('index');
if (!this.session.isAuthenticated) this.router.transitionTo('index');
}
/**
@@ -14,6 +14,7 @@ export default class ScopesScopeProjectsSessionsRoute extends Route {
@service ipc;
@service session;
@service resourceFilterStore;
@service router;
// =attributes
@@ -36,7 +37,7 @@ export default class ScopesScopeProjectsSessionsRoute extends Route {
* If arriving here unauthenticated, redirect to index for further processing.
*/
beforeModel() {
if (!this.session.isAuthenticated) this.transitionTo('index');
if (!this.session.isAuthenticated) this.router.transitionTo('index');
}
/**
@@ -16,6 +16,7 @@ export default class ScopesScopeProjectsTargetsRoute extends Route {
@service notify;
@service confirm;
@service resourceFilterStore;
@service router;
// =attributes
@@ -32,7 +33,7 @@ export default class ScopesScopeProjectsTargetsRoute extends Route {
* If arriving here unauthenticated, redirect to index for further processing.
*/
beforeModel() {
if (!this.session.isAuthenticated) this.transitionTo('index');
if (!this.session.isAuthenticated) this.router.transitionTo('index');
}
/**
@@ -1,12 +1,17 @@
import Route from '@ember/routing/route';
import { inject as service } from '@ember/service';
export default class ScopesScopeProjectsTargetsTargetIndexRoute extends Route {
// =services
@service router;
// =methods
/**
* Navigate to hosts within a target.
*/
afterModel() {
this.transitionTo('scopes.scope.projects.targets.target.sessions');
this.router.transitionTo('scopes.scope.projects.targets.target.sessions');
}
}