Handled null sources for attribution chart and table

refs https://github.com/TryGhost/Team/issues/1932

- removes null sources from attribution chart
- moves null sources count to bottom of attribution table
This commit is contained in:
Rishabh 2022-09-22 21:04:46 +05:30
parent 45a301277d
commit e93f6071cd
4 changed files with 22 additions and 2 deletions

View File

@ -10,7 +10,7 @@
<div style="border-left: 1px solid #eceef0; padding-left: 48px;display: flex;justify-content: center;align-items: center;">
<div style="max-width: 200px;">
<MemberAttribution::SourceAttributionChart @sources={{this.sources}} />
<MemberAttribution::SourceAttributionChart @sources={{this.chartSources}} />
</div>
</div>
</div>

View File

@ -14,6 +14,12 @@ export default class Recents extends Component {
return this.dashboardStats?.memberSourceAttributionCounts || [];
}
get chartSources() {
const counts = this.dashboardStats?.memberSourceAttributionCounts || [];
// filter null source from the list
return counts.filter(source => source.source);
}
get areMembersEnabled() {
return this.dashboardStats.siteStatus?.membersEnabled;
}

View File

@ -7,7 +7,7 @@
{{/if}}
</div>
<div class="gh-dashboard-list-body">
{{#each @sources as |sourceData|}}
{{#each this.sources as |sourceData|}}
<div class="gh-dashboard-list-item">
<div class="gh-dashboard-list-item-sub">
<span class="gh-dashboard-list-text">{{sourceData.source}}</span>

View File

@ -3,4 +3,18 @@ import {inject as service} from '@ember/service';
export default class SourceAttributionTable extends Component {
@service membersUtils;
get sources() {
const availableSources = this.args.sources.filter(source => source.source);
const unavailableSources = this.args.sources.filter(sourceData => !sourceData.source).map((sourceData) => {
return {
...sourceData,
source: 'Unavailable'
};
});
return [
...availableSources,
...unavailableSources
];
}
}