From e32baf390c03452df03af78b6cff1077299e2848 Mon Sep 17 00:00:00 2001 From: Kellar Date: Thu, 28 Nov 2024 15:15:07 +0000 Subject: [PATCH 1/4] Add browse templates menu item --- .../DaoDashboard/Activities/ProposalsHome.tsx | 15 +- .../ui/menus/CreateProposalMenu/index.tsx | 134 ++++++++++++++++++ src/i18n/locales/en/proposal.json | 4 +- 3 files changed, 142 insertions(+), 11 deletions(-) create mode 100644 src/components/ui/menus/CreateProposalMenu/index.tsx diff --git a/src/components/DaoDashboard/Activities/ProposalsHome.tsx b/src/components/DaoDashboard/Activities/ProposalsHome.tsx index 760bfd51e..e41cfcf94 100644 --- a/src/components/DaoDashboard/Activities/ProposalsHome.tsx +++ b/src/components/DaoDashboard/Activities/ProposalsHome.tsx @@ -17,6 +17,7 @@ import { SortBy, } from '../../../types'; import { ProposalsList } from '../../Proposals/ProposalsList'; +import { CreateProposalMenu } from '../../ui/menus/CreateProposalMenu'; import { OptionMenu } from '../../ui/menus/OptionMenu'; import { ModalType } from '../../ui/modals/ModalProvider'; import { useDecentModal } from '../../ui/modals/useDecentModal'; @@ -258,25 +259,19 @@ export function ProposalsHome() { {/* DELEGATE AND CREATE PROPOSAL BUTTONS (non-mobile) */} - + {canDelegate && ( )} {canUserCreateProposal && safe?.address && ( - - - + )} diff --git a/src/components/ui/menus/CreateProposalMenu/index.tsx b/src/components/ui/menus/CreateProposalMenu/index.tsx new file mode 100644 index 000000000..c1e8c7f1b --- /dev/null +++ b/src/components/ui/menus/CreateProposalMenu/index.tsx @@ -0,0 +1,134 @@ +import { + Box, + Button, + Divider, + Flex, + Icon, + Menu, + MenuButton, + MenuItem, + MenuList, + Text, +} from '@chakra-ui/react'; +import { CaretDown } from '@phosphor-icons/react'; +import { Fragment } from 'react'; +import { useTranslation } from 'react-i18next'; +import { useNavigate } from 'react-router-dom'; +import { Address } from 'viem'; +import { NEUTRAL_2_82_TRANSPARENT } from '../../../../constants/common'; +import { DAO_ROUTES } from '../../../../constants/routes'; +import { useNetworkConfig } from '../../../../providers/NetworkConfig/NetworkConfigProvider'; +import { EaseOutComponent } from '../../utils/EaseOutComponent'; + +export function CreateProposalMenu({ safeAddress }: { safeAddress: Address }) { + const { t } = useTranslation('proposal'); + + const { addressPrefix } = useNetworkConfig(); + + const navigate = useNavigate(); + + return ( + + + {({ isOpen }) => ( + + + + {t('createProposal')} + + + + {isOpen && ( + + + + + + navigate(DAO_ROUTES.proposalNew.relative(addressPrefix, safeAddress)) + } + noOfLines={1} + display="flex" + alignItems="center" + justifyContent="flex-start" + rounded="0.75rem" + gap={2} + > + + {t('createFromScratch')} + + + + + + + navigate( + DAO_ROUTES.proposalTemplates.relative(addressPrefix, safeAddress), + ) + } + noOfLines={1} + display="flex" + alignItems="center" + justifyContent="flex-start" + rounded="0.75rem" + gap={2} + > + + {t('browseTemplates')} + + + + + + + )} + + )} + + + ); +} diff --git a/src/i18n/locales/en/proposal.json b/src/i18n/locales/en/proposal.json index 388612f6e..c051bc478 100644 --- a/src/i18n/locales/en/proposal.json +++ b/src/i18n/locales/en/proposal.json @@ -142,5 +142,7 @@ "clawBackEmptyTransactionsError": "Failed to process clawback - child Safe has no safely transferrable tokens", "pendingProposalNotice": "Pending proposal still processing", "metadataFailedParsePlaceholder": "Unknown - Failed to parse metadata", - "multisigNonceDuplicateErrorMessage": "Transaction with the same nonce already exists" + "multisigNonceDuplicateErrorMessage": "Transaction with the same nonce already exists", + "createFromScratch": "Create from scratch", + "browseTemplates": "Browse templates" } From f1ca78f8b45b69ce03a114af546be62c189797f0 Mon Sep 17 00:00:00 2001 From: Kellar Date: Thu, 28 Nov 2024 15:19:49 +0000 Subject: [PATCH 2/4] add padding, back arrow --- src/components/ProposalBuilder/index.tsx | 4 ++-- src/components/ui/menus/CreateProposalMenu/index.tsx | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/components/ProposalBuilder/index.tsx b/src/components/ProposalBuilder/index.tsx index 3ce691abe..410c6e713 100644 --- a/src/components/ProposalBuilder/index.tsx +++ b/src/components/ProposalBuilder/index.tsx @@ -1,5 +1,5 @@ import { Box, Flex, Grid, GridItem, Icon, Text } from '@chakra-ui/react'; -import { SquaresFour, Trash } from '@phosphor-icons/react'; +import { ArrowLeft, SquaresFour } from '@phosphor-icons/react'; import { Formik, FormikProps } from 'formik'; import { useEffect } from 'react'; import { useTranslation } from 'react-i18next'; @@ -165,7 +165,7 @@ export function ProposalBuilder({ }, ] } - ButtonIcon={Trash} + ButtonIcon={ArrowLeft} buttonProps={{ isDisabled: pendingCreateTx, variant: 'secondary', diff --git a/src/components/ui/menus/CreateProposalMenu/index.tsx b/src/components/ui/menus/CreateProposalMenu/index.tsx index c1e8c7f1b..ff145aa2f 100644 --- a/src/components/ui/menus/CreateProposalMenu/index.tsx +++ b/src/components/ui/menus/CreateProposalMenu/index.tsx @@ -67,8 +67,8 @@ export function CreateProposalMenu({ safeAddress }: { safeAddress: Address }) { - + Date: Thu, 28 Nov 2024 15:21:34 +0000 Subject: [PATCH 3/4] update copy --- src/i18n/locales/en/breadcrumbs.json | 2 +- src/i18n/locales/en/proposalTemplate.json | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/i18n/locales/en/breadcrumbs.json b/src/i18n/locales/en/breadcrumbs.json index 248c92c47..64b9da886 100644 --- a/src/i18n/locales/en/breadcrumbs.json +++ b/src/i18n/locales/en/breadcrumbs.json @@ -8,7 +8,7 @@ "proposal": "#{{proposalId}} {{proposalTitle}}", "proposalTemplates": "Proposal Templates", "proposalTemplate": "{{proposalTemplateTitle}}", - "proposalTemplateNew": "New Proposal Template", + "proposalTemplateNew": "Create Proposal Template", "modifyGovernance": "Modify Governance", "parentLink": "Parent-Safe", "settings": "Settings" diff --git a/src/i18n/locales/en/proposalTemplate.json b/src/i18n/locales/en/proposalTemplate.json index 734846d5c..fa447c097 100644 --- a/src/i18n/locales/en/proposalTemplate.json +++ b/src/i18n/locales/en/proposalTemplate.json @@ -1,6 +1,6 @@ { - "createProposalTemplate": "New Proposal Template", - "proposalTemplateTitle": "Proposal Template Title", + "createProposalTemplate": "Create Proposal Template", + "proposalTemplateTitle": "Title", "proposalTemplateTitleHelperText": "A short title for this proposal template", "proposalTemplateDescription": "Description", "proposalTemplateDescriptionHelperText": "Markdown syntax supported", From a51cd2edf1221d1063d80e1280e3cf289ed908d9 Mon Sep 17 00:00:00 2001 From: Kellar Date: Thu, 28 Nov 2024 15:29:24 +0000 Subject: [PATCH 4/4] lil tune up --- .../ui/menus/CreateProposalMenu/index.tsx | 23 ++++++++----------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/src/components/ui/menus/CreateProposalMenu/index.tsx b/src/components/ui/menus/CreateProposalMenu/index.tsx index ff145aa2f..b072a51e8 100644 --- a/src/components/ui/menus/CreateProposalMenu/index.tsx +++ b/src/components/ui/menus/CreateProposalMenu/index.tsx @@ -37,18 +37,15 @@ export function CreateProposalMenu({ safeAddress }: { safeAddress: Address }) { - + navigate(DAO_ROUTES.proposalNew.relative(addressPrefix, safeAddress)) } @@ -99,12 +95,11 @@ export function CreateProposalMenu({ safeAddress }: { safeAddress: Address }) { - + navigate( DAO_ROUTES.proposalTemplates.relative(addressPrefix, safeAddress),