Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ENG-65] [ENG-66] - example proposal templates + unified UX for Sablier PB and general PB #2646

Open
wants to merge 54 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
f06c8b5
WIP: refactoring proposal builder and sablier proposal builder
mudrila Dec 13, 2024
f8e3cdd
Kill custom sablier builder - extract necessary components and use th…
mudrila Dec 20, 2024
c2d3d62
Merge branch 'develop' into feature/#2533-example-proposal-templates
mudrila Dec 20, 2024
84cb21b
Extract reusable sablier proposal builder constants
mudrila Dec 20, 2024
159d51f
Formatting
mudrila Dec 20, 2024
8f94f8e
Create example templates for transfer and sablier stream
mudrila Dec 20, 2024
789164f
Finalize implementation for send assets action template
mudrila Dec 20, 2024
eefefdd
Formatting
mudrila Dec 20, 2024
e4d5678
Add airdrop template
mudrila Dec 20, 2024
2196693
Add missing translations
mudrila Dec 20, 2024
46d3553
Add recipient button
mudrila Dec 20, 2024
bbb5bc9
Little bit copy-pasting cleanup
mudrila Dec 20, 2024
4f1c828
Update copy and fix some bugs in airdrop modal
mudrila Dec 20, 2024
de57c58
Proper Airdrop action display
mudrila Dec 20, 2024
48e37ee
Logical fixes
mudrila Dec 20, 2024
303722f
Figured out there was an extra field which shouldn't be there in Aird…
mudrila Dec 21, 2024
c8cfb5e
Merge branch 'develop' into feature/#2533-example-proposal-templates
mudrila Jan 7, 2025
afdb67d
Better conditional rendering for transactions / streams step in Propo…
mudrila Jan 7, 2025
7c72f99
Merge branch 'feature/#2533-example-proposal-templates' into feature/…
mudrila Jan 7, 2025
1344c14
Merge branch 'develop' into feature/#2533-example-proposal-templates
mudrila Jan 10, 2025
e63736f
Refactor isProposalMode
mudrila Jan 10, 2025
fd0f3e1
Formatting
mudrila Jan 10, 2025
bbbb82a
Merge branch 'feature/#2533-example-proposal-templates' into feature/…
mudrila Jan 10, 2025
13f2d12
Fix validation issues and proper display logic for send assets / aird…
mudrila Jan 10, 2025
8cd6ce8
Remove commented out code
mudrila Jan 11, 2025
bb66eae
No index drilling
mudrila Jan 11, 2025
c8754c1
Merge branch 'develop' into feature/#2533-example-proposal-templates
adamgall Jan 16, 2025
a0ce95f
Merge branch 'develop' into feature/#2533-sablier-and-transfer-template
adamgall Jan 16, 2025
6380fcb
Remove unused PROPOSAL_FROM_TEMPLATE mode
mudrila Jan 20, 2025
602b183
Merge branch 'develop' into feature/#2533-example-proposal-templates
mudrila Jan 20, 2025
2d8bc5e
Merge branch 'feature/#2533-example-proposal-templates' into feature/…
mudrila Jan 20, 2025
8887111
Add missing translations
mudrila Jan 20, 2025
d230612
Fix missing step buttons on streams route
mudrila Jan 20, 2025
6e825ca
Merge branch 'develop' into feature/#2533-example-proposal-templates
adamgall Jan 21, 2025
56f3c71
Refactor ProposalBuilder components to enhance modularity and improve…
adamgall Jan 21, 2025
c1611b1
Refactor ProposalBuilder components to replace 'mode' with 'isProposa…
adamgall Jan 22, 2025
fc80505
Enhance ProposalBuilder with Nonce Input for Multisig Support
adamgall Jan 22, 2025
c91c9ce
Merge branch 'develop' into feature/#2533-example-proposal-templates
adamgall Jan 22, 2025
d4b21e7
Merge branch 'feature/#2533-example-proposal-templates' into feature/…
adamgall Jan 22, 2025
5ade551
Enhance ProposalBuilder with Navigation URLs for Proposal Steps
adamgall Jan 22, 2025
1df7f23
Refactor ProposalBuilder and related pages to enhance header function…
adamgall Jan 22, 2025
ac03e4e
Refactor ProposalBuilder to Enhance Metadata Handling and Improve Cod…
adamgall Jan 22, 2025
e764ab4
Refactor ProposalBuilder and Proposal Creation Pages to Enhance Actio…
adamgall Jan 22, 2025
377c14d
Refactor ProposalBuilder and Proposal Creation Pages to Standardize S…
adamgall Jan 22, 2025
62e01de
Refactor ProposalBuilder to Enhance Flexibility and Code Clarity
adamgall Jan 22, 2025
ca5fb8c
Refactor Proposal Creation Pages to Standardize Metadata Step Button …
adamgall Jan 22, 2025
3bdb460
Refactor Proposal Creation Pages to Standardize Step Button Handling
adamgall Jan 22, 2025
50bbcd9
Refactor ProposalBuilder Component and Update Imports for Proposal Cr…
adamgall Jan 22, 2025
f637b6a
Refactor ProposalBuilder and ProposalDetails to Use React.ReactNode f…
adamgall Jan 22, 2025
b63e4a7
Merge pull request #2683 from decentdao/feature/#2533-example-proposa…
mudrila Jan 22, 2025
6dd9366
Merge branch 'feature/#2533-example-proposal-templates' into feature/…
adamgall Jan 22, 2025
352f165
Merge pull request #2647 from decentdao/feature/#2533-sablier-and-tra…
mudrila Jan 22, 2025
a977cde
Action components cleanup
mudrila Jan 23, 2025
60d14be
Formatting
mudrila Jan 23, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
119 changes: 78 additions & 41 deletions src/components/ProposalBuilder/ProposalDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@ import { FormikProps } from 'formik';
import { Fragment, PropsWithChildren, useState } from 'react';
import { useTranslation } from 'react-i18next';
import '../../assets/css/Markdown.css';
import { CreateProposalForm, ProposalBuilderMode } from '../../types/proposalBuilder';
import {
CreateProposalForm,
CreateSablierProposalForm,
ProposalBuilderMode,
Stream,
} from '../../types/proposalBuilder';
import Markdown from '../ui/proposal/Markdown';
import CeleryButtonWithIcon from '../ui/utils/CeleryButtonWithIcon';
import Divider from '../ui/utils/Divider';
Expand All @@ -20,13 +25,18 @@ export function TransactionValueContainer({ children }: PropsWithChildren<{}>) {
);
}

