From 2bb1c9cfec0c6e11485dab0787f6881041560fe5 Mon Sep 17 00:00:00 2001 From: Dharini Jeeva Date: Tue, 14 Jun 2022 14:21:48 -0700 Subject: [PATCH] Chore onboarding route (#1136) * fix: onboarding redirects --- ui/admin/app/routes/onboarding.js | 1 - ui/admin/app/routes/scopes/scope.js | 1 + ui/admin/app/routes/scopes/scope/index.js | 24 +++++++++++++++++----- ui/admin/app/routes/scopes/scope/scopes.js | 2 +- 4 files changed, 21 insertions(+), 7 deletions(-) diff --git a/ui/admin/app/routes/onboarding.js b/ui/admin/app/routes/onboarding.js index cb0b42389..4477d5731 100644 --- a/ui/admin/app/routes/onboarding.js +++ b/ui/admin/app/routes/onboarding.js @@ -22,7 +22,6 @@ export default class OnboardingRoute extends Route { model() { return this.store.query('scope', { scope_id: 'global', - recursive: true, }); } diff --git a/ui/admin/app/routes/scopes/scope.js b/ui/admin/app/routes/scopes/scope.js index 534940834..94b6afc71 100644 --- a/ui/admin/app/routes/scopes/scope.js +++ b/ui/admin/app/routes/scopes/scope.js @@ -54,6 +54,7 @@ export default class ScopesScopeRoute extends Route { orgs = await this.store .query('scope', { scope_id: 'global' }) .catch(() => A([])); + if (model.isProject) { projects = await this.store.query('scope', { scope_id: model.scopeID }); } diff --git a/ui/admin/app/routes/scopes/scope/index.js b/ui/admin/app/routes/scopes/scope/index.js index d2d2efeea..86d3c5fe1 100644 --- a/ui/admin/app/routes/scopes/scope/index.js +++ b/ui/admin/app/routes/scopes/scope/index.js @@ -13,14 +13,28 @@ export default class ScopesScopeIndexRoute extends Route { * Redirects to scopes/scope/authenticate for further processing. * If already authenticated, redirects to scopes/scope/scopes to display * list of sub scopes. + * + * If authenticated but no orgs exist, redirect into onboarding. */ redirect(model) { + const hasOrgs = this.store.peekAll('scope').filterBy('type', 'org').length; + + // Must authenticate before proceeding anywhere else if (!this.session.isAuthenticated) { - this.router.transitionTo('scopes.scope.authenticate'); - } else if (model.isProject) { - this.router.transitionTo('scopes.scope.edit'); - } else { - this.router.transitionTo('scopes.scope.scopes'); + return this.router.transitionTo('scopes.scope.authenticate'); } + + // If authenticated but no orgs exist yet, redirect to onboarding + if (this.session.isAuthenticated && !hasOrgs) { + return this.router.transitionTo('onboarding.quick-setup.choose-path'); + } + + // If this a project scope, there are no further sub scopes, so show edit + if (model.isProject) { + return this.router.transitionTo('scopes.scope.edit'); + } + + // For all other scope types (global and org), show sub scopes + return this.router.transitionTo('scopes.scope.scopes'); } } diff --git a/ui/admin/app/routes/scopes/scope/scopes.js b/ui/admin/app/routes/scopes/scope/scopes.js index 4052d285a..26a8dbc27 100644 --- a/ui/admin/app/routes/scopes/scope/scopes.js +++ b/ui/admin/app/routes/scopes/scope/scopes.js @@ -23,7 +23,7 @@ export default class ScopesScopeScopesRoute extends Route { /** * Loads sub scopes for the current scope. - * @return {Promise + * @return {Promise} */ async model() { const currentScope = this.modelFor('scopes.scope');