mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-18 16:01:40 +03:00
17a6217cc7
fixes https://github.com/TryGhost/Team/issues/2404 This change introduces a new 'post' query parameter to the members and member routes. Previously, the members route would check if the previous route was the analytics page, and then show the breadcrumbs to go back to the analytics page. But when navigating to the members page from the menu, we don't want to show the breadcrumbs. To accomplish this, the routes that point to the members page from the analytics page now specifically pass on the post id in the query parameters. The query parameter is then passed on from the members page to the member page. `directlyFromAnalytics` is still used in the member route, to know wheter we came from the members page or from the analytics page (changes the breadcrumbs). This doesn't need to go via a query parameter (figured that would make the url too long/complex). The resetController method is now implemented and resets the filter and/or fromAnalytics post id if required (when going from members to member, we don't want to reset it because the we would lose the filter going back).
53 lines
1.6 KiB
JavaScript
53 lines
1.6 KiB
JavaScript
import AdminRoute from 'ghost-admin/routes/admin';
|
|
import {inject as service} from '@ember/service';
|
|
|
|
export default class MembersRoute extends AdminRoute {
|
|
@service store;
|
|
@service feature;
|
|
|
|
queryParams = {
|
|
label: {refreshModel: true},
|
|
searchParam: {refreshModel: true, replace: true},
|
|
paidParam: {refreshModel: true},
|
|
orderParam: {refreshModel: true},
|
|
filterParam: {refreshModel: true},
|
|
postAnalytics: {refreshModel: false}
|
|
};
|
|
|
|
beforeModel() {
|
|
super.beforeModel(...arguments);
|
|
// - TODO: redirect if members is disabled?
|
|
}
|
|
|
|
model(params) {
|
|
this.controllerFor('members').resetFilters(params);
|
|
return this.controllerFor('members').fetchMembersTask.perform(params);
|
|
}
|
|
|
|
// trigger a background load of members plus labels for filter dropdown
|
|
setupController(controller) {
|
|
super.setupController(...arguments);
|
|
controller.fetchLabelsTask.perform();
|
|
}
|
|
|
|
resetController(controller, _isExiting, transition) {
|
|
super.resetController(...arguments);
|
|
|
|
if (controller.postAnalytics) {
|
|
controller.set('postAnalytics', null);
|
|
// Only reset filters if we are not going to member route
|
|
// Otherwise the filters will be gone if we return
|
|
if (!transition?.to?.name?.startsWith('member')) {
|
|
controller.set('filterParam', null);
|
|
}
|
|
}
|
|
}
|
|
|
|
buildRouteInfoMetadata() {
|
|
return {
|
|
titleToken: 'Members',
|
|
mainClasses: ['gh-main-fullwidth']
|
|
};
|
|
}
|
|
}
|