Skip to content

Commit

Permalink
feature: added the ability to leave a comment when voting on proposals
Browse files Browse the repository at this point in the history
  • Loading branch information
dafuga authored and aaroncox committed Feb 24, 2019
1 parent 6e79498 commit 6033e15
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 21 deletions.
1 change: 1 addition & 0 deletions app/renderer/assets/locales/en-US/tools.json
Expand Up @@ -252,6 +252,7 @@
"tools_permissions_warning_header": "Changing keys is a potentially dangerous action",
"tools_proposal_approved_message_content": "The stake weighted value of this account has been recorded as approving this proposal.",
"tools_proposal_approved_message_header": "This account has approved this proposal.",
"tools_proposal_leave_comment": "Leave a comment about this proposal..",
"tools_proposal_modify_vote": "If you would like to modify your vote, use the buttons below.",
"tools_proposal_rejected_message_content": "The stake weighted value of this account has been recorded as opposing this proposal.",
"tools_proposal_rejected_message_header": "This account has opposed this proposal.",
Expand Down
56 changes: 35 additions & 21 deletions app/shared/components/Tools/Governance/Proposals/Proposal.js
Expand Up @@ -4,7 +4,7 @@ import { translate } from 'react-i18next';
import { find } from 'lodash';

import TimeAgo from 'react-timeago';
import { Button, Divider, List, Header, Message, Segment } from 'semantic-ui-react';
import { Button, Divider, List, Header, Message, Segment, Form } from 'semantic-ui-react';

import GlobalModalDangerLink from '../../../Global/Modal/DangerLink';
import ToolsGovernanceProposalsProposalVote from './Proposal/Vote';
Expand All @@ -13,9 +13,10 @@ class ToolsGovernanceProposalsProposal extends Component<Props> {
approve = (proposal) => {
const { actions, settings } = this.props;
const { scope } = this.props;
const { comment } = this.state;
const voter = settings.account;
const vote = 1;
const json = JSON.stringify({});
const json = JSON.stringify( comment ? { comment } : {});
actions.voteProposal(scope, voter, proposal, vote, json);
};
oppose = (proposal) => {
Expand All @@ -37,7 +38,6 @@ class ToolsGovernanceProposalsProposal extends Component<Props> {
actions,
blockExplorers,
isLocked,
voteDisabled,
settings,
proposal,
system,
Expand Down Expand Up @@ -150,15 +150,22 @@ class ToolsGovernanceProposalsProposal extends Component<Props> {
icon: 'checkmark'
}}
confirm={(
<Button
color="blue"
content={t('confirm')}
disabled={isSupporting}
floated="right"
icon="checkmark"
loading={isVotePending}
onClick={() => this.approve(proposal_name)}
/>
<Form>
<Form.TextArea
rows={3}
placeholder={t('tools_proposal_leave_comment')}
onChange={(e) => this.setState({ comment: e.target.value })}
/>
<Button
color="blue"
content={t('confirm')}
disabled={isSupporting}
floated="right"
icon="checkmark"
loading={isVotePending}
onClick={() => this.approve(proposal_name)}
/>
</Form>
)}
content={t('tools_governance_proposal_confirm_vote_yes')}
isLocked={isLocked}
Expand All @@ -178,15 +185,22 @@ class ToolsGovernanceProposalsProposal extends Component<Props> {
icon: 'x'
}}
confirm={(
<Button
color="blue"
content={t('confirm')}
disabled={isAgainst}
floated="right"
icon="checkmark"
loading={isVotePending}
onClick={() => this.oppose(proposal_name)}
/>
<Form>
<Form.TextArea
rows={3}
placeholder={t('tools_proposal_leave_comment')}
onChange={(e) => this.setState({ comment: e.target.value })}
/>
<Button
color="blue"
content={t('confirm')}
disabled={isAgainst}
floated="right"
icon="checkmark"
loading={isVotePending}
onClick={() => this.oppose(proposal_name)}
/>
</Form>
)}
content={t('tools_governance_proposal_confirm_vote_no')}
isLocked={isLocked}
Expand Down
Expand Up @@ -6,6 +6,7 @@ import { Segment } from 'semantic-ui-react';

import GlobalTransactionModal from '../../../../Global/Transaction/Modal';
import WalletPanelLocked from '../../../../Wallet/Panel/Locked';
import { Form } from '../../../../Wallet/Panel/Modal/Account/Request/Code';

class ToolsGovernanceProposalsProposalVote extends Component<Props> {
render() {
Expand Down

0 comments on commit 6033e15

Please sign in to comment.