Ghost/ghost/admin/app/routes/dashboard.js
Kevin Ansfield 9760e67b3d Added "Get started" modal for first-load onboarding
refs https://github.com/TryGhost/Team/issues/1295

- modal is triggered by the query param `?firstStart=true`, eg https://localhost:2368/ghost/#/?firstStart=true
- clears the query param after triggering the modal so it doesn't get re-triggered after leaving and re-entering the dashboard route
2022-02-01 17:47:50 +00:00

35 lines
1000 B
JavaScript

import AuthenticatedRoute from 'ghost-admin/routes/authenticated';
import {inject as service} from '@ember/service';
export default class DashboardRoute extends AuthenticatedRoute {
@service feature;
@service modals;
beforeModel(transition) {
super.beforeModel(...arguments);
if (!this.session.user.isAdmin) {
return this.transitionTo('site');
}
if (this.feature.improvedOnboarding && transition.to?.queryParams?.firstStart === 'true') {
this.modals.open('modals/get-started');
// clear the query param so it doesn't stick around
transition.abort();
const queryParams = Object.assign({}, transition.to.queryParams, {firstStart: false});
this.transitionTo('dashboard', {queryParams});
}
}
buildRouteInfoMetadata() {
return {
mainClasses: ['gh-main-wide']
};
}
setupController() {
this.controller.initialise();
}
}