Skip to content

Commit 5315a15

Browse files
committed
fix: change content of save button after saving
1 parent fab452e commit 5315a15

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

src/welcome/admin.js

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -408,11 +408,12 @@ const Sidenav = ( {
408408
currentSearch,
409409
filteredSearchTree,
410410
isSaving,
411+
isRecentlySaved,
411412
hasV2Tab,
412413
} ) => {
413414
const saveButtonClasses = classnames( [
414415
's-save-changes',
415-
{ 's-button-has-unsaved-changes': hasUnsavedChanges },
416+
{ 's-button-has-unsaved-changes': hasUnsavedChanges && ! isRecentlySaved },
416417
] )
417418

418419
return (
@@ -456,8 +457,15 @@ const Sidenav = ( {
456457
<button
457458
className={ saveButtonClasses }
458459
onClick={ handleSettingsSave }
460+
disabled={ isRecentlySaved }
459461
>
460-
{ isSaving ? <Spinner /> : __( 'Save Changes', i18n ) }
462+
{ isSaving ? (
463+
<Spinner />
464+
) : isRecentlySaved ? (
465+
__( 'Saved Succesfully!', i18n )
466+
) : (
467+
__( 'Save Changes', i18n )
468+
) }
461469
</button>
462470
</div>
463471
</>
@@ -493,6 +501,7 @@ const Settings = () => {
493501
const [ currentTab, setCurrentTab ] = useState( 'editor-settings' )
494502
const [ currentSearch, setCurrentSearch ] = useState( '' )
495503
const [ isSaving, setIsSaving ] = useState( false )
504+
const [ isRecentlySaved, setIsRecentlySaved ] = useState( false )
496505
const [ hasV2Tab, setHasV2Tab ] = useState( false )
497506

498507
const hasV2Compatibility = currentSettings => {
@@ -511,12 +520,16 @@ const Settings = () => {
511520
return
512521
}
513522
setIsSaving( true )
523+
setIsRecentlySaved( true )
514524
const model = new models.Settings( unsavedChanges )
515525
model.save().then( () => {
516526
// Add a little more time for the spinner for better feedback
517527
setTimeout( () => {
518528
setIsSaving( false )
519529
}, 500 )
530+
setTimeout( () => {
531+
setIsRecentlySaved( false )
532+
}, 1500 )
520533
} )
521534
setUnsavedChanges( {} )
522535
}, [ unsavedChanges, settings ] )
@@ -591,6 +604,7 @@ const Settings = () => {
591604
currentSearch={ currentSearch }
592605
filteredSearchTree={ filteredSearchTree }
593606
isSaving={ isSaving }
607+
isRecentlySaved={ isRecentlySaved }
594608
hasV2Tab={ hasV2Tab }
595609
/>
596610
<article className="s-box" id={ currentTab }>

0 commit comments

Comments
 (0)