Skip to content

Commit

Permalink
add dynamic button based on the next state to be saved
Browse files Browse the repository at this point in the history
  • Loading branch information
marekhrabe committed Jul 25, 2019
1 parent 03227a6 commit 8320d22
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { withSelect } from '@wordpress/data';
*/
import BaseOption from './base';

export function CustomFieldsConfirmation() {
export function CustomFieldsConfirmation( { nextState } ) {
const [ isReloading, setIsReloading ] = useState( false );

return (
Expand All @@ -29,7 +29,7 @@ export function CustomFieldsConfirmation() {
document.getElementById( 'toggle-custom-fields-form' ).submit();
} }
>
{ __( 'Save & Reload' ) }
{ nextState === true ? __( 'Enable & Reload' ) : __( 'Disable & Reload' ) }
</Button>
</>
);
Expand All @@ -44,7 +44,7 @@ export function EnableCustomFieldsOption( { label, areCustomFieldsEnabled } ) {
isChecked={ isChecked }
onChange={ setIsChecked }
>
{ isChecked !== areCustomFieldsEnabled && <CustomFieldsConfirmation /> }
{ isChecked !== areCustomFieldsEnabled && <CustomFieldsConfirmation nextState={ isChecked } /> }
</BaseOption>
);
}
Expand Down

0 comments on commit 8320d22

Please sign in to comment.