Wired save button state for portal settings modal

refs https://github.com/TryGhost/Product/issues/3545

- adds dynamic loading state for portal modal save button
This commit is contained in:
Rishabh 2023-07-07 16:18:00 +05:30 committed by Rishabh Garg
parent ad0e52ac39
commit 26c2590923

View File

@ -63,6 +63,7 @@ const PortalModal: React.FC = () => {
const modal = useModal();
const [selectedPreviewTab, setSelectedPreviewTab] = useState('signup');
const {settings, saveSettings, siteData} = useContext(SettingsContext);
const {data: tiers, update: updateTiers} = useTiers();
@ -143,11 +144,17 @@ const PortalModal: React.FC = () => {
{id: 'account', title: 'Account page'},
{id: 'links', title: 'Links'}
];
let okLabel = 'Save & close';
if (saveState === 'saving') {
okLabel = 'Saving...';
} else if (saveState === 'saved') {
okLabel = 'Saved';
}
return <PreviewModalContent
deviceSelector={selectedPreviewTab !== 'links'}
dirty={saveState === 'unsaved'}
okLabel='Save & close'
okLabel={okLabel}
preview={preview}
previewBgColor={selectedPreviewTab === 'links' ? 'white' : 'grey'}
previewToolbarTabs={previewTabs}