Firm up on change controller (#3214)
This commit is contained in:
parent
1d25f97798
commit
65db25b254
@ -49,7 +49,7 @@ function ValidateController ({ accountId, controllerId, defaultController, onErr
|
||||
let newError: string | null = null;
|
||||
let isFatal = false;
|
||||
|
||||
if (bondedId) {
|
||||
if (bondedId && (controllerId !== accountId)) {
|
||||
isFatal = true;
|
||||
newError = t('A controller account should not map to another stash. This selected controller is a stash, controlled by {{bondedId}}', { replace: { bondedId } });
|
||||
} else if (stashId) {
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import React, { useState } from 'react';
|
||||
import React, { useCallback, useState } from 'react';
|
||||
import { InputAddress, Modal, TxButton } from '@polkadot/react-components';
|
||||
|
||||
import { useTranslation } from '../../translate';
|
||||
@ -16,9 +16,14 @@ interface Props {
|
||||
|
||||
function SetControllerAccount ({ defaultControllerId, onClose, stashId }: Props): React.ReactElement<Props> {
|
||||
const { t } = useTranslation();
|
||||
const [, setControllerError] = useState<string | null>(null);
|
||||
const [isFatal, setIsFatal] = useState(false);
|
||||
const [controllerId, setControllerId] = useState<string | null>(null);
|
||||
|
||||
const _setError = useCallback(
|
||||
(_: string | null, isFatal: boolean) => setIsFatal(isFatal),
|
||||
[]
|
||||
);
|
||||
|
||||
return (
|
||||
<Modal
|
||||
header={t<string>('Change controller account')}
|
||||
@ -51,7 +56,7 @@ function SetControllerAccount ({ defaultControllerId, onClose, stashId }: Props)
|
||||
accountId={stashId}
|
||||
controllerId={controllerId}
|
||||
defaultController={defaultControllerId}
|
||||
onError={setControllerError}
|
||||
onError={_setError}
|
||||
/>
|
||||
</Modal.Column>
|
||||
<Modal.Column>
|
||||
@ -63,7 +68,7 @@ function SetControllerAccount ({ defaultControllerId, onClose, stashId }: Props)
|
||||
<TxButton
|
||||
accountId={stashId}
|
||||
icon='sign-in-alt'
|
||||
isDisabled={!controllerId}
|
||||
isDisabled={!controllerId || isFatal}
|
||||
isPrimary
|
||||
label={t<string>('Set controller')}
|
||||
onStart={onClose}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user