Skip to content
This repository was archived by the owner on Oct 11, 2024. It is now read-only.

Commit e9f51ce

Browse files
authored
Merge pull request #386 from 0xProject/feat/governance-proposal-history-updates
governance proposal history UI updates
2 parents c230474 + 3607172 commit e9f51ce

File tree

3 files changed

+29
-22
lines changed

3 files changed

+29
-22
lines changed

ts/pages/governance/countdown.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export const Countdown: React.StatelessComponent<Props> = ({ startDate, endDate
3737
voteTextPrefix = 'Voting ends: ';
3838
}
3939
const timeToDisplay = isUpcoming ? startTime : endTime;
40-
const timeText = ` • ${getRelativeTime(timeToDisplay)}`;
40+
const timeText = isUpcoming ? ` • ${getRelativeTime(timeToDisplay)}` : ``;
4141
const voteText = `${voteTextPrefix} ${timeToDisplay.format('L LT')} ${moment()
4242
.tz(moment.tz.guess())
4343
.format('z')} ${timeText}`;

ts/pages/governance/governance.tsx

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,13 @@ interface State {
3636
tally?: TallyInterface;
3737
}
3838

39+
interface HistoryState {
40+
done: boolean;
41+
timestamp: moment.Moment;
42+
outcome?: string;
43+
show: boolean;
44+
}
45+
3946
const benefitLabels: LabelInterface = {
4047
1: 'Little Benefit',
4148
2: 'Medium Benefit',
@@ -48,7 +55,7 @@ const riskLabels: LabelInterface = {
4855
3: 'High Risk',
4956
};
5057

51-
type ProposalState = 'created' | 'active' | 'failed' | 'accepted';
58+
type ProposalState = 'active' | 'finalized';
5259

5360
export class Governance extends React.Component<RouteComponentProps<any>> {
5461
public state: State = {
@@ -79,25 +86,16 @@ export class Governance extends React.Component<RouteComponentProps<any>> {
7986
const outcome = getVoteOutcome(tally);
8087

8188
const proposalHistoryState = {
82-
created: {
83-
done: true,
84-
timestamp: voteStartDate,
85-
show: true,
86-
},
8789
active: {
8890
done: now.isAfter(voteStartDate),
8991
timestamp: voteStartDate,
9092
show: true,
9193
},
92-
failed: {
93-
done: hasVoteEnded && outcome === 'rejected',
94-
timestamp: this._proposalData?.voteEndDate,
95-
show: hasVoteEnded && outcome === 'rejected',
96-
},
97-
accepted: {
98-
done: hasVoteEnded && outcome === 'accepted',
94+
finalized: {
95+
done: hasVoteEnded && (outcome === 'rejected' || outcome === 'accepted'),
9996
timestamp: this._proposalData?.voteEndDate,
100-
show: (hasVoteStarted && !hasVoteEnded) || (hasVoteEnded && outcome === 'accepted'),
97+
outcome,
98+
show: hasVoteEnded && (outcome === 'rejected' || outcome === 'accepted'),
10199
},
102100
};
103101

@@ -135,22 +133,25 @@ export class Governance extends React.Component<RouteComponentProps<any>> {
135133
<ProposalHistory>
136134
<Ticks>
137135
{Object.keys(proposalHistoryState).map((state: string) => {
138-
const historyState = proposalHistoryState[state as ProposalState];
136+
const historyState: HistoryState = proposalHistoryState[state as ProposalState];
139137
if (!historyState.show) {
140138
return null;
141139
}
142140
return (
143141
<>
144-
<Tick isActive={historyState.done} isFailed={state === 'failed'}>
142+
<Tick
143+
isActive={historyState.done}
144+
isFailed={historyState.outcome === 'rejected'}
145+
>
145146
<img
146147
src={
147-
state === 'failed'
148+
historyState.outcome === 'rejected'
148149
? '/images/governance/cross.svg'
149150
: '/images/governance/tick_mark.svg'
150151
}
151152
/>
152153
</Tick>
153-
{!['accepted', 'failed'].includes(state) && (
154+
{!['accepted', 'failed', 'finalized'].includes(state) && (
154155
<Connector className={state === 'active' ? 'small' : ''} />
155156
)}
156157
</>
@@ -159,7 +160,7 @@ export class Governance extends React.Component<RouteComponentProps<any>> {
159160
</Ticks>
160161
<HistoryCells>
161162
{Object.keys(proposalHistoryState).map((state: string) => {
162-
const historyState = proposalHistoryState[state as ProposalState];
163+
const historyState: HistoryState = proposalHistoryState[state as ProposalState];
163164
if (!historyState.show) {
164165
return null;
165166
}
@@ -172,6 +173,11 @@ export class Governance extends React.Component<RouteComponentProps<any>> {
172173
fontWeight={400}
173174
>
174175
{state}
176+
{historyState.done &&
177+
(historyState.outcome === 'rejected' ||
178+
historyState.outcome === 'accepted')
179+
? ` - ${historyState.outcome}`
180+
: ''}
175181
</StateTitle>
176182
<Text
177183
fontColor={colors.textDarkSecondary}
@@ -180,7 +186,7 @@ export class Governance extends React.Component<RouteComponentProps<any>> {
180186
fontWeight={300}
181187
>
182188
{historyState.done
183-
? historyState.timestamp.format('MMMM Do, YYYY - hh:mm a')
189+
? `${historyState.timestamp.format('MMMM Do, YYYY - hh:mm a')}`
184190
: 'TBD'}
185191
</Text>
186192
</CellContent>

ts/pages/governance/vote_index_card.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ export const VoteIndexCard: React.StatelessComponent<VoteIndexCardProps> = (prop
127127
forVotes,
128128
quorumThreshold,
129129
} = props;
130+
130131
return (
131132
<ReactRouterLink style={{ order }} to={`${WebsitePaths.Vote}/proposal/${id}`}>
132133
<Section
@@ -160,7 +161,7 @@ export const VoteIndexCard: React.StatelessComponent<VoteIndexCardProps> = (prop
160161
<VoteStatusText
161162
status={getStatus(
162163
isCanceled,
163-
againstVotes < forVotes && forVotes > quorumThreshold,
164+
!isHappening && againstVotes < forVotes && forVotes > quorumThreshold,
164165
isUpcoming,
165166
)}
166167
/>

0 commit comments

Comments
 (0)