Skip to content

Commit a201a04

Browse files
authored
Merge pull request #2614 from emmanuel-musau/feat/add-governance-actions-outcomes-support
feat: add support for governance actions outcomes
2 parents 5a6eafd + 746402f commit a201a04

File tree

13 files changed

+273
-54
lines changed

13 files changed

+273
-54
lines changed

govtool/frontend/.env.example

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ VITE_GTM_ID=""
77
VITE_IS_DEV=true
88
VITE_USERSNAP_SPACE_API_KEY=""
99
VITE_IS_PROPOSAL_DISCUSSION_FORUM_ENABLED='true'
10+
VITE_IS_GOVERNANCE_OUTCOMES_PILLAR_ENABLED='true'
1011
VITE_PDF_API_URL=""
1112
VITE_IPFS_GATEWAY=""
1213
VITE_IPFS_PROJECT_ID=""

govtool/frontend/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
"@emotion/styled": "^11.11.0",
2828
"@emurgo/cardano-serialization-lib-asmjs": "^12.1.1",
2929
"@hookform/resolvers": "^3.3.1",
30+
"@intersect.mbo/govtool-outcomes-pillar-ui": "^1.0.0-beta.1",
3031
"@intersect.mbo/intersectmbo.org-icons-set": "^1.0.8",
3132
"@intersect.mbo/pdf-ui": "^0.5.6",
3233
"@mui/icons-material": "^5.14.3",

govtool/frontend/src/App.tsx

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { useCallback, useEffect } from "react";
22
import { Route, Routes, useNavigate } from "react-router-dom";
33