export default function ProposalTemplateDetails({
values: { proposalMetadata, transactions },
export default function ProposalDetails({
values,
mode,
}: FormikProps<CreateProposalForm> & { mode: ProposalBuilderMode }) {
}: FormikProps<CreateProposalForm | CreateSablierProposalForm> & { mode: ProposalBuilderMode }) {
const { t } = useTranslation(['proposalTemplate', 'proposal']);
const { proposalMetadata, transactions } = values;
const trimmedTitle = proposalMetadata.title?.trim();
const [descriptionCollapsed, setDescriptionCollapsed] = useState(true);
let streams: Stream[] = [];
if (mode === ProposalBuilderMode.SABLIER) {
streams = (values as CreateSablierProposalForm).streams;
}

return (
<Box
Expand Down Expand Up @@ -82,49 +92,76 @@ export default function ProposalTemplateDetails({
/>
)}
<Divider />
{transactions.map((transaction, i) => {
const valueBiggerThanZero = transaction.ethValue.bigintValue
? transaction.ethValue.bigintValue > 0n
: false;
return (
<Fragment key={i}>
<Text color="neutral-7">{t('labelTargetAddress', { ns: 'proposal' })}</Text>
{transaction.targetAddress && (
<TransactionValueContainer>{transaction.targetAddress}</TransactionValueContainer>
{mode !== ProposalBuilderMode.SABLIER &&
transactions.map((transaction, i) => {
const valueBiggerThanZero = transaction.ethValue.bigintValue
? transaction.ethValue.bigintValue > 0n
: false;
return (
<Fragment key={i}>
<Text color="neutral-7">{t('labelTargetAddress', { ns: 'proposal' })}</Text>
{transaction.targetAddress && (
<TransactionValueContainer>{transaction.targetAddress}</TransactionValueContainer>
)}
<Divider />
<Text color="neutral-7">{t('labelFunctionName', { ns: 'proposal' })}</Text>
{transaction.functionName && (
<TransactionValueContainer>{transaction.functionName}</TransactionValueContainer>
)}
{transaction.parameters.map((parameter, parameterIndex) => (
<Fragment key={parameterIndex}>
<Text color="neutral-7">{t('parameter')}</Text>
{parameter.signature && (
<TransactionValueContainer>{parameter.signature}</TransactionValueContainer>
)}
<Text color="neutral-7">
{!!parameter.label ? parameter.label : t('value')}
</Text>
{(parameter.label || parameter.value) && (
<TransactionValueContainer>
{parameter.value || t('userInput')}
</TransactionValueContainer>
)}
</Fragment>
))}
<Divider />
<HStack justifyContent="space-between">
<Text color="neutral-7">{t('eth')}</Text>
<Text
textAlign="right"
color={valueBiggerThanZero ? 'white-0' : 'neutral-7'}
wordBreak="break-all"
>
{valueBiggerThanZero ? transaction.ethValue.value : 'n/a'}
</Text>
</HStack>
</Fragment>
);
})}
{mode === ProposalBuilderMode.SABLIER &&
streams.map((stream, idx) => (
<Fragment key={idx}>
<Text color="neutral-7">{t('labelRecipientAddress', { ns: 'proposal' })}</Text>
{stream.recipientAddress && (
<TransactionValueContainer>{stream.recipientAddress}</TransactionValueContainer>
)}
<Divider />
<Text color="neutral-7">{t('labelFunctionName', { ns: 'proposal' })}</Text>
{transaction.functionName && (
<TransactionValueContainer>{transaction.functionName}</TransactionValueContainer>
<Text color="neutral-7">{t('labelTotalAmount', { ns: 'proposal' })}</Text>
{stream.totalAmount && (
<TransactionValueContainer>{stream.totalAmount.value}</TransactionValueContainer>
)}
{transaction.parameters.map((parameter, parameterIndex) => (
<Fragment key={parameterIndex}>
<Text color="neutral-7">{t('parameter')}</Text>
{parameter.signature && (
<TransactionValueContainer>{parameter.signature}</TransactionValueContainer>
)}
<Text color="neutral-7">{!!parameter.label ? parameter.label : t('value')}</Text>
{(parameter.label || parameter.value) && (
<TransactionValueContainer>
{parameter.value || t('userInput')}
</TransactionValueContainer>
)}
<Divider />
<Text color="neutral-7">{t('labelTranches', { ns: 'proposal' })}</Text>
{stream.tranches.map((tranche, trancheIdx) => (
<Fragment key={trancheIdx}>
<Text color="neutral-7">{t('labelTrancheAmount', { ns: 'proposal' })}</Text>
<TransactionValueContainer>{tranche.amount.value}</TransactionValueContainer>
<Text color="neutral-7">{t('labelTrancheDuration', { ns: 'proposal' })}</Text>
<TransactionValueContainer>{tranche.duration.value}</TransactionValueContainer>
</Fragment>
))}
<Divider />
<HStack justifyContent="space-between">
<Text color="neutral-7">{t('eth')}</Text>
<Text
textAlign="right"
color={valueBiggerThanZero ? 'white-0' : 'neutral-7'}
wordBreak="break-all"
>
{valueBiggerThanZero ? transaction.ethValue.value : 'n/a'}
</Text>
</HStack>
</Fragment>
);
})}
))}
</VStack>
</Box>
);
Expand Down
Loading
Loading