Merge branch 'core' into order-of-cards
This commit is contained in:
commit
e73094bd0a
|
@ -17,6 +17,10 @@ class App extends Component {
|
|||
return <Ballots isActiveFilter={true}/>;
|
||||
}
|
||||
|
||||
onToFinalizeBallotsRender = () => {
|
||||
return <Ballots isToFinalizeFilter={true}/>;
|
||||
}
|
||||
|
||||
onNewBallotRender = () => {
|
||||
return <NewBallot/>;
|
||||
}
|
||||
|
@ -37,7 +41,8 @@ class App extends Component {
|
|||
currentPath === `${commonStore.rootPath}`
|
||||
|| currentPath === "/"
|
||||
|| currentPath === `${commonStore.rootPath}/`
|
||||
|| currentPath === `${commonStore.rootPath}/active`;
|
||||
|| currentPath === `${commonStore.rootPath}/active`
|
||||
|| currentPath === `${commonStore.rootPath}/tofinalize`;
|
||||
return showNavPan;
|
||||
}
|
||||
|
||||
|
@ -49,6 +54,7 @@ class App extends Component {
|
|||
<div className="nav">
|
||||
<NavLink className="nav-i" exact activeClassName="nav-i_active" to={`${commonStore.rootPath}/`}>All</NavLink>
|
||||
<NavLink className="nav-i" activeClassName="nav-i_active" to={`${commonStore.rootPath}/active`}>Active</NavLink>
|
||||
<NavLink className="nav-i" activeClassName="nav-i_active" to={`${commonStore.rootPath}/tofinalize`}>To finalize</NavLink>
|
||||
</div>
|
||||
<input type="search" className="search-input" onChange={this.onSearch}/>
|
||||
</div>
|
||||
|
@ -61,6 +67,7 @@ class App extends Component {
|
|||
<Route exact path={`/`} render={this.onBallotsRender}/>
|
||||
<Route exact path={`${commonStore.rootPath}/`} render={this.onBallotsRender}/>
|
||||
<Route exact path={`${commonStore.rootPath}/active`} render={this.onActiveBallotsRender}/>
|
||||
<Route exact path={`${commonStore.rootPath}/tofinalize`} render={this.onToFinalizeBallotsRender}/>
|
||||
<Route path={`${commonStore.rootPath}/new`} render={this.onNewBallotRender}/>
|
||||
{/*<Route path={`${commonStore.rootPath}/settings`} render={this.onSettingsRender}/>*/}
|
||||
<Footer netId={contractsStore.netId} />
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -14,6 +14,10 @@
|
|||
&-i {
|
||||
@extend %white-block;
|
||||
|
||||
&-not-finalized {
|
||||
background-color: rgba(8,179,242,0.1);
|
||||
}
|
||||
|
||||
&:hover {
|
||||
box-shadow: 0 11px 11px 0 fade-out(#326cb5, 0.85);
|
||||
}
|
||||
|
@ -58,6 +62,8 @@
|
|||
&--name {
|
||||
color: #333;
|
||||
font-weight: bold;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
&--created {
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
background-image: url(./images/info.png);
|
||||
background-repeat: no-repeat;
|
||||
background-position: left center;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.new-form & {
|
||||
|
|
|
@ -354,7 +354,8 @@ export class BallotCard extends React.Component {
|
|||
|
||||
showCard = () => {
|
||||
let { commonStore } = this.props;
|
||||
let show = commonStore.isActiveFilter ? !this.isFinalized : true;
|
||||
let checkToFinalizeFilter = commonStore.isToFinalizeFilter ? !this.isFinalized && this.timeToFinish.val == 0 : true;
|
||||
let show = commonStore.isActiveFilter ? !this.isFinalized : checkToFinalizeFilter;
|
||||
return show;
|
||||
}
|
||||
|
||||
|
@ -396,7 +397,8 @@ export class BallotCard extends React.Component {
|
|||
|
||||
render () {
|
||||
let { contractsStore, votingType, children, isSearchPattern } = this.props;
|
||||
let ballotClass = (this.showCard() && (this.isCreatorPattern() || this.isMemoPattern() || isSearchPattern)) ? "ballots-i" : "ballots-i display-none";
|
||||
let isFromSearch = (this.isCreatorPattern() || this.isMemoPattern() || isSearchPattern);
|
||||
let ballotClass = (this.showCard() && isFromSearch) ? this.isFinalized ? "ballots-i" : "ballots-i ballots-i-not-finalized" : "ballots-i display-none";
|
||||
const threshold = this.getThreshold(contractsStore, votingType);
|
||||
return (
|
||||
<div className={ballotClass}>
|
||||
|
|
|
@ -8,6 +8,7 @@ export class Ballots extends React.Component {
|
|||
componentWillMount () {
|
||||
const { commonStore } = this.props;
|
||||
commonStore.isActiveFilter = this.props.isActiveFilter;
|
||||
commonStore.isToFinalizeFilter = this.props.isToFinalizeFilter;
|
||||
}
|
||||
|
||||
render () {
|
||||
|
|
|
@ -20,7 +20,7 @@ export class NewBallot extends React.Component {
|
|||
const { commonStore, contractsStore, ballotStore, validatorStore } = this.props;
|
||||
const twoDays = moment.utc().add(2, 'days').format();
|
||||
let neededMinutes = moment(twoDays).diff(moment(ballotStore.endTime), 'minutes');
|
||||
let neededHours = Math.round(neededMinutes/60);
|
||||
let neededHours = Math.round(neededMinutes / 60);
|
||||
let duration = 48 - neededHours;
|
||||
|
||||
if (ballotStore.isNewValidatorPersonalData) {
|
||||
|
@ -33,19 +33,27 @@ export class NewBallot extends React.Component {
|
|||
}
|
||||
}
|
||||
|
||||
if(!ballotStore.memo){
|
||||
if(!ballotStore.memo) {
|
||||
swal("Warning!", messages.DESCRIPTION_IS_EMPTY, "warning");
|
||||
commonStore.hideLoading();
|
||||
return false;
|
||||
}
|
||||
|
||||
if(neededMinutes > 0) {
|
||||
neededMinutes = neededHours*60 - neededMinutes;
|
||||
neededMinutes = neededHours * 60 - neededMinutes;
|
||||
swal("Warning!", messages.SHOULD_BE_MORE_THAN_TWO_DAYS(duration, neededHours, neededMinutes), "warning");
|
||||
commonStore.hideLoading();
|
||||
return false;
|
||||
}
|
||||
|
||||
const twoWeeks = moment.utc().add(14, 'days').format();
|
||||
let exceededMinutes = moment(ballotStore.endTime).diff(moment(twoWeeks), 'minutes');
|
||||
if (exceededMinutes > 0) {
|
||||
swal("Warning!", messages.SHOULD_BE_LESS_OR_EQUAL_14_DAYS(duration), "warning");
|
||||
commonStore.hideLoading();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (ballotStore.isBallotForKey) {
|
||||
for (let ballotKeysProp in ballotStore.ballotKeys) {
|
||||
if (!ballotStore.ballotKeys[ballotKeysProp]) {
|
||||
|
|
|
@ -13,19 +13,20 @@ export default class VotingToChangeKeys {
|
|||
let votingToChangeKeysABI = await helpers.getABI(branch, 'VotingToChangeKeys')
|
||||
|
||||
this.votingToChangeKeysInstance = new web3_10.eth.Contract(votingToChangeKeysABI, VOTING_TO_CHANGE_KEYS_ADDRESS);
|
||||
this.gasPrice = web3_10.utils.toWei('1', 'gwei');
|
||||
}
|
||||
|
||||
//setters
|
||||
createVotingForKeys({startTime, endTime, affectedKey, affectedKeyType, miningKey, ballotType, sender, memo}) {
|
||||
return this.votingToChangeKeysInstance.methods.createVotingForKeys(startTime, endTime, affectedKey, affectedKeyType, miningKey, ballotType, memo).send({from: sender});
|
||||
return this.votingToChangeKeysInstance.methods.createVotingForKeys(startTime, endTime, affectedKey, affectedKeyType, miningKey, ballotType, memo).send({from: sender, gasPrice: this.gasPrice});
|
||||
}
|
||||
|
||||
vote(_id, choice, sender) {
|
||||
return this.votingToChangeKeysInstance.methods.vote(_id, choice).send({from: sender});
|
||||
return this.votingToChangeKeysInstance.methods.vote(_id, choice).send({from: sender, gasPrice: this.gasPrice});
|
||||
}
|
||||
|
||||
finalize(_id, sender) {
|
||||
return this.votingToChangeKeysInstance.methods.finalize(_id).send({from: sender});
|
||||
return this.votingToChangeKeysInstance.methods.finalize(_id).send({from: sender, gasPrice: this.gasPrice});
|
||||
}
|
||||
|
||||
//getters
|
||||
|
|
|
@ -13,19 +13,20 @@ export default class VotingToChangeMinThreshold {
|
|||
let votingToChangeMinThresholdABI = await helpers.getABI(branch, 'VotingToChangeMinThreshold')
|
||||
|
||||
this.votingToChangeMinThresholdInstance = new web3_10.eth.Contract(votingToChangeMinThresholdABI, VOTING_TO_CHANGE_MIN_THRESHOLD_ADDRESS);
|
||||
this.gasPrice = web3_10.utils.toWei('1', 'gwei');
|
||||
}
|
||||
|
||||
//setters
|
||||
createBallotToChangeThreshold({startTime, endTime, proposedValue, sender, memo}) {
|
||||
return this.votingToChangeMinThresholdInstance.methods.createBallotToChangeThreshold(startTime, endTime, proposedValue, memo).send({from: sender})
|
||||
return this.votingToChangeMinThresholdInstance.methods.createBallotToChangeThreshold(startTime, endTime, proposedValue, memo).send({from: sender, gasPrice: this.gasPrice})
|
||||
}
|
||||
|
||||
vote(_id, choice, sender) {
|
||||
return this.votingToChangeMinThresholdInstance.methods.vote(_id, choice).send({from: sender})
|
||||
return this.votingToChangeMinThresholdInstance.methods.vote(_id, choice).send({from: sender, gasPrice: this.gasPrice})
|
||||
}
|
||||
|
||||
finalize(_id, sender) {
|
||||
return this.votingToChangeMinThresholdInstance.methods.finalize(_id).send({from: sender})
|
||||
return this.votingToChangeMinThresholdInstance.methods.finalize(_id).send({from: sender, gasPrice: this.gasPrice})
|
||||
}
|
||||
|
||||
//getters
|
||||
|
|
|
@ -13,19 +13,20 @@ export default class VotingToChangeProxy {
|
|||
let votingToChangeProxyABI = await helpers.getABI(branch, 'VotingToChangeProxyAddress')
|
||||
|
||||
this.votingToChangeProxyInstance = new web3_10.eth.Contract(votingToChangeProxyABI, VOTING_TO_CHANGE_PROXY_ADDRESS);
|
||||
this.gasPrice = web3_10.utils.toWei('1', 'gwei');
|
||||
}
|
||||
|
||||
//setters
|
||||
createBallotToChangeProxyAddress({startTime, endTime, proposedValue, contractType, sender, memo}) {
|
||||
return this.votingToChangeProxyInstance.methods.createBallotToChangeProxyAddress(startTime, endTime, proposedValue, contractType, memo).send({from: sender})
|
||||
return this.votingToChangeProxyInstance.methods.createBallotToChangeProxyAddress(startTime, endTime, proposedValue, contractType, memo).send({from: sender, gasPrice: this.gasPrice})
|
||||
}
|
||||
|
||||
vote(_id, choice, sender) {
|
||||
return this.votingToChangeProxyInstance.methods.vote(_id, choice).send({from: sender})
|
||||
return this.votingToChangeProxyInstance.methods.vote(_id, choice).send({from: sender, gasPrice: this.gasPrice})
|
||||
}
|
||||
|
||||
finalize(_id, sender) {
|
||||
return this.votingToChangeProxyInstance.methods.finalize(_id).send({from: sender})
|
||||
return this.votingToChangeProxyInstance.methods.finalize(_id).send({from: sender, gasPrice: this.gasPrice})
|
||||
}
|
||||
|
||||
//getters
|
||||
|
|
|
@ -27,6 +27,9 @@ messages.SHOULD_BE_MORE_THAN_TWO_DAYS = (duration, neededHours, neededMinutes) =
|
|||
Please add ${neededHours} hours and ${neededMinutes} minutes in order to set correct end time
|
||||
`;
|
||||
}
|
||||
messages.SHOULD_BE_LESS_OR_EQUAL_14_DAYS = (duration) => {
|
||||
return `Ballot end time should not be more than 14 days from now in UTC time. Current duration is ${duration} hours.`;
|
||||
}
|
||||
messages.FAILED_TX = `Your transaction was failed. Please make sure you set correct parameters for ballot creation.
|
||||
Make sure you don't have Transaction Error. Exception thrown in contract code message in metamask before you sign it.`
|
||||
messages.DESCRIPTION_IS_EMPTY = "Description cannot be empty";
|
||||
|
|
|
@ -4,11 +4,13 @@ class CommonStore {
|
|||
@observable loading;
|
||||
@observable rootPath;
|
||||
@observable isActiveFilter;
|
||||
@observable isToFinalizeFilter;
|
||||
@observable searchTerm;
|
||||
|
||||
constructor() {
|
||||
this.loading = false;
|
||||
this.isActiveFilter = false;
|
||||
this.isToFinalizeFilter = false;
|
||||
this.rootPath = '/poa-dapps-voting'
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue