* remove filtering on actions tab * remove unused balances on actions * remove unused balances on actions * only show stash * show stashed including validators and nominators * some buttons * new stake button * bond edit init * BondEdit button * combined session and validating button * remove comments * remove css hack * phrasing * validator prefs * can edit validator prefs * fix validatorPrefs undifined and nits * validate unstakeThreshold (<11) * with setting button noautoclose * fix nominee styling * change session and process feeling * lint * change nominees without defaultValue * display and change reward destination * change controller * add balances on bond and unbond * available balance, setting button right, nameOrAddress * back to the old flow with set session key, cleanup logs * balance off on chrome * fix comments + a design hickup on chrome * fix conflicts * nits * Various small UI fixes * Types for getAddress defaults * use name * type props for Row * lint
65 lines
1.4 KiB
TypeScript
65 lines
1.4 KiB
TypeScript
// Copyright 2017-2019 @polkadot/ui-staking authors & contributors
|
|
// This software may be modified and distributed under the terms
|
|
// of the Apache-2.0 license. See the LICENSE file for details.
|
|
|
|
import { I18nProps } from '@polkadot/ui-app/types';
|
|
|
|
import BN from 'bn.js';
|
|
import React from 'react';
|
|
import { Icon } from '@polkadot/ui-app';
|
|
|
|
import translate from '../../translate';
|
|
|
|
type Props = I18nProps & {
|
|
unstakeThreshold: BN | undefined,
|
|
onError: (error: string | null) => void
|
|
};
|
|
|
|
type State = {
|
|
error: string | null
|
|
};
|
|
|
|
class InputValidationUnstakeThreshold extends React.PureComponent<Props, State> {
|
|
state: State = {
|
|
error: null
|
|
};
|
|
|
|
static getDerivedStateFromProps ({ onError, t, unstakeThreshold }: Props, prevState: State): State | null {
|
|
let error = null;
|
|
|
|
if (!unstakeThreshold) {
|
|
return null;
|
|
}
|
|
|
|
if (unstakeThreshold.ltn(0)) {
|
|
error = t('The Threshold must be a positive number');
|
|
} else if (unstakeThreshold.gtn(10)) {
|
|
error = t('The Threshold must lower than 11');
|
|
}
|
|
|
|
if (error === prevState.error || !unstakeThreshold) {
|
|
return null;
|
|
}
|
|
|
|
onError(error);
|
|
|
|
return { error };
|
|
}
|
|
|
|
render () {
|
|
const { error } = this.state;
|
|
|
|
if (!error) {
|
|
return null;
|
|
}
|
|
|
|
return (
|
|
<article className='warning'>
|
|
<div><Icon name='warning sign' />{error}</div>
|
|
</article>
|
|
);
|
|
}
|
|
}
|
|
|
|
export default translate(InputValidationUnstakeThreshold);
|