Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
vctt94 committed Apr 3, 2020
1 parent 008c579 commit fdd13d4
Show file tree
Hide file tree
Showing 8 changed files with 59 additions and 67 deletions.
2 changes: 1 addition & 1 deletion app/actions/GovernanceActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ export const getProposalDetails = (token) => async (dispatch, getState) => {
}
};

export const viewProposalDetails = (token) => (dispatch, getState) => {
export const viewProposalDetails = (token) => (dispatch) => {
dispatch(pushHistory(`/proposal/details/${token}`));
};

Expand Down
3 changes: 1 addition & 2 deletions app/components/modals/Modal.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { showCheck, eventOutsideElement } from "helpers";
import ReactDOM from "react-dom";
import { modal } from "connectors";
import EventListener from "react-event-listener";
import "style/Modals.less";
import Draggable from "react-draggable";
Expand Down Expand Up @@ -28,7 +27,7 @@ function Modal(props) {
const showingSidebarMenu = useSelector(sel.showingSidebarMenu);
const { children, className, draggable } = props;
const domNode = document.getElementById("modal-portal");
const modalRef = useRef(null)
const modalRef = useRef(null);

const innerView = <div ref={modalRef} className={cx((showingSidebarMenu ? expandSideBar ? "app-modal " : "app-modal-reduced-bar " : "app-modal-standalone "), className && className, draggable && " draggable-modal ")}>
{children}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { FormattedMessage as T } from "react-intl";
import { EnableExternalRequestButton } from "buttons";
import { EXTERNALREQUEST_POLITEIA } from "main_dev/externalRequests";
import { proposals } from "connectors";

export default ({ getTokenAndInitialBatch }) => (
<div className="politeia-disabled-wrapper">
Expand Down
96 changes: 48 additions & 48 deletions app/components/views/ProposalDetails/ChooseVoteOption.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { useMachine } from "@xstate/react";
import { StakeyBounceXs } from "indicators";
import { useDispatch } from "react-redux";
import { useState } from "react";
import { ProposalError } from "./helpers"
import { ProposalError } from "./helpers";
import * as gov from "actions/GovernanceActions";

const VoteOption = ({ value, description, onClick, checked }) => (
Expand All @@ -14,50 +14,50 @@ const VoteOption = ({ value, description, onClick, checked }) => (
readOnly={!onClick} onChange={onClick}
value={value}
checked ={checked}
/>
/>
<label className={"radio-label " + value} htmlFor={value}/>{description}
</div>
);

function UpdateVoteChoiceModalButton({ onSubmit, newVoteChoice, eligibleTicketCount }) {
return (
<PassphraseModalButton
modalTitle={
<>
<T id="proposals.updateVoteChoiceModal.title" m="Confirm Your Vote" />
<div className="proposal-vote-confirmation">
<div className={newVoteChoice+"-proposal"}/>
{newVoteChoice}
</div>
</>
}
modalDescription={
<T
id="proposalDetails.votingInfo.eligibleCount"
m="You have {count, plural, one {one ticket} other {# tickets}} eligible for voting"
values={{ count: eligibleTicketCount }}
/>
}
disabled={!newVoteChoice}
onSubmit={onSubmit}
buttonLabel={<T id="proposals.updateVoteChoiceModal.btnLabel" m="Cast Vote" />}
/>
)};
<PassphraseModalButton
modalTitle={
<>
<T id="proposals.updateVoteChoiceModal.title" m="Confirm Your Vote" />
<div className="proposal-vote-confirmation">
<div className={newVoteChoice+"-proposal"}/>
{newVoteChoice}
</div>
</>
}
modalDescription={
<T
id="proposalDetails.votingInfo.eligibleCount"
m="You have {count, plural, one {one ticket} other {# tickets}} eligible for voting"
values={{ count: eligibleTicketCount }}
/>
}
disabled={!newVoteChoice}
onSubmit={onSubmit}
buttonLabel={<T id="proposals.updateVoteChoiceModal.btnLabel" m="Cast Vote" />}
/>
);}

function getError(error) {
if (!error) return;
if (typeof error === "string") return error;
if (typeof error === "object") {
if (error.message) return error.message;
return JSON.stringify(error);
}
}
}

function ChooseVoteOption({
viewedProposalDetails, voteOptions, currentVoteChoice, votingComplete, eligibleTicketCount
}) {
const [ newVoteChoice, setVoteOption ] = useState(null);

const dispatch = useDispatch();
const onUpdateVoteChoice = (privatePassphrase) => dispatch(
gov.updateVoteChoice(viewedProposalDetails, newVoteChoice, privatePassphrase)
Expand Down Expand Up @@ -85,40 +85,40 @@ function ChooseVoteOption({
return <VoteOption
value={o.id} key={o.id}
description={o.id.charAt(0).toUpperCase()+o.id.slice(1)}
onClick={ () => currentVoteChoice === "abstain" && setVoteOption(o.id) }
onClick={ () => currentVoteChoice === "abstain" && setVoteOption(o.id) }
checked={ newVoteChoice ? newVoteChoice === o.id : currentVoteChoice !== "abstain" ? currentVoteChoice.id === o.id : null }
/>
/>;
})}
</div>
</div>
{ !votingComplete &&
<UpdateVoteChoiceModalButton {...{
newVoteChoice, onSubmit: (privatePassphrase) => send({type: "FETCH", privatePassphrase }), eligibleTicketCount
newVoteChoice, onSubmit: (privatePassphrase) => send({ type: "FETCH", privatePassphrase }), eligibleTicketCount
}} />
}
</>
);

switch (state.value) {
case "idle":
return <ChooseOptions {...{
setVoteOption, newVoteChoice, eligibleTicketCount, currentVoteChoice,
voteOptions, votingComplete
}} />;
case "loading":
return (
<div className="proposal-details-updating-vote-choice">
<StakeyBounceXs />
<T id="proposalDetails.votingInfo.updatingVoteChoice" m="Updating vote choice" />...
</div>
);
case "success":
return <ChooseOptions {...{
setVoteOption, newVoteChoice, eligibleTicketCount, currentVoteChoice,
voteOptions, votingComplete
}} />;
case "failure":
return <ProposalError {...{ error }} />;
case "idle":
return <ChooseOptions {...{
setVoteOption, newVoteChoice, eligibleTicketCount, currentVoteChoice,
voteOptions, votingComplete
}} />;
case "loading":
return (
<div className="proposal-details-updating-vote-choice">
<StakeyBounceXs />
<T id="proposalDetails.votingInfo.updatingVoteChoice" m="Updating vote choice" />...
</div>
);
case "success":
return <ChooseOptions {...{
setVoteOption, newVoteChoice, eligibleTicketCount, currentVoteChoice,
voteOptions, votingComplete
}} />;
case "failure":
return <ProposalError {...{ error }} />;
}
}

