Fixed member page breadcrumbs coming from analytics

fixes https://github.com/TryGhost/Team/issues/2140
This commit is contained in:
Simon Backx 2022-10-27 17:24:57 +02:00
parent b916300ceb
commit 2903a30d39
3 changed files with 13 additions and 4 deletions

View File

@ -27,6 +27,9 @@ export default class MemberController extends Controller {
_previousLabels = null;
_previousNewsletters = null;
directlyFromAnalytics = false;
fromAnalytics = null;
constructor() {
super(...arguments);
this._availableLabels = this.store.peekAll('label');

View File

@ -34,6 +34,7 @@ export default class MembersRoute extends AdminRoute {
controller.fetchMemberTask.perform(member.id);
}
controller.directlyFromAnalytics = false;
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'] ?? {};
@ -41,6 +42,7 @@ export default class MembersRoute extends AdminRoute {
// We need to store analytics in 'this' to have it accessible for the member route
this.fromAnalytics = Object.values(oldParams);
controller.fromAnalytics = this.fromAnalytics;
controller.directlyFromAnalytics = true;
} else if (transition.from?.metadata?.fromAnalytics) {
// Handle returning from member route
const fromAnalytics = transition.from?.metadata.fromAnalytics ?? null;

View File

@ -10,10 +10,14 @@
<LinkTo @route="posts.analytics" @models={{this.fromAnalytics}}>
Analytics
</LinkTo>
{{svg-jar "arrow-right-small"}}
<LinkTo @route="members" data-test-link="members-back">
Members
</LinkTo>
{{#unless this.directlyFromAnalytics}}
{{svg-jar "arrow-right-small"}}
<LinkTo @route="members" data-test-link="members-back">
Members
</LinkTo>
{{/unless}}
{{svg-jar "arrow-right-small"}} {{if this.member.isNew "New member" "Edit member"}}
</div>
{{else}}