Skip to content

Commit 53c151c

Browse files
authored
Merge pull request #2698 from IntersectMBO/feat/2178-usersnap-show-url-and-hash-of-anchor-data-in-governance-action-view
2 parents c322fab + 2d6c29c commit 53c151c

File tree

5 files changed

+53
-2
lines changed

5 files changed

+53
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ changes.
1313
### Added
1414

1515
- Add share DRep button to every DRep instead of only our own [Issue 2686](https://github.com/IntersectMBO/govtool/issues/2686)
16+
- Show metadata anchor in Governance Action Details [Issue 2178](https://github.com/IntersectMBO/govtool/issues/2178)
1617

1718
### Fixed
1819

govtool/frontend/src/components/molecules/GovernanceActionCardElement.tsx

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import Markdown from "react-markdown";
44

55
import { Typography, Tooltip, CopyButton, TooltipProps } from "@atoms";
66
import { removeMarkdown } from "@/utils";
7+
import { ICONS } from "@/consts";
8+
import { useModal } from "@/context";
79

810
type BaseProps = {
911
label: string;
@@ -18,11 +20,13 @@ type BaseProps = {
1820
type PillVariantProps = BaseProps & {
1921
textVariant: "pill";
2022
isCopyButton?: false;
23+
isLinkButton?: false;
2124
};
2225

2326
type OtherVariantsProps = BaseProps & {
2427
textVariant?: "oneLine" | "twoLines" | "longText";
2528
isCopyButton?: boolean;
29+
isLinkButton?: boolean;
2630
};
2731

2832
type GovernanceActionCardElementProps = (
@@ -37,11 +41,14 @@ export const GovernanceActionCardElement = ({
3741
isSliderCard,
3842
textVariant = "oneLine",
3943
isCopyButton,
44+
isLinkButton,
4045
tooltipProps,
4146
marginBottom,
4247
isMarkdown = false,
4348
isSemiTransparent = false,
4449
}: GovernanceActionCardElementProps) => {
50+
const { openModal } = useModal();
51+
4552
if (!text) {
4653
return null;
4754
}
@@ -160,7 +167,7 @@ export const GovernanceActionCardElement = ({
160167
WebkitLineClamp: 2,
161168
whiteSpace: "normal",
162169
}),
163-
...(isCopyButton && {
170+
...((isCopyButton || isLinkButton) && {
164171
color: "primaryBlue",
165172
}),
166173
...(isSemiTransparent && {
@@ -176,6 +183,24 @@ export const GovernanceActionCardElement = ({
176183
<CopyButton text={text.toString()} variant="blueThin" />
177184
</Box>
178185
)}
186+
{isLinkButton && (
187+
<Box ml={1}>
188+
<img
189+
data-testid="link-button"
190+
alt="link"
191+
src={ICONS.externalLinkIcon}
192+
style={{ cursor: "pointer" }}
193+
onClick={() => {
194+
openModal({
195+
type: "externalLink",
196+
state: {
197+
externalLink: text.toString(),
198+
},
199+
});
200+
}}
201+
/>
202+
</Box>
203+
)}
179204
</Box>
180205
)}
181206
</Box>

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ export const GovernanceActionDetailsCardData = ({
8888
url,
8989
type,
9090
protocolParams,
91+
metadataHash,
9192
},
9293
}: GovernanceActionDetailsCardDataProps) => {
9394
const { epochParams } = useAppContext();
@@ -318,6 +319,21 @@ export const GovernanceActionDetailsCardData = ({
318319
amount={withdrawal.amount}
319320
/>
320321
))}
322+
<GovernanceActionCardElement
323+
label={t("govActions.anchorURL")}
324+
text={url}
325+
textVariant="longText"
326+
dataTestId="anchor-url"
327+
isLinkButton
328+
/>
329+
<GovernanceActionCardElement
330+
label={t("govActions.anchorHash")}
331+
text={metadataHash}
332+
textVariant="longText"
333+
dataTestId="anchor-hash"
334+
isCopyButton
335+
/>
336+
321337
<GovernanceActionDetailsCardLinks links={references} />
322338
</Box>
323339
);

govtool/frontend/src/i18n/locales/en.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,8 @@
344344
"about": "About",
345345
"abstract": "Abstract",
346346
"amount": "Amount:",
347+
"anchorURL": "Anchor URL",
348+
"anchorHash": "Anchor Hash",
347349
"backToGovActions": "Back to Governance Actions",
348350
"castVote": "<0>You voted {{vote}} on this proposal</0>\non {{date}} (Epoch {{epoch}})",
349351
"castVoteDeadline": "You can change your vote up to {{date}} (Epoch {{epoch}})",

govtool/frontend/src/stories/GovernanceActionDetailsCard.stories.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ const commonArgs = {
4242
expiryEpochNo: 1000001,
4343
expiryDate: new Date().toISOString(),
4444
type: GovernanceActionType.InfoAction,
45-
url: "https://exampleurl.com",
45+
url: "https://exampleMetadataUrl.com",
4646
title: "Example title",
4747
dRepYesVotes: 1000000,
4848
dRepNoVotes: 302,
@@ -106,6 +106,13 @@ async function assertGovActionDetails(
106106
await expect(canvas.getByTestId(`${cip129GovActionId}-id`)).toHaveTextContent(
107107
cip129GovActionId,
108108
);
109+
110+
await expect(canvas.getByTestId("anchor-url")).toHaveTextContent(
111+
args.proposal.url,
112+
);
113+
await expect(canvas.getByTestId("anchor-hash")).toHaveTextContent(
114+
args.proposal.metadataHash,
115+
);
109116
}
110117

111118
export const GovernanceActionDetailsCardComponent: Story = {

0 commit comments

Comments
 (0)