0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-03-11 02:12:21 -05:00

Added mentions page for a post

fixes https://github.com/TryGhost/Team/issues/2590

Added a new route that only shows mentions for a given post. Reuses the same controller and template.
This commit is contained in:
Simon Backx 2023-02-22 10:48:15 +01:00
parent ea2a80583b
commit 85ac38cc48
6 changed files with 47 additions and 24 deletions

View file

@ -147,7 +147,7 @@
{{/if}}
</div>
<div class="gh-dashboard-list-footer">
<LinkTo @route="mentions">View all mentions &rarr;</LinkTo>
<LinkTo @route="posts.mentions" @model={{this.post.id}}>View all mentions &rarr;</LinkTo>
</div>
</div>
{{/if}}

View file

@ -2,6 +2,10 @@ import Controller from '@ember/controller';
export default class MentionsController extends Controller {
get mentionsInfinityModel() {
return this.model;
return this.model.mentions;
}
get post() {
return this.model.post;
}
}

View file

@ -30,6 +30,7 @@ Router.map(function () {
this.route('posts');
this.route('posts.analytics', {path: '/posts/analytics/:post_id'});
this.route('posts.mentions', {path: '/posts/analytics/:post_id/mentions'});
this.route('posts.debug', {path: '/posts/analytics/:post_id/debug'});
this.route('pages');
@ -55,7 +56,7 @@ Router.map(function () {
this.route('settings.code-injection', {path: '/settings/code-injection'});
this.route('settings.history', {path: '/settings/history'});
this.route('settings.analytics', {path: '/settings/analytics'});
// testing websockets
this.route('websockets');

View file

@ -1,4 +1,5 @@
import AuthenticatedRoute from 'ghost-admin/routes/authenticated';
import RSVP from 'rsvp';
import {inject as service} from '@ember/service';
export default class MentionsRoute extends AuthenticatedRoute {
@ -15,7 +16,7 @@ export default class MentionsRoute extends AuthenticatedRoute {
}
}
model() {
model(params) {
const perPage = this.perPage;
const paginationParams = {
perPageParam: 'limit',
@ -25,6 +26,13 @@ export default class MentionsRoute extends AuthenticatedRoute {
const paginationSettings = {perPage, startingPage: 1, order: 'created_at desc', ...paginationParams};
return this.infinity.model('mention', paginationSettings);
if (params.post_id) {
paginationSettings.filter = `resource_id:${params.post_id}+resource_type:post`;
}
return RSVP.hash({
mentions: this.infinity.model('mention', paginationSettings),
post: params.post_id ? this.store.findRecord('post', params.post_id) : null
});
}
}

View file

@ -0,0 +1,6 @@
import MentionsRoute from '../mentions';
export default class PostsMentionsRoute extends MentionsRoute {
controllerName = 'mentions';
templateName = 'mentions';
}

View file

@ -1,29 +1,33 @@
<section class="gh-canvas" {{scroll-top}}>
<GhCanvasHeader class="gh-canvas-header">
<div class="flex flex-column flex-grow-1">
{{!-- TODO: Only show breadcrumbs if the page is visited from Post analytics --}}
{{!-- <div class="gh-canvas-breadcrumb">
<LinkTo @route="posts">
Posts
</LinkTo>
{{svg-jar "arrow-right-small"}}
<LinkTo @route="posts">
Analytics
</LinkTo>
{{svg-jar "arrow-right-small"}}Mentions
</div> --}}
{{#if this.post }}
<div class="gh-canvas-breadcrumb">
<LinkTo @route="posts">
Posts
</LinkTo>
{{svg-jar "arrow-right-small"}}
<LinkTo @route="posts.analytics" @model={{this.post.id}}>
Analytics
</LinkTo>
{{svg-jar "arrow-right-small"}}Mentions
</div>
{{/if}}
<h2 class="gh-canvas-title gh-post-title" data-test-screen-title>
{{!-- TODO: Show the post name instead of "Mentions" if the page is visited from Post analytics --}}
Mentions
{{#if this.post }}
{{this.post.title}}
{{else}}
Mentions
{{/if}}
</h2>
{{!-- TODO: Only show the div below if the page is visited from Post analytics --}}
{{!-- <div class="gh-post-analytics-meta">
<div class="gh-post-analytics-meta-text">
This post was mentioned in:
{{#if this.post }}
<div class="gh-post-analytics-meta">
<div class="gh-post-analytics-meta-text">
This post was mentioned in:
</div>
</div>
</div> --}}
{{/if}}
</div>
</GhCanvasHeader>
<section class="gh-mentions-main-section">