Skip to content

Commit 4f87b87

Browse files
committed
feat(#1188): add button to submit a governance action
1 parent 05ac717 commit 4f87b87

File tree

4 files changed

+57
-30
lines changed

4 files changed

+57
-30
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ changes.
1616
- Add CC votes percentages, not voted and Ratification threshold
1717
- Add support for submitting all 7 governance action types [Issue 2258](https://github.com/IntersectMBO/govtool/issues/2258)
1818
- Add workflow to automatically update any of the @intersect.mbo package [Issue 2968](https://github.com/IntersectMBO/govtool/issues/2968)
19+
- Add Propose Governance Action button in governance actions dashboard [Issue 1188](https://github.com/IntersectMBO/govtool/issues/1188)
1920

2021
### Fixed
2122

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

Lines changed: 54 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1-
import { useState, useEffect } from "react";
1+
import { useState, useEffect, useCallback } from "react";
22
import { Box, CircularProgress, Tab, Tabs, styled } from "@mui/material";
3-
import { useLocation } from "react-router-dom";
3+
import { useLocation, useNavigate } from "react-router-dom";
44

55
import {
66
GOVERNANCE_ACTIONS_FILTERS,
77
GOVERNANCE_ACTIONS_SORTING,
8+
PATHS,
9+
PDF_PATHS,
810
} from "@consts";
9-
import { useCardano, useDataActionsBar } from "@context";
11+
import { useCardano, useDataActionsBar, useFeatureFlag } from "@context";
1012
import {
1113
useGetProposalsQuery,
1214
useGetVoterInfo,
@@ -18,6 +20,7 @@ import {
1820
GovernanceActionsToVote,
1921
DashboardGovernanceActionsVotedOn,
2022
} from "@organisms";
23+
import { Button } from "@atoms";
2124

2225
type TabPanelProps = {
2326
children?: React.ReactNode;
@@ -74,6 +77,8 @@ export const DashboardGovernanceActions = () => {
7477
const { isMobile } = useScreenDimension();
7578
const { t } = useTranslation();
7679
const { isEnableLoading } = useCardano();
80+
const { isProposalDiscussionForumEnabled } = useFeatureFlag();
81+
const navigate = useNavigate();
7782

7883
const queryFilters =
7984
chosenFilters.length > 0 ? chosenFilters : defaultCategories;
@@ -94,6 +99,14 @@ export const DashboardGovernanceActions = () => {
9499
setContent(newValue);
95100
};
96101

102+
const onClickPropose = useCallback(() => {
103+
navigate(
104+
isProposalDiscussionForumEnabled
105+
? PDF_PATHS.proposalDiscussionPropose
106+
: PATHS.createGovernanceAction,
107+
);
108+
}, [isProposalDiscussionForumEnabled]);
109+
97110
useEffect(() => {
98111
window.history.replaceState({}, document.title);
99112
}, []);
@@ -126,36 +139,49 @@ export const DashboardGovernanceActions = () => {
126139
) : (
127140
<>
128141
{(voter?.isRegisteredAsDRep || voter?.isRegisteredAsSoleVoter) && (
129-
<Tabs
130-
sx={{
131-
marginTop: 3,
132-
display: "flex",
133-
fontSize: 16,
134-
fontWeight: 500,
135-
}}
136-
value={content}
137-
indicatorColor="secondary"
138-
onChange={handleChange}
139-
aria-label="Governance Actions tabs"
140-
>
141-
<StyledTab
142-
data-testid="to-vote-tab"
143-
label={t("govActions.toVote")}
142+
<Box display="flex" flexDirection="row" alignItems="center">
143+
<Tabs
144144
sx={{
145-
textTransform: "none",
146-
width: !isMobile ? "auto" : "50%",
145+
marginTop: 3,
146+
display: "flex",
147+
fontSize: 16,
148+
fontWeight: 500,
147149
}}
148-
/>
149-
<StyledTab
150-
data-testid="voted-tab"
151-
label={t("govActions.votedOnByMe")}
150+
value={content}
151+
indicatorColor="secondary"
152+
onChange={handleChange}
153+
aria-label="Governance Actions tabs"
154+
>
155+
<StyledTab
156+
data-testid="to-vote-tab"
157+
label={t("govActions.toVote")}
158+
sx={{
159+
textTransform: "none",
160+
width: !isMobile ? "auto" : "50%",
161+
}}
162+
/>
163+
<StyledTab
164+
data-testid="voted-tab"
165+
label={t("govActions.votedOnByMe")}
166+
sx={{
167+
textTransform: "none",
168+
width: !isMobile ? "auto" : "50%",
169+
}}
170+
/>
171+
</Tabs>
172+
<Button
173+
data-testid="proposal-discussion-link"
174+
onClick={onClickPropose}
152175
sx={{
153-
textTransform: "none",
154-
width: !isMobile ? "auto" : "50%",
176+
display: isMobile ? "none" : "block",
177+
ml: "auto",
155178
}}
156-
/>
157-
</Tabs>
179+
>
180+
{t("govActions.propose")}
181+
</Button>
182+
</Box>
158183
)}
184+
159185
<Box height={isMobile ? 24 : 60} />
160186
<CustomTabPanel value={content} index={0}>
161187
<GovernanceActionsToVote

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,7 @@
444444
"noResultsForTheSearch": "No results for the search.",
445445
"onChainTransactionDetails": "On-chain Transaction Details",
446446
"optional": "(optional)",
447+
"propose": "Propose Governance Action",
447448
"provideContext": "Provide context",
448449
"provideContextAboutYourVote": "Provide context about your vote",
449450
"additionalInformationAboutYourVote": "Additional information about your vote",

govtool/frontend/src/pages/GovernanceActions.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { useEffect } from "react";
22
import { useNavigate } from "react-router-dom";
33
import { Box, CircularProgress, Divider } from "@mui/material";
44

5-
import { Background, ScrollToManage, Typography } from "@atoms";
5+
import { Background, Button, ScrollToManage, Typography } from "@atoms";
66
import {
77
GOVERNANCE_ACTIONS_FILTERS,
88
GOVERNANCE_ACTIONS_SORTING,
@@ -96,7 +96,6 @@ export const GovernanceActions = () => {
9696
filtersTitle={t("govActions.filterTitle")}
9797
sortOptions={GOVERNANCE_ACTIONS_SORTING}
9898
/>
99-
10099
{!proposals || isProposalsLoading ? (
101100
<Box
102101
sx={{

0 commit comments

Comments
 (0)