Skip to content

Commit

Permalink
fix: show 3 validator indexes or correct validator count
Browse files Browse the repository at this point in the history
On DashboardTableSummary

See: BEDS-649
  • Loading branch information
marcel-bitfly committed Nov 4, 2024
1 parent e410ce3 commit a99fecc
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 16 deletions.
15 changes: 7 additions & 8 deletions frontend/components/dashboard/table/DashboardTableValidators.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import type {
} from '~/types/dashboard/summary'
import { DashboardValidatorSubsetModal } from '#components'
import { getGroupLabel } from '~/utils/dashboard/group'
import { sortValidatorIds } from '~/utils/dashboard/validator'
import type { DashboardKey } from '~/types/dashboard'
import type {
VDBGroupSummaryData,
Expand All @@ -21,6 +20,7 @@ interface Props {
groupId?: number,
row: VDBSummaryTableRow,
timeFrame?: SummaryTimeFrame,
validatorCount: number,
validators: number[],
}
const props = defineProps<Props>()
Expand Down Expand Up @@ -50,17 +50,16 @@ const openValidatorModal = () => {
const groupName = computed(() => {
return getGroupLabel($t, props.groupId, groups.value, $t('common.total'))
})
const cappedValidators = computed(() =>
sortValidatorIds(props.validators).slice(0, 10),
)
</script>

<template>
<div class="validator_column">
<span v-if="cappedValidators.length <= 3" class="validators">
<span
v-if="validators.length && validatorCount <= 3"
class="validators"
>
<template
v-for="validator in cappedValidators"
v-for="validator in validators"
:key="validator"
>
<BcLink
Expand All @@ -74,7 +73,7 @@ const cappedValidators = computed(() =>
</template>
</span>
<span v-else>
{{ cappedValidators.length }} {{ $t('common.validator', cappedValidators.length) }}
{{ validatorCount }} {{ $t('common.validator', validatorCount) }}
</span>
<FontAwesomeIcon
v-if="validators?.length"
Expand Down
8 changes: 7 additions & 1 deletion frontend/components/dashboard/table/SummaryValue.vue
Original file line number Diff line number Diff line change
Expand Up @@ -82,21 +82,26 @@ const data = computed(() => {
)
) {
let validators: number[] = []
let validatorCount: number = 0
let context: DashboardValidatorContext = 'attestation'
if (props.property === 'validators_proposal') {
validators = col.proposal_validators
validators = col.proposal_validators ?? []
validatorCount = col.proposal_validator_count ?? 0
context = 'proposal'
}
else if (props.property === 'validators_sync') {
validators = col.sync.validators ?? []
validatorCount = col.sync.validator_count ?? 0
context = 'sync'
}
else if (props.property === 'validators_slashings') {
validators = col.slashings?.validators ?? []
validatorCount = col.slashings.validator_count ?? 0
context = 'slashings'
}
return {
context,
validatorCount,
validators,
}
}
Expand Down Expand Up @@ -252,6 +257,7 @@ const openValidatorModal = () => {
<DashboardTableValidators
v-else-if="data?.validators"
:validators="data.validators"
:validator-count="data?.validatorCount"
:time-frame="props.timeFrame"
:context="data.context"
:dashboard-key
Expand Down
7 changes: 0 additions & 7 deletions frontend/utils/dashboard/validator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,6 @@ export function totalDutyRewards(duties?: ValidatorHistoryDuties) {
}
}

export function sortValidatorIds(list?: number[]): number[] {
if (!list) {
return []
}
return [ ...list ].sort((a, b) => a - b)
}

export function sortSummaryValidators(
list?: VDBSummaryValidator[],
): VDBSummaryValidator[] {
Expand Down

0 comments on commit a99fecc

Please sign in to comment.