feat(governance): avoid showing untitled proposals (#3851)

This commit is contained in:
Sam Keen 2023-05-19 16:19:28 +01:00 committed by GitHub
parent ff3519279d
commit 5bd18cc127
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 62 additions and 9 deletions

View File

@ -124,7 +124,7 @@ describe('Proposal header', () => {
})
);
expect(screen.getByTestId('proposal-title')).toHaveTextContent(
'Unknown proposal'
'New asset proposal'
);
expect(screen.getByTestId('proposal-type')).toHaveTextContent('New asset');
expect(screen.getByTestId('proposal-details')).toHaveTextContent(

View File

@ -21,6 +21,7 @@ export const ProposalHeader = ({
let details: ReactNode;
let proposalType = '';
let fallbackTitle = '';
const title = proposal?.rationale.title.trim();
@ -29,6 +30,7 @@ export const ProposalHeader = ({
switch (change?.__typename) {
case 'NewMarket': {
proposalType = 'NewMarket';
fallbackTitle = t('NewMarketProposal');
details = (
<>
<span>
@ -50,6 +52,7 @@ export const ProposalHeader = ({
}
case 'UpdateMarket': {
proposalType = 'UpdateMarket';
fallbackTitle = t('UpdateMarketProposal');
details = (
<>
<span>{t('Market change')}:</span>{' '}
@ -60,6 +63,7 @@ export const ProposalHeader = ({
}
case 'NewAsset': {
proposalType = 'NewAsset';
fallbackTitle = t('NewAssetProposal');
details = (
<>
<span>{t('Symbol')}:</span> <Lozenge>{change.symbol}.</Lozenge>{' '}
@ -81,6 +85,7 @@ export const ProposalHeader = ({
}
case 'UpdateNetworkParameter': {
proposalType = 'NetworkParameter';
fallbackTitle = t('NetworkParameterProposal');
details = (
<>
<span>{t('Change')}:</span>{' '}
@ -95,11 +100,13 @@ export const ProposalHeader = ({
}
case 'NewFreeform': {
proposalType = 'Freeform';
fallbackTitle = t('FreeformProposal');
details = <span />;
break;
}
case 'UpdateAsset': {
proposalType = 'UpdateAsset';
fallbackTitle = t('UpdateAssetProposal');
details = (
<>
<span>{t('AssetID')}:</span>{' '}
@ -115,10 +122,14 @@ export const ProposalHeader = ({
<div data-testid="proposal-title">
{isListItem ? (
<header>
<SubHeading title={titleContent || t('Unknown proposal')} />
<SubHeading
title={titleContent || fallbackTitle || t('Unknown proposal')}
/>
</header>
) : (
<Heading title={titleContent || t('Unknown proposal')} />
<Heading
title={titleContent || fallbackTitle || t('Unknown proposal')}
/>
)}
</div>

View File

@ -49,6 +49,7 @@ export const ProposeFreeform = () => {
formState: { errors },
setValue,
watch,
trigger,
} = useForm<FreeformProposalFormFields>();
const { finalizedProposal, submit, Dialog } = useProposalSubmit();
@ -85,7 +86,13 @@ export const ProposeFreeform = () => {
await submit(assembleProposal(fields));
};
const viewJson = () => {
const viewJson = async () => {
const isValid = await trigger();
if (!isValid) {
return;
}
const formData = watch();
downloadJson(
JSON.stringify(assembleProposal(formData)),

View File

@ -89,6 +89,7 @@ export const ProposeNetworkParameter = () => {
formState: { errors },
setValue,
watch,
trigger,
} = useForm<NetworkParameterProposalFormFields>();
const { finalizedProposal, submit, Dialog } = useProposalSubmit();
@ -148,7 +149,13 @@ export const ProposeNetworkParameter = () => {
await submit(assembleProposal(fields));
};
const viewJson = () => {
const viewJson = async () => {
const isValid = await trigger();
if (!isValid) {
return;
}
const formData = watch();
downloadJson(
JSON.stringify(assembleProposal(formData)),

View File

@ -61,6 +61,7 @@ export const ProposeNewAsset = () => {
formState: { errors },
setValue,
watch,
trigger,
} = useForm<NewAssetProposalFormFields>();
const { finalizedProposal, submit, Dialog } = useProposalSubmit();
@ -117,7 +118,13 @@ export const ProposeNewAsset = () => {
await submit(assembleProposal(fields));
};
const viewJson = () => {
const viewJson = async () => {
const isValid = await trigger();
if (!isValid) {
return;
}
const formData = watch();
downloadJson(
JSON.stringify(assembleProposal(formData)),

View File

@ -59,6 +59,7 @@ export const ProposeNewMarket = () => {
formState: { errors },
setValue,
watch,
trigger,
} = useForm<NewMarketProposalFormFields>();
const { finalizedProposal, submit, Dialog } = useProposalSubmit();
@ -107,7 +108,13 @@ export const ProposeNewMarket = () => {
await submit(assembleProposal(fields));
};
const viewJson = () => {
const viewJson = async () => {
const isValid = await trigger();
if (!isValid) {
return;
}
const formData = watch();
downloadJson(
JSON.stringify(assembleProposal(formData)),

View File

@ -59,6 +59,7 @@ export const ProposeUpdateAsset = () => {
formState: { errors },
setValue,
watch,
trigger,
} = useForm<UpdateAssetProposalFormFields>();
const { finalizedProposal, submit, Dialog } = useProposalSubmit();
@ -107,7 +108,13 @@ export const ProposeUpdateAsset = () => {
await submit(assembleProposal(fields));
};
const viewJson = () => {
const viewJson = async () => {
const isValid = await trigger();
if (!isValid) {
return;
}
const formData = watch();
downloadJson(
JSON.stringify(assembleProposal(formData)),

View File

@ -106,6 +106,7 @@ export const ProposeUpdateMarket = () => {
formState: { errors },
setValue,
watch,
trigger,
} = useForm<UpdateMarketProposalFormFields>();
const { finalizedProposal, submit, Dialog } = useProposalSubmit();
@ -157,7 +158,13 @@ export const ProposeUpdateMarket = () => {
await submit(assembleProposal(fields));
};
const viewJson = () => {
const viewJson = async () => {
const isValid = await trigger();
if (!isValid) {
return;
}
const formData = watch();
downloadJson(
JSON.stringify(assembleProposal(formData)),