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

improve preboostable logic, feedback and layout #1482

Merged
merged 7 commits into from
Mar 13, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
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
4 changes: 2 additions & 2 deletions src/components/Proposal/ActionButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -230,13 +230,13 @@ class ActionButton extends React.Component<IProps, IState> {
/> : ""
}

{ proposalState.stage === IProposalStage.Queued && proposalState.upstakeNeededToPreBoost.lt(new BN(0)) ?
{ proposalState.stage === IProposalStage.Queued && proposalState.upstakeNeededToPreBoost.ltn(0) ?
Copy link
Contributor

Choose a reason for hiding this comment

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

are you sure this works? didn't use to, maybe they fixed it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

has always worked for me. testing the functionality seems to work

<button className={css.preboostButton} onClick={this.handleClickExecute("Pre-Boost")} data-test-id="buttonBoost">
<img src="/assets/images/Icon/boost.svg"/>
{ /* space after <span> is there on purpose */ }
<span> Pre-Boost</span>
</button> :
proposalState.stage === IProposalStage.PreBoosted && expired && proposalState.downStakeNeededToQueue.lte(new BN(0)) ?
proposalState.stage === IProposalStage.PreBoosted && expired && proposalState.downStakeNeededToQueue.lten(0) ?
<button className={css.unboostButton} onClick={this.handleClickExecute("Un-boost")} data-test-id="buttonBoost">
<img src="/assets/images/Icon/boost.svg"/>
<span> Un-Boost</span>
Expand Down
17 changes: 9 additions & 8 deletions src/components/Proposal/Staking/BoostAmount.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { IProposalStage, IProposalState } from "@daostack/client";

import BN = require("bn.js");
import classNames from "classnames";
import { formatTokens } from "lib/util";
import * as React from "react";
Expand All @@ -26,32 +25,34 @@ export default class BoostAmount extends React.Component<IProps, null> {
[css.wrapper]: true,
[css.detailView]: detailView,
});
const nothing = <span className={css.boostedAmount}><b>&nbsp;</b></span>;

return (
<div className={wrapperClass}>
{
proposal.stage === IProposalStage.Queued && !expired && proposal.upstakeNeededToPreBoost.gte(new BN(0)) ?
!expired ? ((proposal.stage === IProposalStage.Queued && proposal.upstakeNeededToPreBoost.gten(0)) ?
Copy link
Contributor

Choose a reason for hiding this comment

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

I dont think this is right, cant you still boost/unboost a pre-boosted proposal that is expired? or do we want to turn that off

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was misinterpreting what "expired" meant (forgetting that it often means expired only within the context of the current phase, but not necessarily that the proposal is dead, and not necessarily that the expired state is even represented yet in the blockchain).

So good catch. I have reverted the change.

<span className={css.boostedAmount}>
<b>
{detailView ? <img src="/assets/images/Icon/Boost-slate.svg" /> : ""}
&gt; {formatTokens(proposal.upstakeNeededToPreBoost, "GEN")} to boost
&gt; {formatTokens(proposal.upstakeNeededToPreBoost, "GEN")} on Pass to boost
</b>
</span>
: proposal.stage === IProposalStage.PreBoosted && proposal.downStakeNeededToQueue.lte(new BN(0)) ?
: proposal.stage === IProposalStage.PreBoosted && proposal.downStakeNeededToQueue.lten(0) ?
<span className={css.boostedAmount}>
<b>
{detailView ? <img src="/assets/images/Icon/Boost-slate.svg" /> : ""}
&gt; {formatTokens(proposal.downStakeNeededToQueue.abs(), "GEN")} Pass to stay boosted
&gt; {formatTokens(proposal.downStakeNeededToQueue.abs(), "GEN")} on Pass to stay boosted
Copy link
Contributor

Choose a reason for hiding this comment

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

does this fit?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes

</b>
</span>
: proposal.stage === IProposalStage.PreBoosted && proposal.downStakeNeededToQueue.gt(new BN(0)) ?
: proposal.stage === IProposalStage.PreBoosted && proposal.downStakeNeededToQueue.gtn(0) ?
<span className={css.boostedAmount + " " + css.unboostAmount}>
<b>
{detailView ? <img src="/assets/images/Icon/Boost-slate.svg" /> : ""}
{formatTokens(proposal.downStakeNeededToQueue, "GEN")} on Fail to un-boost
&gt;= {formatTokens(proposal.downStakeNeededToQueue, "GEN")} on Fail to un-boost
</b>
</span>
: <span className={css.boostedAmount}><b>&nbsp;</b></span>
: nothing
) : nothing
}
</div>
);
Expand Down
100 changes: 50 additions & 50 deletions src/components/Proposal/Staking/StakeButtons.scss
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
.predictions {
.stakesFor span, .stakesAgainst span {
.stakesFor span,
.stakesAgainst span {
width: 50px;
}

span {
text-align: left;
display: inline-block;
color: rgba(104, 154, 214, 1.000);
color: rgba(104, 154, 214, 1);
min-width: 3%;
font-size: 13px;

Expand All @@ -28,8 +29,8 @@

button {
font-weight: $bold;
color: rgba(3, 118, 255, 1.000);
background-color: rgba(225, 235, 247, 1.000);
color: rgba(3, 118, 255, 1);
background-color: rgba(225, 235, 247, 1);
height: 25px;
line-height: 14px;
position: relative;
Expand Down Expand Up @@ -58,7 +59,6 @@
}

button.pendingPrediction {

strong {
opacity: 0;
}
Expand Down Expand Up @@ -88,7 +88,7 @@
button {
border: 1px solid $black-tenthtone;
color: $black-halftone;
transition: all .25s ease;
transition: all 0.25s ease;

&:hover {
color: $accent-1;
Expand Down Expand Up @@ -117,7 +117,7 @@
button {
color: $black-halftone;
border: 1px solid $black-tenthtone;
transition: all .25s ease;
transition: all 0.25s ease;

&:hover {
color: $accent-2;
Expand Down Expand Up @@ -150,7 +150,9 @@
}

.predictions.unconfirmedPrediction {
.loading { display: block; }
.loading {
display: block;
}
}

.enablePredictions {
Expand All @@ -171,7 +173,6 @@
padding-top: 5px;
padding-bottom: 7px;
margin: 0 auto;
border-radius: 12.5px;
background-color: #0076ff;
color: white;
font-weight: normal;
Expand All @@ -189,6 +190,8 @@
font-size: 11px;
letter-spacing: 0.2px;
color: #689bd6;
margin-left: 2px;
margin-right: 2px;
}

.detailView {
Expand All @@ -203,7 +206,7 @@

h3 {
display: block;
color: rgba(104, 155, 214, 1.000);
color: rgba(104, 155, 214, 1);
width: 100%;
position: absolute;
top: 0;
Expand Down Expand Up @@ -253,7 +256,6 @@
border: 1px solid $black-tenthtone;
}
50% {

border: 1px solid $accent-1;
}
100% {
Expand All @@ -265,7 +267,6 @@
border: 1px solid $black-tenthtone;
}
50% {

border: 1px solid $accent-2;
}
100% {
Expand All @@ -275,7 +276,6 @@

/**** Pre-approve *****/
.preApproval {

h3 {
background-color: #122e5b;
border-radius: 15px 15px 0 0;
Expand All @@ -300,7 +300,7 @@
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%,-50%);
transform: translate(-50%, -50%);
padding: 0 0 20px 0;
border-radius: 15px 15px 0 0;
font-size: 14px;
Expand All @@ -309,7 +309,7 @@
p {
padding: 0 15px 6px 15px;
font-size: 14px;
opacity: .6;
opacity: 0.6;
}

.preapproveButtonsWrapper {
Expand All @@ -333,8 +333,8 @@
}

button:first-of-type {
background-color: rgba(225, 235, 247, 1.000);
color: rgba(0, 113, 255, 1.000);
background-color: rgba(225, 235, 247, 1);
color: rgba(0, 113, 255, 1);
}
}
}
Expand All @@ -345,7 +345,7 @@

.contextTitle {
width: 100%;
border-bottom: 1px solid rgba(233, 238, 244, 1.000);
border-bottom: 1px solid rgba(233, 238, 244, 1);
text-align: left;
position: relative;
top: -5px;
Expand All @@ -354,7 +354,7 @@
span {
font-size: 11px;
font-family: "Open Sans";
color: rgba(154, 169, 181, 1.000);
color: rgba(154, 169, 181, 1);
padding: 3px;
background-color: white;
position: relative;
Expand All @@ -365,40 +365,40 @@
}

.contextContent button {
display: block;
text-align: left;
width: 100%;
border: none;
background-color: rgba(240, 245, 251, 0);
transition: all .25s ease;
padding: 5px 0;
border-radius: 0;
margin: 0 0 0 0;
color: rgba(78, 97, 118, 1.000);
font-weight: normal;

img {
margin-left: 15px;
position: relative;
top: 3px;
margin-right: 10px;
}
display: block;
text-align: left;
width: 100%;
border: none;
background-color: rgba(240, 245, 251, 0);
transition: all 0.25s ease;
padding: 5px 0;
border-radius: 0;
margin: 0 0 0 0;
color: rgba(78, 97, 118, 1);
font-weight: normal;

img {
margin-left: 15px;
position: relative;
top: 3px;
margin-right: 10px;
}

span {
display: inline-block;
position: relative;
top: -2px;
left: 10px;
}
span {
display: inline-block;
position: relative;
top: -2px;
left: 10px;
}

&:hover {
background-color: rgba(240, 245, 251, 1.000);
}
&:hover {
background-color: rgba(240, 245, 251, 1);
}
}

.contextContent .disabledPredictions {
width: 80%;
text-align: center;
margin: 5px auto 0 auto;
display: block;
width: 80%;
text-align: center;
margin: 5px auto 0 auto;
display: block;
}
8 changes: 4 additions & 4 deletions src/components/Proposal/Staking/StakeButtons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -277,8 +277,8 @@ class StakeButtons extends React.Component<IProps, IState> {
</Tooltip> :
passButton
}
{parentPage !== Page.ProposalDetails && proposal.stage === IProposalStage.Queued && !expired ?
<div className={css.toBoostMessage}>&gt;{formatTokens(proposal.upstakeNeededToPreBoost, "GEN to boost")}</div>
{parentPage !== Page.ProposalDetails && proposal.stage === IProposalStage.Queued && !expired && proposal.upstakeNeededToPreBoost.gten(0) ?
<div className={css.toBoostMessage}>&gt; {formatTokens(proposal.upstakeNeededToPreBoost, "GEN to boost")}</div>
: ""}
{
(currentAccountAddress && tip(IProposalOutcome.Pass) !== "") ?
Expand All @@ -287,8 +287,8 @@ class StakeButtons extends React.Component<IProps, IState> {
</Tooltip> :
failButton
}
{parentPage !== Page.ProposalDetails && proposal.stage === IProposalStage.PreBoosted && !expired ?
<div className={css.toBoostMessage}>{formatTokens(proposal.downStakeNeededToQueue, " GEN to un-boost")}</div>
{parentPage !== Page.ProposalDetails && proposal.stage === IProposalStage.PreBoosted && !expired && proposal.downStakeNeededToQueue.gtn(0) ?
<div className={css.toBoostMessage}>&gt;= {formatTokens(proposal.downStakeNeededToQueue, " GEN to un-boost")}</div>
: ""}
</div>
: <span className={css.disabledPredictions}>
Expand Down
10 changes: 8 additions & 2 deletions src/components/Shared/PreTransactionModal.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { IDAOState, IMemberState, IProposalState } from "@daostack/client";
import { IDAOState, IMemberState, IProposalState, IProposalStage } from "@daostack/client";
import { enableWalletProvider } from "arc";

import BN = require("bn.js");
Expand Down Expand Up @@ -371,7 +371,13 @@ class PreTransactionModal extends React.Component<IProps, IState> {
}
</ul>
</div>
<div className={css.xToBoost}>&gt; {formatTokens(proposal.upstakeNeededToPreBoost, "GEN") + " needed to boost this proposal"}</div>
{ (proposal.stage === IProposalStage.Queued && actionType === ActionTypes.StakePass && proposal.upstakeNeededToPreBoost.gten(0)) ?
<div className={css.xToBoost}>&gt; {formatTokens(proposal.upstakeNeededToPreBoost, "GEN") + " needed to boost this proposal"}</div>
:
(proposal.stage === IProposalStage.PreBoosted && actionType === ActionTypes.StakeFail && proposal.downStakeNeededToQueue.gtn(0)) ?
<div className={css.xToBoost}>&gt;= {formatTokens(proposal.downStakeNeededToQueue, "GEN") + " needed to unboost this proposal"}</div>
: ""
}
</div>
</div>
</div>
Expand Down
4 changes: 1 addition & 3 deletions src/components/Shared/ProposalCountdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import * as moment from "moment";
import * as React from "react";
import { closingTime } from "lib/proposalHelpers";

import BN = require("bn.js");

import * as css from "./Countdown.scss";

interface IProps {
Expand Down Expand Up @@ -129,7 +127,7 @@ export default class ProposalCountdown extends React.Component<IProps, IState> {
{this.props.detailView ?
<span className={css.label}>
{ proposal.stage === IProposalStage.Queued ? "Proposal will expire in" :
proposal.stage === IProposalStage.PreBoosted && proposal.downStakeNeededToQueue.lte(new BN(0)) ? "Proposal will un-boost in" :
proposal.stage === IProposalStage.PreBoosted && proposal.downStakeNeededToQueue.lten(0) ? "Proposal will un-boost in" :
proposal.stage === IProposalStage.PreBoosted ? "Proposal will boost in" :
(proposal.stage === IProposalStage.Boosted || proposal.stage === IProposalStage.QuietEndingPeriod) && proposal.winningOutcome === IProposalOutcome.Pass ? "Proposal will pass in" :
(proposal.stage === IProposalStage.Boosted || proposal.stage === IProposalStage.QuietEndingPeriod) ? "Proposal will fail in" :
Expand Down