fix(ui): revert-to-published button showing on new drafts (#13897)
### What? Hide the "**Revert to published**" button when creating a new draft that has never been published. ### Why? Previously, the button was visible on new drafts, which was confusing because there was no published version to revert to. ### How? Updated the revert button condition to also require `hasPublishedDoc`.
This commit is contained in:
@@ -198,27 +198,29 @@ export const Status: React.FC = () => {
|
|||||||
/>
|
/>
|
||||||
</React.Fragment>
|
</React.Fragment>
|
||||||
)}
|
)}
|
||||||
{((!isTrashed && canUpdate && statusToRender === 'changed') ||
|
{!isTrashed &&
|
||||||
statusToRender === 'draft') && (
|
canUpdate &&
|
||||||
<React.Fragment>
|
hasPublishedDoc &&
|
||||||
—
|
(statusToRender === 'changed' || statusToRender === 'draft') && (
|
||||||
<Button
|
<React.Fragment>
|
||||||
buttonStyle="none"
|
—
|
||||||
className={`${baseClass}__action`}
|
<Button
|
||||||
id="action-revert-to-published"
|
buttonStyle="none"
|
||||||
onClick={() => toggleModal(revertModalSlug)}
|
className={`${baseClass}__action`}
|
||||||
>
|
id="action-revert-to-published"
|
||||||
{t('version:revertToPublished')}
|
onClick={() => toggleModal(revertModalSlug)}
|
||||||
</Button>
|
>
|
||||||
<ConfirmationModal
|
{t('version:revertToPublished')}
|
||||||
body={t('version:aboutToRevertToPublished')}
|
</Button>
|
||||||
confirmingLabel={t('version:reverting')}
|
<ConfirmationModal
|
||||||
heading={t('version:confirmRevertToSaved')}
|
body={t('version:aboutToRevertToPublished')}
|
||||||
modalSlug={revertModalSlug}
|
confirmingLabel={t('version:reverting')}
|
||||||
onConfirm={() => performAction('revert')}
|
heading={t('version:confirmRevertToSaved')}
|
||||||
/>
|
modalSlug={revertModalSlug}
|
||||||
</React.Fragment>
|
onConfirm={() => performAction('revert')}
|
||||||
)}
|
/>
|
||||||
|
</React.Fragment>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user