fix: hide enacted on proposal details page for freeform proposals (#1503)

This commit is contained in:
Dexter Edwards 2022-09-27 13:59:09 +01:00 committed by GitHub
parent 9836f29e15
commit 0d8c052ec6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 33 additions and 9 deletions

View File

@ -686,5 +686,6 @@
"MoreMarketsInfo": "To see Explorer data on existing markets visit",
"MoreAssetsInfo": "To see Explorer data on existing assets visit",
"ProposalNotFound": "Proposal not found",
"ProposalNotFoundDetails": "The proposal you are looking for is not here, it may have been enacted before the last chain restore. You could check the Vega forums/discord instead for information about it."
"ProposalNotFoundDetails": "The proposal you are looking for is not here, it may have been enacted before the last chain restore. You could check the Vega forums/discord instead for information about it.",
"FreeformProposal": "Freeform proposal"
}

View File

@ -79,6 +79,28 @@ it('Changes data based on if data is in future or past', () => {
).toBeInTheDocument();
});
it('Does not render enactment time for freeform proposal', () => {
const proposal = generateProposal({
state: ProposalState.STATE_ENACTED,
terms: {
__typename: 'ProposalTerms',
change: {
__typename: 'NewFreeform',
},
},
});
render(<ProposalChangeTable proposal={proposal} />);
expect(screen.queryByText('Enacted on')).not.toBeInTheDocument();
expect(
screen.queryByText(
format(
new Date(proposal.terms.enactmentDatetime || 0),
DATE_FORMAT_DETAILED
)
)
).not.toBeInTheDocument();
});
it('Renders error details and rejection reason if present', () => {
const errorDetails = 'Error message';
const proposal = generateProposal({

View File

@ -31,12 +31,14 @@ export const ProposalChangeTable = ({ proposal }: ProposalChangeTableProps) => {
: t('closedOn')}
{format(new Date(terms.closingDatetime), DATE_FORMAT_DETAILED)}
</KeyValueTableRow>
<KeyValueTableRow>
{isFuture(new Date(terms.enactmentDatetime || 0))
? t('proposedEnactment')
: t('enactedOn')}
{format(new Date(terms.enactmentDatetime || 0), DATE_FORMAT_DETAILED)}
</KeyValueTableRow>
{terms.change.__typename !== 'NewFreeform' ? (
<KeyValueTableRow>
{isFuture(new Date(terms.enactmentDatetime || 0))
? t('proposedEnactment')
: t('enactedOn')}
{format(new Date(terms.enactmentDatetime || 0), DATE_FORMAT_DETAILED)}
</KeyValueTableRow>
) : null}
<KeyValueTableRow>
{t('proposedBy')}
<span style={{ wordBreak: 'break-word' }}>{proposal.party.id}</span>

View File

@ -73,8 +73,7 @@ export const ProposalHeader = ({ proposal }: { proposal: ProposalFields }) => {
break;
}
case 'NewFreeform': {
details = `${proposal.id}`;
details = `${t('FreeformProposal')}: ${proposal.id}`;
break;
}
}