Skip to content

Commit b8f4414

Browse files
committed
fix: get chart history ability based on dashboard instead of users
See: BEDS-875
1 parent 14805c6 commit b8f4414

File tree

6 files changed

+22
-51
lines changed

6 files changed

+22
-51
lines changed

frontend/components/dashboard/chart/DashboardChartRewardsFilter.vue

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,30 +11,20 @@ type AggregationTimeframe = keyof ChartHistorySeconds
1111
1212
const {
1313
groups,
14-
isGuestDashboard,
1514
} = defineProps<{
1615
groups: VDBOverviewGroup[],
17-
isGuestDashboard?: boolean,
1816
}>()
1917
2018
const { t: $t } = useTranslation()
2119
20+
const { networkInfo } = useNetworkStore()
21+
const validatorDashboardsOverviewStore = useValidatorDashboardOverviewStore()
2222
const {
2323
hasAbilityRewardsChartHistory,
24-
isLoggedIn,
25-
} = useUserStore()
26-
const { networkInfo } = useNetworkStore()
24+
} = storeToRefs(validatorDashboardsOverviewStore)
2725
2826
const chartFilter = defineModel<RewardsChartFilter>({ required: true })
2927
30-
const productStore = useProductsStore()
31-
32-
const freeUserAbilityRewardsChartHistory = computed(() => {
33-
const rewardsChartHistorySeconds
34-
= productStore.premiumProducts.value['Free']?.premium_perks.rewards_chart_history_seconds
35-
return rewardsChartHistorySeconds
36-
})
37-
3828
const aggregationTimeframes: AggregationTimeframe[] = [
3929
'hourly',
4030
'daily',
@@ -43,9 +33,7 @@ const aggregationTimeframes: AggregationTimeframe[] = [
4333
const aggregationList = computed(() => {
4434
return aggregationTimeframes.map((timeframe) => {
4535
return {
46-
disabled: isLoggedIn.value
47-
? !hasAbilityRewardsChartHistory.value[timeframe]
48-
: !freeUserAbilityRewardsChartHistory.value[timeframe],
36+
disabled: !hasAbilityRewardsChartHistory.value[timeframe],
4937
id: timeframe,
5038
label: $t(`time_frames.${timeframe}`),
5139
}
@@ -79,7 +67,6 @@ const handleSetEndDate = (value: Date) => {
7967
<template>
8068
<div class="chart-filter-row">
8169
<BcDropdown
82-
v-if="!isGuestDashboard"
8370
v-model="chartFilter.aggregation"
8471
:options="aggregationList"
8572
option-value="id"

frontend/components/dashboard/chart/DashboardChartSummaryFilter.vue

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,34 +10,21 @@ import {
1010
} from '~/types/dashboard/summary'
1111
import { getGroupLabel } from '~/utils/dashboard/group'
1212
13-
const { isGuestDashboard } = defineProps<{ isGuestDashboard: boolean }>()
14-
1513
const { t: $t } = useTranslation()
1614
const validatorDashboardOverviewStore = useValidatorDashboardOverviewStore()
1715
const {
16+
hasAbilityChartHistory,
1817
overview,
1918
} = storeToRefs(validatorDashboardOverviewStore)
20-
const {
21-
hasAbilityChartHistory,
22-
isLoggedIn,
23-
} = useUserStore()
2419
2520
const chartFilter = defineModel<SummaryChartFilter>({ required: true })
2621
2722
/** aggregation */
2823
const aggregation = ref<AggregationTimeframe>(chartFilter.value.aggregation)
2924
30-
const productStore = useProductsStore()
31-
32-
const freeUserAbilityChartHistory = computed(() =>
33-
productStore.premiumProducts.value['Free']?.premium_perks.chart_history_seconds,
34-
)
35-
3625
const aggregationList = computed(() => {
3726
return AggregationTimeframes.map(timeframe => ({
38-
disabled: isLoggedIn.value
39-
? !hasAbilityChartHistory.value[timeframe]
40-
: !freeUserAbilityChartHistory.value[timeframe],
27+
disabled: !hasAbilityChartHistory.value[timeframe],
4128
id: timeframe,
4229
label: $t(`time_frames.${timeframe}`),
4330
}))
@@ -148,7 +135,6 @@ const selectedLabel = computed(() => {
148135
<template>
149136
<div class="chart-filter-row">
150137
<BcDropdown
151-
v-if="!isGuestDashboard"
152138
v-model="aggregation"
153139
:options="aggregationList"
154140
option-value="id"

frontend/components/dashboard/table/DashboardTableRewards.vue

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,6 @@ watch(() => selectedValidatorGroups.value, (newValue) => {
172172
v-if="!tableIsShown"
173173
v-model="chartFilter"
174174
:groups="usedValidatorGroups"
175-
:is-guest-dashboard
176175
/>
177176
</template>
178177
<template #table>

frontend/components/dashboard/table/DashboardTableSummary.vue

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,6 @@ watch(
175175
<DashboardChartSummaryFilter
176176
v-else
177177
v-model="chartFilter"
178-
:is-guest-dashboard
179178
/>
180179
</template>
181180
<template #table>

frontend/stores/dashboard/useValidatorDashboardOverviewStore.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,24 @@ export const useValidatorDashboardOverviewStore = defineStore('validator-dashboa
8484

8585
const groups = computed(() => overview.value?.groups)
8686

87+
const hasAbilityRewardsChartHistory = computed(() => ({
88+
daily: (overview.value?.rewards_chart_history_seconds?.daily ?? 0) > 0,
89+
epoch: (overview.value?.rewards_chart_history_seconds?.epoch ?? 0) > 0,
90+
hourly: (overview.value?.rewards_chart_history_seconds?.hourly ?? 0) > 0,
91+
weekly: (overview.value?.rewards_chart_history_seconds?.weekly ?? 0) > 0,
92+
}))
93+
94+
const hasAbilityChartHistory = computed(() => ({
95+
daily: (overview.value?.chart_history_seconds?.daily ?? 0) > 0,
96+
epoch: (overview.value?.chart_history_seconds?.epoch ?? 0) > 0,
97+
hourly: (overview.value?.chart_history_seconds?.hourly ?? 0) > 0,
98+
weekly: (overview.value?.chart_history_seconds?.weekly ?? 0) > 0,
99+
}))
100+
87101
return {
88102
groups,
103+
hasAbilityChartHistory,
104+
hasAbilityRewardsChartHistory,
89105
hasValidators,
90106
isLargeDashboard,
91107
loading,

frontend/stores/useUserStore.ts

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -50,25 +50,9 @@ export function useUserStore() {
5050

5151
const premium_perks = computed(() => user.value?.premium_perks)
5252

53-
const hasAbilityRewardsChartHistory = computed(() => ({
54-
daily: (user.value?.premium_perks.rewards_chart_history_seconds?.daily ?? 0) > 0,
55-
epoch: (user.value?.premium_perks.rewards_chart_history_seconds?.epoch ?? 0) > 0,
56-
hourly: (user.value?.premium_perks.rewards_chart_history_seconds?.hourly ?? 0) > 0,
57-
weekly: (user.value?.premium_perks.rewards_chart_history_seconds?.weekly ?? 0) > 0,
58-
}))
59-
60-
const hasAbilityChartHistory = computed(() => ({
61-
daily: (user.value?.premium_perks.chart_history_seconds?.daily ?? 0) > 0,
62-
epoch: (user.value?.premium_perks.chart_history_seconds?.epoch ?? 0) > 0,
63-
hourly: (user.value?.premium_perks.chart_history_seconds?.hourly ?? 0) > 0,
64-
weekly: (user.value?.premium_perks.chart_history_seconds?.weekly ?? 0) > 0,
65-
}))
66-
6753
return {
6854
doLogout,
6955
getUser,
70-
hasAbilityChartHistory,
71-
hasAbilityRewardsChartHistory,
7256
hasV1Notifications,
7357
isLoggedIn,
7458
premium_perks,

0 commit comments

Comments
 (0)