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
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
33 changed files with 84 additions and 57 deletions

View File

@ -145,8 +145,10 @@ function deleteWorkflowEntry({ title }) {
assertNotification(notifications.deletedUnpublished);
}
const STATUS_BUTTON_TEXT = 'Status:';
function assertWorkflowStatusInEditor(status) {
cy.contains('[role="button"]', 'Set status').as('setStatusButton');
cy.contains('[role="button"]', STATUS_BUTTON_TEXT).as('setStatusButton');
cy.get('@setStatusButton')
.parent()
.within(() => {
@ -209,7 +211,7 @@ function assertWorkflowStatus({ title }, status) {
}
function updateWorkflowStatusInEditor(newStatus) {
selectDropdownItem('Set status', newStatus);
selectDropdownItem(STATUS_BUTTON_TEXT, newStatus);
assertNotification(notifications.updated);
}

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 => {

View File

@ -135,7 +135,7 @@ const bg = {
save: 'Запази',
deleting: 'Изтриване...',
updating: 'Актуализиране...',
setStatus: 'Задайте състояние',
status: 'Cъстояние: %{status}',
backCollection: 'Записване в %{collectionLabel} колекция',
unsavedChanges: 'Незапазени Промени',
changesSaved: 'Запазени промени',

View File

@ -134,7 +134,7 @@ const ca = {
save: 'Guardar',
deleting: 'Eliminant...',
updating: 'Actualizant...',
setStatus: 'Actualizar estat',
status: 'Estat: %{status}',
backCollection: ' Escrivint a la colecció %{collectionLabel}',
unsavedChanges: 'Canvis no guardats',
changesSaved: 'Canvis guardats',

View File

@ -134,7 +134,7 @@ const cs = {
save: 'Uložit',
deleting: 'Vymazávání…',
updating: 'Aktualizace…',
setStatus: 'Změnit status',
status: 'Status: %{status}',
backCollection: ' Píšete v kolekci %{collectionLabel}',
unsavedChanges: 'Neuložené změny',
changesSaved: 'Změny uloženy',

View File

@ -131,7 +131,7 @@ const da = {
save: 'Gem',
deleting: 'Sletter...',
updating: 'Updaterer...',
setStatus: 'Sæt status',
status: 'Status: %{status}',
backCollection: ' Skriver til %{collectionLabel} samlingen',
unsavedChanges: 'Ugemte ændringer',
changesSaved: 'Ændringer gemt',

View File

@ -126,7 +126,7 @@ const de = {
save: 'Speichern',
deleting: 'Löschen...',
updating: 'Aktualisieren...',
setStatus: 'Status setzen',
status: 'Status: %{status}',
backCollection: 'Zurück zu allen %{collectionLabel}',
unsavedChanges: 'Ungespeicherte Änderungen',
changesSaved: 'Änderungen gespeichert',

View File

@ -137,7 +137,7 @@ const en = {
'Entry is being reviewed, no further actions are required. However, you can still make additional changes while it is being reviewed.',
deleting: 'Deleting...',
updating: 'Updating...',
setStatus: 'Set status',
status: 'Status: %{status}',
backCollection: ' Writing in %{collectionLabel} collection',
unsavedChanges: 'Unsaved Changes',
changesSaved: 'Changes saved',

View File

@ -115,7 +115,7 @@ const es = {
save: 'Guardar',
deleting: 'Eliminando...',
updating: 'Actualizando...',
setStatus: 'Actualizar estado',
status: 'Estado: %{status}',
backCollection: ' Escribiendo en la colección %{collectionLabel}',
unsavedChanges: 'Cambios no guardados',
changesSaved: 'Cambios guardados',

View File

@ -136,7 +136,7 @@ const fr = {
save: 'Enregistrer',
deleting: 'Suppression...',
updating: 'Mise à jour...',
setStatus: 'Définir le statut',
status: 'Statut: %{status}',
backCollection: ' Écriture dans la collection %{collectionLabel}',
unsavedChanges: 'Modifications non enregistrées',
changesSaved: 'Modifications enregistrées',

View File

@ -101,7 +101,7 @@ const gr = {
save: 'Αποθήκευση',
deleting: 'Διαγραφή...',
updating: 'Ενημέρωση...',
setStatus: 'Ορισμός κατάστασης',
status: 'Κατάστασης: %{status}',
backCollection: ' Εγγραφή στη συλλογή %{collectionLabel}',
unsavedChanges: 'Μη αποθηκευμένες αλλαγές',
changesSaved: 'Αλλαγές που αποθηκεύτηκαν',

View File

@ -130,7 +130,7 @@ const hr = {
save: 'Spremi',
deleting: 'Brisanje...',
updating: 'Ažuriranje...',
setStatus: 'Postavi status',
status: 'Status: %{status}',
backCollection: 'Pisanje u %{collectionLabel} zbirci',
unsavedChanges: 'Nespremljene promjene',
changesSaved: 'Promjene spremljene',

View File

@ -85,7 +85,7 @@ const hu = {
save: 'Mentés',
deleting: 'Törlés...',
updating: 'Frissítés...',
setStatus: 'Állapot beállitása',
status: 'Beállitása: %{status}',
backCollection: ' Írás a %{collectionLabel} gyűjteménybe',
unsavedChanges: 'Nemmentett változtatások',
changesSaved: 'Változások elmentve',

View File

@ -98,7 +98,7 @@ const it = {
save: 'Salva',
deleting: 'Cancellando...',
updating: 'Aggiornando...',
setStatus: 'Imposta status',
status: 'Status: %{status}',
backCollection: ' Scrivendo nella sezione %{collectionLabel}',
unsavedChanges: 'Modifiche non salvate',
changesSaved: 'Modifiche salvate',

View File

@ -134,7 +134,7 @@ const ja = {
save: '保存',
deleting: '削除しています...',
updating: '更新しています...',
setStatus: 'ステータスを変更する',
status: 'ステータスを: %{status}',
backCollection: '%{collectionLabel}のエントリを作成中',
unsavedChanges: '未保存',
changesSaved: '保存済',

View File

@ -122,7 +122,7 @@ const ko = {
save: '저장',
deleting: '삭제 중...',
updating: '업데이트 중...',
setStatus: '상태 설정',
status: '상태: %{status}',
backCollection: '%{collectionLabel} 컬랙션에 작성하는 중',
unsavedChanges: '변경사항 저장되지 않음',
changesSaved: '변경사항 저장됨',

View File

@ -132,7 +132,7 @@ const lt = {
save: 'Išsaugoti',
deleting: 'Trinama...',
updating: 'Atnaujinama...',
setStatus: 'Nustatyti statusą',
status: 'Statusą: %{status}',
backCollection: ' Rašoma %{collectionLabel} kolekcijoje',
unsavedChanges: 'Neišsaugoti pakeitimai',
changesSaved: 'Pakeitimai išsauogti',

View File

@ -112,7 +112,7 @@ const nb_no = {
save: 'Lagre',
deleting: 'Sletter...',
updating: 'Oppdaterer...',
setStatus: 'Sett status',
status: 'Status: %{status}',
backCollection: ' Skriver i samlingen %{collectionLabel}',
unsavedChanges: 'Ulagrede endringer',
changesSaved: 'Endringer lagret',

View File

@ -133,7 +133,7 @@ const nl = {
save: 'Opslaan',
deleting: 'Verwijderen...',
updating: 'Bijwerken...',
setStatus: 'Stel status in',
status: 'Status: %{status}',
backCollection: ' Terug naar %{collectionLabel}',
unsavedChanges: 'Niet-opgeslagen wijzigingen',
changesSaved: 'Wijzigingen opgeslagen',

View File

@ -113,7 +113,7 @@ const nn_no = {
save: 'Lagre',
deleting: 'Slettar...',
updating: 'Oppdaterer...',
setStatus: 'Sett status',
status: 'Status: %{status}',
backCollection: ' Skriv i samlinga %{collectionLabel}',
unsavedChanges: 'Ulagra endringar',
changesSaved: 'Endringar lagret',

View File

@ -113,7 +113,7 @@ const pl = {
save: 'Zapisz',
deleting: 'Usuwanie...',
updating: 'Uaktualnianie...',
setStatus: 'Ustaw status',
status: 'Status: %{status}',
backCollection: ' Edycja treści w zbiorze %{collectionLabel}',
unsavedChanges: 'Niezapisane zmiany',
changesSaved: 'Zmiany zapisane',

View File

@ -121,7 +121,7 @@ const pt = {
save: 'Salvar',
deleting: 'Excluindo...',
updating: 'Atualizando...',
setStatus: 'Definir status',
status: 'Status: %{status}',
backCollection: ' Escrevendo na coleção %{collectionLabel}',
unsavedChanges: 'Alterações não salvas',
changesSaved: 'Alterações salvas',

View File

@ -136,7 +136,7 @@ const ro = {
save: 'Salvează',
deleting: 'Se șterge...',
updating: 'Se actualizează...',
setStatus: 'Setează status',
status: 'Status: %{status}',
backCollection: ' Scrii în colecția „%{collectionLabel}”',
unsavedChanges: 'Modificări nesalvate',
changesSaved: 'Modificări salvate',

View File

@ -131,7 +131,7 @@ const ru = {
save: 'Сохранить',
deleting: 'Удаление…',
updating: 'Обновление…',
setStatus: 'Установить статус',
status: 'Cтатус: %{status}',
backCollection: 'Запись в коллекцию %{collectionLabel}',
unsavedChanges: 'Несохраненные изменения',
changesSaved: 'Изменения сохранены',

View File

@ -135,7 +135,7 @@ const sv = {
save: 'Spara',
deleting: 'Raderar...',
updating: 'Updaterar...',
setStatus: 'Sätt status',
status: 'Status: %{status}',
backCollection: ' Redigerar i samlingen %{collectionLabel}',
unsavedChanges: 'Osparade ändringar',
changesSaved: 'Ändringar sparade',

View File

@ -123,7 +123,7 @@ const th = {
save: 'บันทึก',
deleting: 'กำลังลบ...',
updating: 'กำลังอัปเดต...',
setStatus: 'เซ็ตสถานะ',
status: 'สถานะ: %{status}',
backCollection: ' เขียนในกลุ่ม %{collectionLabel}',
unsavedChanges: 'การเปลี่ยนแปลงยังไม่ได้บันทึก',
changesSaved: 'การเปลี่ยนเปลงถูกบันทึกแล้ว',

View File

@ -103,7 +103,7 @@ const tr = {
save: 'Kayıt Et',
deleting: 'Siliniyor...',
updating: 'Güncelleniyor...',
setStatus: 'Durumu ayarla',
status: 'Durumu: %{status}',
backCollection: '%{collectionLabel} koleksiyonunda yazılı',
unsavedChanges: 'Kaydedilmemiş Değişiklikler',
changesSaved: 'Değişiklikler kaydedildi',

View File

@ -79,7 +79,7 @@ const uk = {
save: 'Зберегти',
deleting: 'Видалення...',
updating: 'Оновлення...',
setStatus: 'Змінити стан',
status: 'Cтан: %{status}',
backCollection: ' Робота над %{collectionLabel} колекцією',
unsavedChanges: 'Незбережені зміни',
changesSaved: 'Зміни збережено',

View File

@ -121,7 +121,7 @@ const vi = {
save: 'Lưu',
deleting: 'Đang xoá...',
updating: 'Đang cập nhật...',
setStatus: 'Đặt trạng thái',
status: 'Trạng: %{status}',
backCollection: ' Đang viết trong bộ sưu tập %{collectionLabel}',
unsavedChanges: 'Thay đổi chưa được lưu',
changesSaved: 'Thay đổi đã được lưu',

View File

@ -131,7 +131,7 @@ const zh_Hans = {
save: '保存',
deleting: '正在删除...',
updating: '正在更新...',
setStatus: '设置状态',
status: '状态: %{status}',
backCollection: '正在集合“%{collectionLabel}”中编写',
unsavedChanges: '含未保存的修改',
changesSaved: '修改已保存',

View File

@ -120,7 +120,7 @@ const zh_Hant = {
save: '儲存',
deleting: '刪除中...',
updating: '更新中...',
setStatus: '設定狀態',
status: '狀態: %{status}',
backCollection: '在集合 %{collectionLabel} 新增內容',
unsavedChanges: '未儲存變更',
changesSaved: '已儲存變更',