Expand Down
12 changes: 5 additions & 7 deletions app/components/views/ProposalDetails/Page.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,19 @@ import { InvisibleButton } from "buttons";
import { PoliteiaLink, VerticalAccordion } from "shared";
import {
ProposalNotVoting, NoTicketsVotingInfo, OverviewField, OverviewVotingProgressInfo,
NoElligibleTicketsVotingInfo, UpdatingVoteChoice, TimeValue,
ProposalText, ProposalAbandoned
NoElligibleTicketsVotingInfo, TimeValue, ProposalText, ProposalAbandoned
} from "./helpers";
import ChooseVoteOption from "./ChooseVoteOption";
import {
VOTESTATUS_ACTIVEVOTE, VOTESTATUS_FINISHEDVOTE, PROPOSALSTATUS_ABANDONED
} from "actions/GovernanceActions";
import { useSelector } from "react-redux";
import { useState } from "react"
import { useState } from "react";
import * as sel from "selectors";

function ProposalDetails ({
function ProposalDetails ({
viewedProposalDetails, showPurchaseTicketsPage, setVoteOption,
newVoteChoice, updateVoteChoiceAttempt, text, goBackHistory,
onUpdateVoteChoice
newVoteChoice, text, goBackHistory
}) {
const {
creator, timestamp, endTimestamp, currentVoteChoice, hasEligibleTickets,
Expand Down Expand Up @@ -47,7 +45,7 @@ function ProposalDetails ({
}} />;
}
return <ProposalNotVoting />;
};
}
let voteInfo = null;
// Check if proposal is abandoned. If it is not we check its vote status
if (proposalStatus === PROPOSALSTATUS_ABANDONED) {
Expand Down
2 changes: 1 addition & 1 deletion app/components/views/ProposalDetails/helpers.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { shell } from "electron";
import { KeyBlueButton, InvisibleConfirmPoliteiaModalButton } from "buttons";
import { FormattedMessage as T } from "react-intl";
import { VotingProgress, PoliteiaLoading } from "indicators";
import { VotingProgress } from "indicators";
import { showCheck } from "helpers";
import { default as ReactMarkdown } from "react-markdown";
import { FormattedRelative } from "shared";
Expand Down
2 changes: 0 additions & 2 deletions app/components/views/ProposalDetails/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { proposals } from "connectors";
import Page from "./Page";
import { ProposalError, politeiaMarkdownIndexMd } from "./helpers";
import { PoliteiaLoading } from "indicators";
import { useState } from "react";
import * as sel from "selectors";
import { useSelector, useDispatch } from "react-redux";
import { useParams } from "react-router-dom";
Expand Down
8 changes: 3 additions & 5 deletions app/reducers/governance.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import {
GETPROPOSAL_ATTEMPT, GETPROPOSAL_FAILED, GETPROPOSAL_SUCCESS,
UPDATEVOTECHOICE_ATTEMPT, UPDATEVOTECHOICE_SUCCESS, UPDATEVOTECHOICE_FAILED,
GETTOKEN_INVENTORY_SUCCESS, GETPROPROSAL_UPDATEVOTESTATUS_ATTEMPT,
GETPROPROSAL_UPDATEVOTESTATUS_SUCCESS, GETPROPROSAL_UPDATEVOTESTATUS_FAILED,
UPDATEVOTECHOICE_SUCCESS, GETTOKEN_INVENTORY_SUCCESS, GETPROPROSAL_UPDATEVOTESTATUS_ATTEMPT,
GETPROPOSAL_ATTEMPT, GETPROPOSAL_FAILED, GETPROPOSAL_SUCCESS, REMOVED_PROPOSALS_FROM_LIST,
GETTOKEN_INVENTORY_ATTEMPT, DISABLE_POLITEIA_SUCCESS, COMPARE_INVENTORY_SUCCESS,
REMOVED_PROPOSALS_FROM_LIST
GETPROPROSAL_UPDATEVOTESTATUS_SUCCESS, GETPROPROSAL_UPDATEVOTESTATUS_FAILED
} from "actions/GovernanceActions";
import {
CLOSEWALLET_SUCCESS
Expand Down

0 comments on commit fdd13d4

Please sign in to comment.