diff --git a/CHANGELOG.md b/CHANGELOG.md
index 10cf8e329..048bea0ed 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -106,6 +106,7 @@ changes.
- Fix displaying the GA Markdowns [Issue 1244](https://github.com/IntersectMBO/govtool/issues/1244)
- Fix app crash on voting on the GA without the connected wallet before [Issue 1313](https://github.com/IntersectMBO/govtool/issues/1313)
- Fix the navigation to Home from Proposal pillar on disconnected wallet [Issue 1355](https://github.com/IntersectMBO/govtool/issues/1355)
+- Fix navigation over Proposal discussion forum pillar [Issue 1436](https://github.com/IntersectMBO/govtool/issues/1436)
### Changed
diff --git a/govtool/frontend/src/App.tsx b/govtool/frontend/src/App.tsx
index 9a8479522..192c3e0df 100644
--- a/govtool/frontend/src/App.tsx
+++ b/govtool/frontend/src/App.tsx
@@ -80,23 +80,6 @@ export default () => {
checkTheWalletIsActive();
}, [checkTheWalletIsActive]);
- // Proposal Discussion Pillar doesn't export pages or react router routes
- // so we need to handle the routing here
- useEffect(() => {
- if (!isProposalDiscussionForumEnabled) return;
- if (
- window.location.pathname.includes(PDF_PATHS.proposalDiscussion) &&
- !window.location.pathname.includes(PATHS.proposalPillar.replace("/*", ""))
- ) {
- navigate(
- `${(isEnabled
- ? PATHS.connectedProposalPillar
- : PATHS.proposalPillar
- ).replace("/*", "")}${window.location.pathname}`,
- );
- }
- }, [window.location.pathname]);
-
return (
<>
@@ -113,7 +96,7 @@ export default () => {
/>
{isProposalDiscussionForumEnabled && !isEnabled && (
}
/>
)}
@@ -121,7 +104,7 @@ export default () => {
} />
{isProposalDiscussionForumEnabled && (
}
/>
)}
diff --git a/govtool/frontend/src/components/atoms/DrawerLink.tsx b/govtool/frontend/src/components/atoms/DrawerLink.tsx
index 94848be2c..5ccf023f1 100644
--- a/govtool/frontend/src/components/atoms/DrawerLink.tsx
+++ b/govtool/frontend/src/components/atoms/DrawerLink.tsx
@@ -3,7 +3,6 @@ import { FC } from "react";
import { NavLink } from "react-router-dom";
import { theme } from "@/theme";
-import { PATHS, PDF_PATHS } from "@/consts";
type LinkProps = {
label: string;
@@ -14,16 +13,6 @@ type LinkProps = {
onClick?: () => void;
};
-const isRouteActive = (isActive: boolean, route: string) =>
- isActive ||
- (route ===
- `${PATHS.proposalPillar.replace("/*", "")}${
- PDF_PATHS.proposalDiscussion
- }` &&
- Object.values(PDF_PATHS).some((pdfPath) =>
- window.location.pathname.includes(pdfPath),
- ));
-
export const DrawerLink: FC = ({ ...props }) => {
const { dataTestId, label, navTo, icon, activeIcon, onClick } = props;
const {
@@ -37,49 +26,41 @@ export const DrawerLink: FC = ({ ...props }) => {
onClick={() => {
if (onClick) onClick();
}}
- style={({ isActive: routeIsActive }) => {
- // Workaround for the PDF routes not being handled by react-router
- const isActive = isRouteActive(routeIsActive, navTo);
- return {
- textDecoration: "none",
- backgroundColor: isActive ? highlightBlue : "transparent",
- padding: "8px 16px",
- display: "block",
- borderRadius: 100,
- };
- }}
+ style={({ isActive }) => ({
+ textDecoration: "none",
+ backgroundColor: isActive ? highlightBlue : "transparent",
+ padding: "8px 16px",
+ display: "block",
+ borderRadius: 100,
+ })}
>
- {({ isActive: routeIsActive }) => {
- // Workaround for the PDF routes not being handled by react-router
- const isActive = isRouteActive(routeIsActive, navTo);
- return (
-
- {activeIcon &&
- icon &&
- typeof icon === "string" &&
- typeof activeIcon === "string" ? (
-
- ) : (
-
- {isActive ? activeIcon : icon}
-
- )}
-
- {label}
-
-
- );
- }}
+ {({ isActive }) => (
+
+ {activeIcon &&
+ icon &&
+ typeof icon === "string" &&
+ typeof activeIcon === "string" ? (
+
+ ) : (
+
+ {isActive ? activeIcon : icon}
+
+ )}
+
+ {label}
+
+
+ )}
);
};
diff --git a/govtool/frontend/src/components/molecules/WalletInfoCard.tsx b/govtool/frontend/src/components/molecules/WalletInfoCard.tsx
index 475828f64..8e2d92f11 100644
--- a/govtool/frontend/src/components/molecules/WalletInfoCard.tsx
+++ b/govtool/frontend/src/components/molecules/WalletInfoCard.tsx
@@ -1,7 +1,7 @@
import { useLocation, useNavigate } from "react-router-dom";
import { Box, Button, Typography } from "@mui/material";
-import { PATHS, gray } from "@consts";
+import { PDF_PATHS, PATHS, gray } from "@consts";
import { useCardano } from "@context";
import { useTranslation } from "@hooks";
import { Card } from "./Card";
@@ -14,11 +14,18 @@ export const WalletInfoCard = () => {
const onClickDisconnect = async () => {
await disconnectWallet();
- navigate(
- pathname.includes("/connected")
- ? `${pathname.replace("/connected", "")}${hash ?? ""}`
- : PATHS.home,
+ const isProposalDiscussionForum = window.location.pathname.includes(
+ PDF_PATHS.proposalDiscussion.replace("/", ""),
);
+
+ if (!isProposalDiscussionForum) {
+ navigate(
+ pathname.includes("/connected")
+ ? `${pathname.replace("/connected", "")}${hash ?? ""}`
+ : PATHS.home,
+ );
+ }
+
window.location.reload();
};
diff --git a/govtool/frontend/src/components/molecules/WalletOption.tsx b/govtool/frontend/src/components/molecules/WalletOption.tsx
index 381fa2ee5..67ea88b42 100644
--- a/govtool/frontend/src/components/molecules/WalletOption.tsx
+++ b/govtool/frontend/src/components/molecules/WalletOption.tsx
@@ -2,7 +2,7 @@ import { FC, useCallback } from "react";
import { To, useNavigate, useLocation } from "react-router-dom";
import { Box, CircularProgress, Typography } from "@mui/material";
-import { PATHS } from "@consts";
+import { PATHS, PDF_PATHS } from "@consts";
import { useCardano } from "@context";
import { theme } from "@/theme";
@@ -32,8 +32,14 @@ export const WalletOptionButton: FC = ({
const enableByWalletName = useCallback(async () => {
if (isEnableLoading) return;
+ const isProposalDiscussionForum = window.location.pathname.includes(
+ PDF_PATHS.proposalDiscussion.replace("/", ""),
+ );
+
const result = await enable(name);
+
if (result?.stakeKey) {
+ if (isProposalDiscussionForum) return;
navigate(
// eslint-disable-next-line no-unneeded-ternary
pathToNavigate
diff --git a/govtool/frontend/src/components/organisms/DashboardCards/ProposeGovActionDashboardCard.tsx b/govtool/frontend/src/components/organisms/DashboardCards/ProposeGovActionDashboardCard.tsx
index 00a0adfc3..c31c2c390 100644
--- a/govtool/frontend/src/components/organisms/DashboardCards/ProposeGovActionDashboardCard.tsx
+++ b/govtool/frontend/src/components/organisms/DashboardCards/ProposeGovActionDashboardCard.tsx
@@ -37,9 +37,7 @@ export const ProposeGovActionDashboardCard = ({
navigate(
isProposalDiscussionForumEnabled
- ? `${PATHS.proposalPillar.replace("/*", "")}${
- PDF_PATHS.proposalDiscussion
- }`
+ ? PDF_PATHS.proposalDiscussion
: PATHS.createGovernanceAction,
);
}, [deposit, votingPower, isProposalDiscussionForumEnabled]);
diff --git a/govtool/frontend/src/components/organisms/HomeCards.tsx b/govtool/frontend/src/components/organisms/HomeCards.tsx
index ae2831594..c2aa04bf8 100644
--- a/govtool/frontend/src/components/organisms/HomeCards.tsx
+++ b/govtool/frontend/src/components/organisms/HomeCards.tsx
@@ -50,12 +50,7 @@ export const HomeCards = () => {
);
const navigateToProposalDiscussionPillar = useCallback(
- () =>
- navigate(
- `${PATHS.connectedProposalPillar.replace("/*", "")}${
- PDF_PATHS.proposalDiscussion
- }`,
- ),
+ () => navigate(PDF_PATHS.proposalDiscussion),
[navigate],
);
diff --git a/govtool/frontend/src/components/organisms/PDFWrapper.tsx b/govtool/frontend/src/components/organisms/PDFWrapper.tsx
deleted file mode 100644
index 310bc889d..000000000
--- a/govtool/frontend/src/components/organisms/PDFWrapper.tsx
+++ /dev/null
@@ -1,57 +0,0 @@
-import React, { ComponentProps, Suspense } from "react";
-import { Box, CircularProgress } from "@mui/material";
-import "@intersect.mbo/pdf-ui/style";
-import { useCardano, useGovernanceActions } from "@/context";
-import { useValidateMutation } from "@/hooks/mutations";
-
-const ProposalDiscussion = React.lazy(
- () => import("@intersect.mbo/pdf-ui/cjs"),
-);
-
-export const PDFWrapper = () => {
- const { validateMetadata } = useValidateMutation();
- const { walletApi, ...context } = useCardano();
- const { createGovernanceActionJsonLD, createHash } = useGovernanceActions();
-
- return (
-
-
-
-
- }
- >
- ["validateMetadata"]
- }
- />
-
-
- );
-};
diff --git a/govtool/frontend/src/components/organisms/TopNav.tsx b/govtool/frontend/src/components/organisms/TopNav.tsx
index 782241d87..0e9d71959 100644
--- a/govtool/frontend/src/components/organisms/TopNav.tsx
+++ b/govtool/frontend/src/components/organisms/TopNav.tsx
@@ -39,6 +39,14 @@ export const TopNav = ({ isConnectButton = true }) => {
setIsDrawerOpen(true);
};
+ const onClickConnectButton = () => {
+ if (isEnabled && stakeKey) {
+ navigate(PATHS.dashboard);
+ } else {
+ openModal({ type: "chooseWallet" });
+ }
+ };
+
return (
{