feat: show current status in status button (#5574)

This commit is contained in:
pcanof
2021-07-07 02:20:14 -06:00
committed by GitHub
parent 647b97438d
commit fbc3728294
33 changed files with 84 additions and 57 deletions

View File

@ -358,18 +358,23 @@ export class EditorToolbar extends React.Component {
renderWorkflowStatusControls = () => {
const { isUpdatingStatus, onChangeStatus, currentStatus, t, useOpenAuthoring } = this.props;
const statusToTranslation = {
[status.get('DRAFT')]: t('editor.editorToolbar.draft'),
[status.get('PENDING_REVIEW')]: t('editor.editorToolbar.inReview'),
[status.get('PENDING_PUBLISH')]: t('editor.editorToolbar.ready'),
};
const buttonText = isUpdatingStatus
? t('editor.editorToolbar.updating')
: t('editor.editorToolbar.status', { status: statusToTranslation[currentStatus] });
return (
<>
<ToolbarDropdown
dropdownTopOverlap="40px"
dropdownWidth="120px"
renderButton={() => (
<StatusButton>
{isUpdatingStatus
? t('editor.editorToolbar.updating')
: t('editor.editorToolbar.setStatus')}
</StatusButton>
)}
renderButton={() => <StatusButton>{buttonText}</StatusButton>}
>
<StatusDropdownItem
label={t('editor.editorToolbar.draft')}

View File

@ -179,7 +179,7 @@ exports[`EditorToolbar should render with default props 1`] = `
class="emotion-18 emotion-19"
>
<mock-link
classname="css-1e27f5b-ToolbarSectionBackLink-toolbarSection evqrzhe8"
classname="css-i3q6wb-ToolbarSectionBackLink-toolbarSection evqrzhe8"
to=""
>
<div
@ -469,7 +469,7 @@ exports[`EditorToolbar should render with status=draft,useOpenAuthoring=false 1`
class="emotion-23 emotion-24"
>
<mock-link
classname="css-1e27f5b-ToolbarSectionBackLink-toolbarSection evqrzhe8"
classname="css-i3q6wb-ToolbarSectionBackLink-toolbarSection evqrzhe8"
to=""
>
<div
@ -520,7 +520,7 @@ exports[`EditorToolbar should render with status=draft,useOpenAuthoring=false 1`
role="button"
tabindex="0"
>
editor.editorToolbar.setStatus
editor.editorToolbar.status
</span>
</div>
</div>
@ -803,7 +803,7 @@ exports[`EditorToolbar should render with status=draft,useOpenAuthoring=true 1`]
class="emotion-30 emotion-31"
>
<mock-link
classname="css-1e27f5b-ToolbarSectionBackLink-toolbarSection evqrzhe8"
classname="css-i3q6wb-ToolbarSectionBackLink-toolbarSection evqrzhe8"
to=""
>
<div
@ -849,7 +849,7 @@ exports[`EditorToolbar should render with status=draft,useOpenAuthoring=true 1`]
role="button"
tabindex="0"
>
editor.editorToolbar.setStatus
editor.editorToolbar.status
</span>
</div>
<div
@ -1131,7 +1131,7 @@ exports[`EditorToolbar should render with status=pending_publish,useOpenAuthorin
class="emotion-23 emotion-24"
>
<mock-link
classname="css-1e27f5b-ToolbarSectionBackLink-toolbarSection evqrzhe8"
classname="css-i3q6wb-ToolbarSectionBackLink-toolbarSection evqrzhe8"
to=""
>
<div
@ -1182,7 +1182,7 @@ exports[`EditorToolbar should render with status=pending_publish,useOpenAuthorin
role="button"
tabindex="0"
>
editor.editorToolbar.setStatus
editor.editorToolbar.status
</span>
</div>
</div>
@ -1447,7 +1447,7 @@ exports[`EditorToolbar should render with status=pending_publish,useOpenAuthorin
class="emotion-28 emotion-29"
>
<mock-link
classname="css-1e27f5b-ToolbarSectionBackLink-toolbarSection evqrzhe8"
classname="css-i3q6wb-ToolbarSectionBackLink-toolbarSection evqrzhe8"
to=""
>
<div
@ -1493,7 +1493,7 @@ exports[`EditorToolbar should render with status=pending_publish,useOpenAuthorin
role="button"
tabindex="0"
>
editor.editorToolbar.setStatus
editor.editorToolbar.status
</span>
</div>
<div
@ -1770,7 +1770,7 @@ exports[`EditorToolbar should render with status=pending_review,useOpenAuthoring
class="emotion-23 emotion-24"
>
<mock-link
classname="css-1e27f5b-ToolbarSectionBackLink-toolbarSection evqrzhe8"
classname="css-i3q6wb-ToolbarSectionBackLink-toolbarSection evqrzhe8"
to=""
>
<div
@ -1821,7 +1821,7 @@ exports[`EditorToolbar should render with status=pending_review,useOpenAuthoring
role="button"
tabindex="0"
>
editor.editorToolbar.setStatus
editor.editorToolbar.status
</span>
</div>
</div>
@ -2104,7 +2104,7 @@ exports[`EditorToolbar should render with status=pending_review,useOpenAuthoring
class="emotion-30 emotion-31"
>
<mock-link
classname="css-1e27f5b-ToolbarSectionBackLink-toolbarSection evqrzhe8"
classname="css-i3q6wb-ToolbarSectionBackLink-toolbarSection evqrzhe8"
to=""
>
<div
@ -2150,7 +2150,7 @@ exports[`EditorToolbar should render with status=pending_review,useOpenAuthoring
role="button"
tabindex="0"
>
editor.editorToolbar.setStatus
editor.editorToolbar.status
</span>
</div>
<div
@ -2375,7 +2375,7 @@ exports[`EditorToolbar should render with workflow controls hasUnpublishedChange
class="emotion-18 emotion-19"
>
<mock-link
classname="css-1e27f5b-ToolbarSectionBackLink-toolbarSection evqrzhe8"
classname="css-i3q6wb-ToolbarSectionBackLink-toolbarSection evqrzhe8"
to=""
>
<div
@ -2580,7 +2580,7 @@ exports[`EditorToolbar should render with workflow controls hasUnpublishedChange
class="emotion-16 emotion-17"
>
<mock-link
classname="css-1e27f5b-ToolbarSectionBackLink-toolbarSection evqrzhe8"
classname="css-i3q6wb-ToolbarSectionBackLink-toolbarSection evqrzhe8"
to=""
>
<div
@ -2805,7 +2805,7 @@ exports[`EditorToolbar should render with workflow controls hasUnpublishedChange
class="emotion-18 emotion-19"
>
<mock-link
classname="css-1e27f5b-ToolbarSectionBackLink-toolbarSection evqrzhe8"
classname="css-i3q6wb-ToolbarSectionBackLink-toolbarSection evqrzhe8"
to=""
>
<div
@ -3035,7 +3035,7 @@ exports[`EditorToolbar should render with workflow controls hasUnpublishedChange
class="emotion-18 emotion-19"
>
<mock-link
classname="css-1e27f5b-ToolbarSectionBackLink-toolbarSection evqrzhe8"
classname="css-i3q6wb-ToolbarSectionBackLink-toolbarSection evqrzhe8"
to=""
>
<div
@ -3265,7 +3265,7 @@ exports[`EditorToolbar should render with workflow controls hasUnpublishedChange
class="emotion-18 emotion-19"
>
<mock-link
classname="css-1e27f5b-ToolbarSectionBackLink-toolbarSection evqrzhe8"
classname="css-i3q6wb-ToolbarSectionBackLink-toolbarSection evqrzhe8"
to=""
>
<div
@ -3495,7 +3495,7 @@ exports[`EditorToolbar should render with workflow controls hasUnpublishedChange
class="emotion-18 emotion-19"
>
<mock-link
classname="css-1e27f5b-ToolbarSectionBackLink-toolbarSection evqrzhe8"
classname="css-i3q6wb-ToolbarSectionBackLink-toolbarSection evqrzhe8"
to=""
>
<div

View File

@ -24,6 +24,12 @@ import {
UNPUBLISHED_ENTRY_PERSIST_REQUEST,
UNPUBLISHED_ENTRY_PERSIST_SUCCESS,
UNPUBLISHED_ENTRY_PERSIST_FAILURE,
UNPUBLISHED_ENTRY_STATUS_CHANGE_REQUEST,
UNPUBLISHED_ENTRY_STATUS_CHANGE_SUCCESS,
UNPUBLISHED_ENTRY_STATUS_CHANGE_FAILURE,
UNPUBLISHED_ENTRY_PUBLISH_REQUEST,
UNPUBLISHED_ENTRY_PUBLISH_SUCCESS,
UNPUBLISHED_ENTRY_PUBLISH_FAILURE,
} from '../actions/editorialWorkflow';
import { selectFolderEntryExtension, selectHasMetaPath } from './collections';
import { getDataPath, duplicateI18nFields } from '../lib/i18n';
@ -136,6 +142,20 @@ function entryDraftReducer(state = Map(), action) {
return state.deleteIn(['entry', 'isPersisting']);
}
case UNPUBLISHED_ENTRY_STATUS_CHANGE_REQUEST:
return state.setIn(['entry', 'isUpdatingStatus'], true);
case UNPUBLISHED_ENTRY_STATUS_CHANGE_FAILURE:
case UNPUBLISHED_ENTRY_STATUS_CHANGE_SUCCESS:
return state.deleteIn(['entry', 'isUpdatingStatus']);
case UNPUBLISHED_ENTRY_PUBLISH_REQUEST:
return state.setIn(['entry', 'isPublishing'], true);
case UNPUBLISHED_ENTRY_PUBLISH_SUCCESS:
case UNPUBLISHED_ENTRY_PUBLISH_FAILURE:
return state.deleteIn(['entry', 'isPublishing']);
case ENTRY_PERSIST_SUCCESS:
case UNPUBLISHED_ENTRY_PERSIST_SUCCESS:
return state.withMutations(state => {