Skip to content

Commit

Permalink
Merge pull request #1899 from IntersectMBO/fix/1889-cannot-view-on-ch…
Browse files Browse the repository at this point in the history
…ain-governance-action-details-when-metadata-incorrect

fix(#1889): fix displaying on-chain governance action details
  • Loading branch information
MSzalowski authored Sep 2, 2024
2 parents 7fa2053 + 5ee7873 commit 38e237b
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 18 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ changes.
- Fix missing DRep name whitespace validation [Issue 1873](https://github.com/IntersectMBO/govtool/issues/1873)
- Fix displaying wrongly formatted Governance Action ID [Issue 1866](https://github.com/IntersectMBO/govtool/issues/1866k)
- Make payment address optional in DRep registration and edit form [Issue 1871](https://github.com/IntersectMBO/govtool/issues/1871)
- Fix displaying wrongly formatted Governance Action ID [Issue 1866](https://github.com/IntersectMBO/govtool/issues/1866)
- Fix displaying the proper Governance Action Details on renavigating between pages
- Fix displaying protocol params Governance Action details when metadata validation fails [Issue 1889](https://github.com/IntersectMBO/govtool/issues/1889)

### Changed

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { diffLines, formatLines } from "unidiff";
import { parseDiff, Diff, Hunk } from "react-diff-view";
import "react-diff-view/style/index.css";
import { Box, Typography } from "@mui/material";
import { useTranslation } from "react-i18next";

import "./react-diff-view.overrides.css";

type Props = {
Expand All @@ -12,6 +15,7 @@ export const GovernanceActionDetailsDiffView = ({
oldJson,
newJson,
}: Props) => {
const { t } = useTranslation();
const diffText = formatLines(
diffLines(
JSON.stringify(oldJson, null, 2),
Expand All @@ -24,19 +28,50 @@ export const GovernanceActionDetailsDiffView = ({
if (!oldJson && !newJson) return;

return (
<Diff viewType="split" diffType={diff.type} hunks={diff.hunks || []}>
{(hunks) =>
hunks.map((hunk) => (
// Hunk component does not allow to pass children as a prop
// but that is the typing issue as passing the children
// is recommended by documentation approach.
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-expect-error
<Hunk key={hunk.content} hunk={hunk}>
{hunk.content}
</Hunk>
))
}
</Diff>
<Box>
<Box
sx={{
display: "flex",
flexDirection: "row",
justifyContent: "space-evenly",
mb: 3,
}}
>
<Typography
sx={{
fontSize: "14px",
color: "neutralGray",
lineHeight: "20px",
fontWeight: 600,
}}
>
{t("govActions.protocolParamsDetails.existing")}
</Typography>
<Typography
sx={{
fontSize: "14px",
color: "neutralGray",
lineHeight: "20px",
fontWeight: 600,
}}
>
{t("govActions.protocolParamsDetails.proposed")}
</Typography>
</Box>
<Diff viewType="split" diffType={diff.type} hunks={diff.hunks || []}>
{(hunks) =>
hunks.map((hunk) => (
// Hunk component does not allow to pass children as a prop
// but that is the typing issue as passing the children
// is recommended by documentation approach.
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-expect-error
<Hunk key={hunk.content} hunk={hunk}>
{hunk.content}
</Hunk>
))
}
</Diff>
</Box>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ export const DashboardGovernanceActions = () => {
value={content}
indicatorColor="secondary"
onChange={handleChange}
aria-label="basic tabs example"
aria-label="Governance Actions tabs"
>
<StyledTab
data-testid="to-vote-tab"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,7 @@ export const GovernanceActionDetailsCardData = ({
visible:
type === GovernanceActionType.ParameterChange &&
!!protocolParams &&
!!epochParams &&
!isDataMissing,
!!epochParams,
},
{
label: "Details",
Expand Down
2 changes: 1 addition & 1 deletion govtool/frontend/src/hooks/queries/useGetProposalQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export const useGetProposalQuery = (proposalId: string, enabled?: boolean) => {
const { dRepID } = useCardano();

const { data, isLoading, refetch, isRefetching } = useQuery(
[QUERY_KEYS.useGetProposalKey, dRepID],
[QUERY_KEYS.useGetProposalKey, dRepID, proposalId],
() => getProposal(proposalId, dRepID),
{
staleTime: Infinity,
Expand Down
4 changes: 4 additions & 0 deletions govtool/frontend/src/i18n/locales/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,10 @@ export const en = {
governanceActionId: "Governance Action ID:",
governanceActionType: "Governance Action Type:",
goToVote: "Go to Vote",
protocolParamsDetails: {
existing: "Existing",
proposed: "Proposed",
},
hardforkDetails: {
currentVersion: "Current version",
proposedVersion: "Proposed version",
Expand Down

0 comments on commit 38e237b

Please sign in to comment.