From fbf6db607ba1d757165696bd9ff6d3e87aa496c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Sza=C5=82owski?= Date: Tue, 11 Feb 2025 10:10:51 +0100 Subject: [PATCH] feat(#1188): add button to submit a governance action --- CHANGELOG.md | 1 + .../organisms/DashboardGovernanceActions.tsx | 82 ++++++++++++------- govtool/frontend/src/i18n/locales/en.json | 1 + .../frontend/src/pages/GovernanceActions.tsx | 3 +- 4 files changed, 57 insertions(+), 30 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 91ab52bbc..7d77e8252 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ changes. - Add metadata url and hash to drep details [Issue 2911](https://github.com/IntersectMBO/govtool/issues/2911) - Add CC votes percentages, not voted and Ratification threshold - Add support for submitting all 7 governance action types [Issue 2258](https://github.com/IntersectMBO/govtool/issues/2258) +- Add Propose Governance Action button in governance actions dashboard [Issue 1188](https://github.com/IntersectMBO/govtool/issues/1188) ### Fixed diff --git a/govtool/frontend/src/components/organisms/DashboardGovernanceActions.tsx b/govtool/frontend/src/components/organisms/DashboardGovernanceActions.tsx index 3bcf8bb90..2efc90aa6 100644 --- a/govtool/frontend/src/components/organisms/DashboardGovernanceActions.tsx +++ b/govtool/frontend/src/components/organisms/DashboardGovernanceActions.tsx @@ -1,12 +1,14 @@ -import { useState, useEffect } from "react"; +import { useState, useEffect, useCallback } from "react"; import { Box, CircularProgress, Tab, Tabs, styled } from "@mui/material"; -import { useLocation } from "react-router-dom"; +import { useLocation, useNavigate } from "react-router-dom"; import { GOVERNANCE_ACTIONS_FILTERS, GOVERNANCE_ACTIONS_SORTING, + PATHS, + PDF_PATHS, } from "@consts"; -import { useCardano, useDataActionsBar } from "@context"; +import { useCardano, useDataActionsBar, useFeatureFlag } from "@context"; import { useGetProposalsQuery, useGetVoterInfo, @@ -18,6 +20,7 @@ import { GovernanceActionsToVote, DashboardGovernanceActionsVotedOn, } from "@organisms"; +import { Button } from "@atoms"; type TabPanelProps = { children?: React.ReactNode; @@ -74,6 +77,8 @@ export const DashboardGovernanceActions = () => { const { isMobile } = useScreenDimension(); const { t } = useTranslation(); const { isEnableLoading } = useCardano(); + const { isProposalDiscussionForumEnabled } = useFeatureFlag(); + const navigate = useNavigate(); const queryFilters = chosenFilters.length > 0 ? chosenFilters : defaultCategories; @@ -94,6 +99,14 @@ export const DashboardGovernanceActions = () => { setContent(newValue); }; + const onClickPropose = useCallback(() => { + navigate( + isProposalDiscussionForumEnabled + ? PDF_PATHS.proposalDiscussionPropose + : PATHS.createGovernanceAction, + ); + }, [isProposalDiscussionForumEnabled]); + useEffect(() => { window.history.replaceState({}, document.title); }, []); @@ -126,36 +139,49 @@ export const DashboardGovernanceActions = () => { ) : ( <> {(voter?.isRegisteredAsDRep || voter?.isRegisteredAsSoleVoter) && ( - - + - + + + + + )} + { filtersTitle={t("govActions.filterTitle")} sortOptions={GOVERNANCE_ACTIONS_SORTING} /> - {!proposals || isProposalsLoading ? (