From 0589f327885b9fa5f6d7c76876e6ebcd55f24a99 Mon Sep 17 00:00:00 2001 From: Kevin Ansfield Date: Tue, 22 Feb 2022 17:13:32 +0000 Subject: [PATCH] Added last seen at column to members list when filtered closes https://github.com/TryGhost/Team/issues/1388 - added `lastSeenAtUTC` property to member model - added `last_seen_at` filter column handling to `` - uses same format as the "Created" column showing the date only and a "days ago" string --- .../gh-members-list-item-column.hbs | 26 ++++++++++++++----- .../app/components/gh-members-list-item.hbs | 8 +++--- ghost/admin/app/models/member.js | 1 + ghost/admin/app/serializers/member.js | 1 + .../tests/acceptance/members/filter-test.js | 6 +++++ 5 files changed, 31 insertions(+), 11 deletions(-) diff --git a/ghost/admin/app/components/gh-members-list-item-column.hbs b/ghost/admin/app/components/gh-members-list-item-column.hbs index f0d6ad21f8..9fd748541a 100644 --- a/ghost/admin/app/components/gh-members-list-item-column.hbs +++ b/ghost/admin/app/components/gh-members-list-item-column.hbs @@ -1,10 +1,10 @@ {{#if (eq @filterColumn 'label')}} - + {{this.labels}} {{else if (eq @filterColumn 'status')}} - + {{#if (not (is-empty @member.status))}} {{capitalize @member.status}} {{else}} @@ -12,8 +12,18 @@ {{/if}} +{{else if (eq @filterColumn 'last_seen_at')}} + + {{#if (not (is-empty @member.lastSeenAtUTC))}} + {{moment-format @member.lastSeenAtUTC "D MMM YYYY"}} +
{{moment-from-now @member.lastSeenAtUTC}}
+ {{else}} + - + {{/if}} +
+ {{else if (eq @filterColumn 'email_count')}} - + {{#if (not (is-empty @member.emailCount))}} {{@member.emailCount}} {{else}} @@ -22,7 +32,7 @@ {{else if (eq @filterColumn 'email_opened_count')}} - + {{#if (not (is-empty @member.emailOpenedCount))}} {{@member.emailOpenedCount}} {{else}} @@ -31,23 +41,25 @@ {{else if (eq @filterColumn 'subscribed')}} - + {{#if (not (is-empty @member.subscribed))}} {{if @member.subscribed "Yes" "No"}} {{else}} - {{/if}} + {{else if (eq @filterColumn 'subscriptions.status')}} - + {{#if (not (is-empty this.subscriptionStatus))}} {{capitalize this.subscriptionStatus}} {{else}} - {{/if}} + {{else if (eq @filterColumn 'subscriptions.plan_interval')}} - + {{#if (not (is-empty this.billingPeriod))}} {{capitalize this.billingPeriod}} {{else}} diff --git a/ghost/admin/app/components/gh-members-list-item.hbs b/ghost/admin/app/components/gh-members-list-item.hbs index 0c021cb661..3709bd7c50 100644 --- a/ghost/admin/app/components/gh-members-list-item.hbs +++ b/ghost/admin/app/components/gh-members-list-item.hbs @@ -11,7 +11,7 @@
{{/each}} {{else}} - +
@@ -36,7 +36,7 @@ {{/if}} {{#if @newsletterEnabled}} {{#if (feature "emailAnalytics")}} - + {{#if (not (is-empty @member.emailOpenRate))}} {{@member.emailOpenRate}}% {{else}} @@ -46,7 +46,7 @@ {{/if}} {{/if}} - + {{#if (and @member.geolocation @member.geolocation.country)}} {{#if (and (eq @member.geolocation.country_code "US") @member.geolocation.region)}} {{@member.geolocation.region}}, US @@ -62,7 +62,7 @@ {{/if}} - + {{#if @member.createdAtUTC}}
{{moment-format @member.createdAtUTC "D MMM YYYY"}}
{{moment-from-now @member.createdAtUTC}}
diff --git a/ghost/admin/app/models/member.js b/ghost/admin/app/models/member.js index d28b32e802..af1f1e155a 100644 --- a/ghost/admin/app/models/member.js +++ b/ghost/admin/app/models/member.js @@ -11,6 +11,7 @@ export default Model.extend(ValidationEngine, { note: attr('string'), status: attr('string'), createdAtUTC: attr('moment-utc'), + lastSeenAtUTC: attr('moment-utc'), subscriptions: attr('member-subscription'), subscribed: attr('boolean', {defaultValue: true}), comped: attr('boolean', {defaultValue: false}), diff --git a/ghost/admin/app/serializers/member.js b/ghost/admin/app/serializers/member.js index 3ca601efe7..5636903370 100644 --- a/ghost/admin/app/serializers/member.js +++ b/ghost/admin/app/serializers/member.js @@ -5,6 +5,7 @@ import {EmbeddedRecordsMixin} from '@ember-data/serializer/rest'; export default class MemberSerializer extends ApplicationSerializer.extend(EmbeddedRecordsMixin) { attrs = { createdAtUTC: {key: 'created_at'}, + lastSeenAtUTC: {key: 'last_seen_at'}, labels: {embedded: 'always'}, emailRecipients: {embedded: 'always'} }; diff --git a/ghost/admin/tests/acceptance/members/filter-test.js b/ghost/admin/tests/acceptance/members/filter-test.js index 327d7c2e37..f4146c2f82 100644 --- a/ghost/admin/tests/acceptance/members/filter-test.js +++ b/ghost/admin/tests/acceptance/members/filter-test.js @@ -520,6 +520,12 @@ describe('Acceptance: Members filtering', function () { expect(findAll('[data-test-list="members-list-item"]').length, '# of filtered member rows - last seen less than 6 days ago') .to.equal(4); + // table shows last seen column+data + expect(find('[data-test-table-column="last_seen_at"]')).to.exist; + expect(findAll('[data-test-table-data="last_seen_at"]').length).to.equal(4); + expect(find('[data-test-table-data="last_seen_at"]')).to.contain.text('5 Feb 2022'); + expect(find('[data-test-table-data="last_seen_at"]')).to.contain.text('5 days ago'); + await fillIn(valueInput, '11'); // last seen less than 11 days ago await blur(valueInput); expect(findAll('[data-test-list="members-list-item"]').length, '# of filtered member rows - last seen less than 11 days ago')