Skip to content

Commit

Permalink
Show details on auction list on specific cases where we might encount…
Browse files Browse the repository at this point in the history
…er duplicates

- 'Direct/Provider' in case of split distribution
- '+x more' in case same entry is split by any chance
  • Loading branch information
radumojic committed May 14, 2024
1 parent 7ae1573 commit d738a23
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/components/Nodes/AuctionListTable/AuctionListBaseRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,10 @@ export const AuctionListBaseRow = ({
className='trim-wrapper trim-size-xl font-headings-regular'
>
<IdentityName />
{details && (
<span className='text-neutral-400 ms-1'>({details})</span>
)}
</NetworkLink>
{details && (
<span className='text-neutral-400 trim-wrapper trim-size-xl'>
<Trim text={details} className='text-neutral-400' />
</span>
)}
</div>
</div>
</td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export const AuctionListExpandRow = ({
colSpan = 7,
index,
validator,
details,
expandRowConfig,
showPosition,
className
Expand Down Expand Up @@ -95,6 +96,7 @@ export const AuctionListExpandRow = ({
return (
<AuctionListBaseRow
validator={validator}
details={details}
index={index}
showPosition={showPosition}
className={classNames('dh', {
Expand Down Expand Up @@ -151,6 +153,7 @@ export const AuctionListExpandRow = ({
return (
<AuctionListBaseRow
validator={validator}
details={details}
index={index}
showPosition={showPosition}
/>
Expand Down
3 changes: 3 additions & 0 deletions src/components/Nodes/AuctionListTable/AuctionListRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export interface AuctionListRowUIType extends AuctionListBaseRowUIType {

export const AuctionListRow = ({
validator,
details,
thresholdRowConfig,
index,
showPosition,
Expand All @@ -43,13 +44,15 @@ export const AuctionListRow = ({
{hasExpand && index && expandRowConfig ? (
<AuctionListExpandRow
validator={validator}
details={details}
expandRowConfig={expandRowConfig}
showPosition={showPosition}
index={index}
/>
) : (
<AuctionListBaseRow
validator={validator}
details={details}
index={index}
showPosition={showPosition}
/>
Expand Down
44 changes: 44 additions & 0 deletions src/components/Nodes/AuctionListTable/AuctionListTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,45 @@ export interface AuctionListTableUIType extends WithClassnameType {
showPosition?: boolean;
}

const getValidatorDetails = ({
validator,
validators
}: {
validator: AuctionValidatorType;
validators: AuctionValidatorType[];
}) => {
if (!validator || !validators || validators.length === 0) {
return '';
}

const { provider, distribution } = validator;
if (distribution && Object.keys(distribution).length > 1) {
if (provider && distribution[provider]) {
return 'Provider';
}

return 'Direct';
}

const multipleIdentityEntries = validators.filter(
(filteredValidator) =>
validator.identity && validator.identity === filteredValidator.identity
).length;
if (multipleIdentityEntries > 1) {
return `+${multipleIdentityEntries} more`;
}

const multipleOwnerEntries = validators.filter(
(filteredValidator) =>
validator.owner && validator.owner === filteredValidator.owner
).length;
if (multipleOwnerEntries > 1) {
return `+${multipleIdentityEntries} more entries`;
}

return '';
};

export const AuctionListTable = ({
auctionListValidators = [],
showPosition = true,
Expand Down Expand Up @@ -178,10 +217,15 @@ export const AuctionListTable = ({
const showThresholdRow = Boolean(
thresholdIndex && index === thresholdIndex && hasNoFilters
);
const details = getValidatorDetails({
validator,
validators: filteredValidators
});

return (
<AuctionListRow
validator={validator}
details={details}
index={index}
key={index}
expandRowConfig={expandRowConfig}
Expand Down

0 comments on commit d738a23

Please sign in to comment.