44
import { Modal, ScrollToTop } from "@atoms";
5-
import { PATHS, PDF_PATHS } from "@consts";
5+
import { PATHS, PDF_PATHS, OUTCOMES_PATHS, USER_PATHS } from "@consts";
66
import { useCardano, useFeatureFlag, useModal } from "@context";
77
import { useWalletConnectionListener } from "@hooks";
88
import {
@@ -39,9 +39,13 @@ import {
3939
import { PublicRoute } from "./pages/PublicRoute";
4040
import { TopBanners } from "./components/organisms/TopBanners";
4141
import { DashboardHome } from "./pages/DashboardHome";
42+
import { GovernanceActionOutComesPillar } from "./pages/GovernanceActionOutComes";
4243

4344
export default () => {
44-
const { isProposalDiscussionForumEnabled } = useFeatureFlag();
45+
const {
46+
isProposalDiscussionForumEnabled,
47+
isGovernanceOutcomesPillarEnabled,
48+
} = useFeatureFlag();
4549
const { enable, isEnabled } = useCardano();
4650
const navigate = useNavigate();
4751
const { modal, openModal, modals } = useModal();
@@ -111,6 +115,18 @@ export default () => {
111115
element={<ProposalDiscussionPillar />}
112116
/>
113117
)}
118+
{isGovernanceOutcomesPillarEnabled && (
119+
<>
120+
<Route
121+
path={`${OUTCOMES_PATHS.governanceActionsOutcomes}/*`}
122+
element={<GovernanceActionOutComesPillar />}
123+
/>
124+
<Route
125+
path={USER_PATHS.governanceActionsVotedByMe}
126+
element={<GovernanceActionOutComesPillar />}
127+
/>
128+
</>
129+
)}
114130
<Route
115131
path={PATHS.dashboardGovernanceActions}
116132
element={<DashboardGovernanceActions />}

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

Lines changed: 45 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export const DashboardDrawerMobile = ({
1818
isDrawerOpen,
1919
setIsDrawerOpen,
2020
}: DashboardDrawerMobileProps) => {
21-
const { isProposalDiscussionForumEnabled } = useFeatureFlag();
21+
const { isProposalDiscussionForumEnabled, isGovernanceOutcomesPillarEnabled } = useFeatureFlag();
2222
const { screenWidth } = useScreenDimension();
2323
const { voter } = useGetVoterInfo();
2424

@@ -75,26 +75,60 @@ export const DashboardDrawerMobile = ({
7575
</Box>
7676
<Grid container direction="column" rowGap={4} mt={6}>
7777
{CONNECTED_NAV_ITEMS.map((navItem) => {
78-
if (
79-
!isProposalDiscussionForumEnabled &&
80-
navItem.dataTestId === "proposal-discussion-link"
81-
) {
82-
return null;
83-
}
84-
8578
return (
8679
<Grid item>
8780
<Link
8881
{...navItem}
8982
size="big"
9083
onClick={() => {
91-
// TODO: Refine if it is needed to remove this eslint-disable
92-
// eslint-disable-next-line no-unused-expressions
93-
navItem.newTabLink && openInNewTab(navItem.newTabLink);
84+
if (navItem.newTabLink) {
85+
openInNewTab(navItem.newTabLink);
86+
}
9487
setIsDrawerOpen(false);
9588
}}
9689
isConnectWallet
9790
/>
91+
{navItem.childNavItems && (
92+
<Grid
93+
container
94+
direction="column"
95+
rowGap={4}
96+
mt={3}
97+
pl={3}
98+
>
99+
{navItem.childNavItems.map((childItem) => {
100+
if (
101+
!isProposalDiscussionForumEnabled &&
102+
childItem.dataTestId === "proposal-discussion-link"
103+
) {
104+
return null;
105+
}
106+
107+
if (
108+
!isGovernanceOutcomesPillarEnabled &&
109+
(childItem.dataTestId === "governance-actions-voted-by-me-link" ||
110+
childItem.dataTestId === "governance-actions-outcomes-link")
111+
) {
112+
return null;
113+
}
114+
115+
return (
116+
<Link
117+
key={childItem.label}
118+
{...childItem}
119+
size="big"
120+
onClick={() => {
121+
if (childItem.newTabLink) {
122+
openInNewTab(childItem.newTabLink);
123+
}
124+
setIsDrawerOpen(false);
125+
}}
126+
isConnectWallet
127+
/>
128+
);
129+
})}
130+
</Grid>
131+
)}
98132
</Grid>
99133
);
100134
})}

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

Lines changed: 42 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { WalletInfoCard, DRepInfoCard } from "@molecules";
99
import { openInNewTab } from "@utils";
1010

1111
export const Drawer = () => {
12-
const { isProposalDiscussionForumEnabled } = useFeatureFlag();
12+
const { isProposalDiscussionForumEnabled, isGovernanceOutcomesPillarEnabled } = useFeatureFlag();
1313
const { voter } = useGetVoterInfo();
1414

1515
return (
@@ -47,13 +47,6 @@ export const Drawer = () => {
4747
rowGap={2}
4848
>
4949
{CONNECTED_NAV_ITEMS.map((navItem) => {
50-
if (
51-
!isProposalDiscussionForumEnabled &&
52-
navItem.dataTestId === "proposal-discussion-link"
53-
) {
54-
return null;
55-
}
56-
5750
return (
5851
<Grid item key={navItem.label}>
5952
<DrawerLink
@@ -64,6 +57,47 @@ export const Drawer = () => {
6457
: undefined
6558
}
6659
/>
60+
{navItem.childNavItems && (
61+
<Grid
62+
columns={1}
63+
container
64+
display="flex"
65+
flex={1}
66+
flexDirection="column"
67+
mt={2}
68+
pl={3}
69+
rowGap={2}
70+
>
71+
{navItem.childNavItems.map((childItem) => {
72+
if (
73+
!isProposalDiscussionForumEnabled &&
74+
childItem.dataTestId === "proposal-discussion-link"
75+
) {
76+
return null;
77+
}
78+
79+
if (
80+
!isGovernanceOutcomesPillarEnabled &&
81+
(childItem.dataTestId === "governance-actions-voted-by-me-link" ||
82+
childItem.dataTestId === "governance-actions-outcomes-link")
83+
) {
84+
return null;
85+
}
86+
87+
return (
88+
<DrawerLink
89+
key={childItem.label}
90+
{...childItem}
91+
onClick={
92+
childItem.newTabLink
93+
? () => openInNewTab(childItem.newTabLink!)
94+
: undefined
95+
}
96+
/>
97+
);
98+
})}
99+
</Grid>
100+
)}
67101
</Grid>
68102
);
69103
})}

govtool/frontend/src/consts/navItems.tsx

Lines changed: 50 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { theme } from "@/theme";
44

55
import { ICONS } from "./icons";
66
import { LINKS } from "./links";
7-
import { PATHS, PDF_PATHS } from "./paths";
7+
import { PATHS, PDF_PATHS, OUTCOMES_PATHS, USER_PATHS } from "./paths";
88

99
export const NAV_ITEMS = [
1010
{
@@ -59,6 +59,7 @@ export const CONNECTED_NAV_ITEMS = [
5959
navTo: PATHS.dashboardDRepDirectory,
6060
activeIcon: ICONS.dRepDirectoryActiveIcon,
6161
icon: ICONS.dRepDirectoryIcon,
62+
newTabLink: null,
6263
},
6364
{
6465
dataTestId: "governance-actions-link",
@@ -67,28 +68,54 @@ export const CONNECTED_NAV_ITEMS = [
6768
activeIcon: ICONS.governanceActionsActiveIcon,
6869
icon: ICONS.governanceActionsIcon,
6970
newTabLink: null,
70-
},
71-
{
72-
dataTestId: "proposal-discussion-link",
73-
label: i18n.t("proposalDiscussion.title"),
74-
navTo: PDF_PATHS.proposalDiscussion,
75-
activeIcon: (
76-
<IconAcademicCap
77-
width="20"
78-
height="20"
79-
viewBox="0 0 24 24"
80-
fill={theme.palette.accentOrange}
81-
/>
82-
),
83-
icon: (
84-
<IconAcademicCap
85-
width="20"
86-
height="20"
87-
viewBox="0 0 24 24"
88-
fill={theme.palette.lightOrange}
89-
/>
90-
),
91-
newTabLink: null,
71+
childNavItems: [
72+
{
73+
dataTestId: "proposal-discussion-link",
74+
label: i18n.t("proposalDiscussion.title"),
75+
navTo: PDF_PATHS.proposalDiscussion,
76+
activeIcon: (
77+
<IconAcademicCap
78+
width="20"
79+
height="20"
80+
viewBox="0 0 24 24"
81+
fill={theme.palette.accentOrange}
82+
/>
83+
),
84+
icon: (
85+
<IconAcademicCap
86+
width="20"
87+
height="20"
88+
viewBox="0 0 24 24"
89+
fill={theme.palette.lightOrange}
90+
/>
91+
),
92+
newTabLink: null,
93+
},
94+
{
95+
dataTestId: "governance-actions-live-voting-link",
96+
label: i18n.t("govActions.liveVoting.title"),
97+
navTo: OUTCOMES_PATHS.governanceActionsLiveVoting,
98+
activeIcon: ICONS.governanceActionsActiveIcon,
99+
icon: ICONS.governanceActionsIcon,
100+
newTabLink: null,
101+
},
102+
{
103+
dataTestId: "governance-actions-outcomes-link",
104+
label: i18n.t("govActions.outcomes.title"),
105+
navTo: OUTCOMES_PATHS.governanceActionsOutcomes,
106+
activeIcon: ICONS.governanceActionsActiveIcon,
107+
icon: ICONS.governanceActionsIcon,
108+
newTabLink: null,
109+
},
110+
{
111+
dataTestId: "governance-actions-voted-by-me-link",
112+
label: i18n.t("govActions.votedByMe.title"),
113+
navTo: USER_PATHS.governanceActionsVotedByMe,
114+
activeIcon: ICONS.governanceActionsActiveIcon,
115+
icon: ICONS.governanceActionsIcon,
116+
newTabLink: null,
117+
},
118+
],
92119
},
93120
{
94121
dataTestId: "guides-link",

govtool/frontend/src/consts/paths.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,13 @@ export const PDF_PATHS = {
3131
proposalDiscussionProposal: "/proposal_discussion/:id",
3232
proposalDiscussionPropose: "/proposal_discussion/propose",
3333
};
34+
35+
export const USER_PATHS = {
36+
governanceActionsVotedByMe: "/my/votes_and_favorites",
37+
};
38+
39+
export const OUTCOMES_PATHS = {
40+
governanceActionsOutcomes: "/outcomes",
41+
governanceActionOutcomes: "/outcomes/governance_actions/:id",
42+
governanceActionsLiveVoting: "/connected/governance_actions",
43+
};

govtool/frontend/src/context/featureFlag.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import { useAppContext } from "./appContext";
1515
*/
1616
type FeatureFlagContextType = {
1717
isProposalDiscussionForumEnabled: boolean;
18+
isGovernanceOutcomesPillarEnabled: boolean;
1819
isVotingOnGovernanceActionEnabled: (
1920
governanceActionType: GovernanceActionType,
2021
) => boolean;
@@ -33,6 +34,7 @@ type FeatureFlagContextType = {
3334

3435
const FeatureFlagContext = createContext<FeatureFlagContextType>({
3536
isProposalDiscussionForumEnabled: false,
37+
isGovernanceOutcomesPillarEnabled: false,
3638
isVotingOnGovernanceActionEnabled: () => false,
3739
areDRepVoteTotalsDisplayed: () => false,
3840
areSPOVoteTotalsDisplayed: () => false,
@@ -129,6 +131,10 @@ const FeatureFlagProvider = ({ children }: PropsWithChildren) => {
129131
import.meta.env.VITE_IS_PROPOSAL_DISCUSSION_FORUM_ENABLED === "true" ||
130132
import.meta.env.VITE_IS_PROPOSAL_DISCUSSION_FORUM_ENABLED === true ||
131133
false,
134+
isGovernanceOutcomesPillarEnabled:
135+
import.meta.env.VITE_IS_GOVERNANCE_OUTCOMES_PILLAR_ENABLED === "true" ||
136+
import.meta.env.VITE_IS_GOVERNANCE_OUTCOMES_PILLAR_ENABLED === true ||
137+
false,
132138
isVotingOnGovernanceActionEnabled,
133139
areDRepVoteTotalsDisplayed,
134140
areSPOVoteTotalsDisplayed,

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -455,6 +455,18 @@
455455
"title": "Info Action",
456456
"label": "Info Action"
457457
}
458+
},
459+
"liveVoting": {
460+
"title": "Live Voting",
461+
"label": "Live Voting"
462+
},
463+
"outcomes": {
464+
"title": "Outcomes",
465+
"label": "Outcomes"
466+
},
467+
"votedByMe": {
468+
"title": "Voted by me",
469+
"label": "Voted by me"
458470
}
459471
},
460472
"hero": {

govtool/frontend/src/pages/Dashboard.tsx

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,18 @@ export const Dashboard = () => {
1919

2020
const getPageTitle = (path: string) => {
2121
if (path === PATHS.dashboard) return t("dashboard.title");
22-
return (
23-
Object.values(CONNECTED_NAV_ITEMS).find(({ navTo }) =>
24-
pathname.startsWith(navTo),
25-
)?.label ?? ""
26-
);
22+
return findNavItem(CONNECTED_NAV_ITEMS, path) ?? "";
2723
};
24+
25+
const findNavItem = (items: NavItem[], targetPath: string): string | null => (
26+
items.reduce<string | null>((result, item) => (
27+
result ?? (
28+
targetPath === item.navTo
29+
? item.label
30+
: (item.childNavItems ? findNavItem(item.childNavItems, targetPath) : null)
31+
)
32+
), null)
33+
);
2834

2935
useEffect(() => {
3036
if (divRef.current && pathname !== PATHS.dashboardGovernanceActions) {

0 commit comments

Comments
 (0)