Skip to content

Commit

Permalink
refactor: use better terminology for dashboard types
Browse files Browse the repository at this point in the history
- replaces all mentions of "public" dashboards with "guest" dashboards, as this is the correct internal terminology.
- replaces all mentions of "hash" regarding guest dashboards with "key", as guest dashboard keys are NOT hashes.
- unifies some misc. function and variable naming
  • Loading branch information
LuccaBitfly committed Nov 27, 2024
1 parent e95f9c9 commit 7a0dba6
Show file tree
Hide file tree
Showing 19 changed files with 129 additions and 126 deletions.
32 changes: 16 additions & 16 deletions frontend/components/dashboard/DashboardControls.vue
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@ const { isLoggedIn } = useUserStore()
const {
dashboardKey,
dashboardType,
isPrivate,
isPublic,
isShared,
isGuestDashboard,
isPrivateDashboard,
isSharedDashboard,
publicEntities,
setDashboardKey,
} = useDashboardKey()
const { refreshOverview } = useValidatorDashboardOverviewStore()
const {
dashboards, getDashboardLabel, refreshDashboards, updateHash,
dashboards, getDashboardLabel, refreshDashboards, updateGuestDashboardKey,
}
= useUserDashboardStore()
Expand All @@ -59,7 +59,7 @@ const manageGroupsModalVisisble = ref(false)
const manageValidatorsModalVisisble = ref(false)
const manageButtons = computed<MenuBarEntry[] | undefined>(() => {
if (isShared.value) {
if (isSharedDashboard.value) {
return undefined
}
Expand Down Expand Up @@ -108,15 +108,15 @@ const shareDashboard = computed(() => {
})
const shareButtonOptions = computed(() => {
const edit = isPrivate.value && !shareDashboard.value?.public_ids?.length
const edit = isPrivateDashboard.value && !shareDashboard.value?.public_ids?.length
const label = isMobile.value
? ''
: !edit
? $t('dashboard.shared')
: $t('dashboard.share')
const icon = !edit ? faUsers : faShare
const disabled = isShared.value || !dashboardKey.value
const disabled = isSharedDashboard.value || !dashboardKey.value
return {
disabled,
edit,
Expand All @@ -130,7 +130,7 @@ const editButtons = computed<MenuBarEntry[]>(() => {
buttons.push({ component: RocketpoolToggle })
if (isPrivate.value) {
if (isPrivateDashboard.value) {
buttons.push({
command: editDashboard,
faIcon: faEdit,
Expand All @@ -148,7 +148,7 @@ const editButtons = computed<MenuBarEntry[]>(() => {
})
}
if (!isShared.value && dashboardKey.value) {
if (!isSharedDashboard.value && dashboardKey.value) {
buttons.push({
command: onDelete,
faIcon: faTrash,
Expand All @@ -172,7 +172,7 @@ const shareView = () => {
},
onClose: (options?: DynamicDialogCloseOptions) => {
if (options?.data === 'DELETE') {
if (isShared.value && dashboardId) {
if (isSharedDashboard.value && dashboardId) {
setDashboardKey(`${dashboardId}`)
}
}
Expand Down Expand Up @@ -202,12 +202,12 @@ const share = () => {
}
const deleteButtonOptions = computed(() => {
const visible = !isShared.value
const visible = !isSharedDashboard.value
const disabled = isPublic.value && publicEntities.value?.length === 0
const disabled = isGuestDashboard.value && publicEntities.value?.length === 0
// private dashboards always get deleted, public dashboards only get cleared
const deleteDashboard = isPrivate.value
// private dashboards always get deleted, guest dashboards only get cleared
const deleteDashboard = isPrivateDashboard.value
// we can only forward if there is something to forward to after a potential deletion
const privateDashboardsCount = isLoggedIn.value
Expand Down Expand Up @@ -281,8 +281,8 @@ const deleteAction = async (
await refreshDashboards()
}
else if (!isLoggedIn.value) {
// simply clear the public dashboard by emptying the hash
updateHash(dashboardType.value, '')
// simply clear the guest dashboard by emptying the key
updateGuestDashboardKey(dashboardType.value, '')
setDashboardKey('')
return
}
Expand Down
18 changes: 9 additions & 9 deletions frontend/components/dashboard/DashboardHeader.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type {
} from '~/types/menuBar'
import { useUserDashboardStore } from '~/stores/dashboard/useUserDashboardStore'
import {
COOKIE_DASHBOARD_ID, type CookieDashboard, type Dashboard, type DashboardKey, type DashboardType,
type Dashboard, type DashboardKey, type DashboardType, GUEST_DASHBOARD_ID, type GuestDashboard,
} from '~/types/dashboard'
const { t: $t } = useTranslation()
Expand All @@ -16,7 +16,7 @@ const { has } = useFeatureFlag()
const { isLoggedIn } = useUserStore()
const { dashboards } = useUserDashboardStore()
const {
dashboardKey, dashboardType, isShared, setDashboardKey,
dashboardKey, dashboardType, isSharedDashboard, setDashboardKey,
} = useDashboardKey()
const emit = defineEmits<{ (e: 'showCreation'): void }>()
Expand All @@ -26,14 +26,14 @@ const getDashboardName = (db: Dashboard): string => {
return db.name || `${$t('dashboard.title')} ${db.id}` // Just to be sure, we should not have dashboards without a name in prod
}
else {
return db.id === COOKIE_DASHBOARD_ID.ACCOUNT
return db.id === GUEST_DASHBOARD_ID.ACCOUNT
? $t('dashboard.account_dashboard')
: $t('dashboard.validator_dashboard')
}
}
const items = computed<MenuBarEntry[]>(() => {
if (dashboards.value === undefined || isShared.value) {
if (dashboards.value === undefined || isSharedDashboard.value) {
return []
}
Expand Down Expand Up @@ -87,13 +87,13 @@ const items = computed<MenuBarEntry[]>(() => {
}
}
addToSortedItems($t('dashboard.header.validator'), dashboards.value?.validator_dashboards?.map((db) => {
const cd = db as CookieDashboard
return createMenuBarButton('validator', getDashboardName(cd), `${cd.hash !== undefined ? cd.hash : cd.id}`)
const gd = db as GuestDashboard
return createMenuBarButton('validator', getDashboardName(gd), `${gd.key !== undefined ? gd.key : gd.id}`)
}))
if (has('feature-account_dashboards')) {
addToSortedItems($t('dashboard.header.account'), dashboards.value?.validator_dashboards?.slice(0, 1).map((db) => {
const cd = db as CookieDashboard
return createMenuBarButton('account', getDashboardName(cd), `${cd.hash ?? cd.id}`)
const gd = db as GuestDashboard
return createMenuBarButton('account', getDashboardName(gd), `${gd.key ?? gd.id}`)
}))
}
const disabledTooltip = !has('feature-notifications') ? $t('common.coming_soon') : undefined
Expand All @@ -115,7 +115,7 @@ const items = computed<MenuBarEntry[]>(() => {
:buttons="items"
/>
<BcButton
v-if="!isShared"
v-if="!isSharedDashboard"
variant="secondary"
class="p-button-icon-only"
@click="emit('showCreation')"
Expand Down
10 changes: 5 additions & 5 deletions frontend/components/dashboard/DashboardShareCodeModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
import { warn } from 'vue'
import type { ValidatorDashboard } from '~/types/api/dashboard'
import { API_PATH } from '~/types/customFetch'
import { isSharedKey } from '~/utils/dashboard/key'
import { isSharedDashboardKey } from '~/utils/dashboard/key'
interface Props {
// Currently only validator dashboards are supported. For public dashboards this will be undefined
// Currently only validator dashboards are supported. For guest dashboards this will be undefined
dashboard?: ValidatorDashboard,
dashboardKey: string,
}
Expand All @@ -29,7 +29,7 @@ const sharedKey = computed(() =>
: props.value?.dashboardKey,
)
const isShared = computed(() => isSharedKey(sharedKey.value))
const isShared = computed(() => isSharedDashboardKey(sharedKey.value))
const path = computed(() => {
const newRoute = router.resolve({
Expand All @@ -41,15 +41,15 @@ const path = computed(() => {
const edit = () => {
if (isReadonly.value) {
warn('cannot edit public dashboard share')
warn('cannot edit guest dashboard share')
return
}
dialogRef?.value?.close('EDIT')
}
const unpublish = async () => {
if (isReadonly.value) {
warn('cannot delete public dashboard share')
warn('cannot delete guest dashboard share')
return
}
if (isUpdating.value) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,9 @@ const selectedGroup = ref<number>(-1)
const {
addEntities,
dashboardKey,
isPublic: isPublicDashboard,
isGuestDashboard,
removeEntities,
}
= useDashboardKey()
} = useDashboardKey()
const {
user,
} = useUserStore()
Expand Down Expand Up @@ -136,7 +135,7 @@ const removeValidators = async (validators?: NumberOrString[]) => {
warn('no validators selected to change group')
return
}
if (isPublicDashboard.value) {
if (isGuestDashboard.value) {
removeEntities(validators.map(v => v.toString()))
return
}
Expand Down Expand Up @@ -275,7 +274,7 @@ const removeRow = (row: VDBManageValidatorsTableRow) => {
const totalValidators = computed(() => addUpValues(overview.value?.validators))
const maxValidatorsPerDashboard = computed(() =>
isPublicDashboard.value || !user.value?.premium_perks?.validators_per_dashboard
isGuestDashboard.value || !user.value?.premium_perks?.validators_per_dashboard
? 20
: user.value.premium_perks.validators_per_dashboard,
)
Expand Down Expand Up @@ -312,7 +311,7 @@ const handleSubmit = (item: InternalPostSearchResponse['data'][number] | undefin
handleInvalidSubmit()
return
}
if (isPublicDashboard.value) {
if (isGuestDashboard.value) {
if (item.type === 'validator') {
addEntities([ `${item.value.index}` ])
resetInput()
Expand Down Expand Up @@ -360,7 +359,7 @@ const inputValidator = ref('')
<BcTableControl
:search-placeholder="
$t(
isPublicDashboard
isGuestDashboard
? 'dashboard.validator.summary.search_placeholder_public'
: 'dashboard.validator.summary.search_placeholder',
)
Expand Down Expand Up @@ -390,7 +389,7 @@ const inputValidator = ref('')
:has-premium-perk-bulk-adding
:total-validators
:max-validators-per-dashboard
:is-public-dashboard
:is-guest-dashboard
@submit="handleSubmit"
/>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { API_PATH } from '~/types/customFetch'
const props = defineProps<{
hasPremiumPerkBulkAdding: boolean,
isPublicDashboard: boolean,
isGuestDashboard: boolean,
maxValidatorsPerDashboard: number,
totalValidators: number,
}>()
Expand Down Expand Up @@ -67,7 +67,7 @@ const isDisabled = (type: InternalPostSearchResponse['data'][number]['type'], va
return true
}
if (
props.isPublicDashboard
props.isGuestDashboard
&& ((type !== 'validator' && type !== 'validator_list'))
) {
return true
Expand Down
9 changes: 5 additions & 4 deletions frontend/components/dashboard/GroupManagementModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ const { fetch } = useCustomFetch()
const dialog = useDialog()
const {
dashboardKey, isPublic,
dashboardKey,
isGuestDashboard,
} = useDashboardKey()
const {
Expand Down Expand Up @@ -186,7 +187,7 @@ const dashboardName = computed(() => {
})
const maxGroupsPerDashboard = computed(() =>
isPublic.value || !user.value?.premium_perks?.validator_groups_per_dashboard
isGuestDashboard.value || !user.value?.premium_perks?.validator_groups_per_dashboard
? 1
: user.value.premium_perks.validator_groups_per_dashboard,
)
Expand Down Expand Up @@ -222,7 +223,7 @@ const isMobile = computed(() => {
:search-placeholder="
$t('dashboard.validator.group_management.search_placeholder')
"
:disabled-filter="isPublic"
:disabled-filter="isGuestDashboard"
@set-search="setSearch"
>
<template #header-left>
Expand Down Expand Up @@ -288,7 +289,7 @@ const isMobile = computed(() => {
: ''
"
:can-be-empty="slotProps.data.id === 0"
:disabled="isPublic"
:disabled="isGuestDashboard"
:pattern="REGEXP_VALID_NAME"
:trim-input="true"
:maxlength="20"
Expand Down
4 changes: 2 additions & 2 deletions frontend/components/dashboard/SharedDashboardModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ const cookiePreference = useCookie<CookiesPreference>(
COOKIE_KEY.COOKIES_PREFERENCE,
{ default: () => undefined },
)
const { isShared } = useDashboardKey()
const { isSharedDashboard } = useDashboardKey()
const { dashboards } = useUserDashboardStore()
const { t: $t } = useTranslation()
const route = useRoute()
const dismissed = ref(false)
const visible = computed(
() =>
isShared.value && !dismissed.value && cookiePreference.value !== undefined,
isSharedDashboard.value && !dismissed.value && cookiePreference.value !== undefined,
)
const text = computed(() => {
Expand Down
2 changes: 1 addition & 1 deletion frontend/components/dashboard/chart/RewardsChart.vue
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ use([
const { fetch } = useCustomFetch()
const {
dashboardKey, isPrivate: groupsEnabled,
dashboardKey, isPrivateDashboard: groupsEnabled,
} = useDashboardKey()
const data = ref<ChartData<number, string> | undefined>()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ async function createDashboard() {
const response = await createAccountDashboard(name.value, publicKey)
await navigateTo(
`/account-dashboard/${response?.hash ?? response?.id ?? 1}`,
`/account-dashboard/${response?.key ?? response?.id ?? 1}`,
)
}
else if (type.value === 'validator') {
Expand Down Expand Up @@ -154,7 +154,7 @@ async function createDashboard() {
{ dashboardKey: response.id },
)
}
await navigateTo(`/dashboard/${response?.hash ?? response?.id ?? 1}`)
await navigateTo(`/dashboard/${response?.key ?? response?.id ?? 1}`)
}
}
</script>
Expand Down
5 changes: 3 additions & 2 deletions frontend/components/dashboard/table/DashboardTableBlocks.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import { BcFormatHash } from '#components'
import { getGroupLabel } from '~/utils/dashboard/group'
const {
dashboardKey, isPublic,
dashboardKey,
isGuestDashboard,
} = useDashboardKey()
const cursor = ref<Cursor>()
Expand Down Expand Up @@ -118,7 +119,7 @@ const isRowExpandable = (row: VDBBlocksTableRow) => {
:title="$t('dashboard.validator.blocks.title')"
:search-placeholder="
$t(
isPublic
isGuestDashboard
? 'dashboard.validator.blocks.search_placeholder_public'
: 'dashboard.validator.blocks.search_placeholder',
)
Expand Down
5 changes: 3 additions & 2 deletions frontend/components/dashboard/table/DashboardTableRewards.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ import { formatRewardValueOption } from '~/utils/dashboard/table'
import { useValidatorDashboardOverviewStore } from '~/stores/dashboard/useValidatorDashboardOverviewStore'
const {
dashboardKey, isPublic,
dashboardKey,
isGuestDashboard,
} = useDashboardKey()
const cursor = ref<Cursor>()
Expand Down Expand Up @@ -145,7 +146,7 @@ const findNextEpochDuties = (epoch: number) => {
:title="$t('dashboard.validator.rewards.title')"
:search-placeholder="
$t(
isPublic
isGuestDashboard
? 'dashboard.validator.rewards.search_placeholder_public'
: 'dashboard.validator.rewards.search_placeholder',
)
Expand Down
Loading

0 comments on commit 7a0dba6

Please sign in to comment.