fix: Remove Unpublish UI button if collection has a delete: false. (#3887) (#5314)

This commit is contained in:
Abdallah Abis 2021-04-29 09:48:06 +00:00 committed by GitHub
parent 85550eba9e
commit 724d172cf0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -378,7 +378,7 @@ class EditorToolbar extends React.Component {
);
};
renderExistingEntryWorkflowPublishControls = ({ canCreate, canPublish }) => {
renderExistingEntryWorkflowPublishControls = ({ canCreate, canPublish, canDelete }) => {
const { unPublish, onDuplicate, isPersisting, t } = this.props;
return canPublish || canCreate ? (
@ -393,7 +393,7 @@ class EditorToolbar extends React.Component {
</PublishedToolbarButton>
)}
>
{canPublish && (
{canDelete && canPublish && (
<DropdownItem
label={t('editor.editorToolbar.unpublish')}
icon="arrow"
@ -537,6 +537,7 @@ class EditorToolbar extends React.Component {
const canCreate = collection.get('create');
const canPublish = collection.get('publish') && !useOpenAuthoring;
const canDelete = collection.get('delete', true);
if (currentStatus) {
return (
@ -555,7 +556,7 @@ class EditorToolbar extends React.Component {
return (
<>
{this.renderDeployPreviewControls(t('editor.editorToolbar.deployButtonLabel'))}
{this.renderExistingEntryWorkflowPublishControls({ canCreate, canPublish })}
{this.renderExistingEntryWorkflowPublishControls({ canCreate, canPublish, canDelete })}
</>
);
}