Cleaned up attribution widget on analytics page

- updates attribution widget on analytics page to work same as dashboard with data
This commit is contained in:
Rishabh 2022-09-29 23:33:17 +05:30
parent 40c66dae6a
commit 5eae093b3c
4 changed files with 49 additions and 9 deletions

View File

@ -31,7 +31,6 @@
<MemberAttribution::SourceAttributionTable
@sources={{this.sources}}
@sortColumn={{this.selectedSortColumn}}
@setSortColumn={{this.setSortColumn}}
class="gh-dashboard-attribution-list gh-dashboard-list"
/>
</div>
@ -40,7 +39,6 @@
<MemberAttribution::SourceAttributionChart
@sources={{this.chartSources}}
@sortColumn={{this.selectedSortColumn}}
@setSortColumn={{this.setSortColumn}}
/>
</div>
<div id="gh-dashboard-attribution-tooltip" class="gh-dashboard-tooltip">

View File

@ -4,8 +4,6 @@
{{#if (eq @sortColumn "signups")}}
<div
class="gh-dashboard-list-title {{if (eq @sortColumn "signups") "sorted-by"}}"
role="button" aria-label="Sort by free signups"
{{on "click" (fn @setSortColumn "signups")}}
>
Free signups
</div>
@ -13,9 +11,7 @@
{{#if (eq @sortColumn "paid")}}
{{#if this.membersUtils.paidMembersEnabled}}
<div
role="button" aria-label="Sort by paid signups"
class="gh-dashboard-list-title {{if (eq @sortColumn "paid") "sorted-by"}}"
{{on "click" (fn @setSortColumn "paid")}}
>
<span class="hide-when-small">Paid </span>Conversions
</div>

View File

@ -111,13 +111,14 @@
<div class="gh-dashboard-select" style="top:40px;right:24px">
<PowerSelect
@selected={{this.selectedDisplayOption}}
@options={{this.displayOptions}}
@options={{this.allowedDisplayOptions}}
@searchEnabled={{false}}
@onChange={{this.onDisplayChange}}
@triggerComponent={{component "gh-power-select/trigger"}}
@triggerClass="gh-contentfilter-menu-trigger"
@dropdownClass="gh-contentfilter-menu-dropdown is-narrow"
@matchTriggerWidth={{false}}
@disabled={{this.isDropdownDisabled}}
@horizontalPosition="right"
as |option|
@ -129,7 +130,6 @@
<MemberAttribution::SourceAttributionTable
@sources={{this.sources}}
@sortColumn={{this.sortColumn}}
@setSortColumn={{this.setSortColumn}}
/>
</div>
<div class="gh-attribution-chart-column">
@ -137,7 +137,6 @@
<MemberAttribution::SourceAttributionChart
@sources={{this.sources}}
@sortColumn={{this.sortColumn}}
@setSortColumn={{this.setSortColumn}}
/>
<div id="gh-dashboard-attribution-tooltip" class="gh-dashboard-tooltip">
<div class="gh-dashboard-tooltip-value">

View File

@ -33,10 +33,57 @@ export default class Analytics extends Component {
return this.args.post;
}
get allowedDisplayOptions() {
if (!this.hasPaidConversionData) {
return this.displayOptions.filter(d => d.value === 'signups');
}
if (!this.hasFreeSignups) {
return this.displayOptions.filter(d => d.value === 'paid');
}
return this.displayOptions;
}
get isDropdownDisabled() {
if (!this.hasPaidConversionData || !this.hasFreeSignups) {
return true;
}
return false;
}
get selectedDisplayOption() {
if (!this.hasPaidConversionData) {
return this.displayOptions.find(d => d.value === 'signups');
}
if (!this.hasFreeSignups) {
return this.displayOptions.find(d => d.value === 'paid');
}
return this.displayOptions.find(d => d.value === this.sortColumn) ?? this.displayOptions[0];
}
get selectedSortColumn() {
if (!this.hasPaidConversionData) {
return 'signups';
}
if (!this.hasFreeSignups) {
return 'paid';
}
return this.sortColumn;
}
get hasPaidConversionData() {
return this.sources.some(sourceData => sourceData.paidConversions > 0);
}
get hasFreeSignups() {
return this.sources.some(sourceData => sourceData.signups > 0);
}
@action
onDisplayChange(selected) {
this.sortColumn = selected.value;