Skip to content
This repository has been archived by the owner on Apr 15, 2019. It is now read-only.

Do not show delegate registration form for a delegate - Closes #946 #982

Merged
merged 2 commits into from
Nov 20, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions i18n/locales/de/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@
"You can vote for up to {{count}} delegates in total.": "Du kannst insgesamt für {{count}} Delegierte stimmen.",
"You can vote for up to {{count}} delegates in total._plural": "Bis zu {{count}} Delegierte können insgesamt von einem Konto gewählt werden.",
"You have not forged any blocks yet": "Du hast noch keine Blöcke geforged",
"You have already registered as a delegate.": "Du hast bereits als Delegierter registriert.",
"You need to become a delegate to start forging. If you already registered to become a delegate, your registration hasn't been processed, yet.": "Um Blöcke forgen (erstellen) zu können, musst du Delegierter werden. Wenn du dich schon als Delegierter registriert hast, wurde deine Registrierung noch nicht verarbeitet.",
"You've received {{value}} LSK.": "Du hast {{value}} LSK erhalten.",
"Your transaction of {{amount}} LSK to {{recipientAddress}} was accepted and will be processed in a few seconds.": "Deine Transaktion von {{amount}} LSK zu {{recipientAddress}} wurde akzeptiert und wird in wenigen Sekunden verarbeitet.",
Expand Down
1 change: 1 addition & 0 deletions i18n/locales/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@
"You can select up to {{count}} delegates in one voting turn._plural": "You can select up to {{count}} delegates in one voting turn.",
"You can vote for up to {{count}} delegates in total.": "You can vote for up to {{count}} delegates in total.",
"You can vote for up to {{count}} delegates in total._plural": "You can vote for up to {{count}} delegates in total.",
"You have already registered as a delegate.": "You have already registered as a delegate.",
"You have not forged any blocks yet": "You have not forged any blocks yet",
"You need to become a delegate to start forging. If you already registered to become a delegate, your registration hasn't been processed, yet.": "You need to become a delegate to start forging. If you already registered to become a delegate, your registration hasn't been processed, yet.",
"You've received {{value}} LSK.": "You've received {{value}} LSK.",
Expand Down
11 changes: 11 additions & 0 deletions src/components/registerDelegate/registerDelegate.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class RegisterDelegate extends React.Component {
...authStatePrefill(),
};
}

componentDidMount() {
const newState = {
name: {
Expand All @@ -40,6 +41,16 @@ class RegisterDelegate extends React.Component {
}

render() {
if (this.props.account.isDelegate) {
return (
<div>
<InfoParagraph>
{this.props.t('You have already registered as a delegate.')}
</InfoParagraph>
</div>
);
}

return (
<div>
<form onSubmit={this.register.bind(this)}>
Expand Down
9 changes: 6 additions & 3 deletions src/components/registerDelegate/registerDelegate.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,12 @@ describe('RegisterDelegate', () => {
</Provider>);
});

it('does not allow register as delegate for a delegate account', () => {
wrapper.find('.username input').simulate('change', { target: { value: 'sample_username' } });
expect(wrapper.find('.primary-button button').props().disabled).to.be.equal(true);
it('renders an InfoParagraph component', () => {
expect(wrapper.find('InfoParagraph')).to.have.length(1);
});

it('does not render the delegate registration form for registering', () => {
expect(wrapper.find('form')).to.have.length(0);
});
});
});