Skip to content

Commit 82d98ab

Browse files
authored
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`.
1 parent 66f5d14 commit 82d98ab

File tree

1 file changed

+23
-21
lines changed

1 file changed

+23
-21
lines changed

packages/ui/src/elements/Status/index.tsx

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -198,27 +198,29 @@ export const Status: React.FC = () => {
198198
/>
199199
</React.Fragment>
200200
)}
201-
{((!isTrashed && canUpdate && statusToRender === 'changed') ||
202-
statusToRender === 'draft') && (
203-
<React.Fragment>
204-
&nbsp;&mdash;&nbsp;
205-
<Button
206-
buttonStyle="none"
207-
className={`${baseClass}__action`}
208-
id="action-revert-to-published"
209-
onClick={() => toggleModal(revertModalSlug)}
210-
>
211-
{t('version:revertToPublished')}
212-
</Button>
213-
<ConfirmationModal
214-
body={t('version:aboutToRevertToPublished')}
215-
confirmingLabel={t('version:reverting')}
216-
heading={t('version:confirmRevertToSaved')}
217-
modalSlug={revertModalSlug}
218-
onConfirm={() => performAction('revert')}
219-
/>
220-
</React.Fragment>
221-
)}
201+
{!isTrashed &&
202+
canUpdate &&
203+
hasPublishedDoc &&
204+
(statusToRender === 'changed' || statusToRender === 'draft') && (
205+
<React.Fragment>
206+
&nbsp;&mdash;&nbsp;
207+
<Button
208+
buttonStyle="none"
209+
className={`${baseClass}__action`}
210+
id="action-revert-to-published"
211+
onClick={() => toggleModal(revertModalSlug)}
212+
>
213+
{t('version:revertToPublished')}
214+
</Button>
215+
<ConfirmationModal
216+
body={t('version:aboutToRevertToPublished')}
217+
confirmingLabel={t('version:reverting')}
218+
heading={t('version:confirmRevertToSaved')}
219+
modalSlug={revertModalSlug}
220+
onConfirm={() => performAction('revert')}
221+
/>
222+
</React.Fragment>
223+
)}
222224
</div>
223225
</div>
224226
)

0 commit comments

Comments
 (0)