From e8a7f6aec973290efbab5e0f3a6922ac3c220639 Mon Sep 17 00:00:00 2001 From: Rish Date: Wed, 3 Jun 2020 10:50:14 +0530 Subject: [PATCH] Updated save state handling for button closes https://github.com/TryGhost/members.js/issues/34 - Updates save state handling for button to show intermediary Saved state before resetting - Updates labels based on action running state --- ghost/portal/src/components/ParentContainer.js | 10 ++++++++++ .../portal/src/components/pages/AccountProfilePage.js | 8 +++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/ghost/portal/src/components/ParentContainer.js b/ghost/portal/src/components/ParentContainer.js index 938b533e6a..8371fcabc2 100644 --- a/ghost/portal/src/components/ParentContainer.js +++ b/ghost/portal/src/components/ParentContainer.js @@ -203,10 +203,20 @@ export default class ParentContainer extends React.Component { }); } } + setTimeout(() => { + this.setState({ + action: '' + }); + }, 5000); } catch (e) { this.setState({ action: `${action}:failed` }); + setTimeout(() => { + this.setState({ + action: '' + }); + }, 5000); } } diff --git a/ghost/portal/src/components/pages/AccountProfilePage.js b/ghost/portal/src/components/pages/AccountProfilePage.js index 35ca815886..40eebf1d60 100644 --- a/ghost/portal/src/components/pages/AccountProfilePage.js +++ b/ghost/portal/src/components/pages/AccountProfilePage.js @@ -38,7 +38,13 @@ export default class AccountProfilePage extends React.Component { renderSaveButton() { const isRunning = (this.context.action === 'updateMember:running'); - const label = isRunning ? 'Saving' : 'Save'; + const isSaved = (this.context.action === 'updateMember:success'); + let label = 'Save'; + if (isRunning) { + label = 'Saving'; + } else if (isSaved) { + label = 'Saved'; + } const disabled = isRunning ? true : false; return (