Skip to content

Commit

Permalink
[governance] Add RFP flag to proposals list (#3118)
Browse files Browse the repository at this point in the history
  • Loading branch information
guilhermemntt committed Jan 28, 2021
1 parent 415522c commit 9aca951
Show file tree
Hide file tree
Showing 7 changed files with 86 additions and 13 deletions.
1 change: 1 addition & 0 deletions app/actions/GovernanceActions.js
Expand Up @@ -72,6 +72,7 @@ const fillVoteSummary = (proposal, voteSummary, blockTimestampFromNow) => {
: 60;
proposal.quorumMinimumVotes = Math.round(eligibleVotes * (quorum / 100));
proposal.voteStatus = voteSummary.status;
proposal.approved = voteSummary.approved;

if (totalVotes > proposal.quorumMinimumVotes) {
proposal.quorumPass = true;
Expand Down
Expand Up @@ -21,7 +21,10 @@ const ProposalsListItem = ({
modifiedSinceLastAccess,
votingSinceLastAccess,
quorumMinimumVotes,
finishedVote
finishedVote,
linkto,
linkedfrom,
approved
}) => {
const { viewProposalDetailsHandler, tsDate } = useProposalsListItem(token);
const isVoting = voteStatus === VOTESTATUS_ACTIVEVOTE;
Expand All @@ -36,11 +39,24 @@ const ProposalsListItem = ({
"is-row",
styles.listiTtem,
styles[voteResult],
!approved && styles.declined,
finishedVote && styles.ended,
isModified && styles.modified
)}>
<div>
<div className={styles.name}>{name}</div>
<div className={styles.title}>
<div className={styles.name}>{name}</div>
{linkedfrom && (
<div className={styles.rfp}>
<T id="proposalItem.rfp" m="RFP" />
</div>
)}
{linkto && (
<div className={styles.rfp}>
<T id="proposalItem.proposedForRfp" m="Proposed for RFP" />
</div>
)}
</div>
<div className={styles.token}>{token.substring(0, 7)}</div>
</div>
<div className={styles.resultsArea}>
Expand Down Expand Up @@ -69,7 +85,11 @@ const ProposalsListItem = ({
) : (
<div className={styles.voteResult}>
{quorumPass ? (
voteResult
linkto && !approved && voteResult !== "declined" ? (
<T id="proposals.rfpRejected" m="Proposal not chosen" />
) : (
voteResult
)
) : (
<T id="proposals.quorumNotMet" m="Quorum not met" />
)}
Expand Down
Expand Up @@ -32,11 +32,23 @@
color: var(--input-color);
}

.name {
.title {
display: flex;
flex-direction: row;
font-size: 13px;
line-height: 17px;
}

.name {
color: var(--input-color-default);
width: 440px;
}

.rfp {
border: 1px solid var(--stroke-color-default);
border-radius: 3px;
padding: 0 5px;
margin-left: 15px;
color: var(--stroke-color-default);
}

.token {
Expand Down Expand Up @@ -80,10 +92,12 @@
margin-right: 10px;
}

.voteChoice.yes, .voteChoice.passed {
.voteChoice.yes,
.voteChoice.passed {
background-color: var(--vote-yes-color);
}
.voteChoice.no, .voteChoice.declined {
.voteChoice.no,
.voteChoice.declined {
background-color: var(--vote-no-color);
}

Expand Down
21 changes: 20 additions & 1 deletion app/components/views/ProposalDetailsPage/ProposalDetails.jsx
Expand Up @@ -49,7 +49,8 @@ const ProposalDetails = ({
newVoteChoice,
text,
goBackHistory,
eligibleTicketCount
eligibleTicketCount,
linkedProposal
}) => {
walletEligibleTickets = walletEligibleTickets.map((et, i) => {
walletEligibleTickets[i].txHash = et.ticket;
Expand All @@ -60,6 +61,7 @@ const ProposalDetails = ({
const { themeName } = useTheme();
const isDarkTheme = themeName === DEFAULT_DARK_THEME_NAME;
const shortToken = token.substring(0, 7);
const shortRFPToken = linkedProposal?.token.substring(0, 7);
const proposalPath = `/proposals/${shortToken}`;
const votingActiveOrFinished =
voteStatus === VOTESTATUS_ACTIVEVOTE ||
Expand All @@ -70,6 +72,23 @@ const ProposalDetails = ({
<div className={styles.overviewInfoWrapper}>
<div className={styles.overviewInfo}>
<div className={styles.title}>{name}</div>
{linkedProposal && (
<div className={styles.proposedToRfp}>
<T
id="proposal.overview.proposedToRfp.label"
m="Proposed for {linkedProposal}"
values={{
linkedProposal: (
<PoliteiaLink
isTestnet={isTestnet}
path={`/proposals/${shortRFPToken}`}>
{`${linkedProposal.name} (${shortRFPToken})`}
</PoliteiaLink>
)
}}
/>
</div>
)}
<div className={styles.token}>
<PoliteiaLink isTestnet={isTestnet} path={proposalPath}>
{shortToken}
Expand Down
Expand Up @@ -21,14 +21,19 @@
color: var(--tutorial-header);
}

.proposedToRfp,
.token {
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
width: 100px;
color: var(--overview-balance-label);
}

.token {
width: 100px;
}

.proposedToRfp a,
.token a {
font-size: 13px;
line-height: 19px;
Expand All @@ -37,6 +42,7 @@
cursor: pointer;
}

.proposedToRfp a:hover,
.token a:hover {
color: var(--stroke-color-default);
}
Expand Down
Expand Up @@ -16,7 +16,8 @@ const ProposalDetailsPage = () => {
getProposalError,
goBackHistory,
showPurchaseTicketsPage,
send
send,
linkedProposal
} = useProposalDetailsPage();

const stateComponent = useMemo(() => {
Expand All @@ -43,7 +44,8 @@ const ProposalDetailsPage = () => {
viewedProposalDetails,
goBackHistory,
eligibleTicketCount,
showPurchaseTicketsPage
showPurchaseTicketsPage,
linkedProposal
}}
/>
);
Expand All @@ -67,7 +69,8 @@ const ProposalDetailsPage = () => {
getProposalError,
votingStatus,
showPurchaseTicketsPage,
send
send,
linkedProposal
]);

return (
Expand Down
12 changes: 11 additions & 1 deletion app/components/views/ProposalDetailsPage/hooks.js
Expand Up @@ -17,13 +17,22 @@ export const useProposalDetails = () => {
export const useProposalDetailsPage = () => {
const dispatch = useDispatch();
const { token } = useParams();
const proposals = useSelector(sel.proposals);
const proposalsDetails = useSelector(sel.proposalsDetails);
const getProposalError = useSelector(sel.getProposalError);

const viewedProposalDetails = useMemo(() => proposalsDetails[token], [
token,
proposalsDetails
]);

const linkedProposal = useMemo(() => viewedProposalDetails?.linkto &&
proposals.finishedVote.find(proposal => viewedProposalDetails.linkto === proposal.token)
, [
proposals,
viewedProposalDetails
]);

const eligibleTicketCount =
viewedProposalDetails && viewedProposalDetails.walletEligibleTickets
? proposalsDetails[token].walletEligibleTickets.length
Expand Down Expand Up @@ -69,6 +78,7 @@ export const useProposalDetailsPage = () => {
dispatch,
goBackHistory,
showPurchaseTicketsPage,
send
send,
linkedProposal
};
};

0 comments on commit 9aca951

Please sign in to comment.