Skip to content

Commit 7879174

Browse files
authored
Merge pull request #2565 from IntersectMBO/feat/split-new-constitution-details-into-tabs
feat: split new constitution on-chain details into tabs
2 parents 88908ec + 1830056 commit 7879174

File tree

5 files changed

+49
-28
lines changed

5 files changed

+49
-28
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ changes.
2020

2121
### Changed
2222

23-
-
23+
- Split New constitution on-chain details into tabs
2424

2525
### Removed
2626

govtool/frontend/package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import { Box } from "@mui/material";
2+
3+
import { NewConstitutionAnchor, ProposalData } from "@/models";
4+
import { useScreenDimension } from "@/hooks";
5+
6+
import { GovernanceActionCardElement } from "./GovernanceActionCardElement";
7+
8+
export const GovernanceActionNewConstitutionDetailsTabContent = ({
9+
details,
10+
}: Pick<ProposalData, "details">) => {
11+
const { screenWidth } = useScreenDimension();
12+
return (
13+
<Box>
14+
<GovernanceActionCardElement
15+
isCopyButton
16+
label="Data Hash"
17+
text={(details?.anchor as NewConstitutionAnchor)?.dataHash as string}
18+
dataTestId="new-constitution-data-hash"
19+
textVariant={screenWidth > 1600 ? "longText" : "oneLine"}
20+
/>
21+
<GovernanceActionCardElement
22+
isCopyButton
23+
label="New Constitution Link"
24+
text={(details?.anchor as NewConstitutionAnchor)?.url as string}
25+
dataTestId="new-constitution-url"
26+
textVariant={screenWidth > 1600 ? "longText" : "oneLine"}
27+
/>
28+
</Box>
29+
);
30+
};

govtool/frontend/src/components/molecules/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ export * from "./GovernanceActionDetailsCardLinks";
2828
export * from "./GovernanceActionDetailsCardOnChainData";
2929
export * from "./GovernanceActionDetailsCardVotes";
3030
export * from "./GovernanceActionDetailsDiffView";
31+
export * from "./GovernanceActionNewConstitutionDetailsTabContent";
3132
export * from "./GovernanceActionNewCommitteeDetailsTabContent";
3233
export * from "./GovernanceActionsDatesBox";
3334
export * from "./GovernanceVotedOnCard";

govtool/frontend/src/components/organisms/GovernanceActionDetailsCardData.tsx

Lines changed: 15 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
GovernanceActionDetailsDiffView,
1212
GovernanceActionNewCommitteeDetailsTabContent,
1313
GovernanceActionCardTreasuryWithdrawalElement,
14+
GovernanceActionNewConstitutionDetailsTabContent,
1415
} from "@molecules";
1516
import { useScreenDimension, useTranslation } from "@hooks";
1617
import {
@@ -22,11 +23,7 @@ import {
2223
mapArrayToObjectByKeys,
2324
encodeCIP129Identifier,
2425
} from "@utils";
25-
import {
26-
MetadataValidationStatus,
27-
NewConstitutionAnchor,
28-
ProposalData,
29-
} from "@models";
26+
import { MetadataValidationStatus, ProposalData } from "@models";
3027
import { GovernanceActionType } from "@/types/governanceAction";
3128
import { useAppContext } from "@/context";
3229

@@ -200,6 +197,19 @@ export const GovernanceActionDetailsCardData = ({
200197
),
201198
visible: type === GovernanceActionType.NewCommittee && !!details,
202199
},
200+
{
201+
label: "Details",
202+
dataTestId: "parameters-tab",
203+
content: (
204+
<GovernanceActionNewConstitutionDetailsTabContent
205+
details={details}
206+
/>
207+
),
208+
visible:
209+
type === GovernanceActionType.NewConstitution &&
210+
!!details &&
211+
!!details?.anchor,
212+
},
203213
].filter((tab) => tab.visible),
204214
[
205215
abstract,
@@ -307,26 +317,6 @@ export const GovernanceActionDetailsCardData = ({
307317
amount={withdrawal.amount}
308318
/>
309319
))}
310-
{details?.anchor && type === GovernanceActionType.NewConstitution && (
311-
<>
312-
<GovernanceActionCardElement
313-
isCopyButton
314-
label="Data Hash"
315-
text={
316-
(details?.anchor as NewConstitutionAnchor)?.dataHash as string
317-
}
318-
dataTestId="new-constitution-data-hash"
319-
textVariant={screenWidth > 1600 ? "longText" : "oneLine"}
320-
/>
321-
<GovernanceActionCardElement
322-
isCopyButton
323-
label="URL"
324-
text={(details?.anchor as NewConstitutionAnchor)?.url as string}
325-
dataTestId="new-constitution-url"
326-
textVariant={screenWidth > 1600 ? "longText" : "oneLine"}
327-
/>
328-
</>
329-
)}
330320
<GovernanceActionDetailsCardLinks links={references} />
331321
</Box>
332322
);

0 commit comments

Comments
 (0)