Skip to content

Commit

Permalink
Purchases: Fix button display issues on cancellation of Private Regis…
Browse files Browse the repository at this point in the history
…tration (Fixes #195)
  • Loading branch information
umurkontaci authored and scruffian committed Nov 26, 2015
1 parent e8f8661 commit 69b12b9
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
20 changes: 16 additions & 4 deletions client/me/purchases/cancel-private-registration/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ import { goToManagePurchase, isDataLoading, recordPageView } from '../utils';
const CancelPrivateRegistration = React.createClass( {
getInitialState() {
return {
disabled: false
disabled: false,
cancelling: false
};
},

Expand All @@ -33,14 +34,22 @@ const CancelPrivateRegistration = React.createClass( {
recordPageView( 'cancel_private_registration', this.props, nextProps );
},

cancel() {
cancel( event ) {
// We call blur on the cancel button to remove the blue outline that shows up when you click on the button
event.target.blur();

const { domain, id } = this.props.selectedPurchase.data;

this.setState( {
disabled: true
disabled: true,
cancelling: true
} );

cancelPrivateRegistration( id, canceledSuccessfully => {
this.setState( {
cancelling: false,
disabled: false
} );
if ( canceledSuccessfully ) {
page( paths.managePurchaseDestination( domain, id, 'canceled-private-registration' ) );
}
Expand Down Expand Up @@ -87,7 +96,10 @@ const CancelPrivateRegistration = React.createClass( {
onClick={ this.cancel }
className="cancel-private-registration__cancel-button"
disabled={ this.state.disabled }>
{ this.translate( 'Cancel Private Registration' ) }
{
this.state.cancelling
? this.translate( 'Processing…' )
: this.translate( 'Cancel Private Registration' ) }
</Button>
);
},
Expand Down
4 changes: 4 additions & 0 deletions client/me/purchases/cancel-private-registration/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,8 @@

.cancel-private-registration__cancel-button {
margin-top: 10px;

&[disabled] {
color: $gray;
}
}

0 comments on commit 69b12b9

Please sign in to comment.