9d121d8e9a
closes https://linear.app/tryghost/issue/ANAL-10/stats-page-in-ghost-admin - Adds all the structure, logic and permissions tests for the Stats page to check we're loading the right thing at the right time - Adds @tinybirdco/charts as a dependency, and has a single example of a chart setup using the right config
29 lines
802 B
JavaScript
29 lines
802 B
JavaScript
import AuthenticatedRoute from 'ghost-admin/routes/authenticated';
|
|
import {inject} from 'ghost-admin/decorators/inject';
|
|
|
|
export default class StatsRoute extends AuthenticatedRoute {
|
|
@inject config;
|
|
|
|
beforeModel() {
|
|
super.beforeModel(...arguments);
|
|
|
|
// This is based on the logic for the dashboard
|
|
if (this.session.user.isContributor) {
|
|
return this.transitionTo('posts');
|
|
} else if (!this.session.user.isAdmin) {
|
|
return this.transitionTo('site');
|
|
}
|
|
|
|
// This ensures that we don't load this page if the stats config is not set
|
|
if (!this.config.stats) {
|
|
return this.transitionTo('home');
|
|
}
|
|
}
|
|
|
|
buildRouteInfoMetadata() {
|
|
return {
|
|
titleToken: 'Stats'
|
|
};
|
|
}
|
|
}
|