Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove space between buttons v3 #5729

Merged
merged 6 commits into from
Aug 27, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 32 additions & 31 deletions packages/netlify-cms-core/src/components/Editor/EditorToolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -302,13 +302,20 @@ export class EditorToolbar extends React.Component {
}

renderSimpleSaveControls = () => {
taineriley1 marked this conversation as resolved.
Show resolved Hide resolved
const { showDelete, onDelete, t } = this.props;
const { collection, hasChanged, isNewEntry, showDelete, onDelete, t } = this.props;
const canCreate = collection.get('create');

return (
<div>
{showDelete ? (
<DeleteButton onClick={onDelete}>{t('editor.editorToolbar.deleteEntry')}</DeleteButton>
) : null}
</div>
<>
{!isNewEntry && !hasChanged
? this.renderExistingEntrySimplePublishControls({ canCreate })
: this.renderNewEntrySimplePublishControls({ canCreate })}
<div>
{showDelete ? (
<DeleteButton onClick={onDelete}>{t('editor.editorToolbar.deleteEntry')}</DeleteButton>
) : null}
</div>
</>
);
};

Expand Down Expand Up @@ -546,18 +553,11 @@ export class EditorToolbar extends React.Component {
};

renderSimplePublishControls = () => {
taineriley1 marked this conversation as resolved.
Show resolved Hide resolved
const { collection, hasChanged, isNewEntry, t } = this.props;
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'))}</>;
taineriley1 marked this conversation as resolved.
Show resolved Hide resolved
}
return this.renderNewEntrySimplePublishControls({ canCreate });
};

renderWorkflowSaveControls = () => {
taineriley1 marked this conversation as resolved.
Show resolved Hide resolved
Expand All @@ -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 &&
Expand All @@ -593,6 +599,14 @@ export class EditorToolbar extends React.Component {
>
{isPersisting ? t('editor.editorToolbar.saving') : t('editor.editorToolbar.save')}
</SaveButton>,
currentStatus
? [
this.renderWorkflowStatusControls(),
this.renderNewEntryWorkflowPublishControls({ canCreate, canPublish }),
]
: !isNewEntry
? this.renderExistingEntryWorkflowPublishControls({ canCreate, canPublish, canDelete })
taineriley1 marked this conversation as resolved.
Show resolved Hide resolved
: '',
(!showDelete || useOpenAuthoring) && !hasUnpublishedChanges && !isModification ? null : (
<DeleteButton
key="delete-button"
Expand All @@ -605,32 +619,19 @@ export class EditorToolbar extends React.Component {
};

renderWorkflowPublishControls = () => {
taineriley1 marked this conversation as resolved.
Show resolved Hide resolved
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);
const { currentStatus, isNewEntry, t } = this.props;

if (currentStatus) {
return (
<>
{this.renderDeployPreviewControls(t('editor.editorToolbar.deployPreviewButtonLabel'))}
{this.renderWorkflowStatusControls()}
{this.renderNewEntryWorkflowPublishControls({ canCreate, canPublish })}
</>
<>{this.renderDeployPreviewControls(t('editor.editorToolbar.deployPreviewButtonLabel'))}</>
taineriley1 marked this conversation as resolved.
Show resolved Hide resolved
);
}

/**
* 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'))}</>;
taineriley1 marked this conversation as resolved.
Show resolved Hide resolved
}
};

Expand Down
Loading