Fixed breadcrumbs when going from analytics to member

refs https://github.com/TryGhost/Team/issues/2140
This commit is contained in:
Simon Backx 2022-10-26 14:32:31 +02:00
parent 310459c3b9
commit 4501c82820

View File

@ -34,7 +34,19 @@ export default class MembersRoute extends AdminRoute {
controller.fetchMemberTask.perform(member.id);
}
if (transition.from?.name === 'members.index' && transition.from?.parent?.name === 'members') {
if (transition.from?.name === 'posts.analytics') {
// Sadly transition.from.params is not reliable to use (not populated on transitions)
const oldParams = transition.router?.oldState?.params['posts.analytics'] ?? {};
// We need to store analytics in 'this' to have it accessible for the member route
this.fromAnalytics = Object.values(oldParams);
controller.fromAnalytics = this.fromAnalytics;
} else if (transition.from?.metadata?.fromAnalytics) {
// Handle returning from member route
const fromAnalytics = transition.from?.metadata.fromAnalytics ?? null;
controller.fromAnalytics = fromAnalytics;
this.fromAnalytics = fromAnalytics;
} else if (transition.from?.name === 'members.index' && transition.from?.parent?.name === 'members') {
const fromAnalytics = transition.from?.parent?.metadata.fromAnalytics ?? null;
controller.fromAnalytics = fromAnalytics;
this.fromAnalytics = fromAnalytics;