Ghost/ghost/admin/app/components/dashboard/latest-member-activity.hbs
Kevin Ansfield b5db0d57d9 Updated dashboard member activity widget to use fetcher resource
refs https://github.com/TryGhost/Team/issues/1277

- re-uses same fetcher resource used on member activities screen
  - allows for component to be simplified as it no longer needs to care about handling data loading itself
  - drops use of 1-minute data caching as there is no real need for it in typical usage and can be confusing when the dashboard didn't update as expected
- exposed error message on `members-event-fetcher` if one is encountered
2022-01-22 16:04:54 +00:00

55 lines
2.9 KiB
Handlebars

{{#if this.shouldDisplay}}
<div class="gh-dashboard-box grey activity-feed" data-test-dashboard-member-activity>
<h4 class="gh-dashboard-header">Activity feed</h4>
<div class="content">
{{#let (members-event-fetcher filter=(if (feature "membersActivityFeed") "type:-[email_delivered_event,email_opened_event,email_failed_event]") pageSize=5) as |eventsFetcher|}}
{{#if eventsFetcher.isLoading}}
Loading...
{{/if}}
{{#if eventsFetcher.isError}}
<p class="error">
There was an error loading events
{{#if eventsFetcher.errorMessage}}
<code>{{eventsFetcher.errorMessage}}</code>
{{/if}}
</p>
{{/if}}
{{#unless (or eventsFetcher.isLoading eventsFetcher.isError)}}
<GhMemberActivityEventParser @events={{eventsFetcher.data}} as |parsedEvents|>
<div class="gh-event-timeline">
{{#if parsedEvents}}
<ul class="gh-dashboard-activity-feed">
{{#each parsedEvents as |event|}}
<li data-test-dashboard-member-activity-item>
<LinkTo class="member-details" @route="member" @model="{{event.member_id}}">
<div class="activity">
<div>
<span class="member">{{event.subject}}</span> {{event.action}} {{event.object}} <span class="highlight">{{event.info}}</span>
</div>
</div>
</LinkTo>
<span class="time">{{event.timestamp}}</span>
</li>
{{/each}}
</ul>
{{else}}
<div class="gh-no-data-list" data-test-no-member-activities>
{{svg-jar "no-data-list"}}
<span>No member activity available.</span>
</div>
{{/if}}
</div>
</GhMemberActivityEventParser>
{{#if (feature "membersActivityFeed")}}
<div class="gh-dashboard-top-members-footer">
<LinkTo @route="members-activity">See all activity {{svg-jar "arrow-right"}}</LinkTo>
</div>
{{/if}}
{{/unless}}
{{/let}}
</div>
</div>
{{/if}}