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

Update Proposal list #1472

Merged
merged 27 commits into from
Mar 26, 2024
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
d2c3ff8
update Badge component with updated designs
Da-Colon Mar 19, 2024
f0e2538
create badge to display quorum
Da-Colon Mar 19, 2024
910092c
update badge to use meetQuroum for linearERC20Strategy
Da-Colon Mar 19, 2024
976ae20
update hover colors for timelock and frozen badges
Da-Colon Mar 19, 2024
04c06ec
update Activity/Proposal description and title to updated designs
Da-Colon Mar 19, 2024
19eaac2
add author to Description
Da-Colon Mar 20, 2024
f2df8cc
Replace ActivityGovernance with Updated ProposalCard
Da-Colon Mar 20, 2024
680a38e
replace ActivityGovernance with ProposalCard
Da-Colon Mar 20, 2024
4e2c15e
update to lastest badge colors
Da-Colon Mar 20, 2024
4e2941c
remove unused file
Da-Colon Mar 20, 2024
4fe5fa3
remove comments
Da-Colon Mar 20, 2024
8e873f1
run lint/pretty
Da-Colon Mar 20, 2024
b496ced
fix badge colors
Da-Colon Mar 20, 2024
574fbc8
fix alignment
Da-Colon Mar 20, 2024
3bd3ecc
pretty/lint run
Da-Colon Mar 20, 2024
7eff319
remove fragment
Da-Colon Mar 21, 2024
b728ea0
update colors to match figma
Da-Colon Mar 25, 2024
36f73db
adjust padding
Da-Colon Mar 25, 2024
3b0d3a6
clean up logic around description and title to more closely match des…
Da-Colon Mar 25, 2024
72690ec
remove comment
Da-Colon Mar 25, 2024
f40fa6a
switch back to previous way to calc quorum
Da-Colon Mar 25, 2024
bdb272e
run pretty/lint
Da-Colon Mar 25, 2024
533cf46
remove unused package
Da-Colon Mar 25, 2024
c51a58a
remove ugly hardcoded values
Da-Colon Mar 25, 2024
6e8507e
update markdown css with maxWidth 0 to allow content to shrink
Da-Colon Mar 25, 2024
2886d03
run pretty/lint
Da-Colon Mar 25, 2024
78aa6e4
revent author on details screen
Da-Colon Mar 25, 2024
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
41 changes: 37 additions & 4 deletions src/components/Activity/ActivityDescription.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
import { Box, Flex } from '@chakra-ui/react';
import { useGetMetadata } from '../../hooks/DAO/proposal/useGetMetadata';
import { Activity, FractalProposal, SnapshotProposal } from '../../types';
import useDisplayName from '../../hooks/utils/useDisplayName';
import {
Activity,
AzoriusProposal,
FractalProposal,
MultisigProposal,
SnapshotProposal,
} from '../../types';
import Avatar from '../ui/page/Header/Avatar';
import Markdown from '../ui/proposal/Markdown';
import { ProposalTitle } from './ActivityDescriptionGovernance';
import { ActivityDescriptionTreasury } from './ActivityDescriptionTreasury';
Expand All @@ -12,26 +20,51 @@ interface IActivityDescription {

export function ActivityDescription({ activity, showFullDescription }: IActivityDescription) {
const metaData = useGetMetadata(activity as FractalProposal);

const snapshotProposal = activity as SnapshotProposal;
const azoriusProposal = activity as AzoriusProposal;
const multisigProposal = activity as MultisigProposal;

const description = snapshotProposal.description || metaData.description;
const isSnapshotProposal = !!snapshotProposal.snapshotProposalId;
const isAzoriusProposal = !!azoriusProposal.proposer;

const proposer = isAzoriusProposal
? azoriusProposal.proposer
: isSnapshotProposal
? snapshotProposal.author
: multisigProposal.confirmations[0].owner;

const { displayName: author } = useDisplayName(proposer);
return (
<Flex
color="grayscale.100"
textStyle="text-lg-mono-semibold"
gap="0.5rem"
mr="1rem"
mt="0.5rem"
flexWrap="wrap"
>
<ProposalTitle activity={activity} />
<Flex
gap={2}
alignItems="center"
color="#B3B3B3"
textStyle="text-md-sans-regular"
>
<Avatar
size="sm"
address={author}
/>
<Box>{author}</Box>
</Flex>
{description && (
<Box
my={4}
minWidth="100%"
textColor="#B3B3B3"
>
<Markdown
content={description}
truncate={!showFullDescription}
collapsedLines={3}
/>
</Box>
)}
Expand Down
31 changes: 24 additions & 7 deletions src/components/Activity/ActivityDescriptionGovernance.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Text } from '@chakra-ui/react';
import { Box, Flex, Text } from '@chakra-ui/react';
import { useTranslation } from 'react-i18next';
import { useGetMetadata } from '../../hooks/DAO/proposal/useGetMetadata';
import {
Expand Down Expand Up @@ -46,10 +46,17 @@ export function ProposalTitle({ activity }: { activity: Activity }) {

if ((activity as SnapshotProposal).snapshotProposalId) {
return (
<>
<Flex
textStyle="text-lg-sans-medium"
fontSize="20px"
alignItems="center"
color="grayscale.100"
pr={2}
gap={2}
>
<Text>{formatId((activity as SnapshotProposal).snapshotProposalId)}</Text>
<Text>{(activity as SnapshotProposal).title}</Text>
</>
</Flex>
);
}

Expand All @@ -58,11 +65,21 @@ export function ProposalTitle({ activity }: { activity: Activity }) {
treasuryActivity.transferAddresses && !!treasuryActivity.transferAddresses.length;

return (
<>
<Text>{formatId((activity as GovernanceActivity).proposalId)}</Text>
{metaData.title ? <Text>{metaData.title}</Text> : null}
<Box
textStyle="text-lg-sans-medium"
fontSize="20px"
color="grayscale.100"
pr={2}
>
<Flex
gap={2}
alignItems="center"
>
<Text>{formatId((activity as GovernanceActivity).proposalId)}</Text>
{metaData.title ? <Text>{metaData.title}</Text> : null}
</Flex>
{hasTransfers && <Text> {t('proposalDescriptionCont', { ns: 'dashboard' })} </Text>}
<OnChainRejectionMessage activity={activity} />
</>
</Box>
);
}
64 changes: 0 additions & 64 deletions src/components/Activity/ActivityGovernance.tsx

This file was deleted.

76 changes: 76 additions & 0 deletions src/components/Proposals/ProposalCard/ProposalCard.tsx
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Main entry to changes. Replaces current ActivityGovernance component.

Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
import { Box, Flex, Image, Text } from '@chakra-ui/react';
import { format } from 'date-fns';
import { useTranslation } from 'react-i18next';
import { Link } from 'react-router-dom';
import { DAO_ROUTES } from '../../../constants/routes';
import { useFractal } from '../../../providers/App/AppProvider';
import { ActivityEventType, FractalProposal, SnapshotProposal } from '../../../types';
import { DEFAULT_DATE_FORMAT } from '../../../utils';
import { ActivityDescription } from '../../Activity/ActivityDescription';
import { Badge } from '../../ui/badges/Badge';
import QuorumBadge from '../../ui/badges/QuorumBadge';

function ProposalCard({ proposal }: { proposal: FractalProposal }) {
const {
node: { daoAddress },
} = useFractal();
const { t } = useTranslation('common');

const eventDateLabel = t(
proposal.eventType === ActivityEventType.Treasury
? proposal.transaction?.to === daoAddress
? 'received'
: 'sent'
: 'created',
);

const isSnapshotProposal = !!(proposal as SnapshotProposal).snapshotProposalId;

return (
<Link to={DAO_ROUTES.proposal.relative(daoAddress, proposal.proposalId)}>
<Box
minHeight="6.25rem"
bg="chocolate.900"
_hover={{ bg: '#0B0A09' }}
Da-Colon marked this conversation as resolved.
Show resolved Hide resolved
p="1.5rem"
borderRadius="0.5rem"
>
{/* Top Row */}
<Flex justifyContent="space-between">
<Flex
gap={2}
alignItems="center"
>
<Badge
labelKey={proposal.state!}
size="sm"
proposal={proposal}
/>
{isSnapshotProposal && (
<Image
src="/images/snapshot-icon-fill.svg"
alt={t('snapshot')}
ml={1}
/>
)}
</Flex>
<QuorumBadge proposal={proposal} />
</Flex>
<ActivityDescription activity={proposal} />
<Box>
{proposal.eventDate && (
<Text
mt={2}
textStyle="text-base-sans-regular"
color="#838383"
Da-Colon marked this conversation as resolved.
Show resolved Hide resolved
>
{eventDateLabel} {format(proposal.eventDate, DEFAULT_DATE_FORMAT)}
</Text>
)}
</Box>
</Box>
</Link>
);
}

export default ProposalCard;
6 changes: 3 additions & 3 deletions src/components/Proposals/ProposalsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import { DAO_ROUTES } from '../../constants/routes';
import useSubmitProposal from '../../hooks/DAO/proposal/useSubmitProposal';
import { useFractal } from '../../providers/App/AppProvider';
import { FractalProposal } from '../../types';
import { ActivityGovernance } from '../Activity/ActivityGovernance';
import { EmptyBox } from '../ui/containers/EmptyBox';
import { InfoBoxLoader } from '../ui/loaders/InfoBoxLoader';
import ProposalCard from './ProposalCard/ProposalCard';

export function ProposalsList({ proposals }: { proposals: FractalProposal[] }) {
const {
Expand All @@ -27,9 +27,9 @@ export function ProposalsList({ proposals }: { proposals: FractalProposal[] }) {
</Box>
) : proposals.length > 0 ? (
proposals.map(proposal => (
<ActivityGovernance
<ProposalCard
key={proposal.proposalId}
activity={proposal}
proposal={proposal}
/>
))
) : (
Expand Down
6 changes: 3 additions & 3 deletions src/components/pages/DaoDashboard/Activities/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import { useState } from 'react';
import { useTranslation } from 'react-i18next';
import { useFractal } from '../../../../providers/App/AppProvider';
import { ActivityEventType, SortBy, TreasuryActivity, FractalProposal } from '../../../../types';
import { ActivityGovernance } from '../../../Activity/ActivityGovernance';
import { ActivityModule } from '../../../Activity/ActivityModule';
import { ActivityTreasury } from '../../../Activity/ActivityTreasury';
import ProposalCard from '../../../Proposals/ProposalCard/ProposalCard';
import { EmptyBox } from '../../../ui/containers/EmptyBox';
import { InfoBoxLoader } from '../../../ui/loaders/InfoBoxLoader';
import { Sort } from '../../../ui/utils/Sort';
Expand Down Expand Up @@ -48,9 +48,9 @@ export function Activities() {
{sortedActivities.map((activity, i) => {
if (activity.eventType === ActivityEventType.Governance) {
return (
<ActivityGovernance
<ProposalCard
key={i}
activity={activity as FractalProposal}
proposal={activity as FractalProposal}
/>
);
}
Expand Down
Loading