diff --git a/packages/netlify-cms-core/src/components/Editor/EditorToolbar.js b/packages/netlify-cms-core/src/components/Editor/EditorToolbar.js index 3e04ce52..f6c0de12 100644 --- a/packages/netlify-cms-core/src/components/Editor/EditorToolbar.js +++ b/packages/netlify-cms-core/src/components/Editor/EditorToolbar.js @@ -301,14 +301,21 @@ export class EditorToolbar extends React.Component { } } - renderSimpleSaveControls = () => { - const { showDelete, onDelete, t } = this.props; + renderSimpleControls = () => { + const { collection, hasChanged, isNewEntry, showDelete, onDelete, t } = this.props; + const canCreate = collection.get('create'); + return ( -
- {showDelete ? ( - {t('editor.editorToolbar.deleteEntry')} - ) : null} -
+ <> + {!isNewEntry && !hasChanged + ? this.renderExistingEntrySimplePublishControls({ canCreate }) + : this.renderNewEntrySimplePublishControls({ canCreate })} +
+ {showDelete ? ( + {t('editor.editorToolbar.deleteEntry')} + ) : null} +
+ ); }; @@ -545,22 +552,15 @@ export class EditorToolbar extends React.Component { ); }; - renderSimplePublishControls = () => { - const { collection, hasChanged, isNewEntry, t } = this.props; + renderSimpleDeployPreviewControls = () => { + const { hasChanged, isNewEntry, t } = this.props; - const canCreate = collection.get('create'); if (!isNewEntry && !hasChanged) { - return ( - <> - {this.renderDeployPreviewControls(t('editor.editorToolbar.deployButtonLabel'))} - {this.renderExistingEntrySimplePublishControls({ canCreate })} - - ); + return this.renderDeployPreviewControls(t('editor.editorToolbar.deployButtonLabel')); } - return this.renderNewEntrySimplePublishControls({ canCreate }); }; - renderWorkflowSaveControls = () => { + renderWorkflowControls = () => { const { onPersist, onDelete, @@ -573,9 +573,15 @@ export class EditorToolbar extends React.Component { isDeleting, isNewEntry, isModification, + currentStatus, + collection, t, } = this.props; + const canCreate = collection.get('create'); + const canPublish = collection.get('publish') && !useOpenAuthoring; + const canDelete = collection.get('delete', true); + const deleteLabel = (hasUnpublishedChanges && isModification && @@ -593,6 +599,13 @@ export class EditorToolbar extends React.Component { > {isPersisting ? t('editor.editorToolbar.saving') : t('editor.editorToolbar.save')} , + currentStatus + ? [ + this.renderWorkflowStatusControls(), + this.renderNewEntryWorkflowPublishControls({ canCreate, canPublish }), + ] + : !isNewEntry && + this.renderExistingEntryWorkflowPublishControls({ canCreate, canPublish, canDelete }), (!showDelete || useOpenAuthoring) && !hasUnpublishedChanges && !isModification ? null : ( { - const { collection, currentStatus, isNewEntry, useOpenAuthoring, t } = this.props; - - const canCreate = collection.get('create'); - const canPublish = collection.get('publish') && !useOpenAuthoring; - const canDelete = collection.get('delete', true); + renderWorkflowDeployPreviewControls = () => { + const { currentStatus, isNewEntry, t } = this.props; if (currentStatus) { - return ( - <> - {this.renderDeployPreviewControls(t('editor.editorToolbar.deployPreviewButtonLabel'))} - {this.renderWorkflowStatusControls()} - {this.renderNewEntryWorkflowPublishControls({ canCreate, canPublish })} - - ); + return this.renderDeployPreviewControls(t('editor.editorToolbar.deployPreviewButtonLabel')); } /** * Publish control for published workflow entry. */ if (!isNewEntry) { - return ( - <> - {this.renderDeployPreviewControls(t('editor.editorToolbar.deployButtonLabel'))} - {this.renderExistingEntryWorkflowPublishControls({ canCreate, canPublish, canDelete })} - - ); + return this.renderDeployPreviewControls(t('editor.editorToolbar.deployButtonLabel')); } }; @@ -665,12 +663,12 @@ export class EditorToolbar extends React.Component { - {hasWorkflow ? this.renderWorkflowSaveControls() : this.renderSimpleSaveControls()} + {hasWorkflow ? this.renderWorkflowControls() : this.renderSimpleControls()} {hasWorkflow - ? this.renderWorkflowPublishControls() - : this.renderSimplePublishControls()} + ? this.renderWorkflowDeployPreviewControls() + : this.renderSimpleDeployPreviewControls()} diff --git a/packages/netlify-cms-core/src/components/Editor/__tests__/__snapshots__/EditorToolbar.spec.js.snap b/packages/netlify-cms-core/src/components/Editor/__tests__/__snapshots__/EditorToolbar.spec.js.snap index 9e073670..feaca062 100644 --- a/packages/netlify-cms-core/src/components/Editor/__tests__/__snapshots__/EditorToolbar.spec.js.snap +++ b/packages/netlify-cms-core/src/components/Editor/__tests__/__snapshots__/EditorToolbar.spec.js.snap @@ -64,7 +64,7 @@ exports[`EditorToolbar should render normal save button 1`] = ` padding: 0 10px; } -.emotion-8 { +.emotion-13 { display: -webkit-box; display: -webkit-flex; display: -ms-flexbox; @@ -75,7 +75,7 @@ exports[`EditorToolbar should render normal save button 1`] = ` align-items: center; } -.emotion-6 { +.emotion-11 { border: 0; border-radius: 5px; cursor: pointer; @@ -95,7 +95,7 @@ exports[`EditorToolbar should render normal save button 1`] = ` } @media (max-width:1200px) { - .emotion-6 { + .emotion-11 { padding: 0 10px; } } @@ -130,7 +130,7 @@ exports[`EditorToolbar should render normal save button 1`] = ` padding: 0 7px; } -.emotion-13 { +.emotion-9 { position: relative; font-size: 14px; -webkit-user-select: none; @@ -140,7 +140,7 @@ exports[`EditorToolbar should render normal save button 1`] = ` margin: 0 10px; } -.emotion-13 .ei6fm2r1 { +.emotion-9 .ei6fm2r1 { color: #17a2b8; } @@ -154,7 +154,7 @@ exports[`EditorToolbar should render normal save button 1`] = ` color: #ff003b; } -.emotion-10 { +.emotion-6 { border: 0; border-radius: 5px; cursor: pointer; @@ -174,7 +174,7 @@ exports[`EditorToolbar should render normal save button 1`] = ` background-color: #17a2b8; } -.emotion-10:after { +.emotion-6:after { color: #fff; width: 0; height: 0; @@ -191,7 +191,7 @@ exports[`EditorToolbar should render normal save button 1`] = ` } @media (max-width:1200px) { - .emotion-10 { + .emotion-6 { padding-left: 10px; } } @@ -200,7 +200,7 @@ exports[`EditorToolbar should render normal save button 1`] = ` class="emotion-21 emotion-22" >
-
- -
-
-
+
+ +
+
-
- -
-
-
+
+ +
+
+
@@ -744,13 +747,7 @@ exports[`EditorToolbar should render with default props 1`] = `
- -
+ />
- -
-
+
+
-
-
editor.editorToolbar.statusInfoTooltipDraft
+
- -
-
+
+
-
-
+
- -
-
+
+
-
-
editor.editorToolbar.statusInfoTooltipInReview
+