Skip to content

Commit fbc3728

Browse files
authored
feat: show current status in status button (#5574)
1 parent 647b974 commit fbc3728

File tree

33 files changed

+84
-57
lines changed

33 files changed

+84
-57
lines changed

cypress/utils/steps.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,10 @@ function deleteWorkflowEntry({ title }) {
145145
assertNotification(notifications.deletedUnpublished);
146146
}
147147

148+
const STATUS_BUTTON_TEXT = 'Status:';
149+
148150
function assertWorkflowStatusInEditor(status) {
149-
cy.contains('[role="button"]', 'Set status').as('setStatusButton');
151+
cy.contains('[role="button"]', STATUS_BUTTON_TEXT).as('setStatusButton');
150152
cy.get('@setStatusButton')
151153
.parent()
152154
.within(() => {
@@ -209,7 +211,7 @@ function assertWorkflowStatus({ title }, status) {
209211
}
210212

211213
function updateWorkflowStatusInEditor(newStatus) {
212-
selectDropdownItem('Set status', newStatus);
214+
selectDropdownItem(STATUS_BUTTON_TEXT, newStatus);
213215
assertNotification(notifications.updated);
214216
}
215217

packages/netlify-cms-core/src/components/Editor/EditorToolbar.js

+12-7
Original file line numberDiff line numberDiff line change
@@ -358,18 +358,23 @@ export class EditorToolbar extends React.Component {
358358

359359
renderWorkflowStatusControls = () => {
360360
const { isUpdatingStatus, onChangeStatus, currentStatus, t, useOpenAuthoring } = this.props;
361+
362+
const statusToTranslation = {
363+
[status.get('DRAFT')]: t('editor.editorToolbar.draft'),
364+
[status.get('PENDING_REVIEW')]: t('editor.editorToolbar.inReview'),
365+
[status.get('PENDING_PUBLISH')]: t('editor.editorToolbar.ready'),
366+
};
367+
368+
const buttonText = isUpdatingStatus
369+
? t('editor.editorToolbar.updating')
370+
: t('editor.editorToolbar.status', { status: statusToTranslation[currentStatus] });
371+
361372
return (
362373
<>
363374
<ToolbarDropdown
364375
dropdownTopOverlap="40px"
365376
dropdownWidth="120px"
366-
renderButton={() => (
367-
<StatusButton>
368-
{isUpdatingStatus
369-
? t('editor.editorToolbar.updating')
370-
: t('editor.editorToolbar.setStatus')}
371-
</StatusButton>
372-
)}
377+
renderButton={() => <StatusButton>{buttonText}</StatusButton>}
373378
>
374379
<StatusDropdownItem
375380
label={t('editor.editorToolbar.draft')}

packages/netlify-cms-core/src/components/Editor/__tests__/__snapshots__/EditorToolbar.spec.js.snap

+19-19
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ exports[`EditorToolbar should render with default props 1`] = `
179179
class="emotion-18 emotion-19"
180180
>
181181
<mock-link
182-
classname="css-1e27f5b-ToolbarSectionBackLink-toolbarSection evqrzhe8"
182+
classname="css-i3q6wb-ToolbarSectionBackLink-toolbarSection evqrzhe8"
183183
to=""
184184
>
185185
<div
@@ -469,7 +469,7 @@ exports[`EditorToolbar should render with status=draft,useOpenAuthoring=false 1`
469469
class="emotion-23 emotion-24"
470470
>
471471
<mock-link
472-
classname="css-1e27f5b-ToolbarSectionBackLink-toolbarSection evqrzhe8"
472+
classname="css-i3q6wb-ToolbarSectionBackLink-toolbarSection evqrzhe8"
473473
to=""
474474
>
475475
<div
@@ -520,7 +520,7 @@ exports[`EditorToolbar should render with status=draft,useOpenAuthoring=false 1`
520520
role="button"
521521
tabindex="0"
522522
>
523-
editor.editorToolbar.setStatus
523+
editor.editorToolbar.status
524524
</span>
525525
</div>
526526
</div>
@@ -803,7 +803,7 @@ exports[`EditorToolbar should render with status=draft,useOpenAuthoring=true 1`]
803803
class="emotion-30 emotion-31"
804804
>
805805
<mock-link
806-
classname="css-1e27f5b-ToolbarSectionBackLink-toolbarSection evqrzhe8"
806+
classname="css-i3q6wb-ToolbarSectionBackLink-toolbarSection evqrzhe8"
807807
to=""
808808
>
809809
<div
@@ -849,7 +849,7 @@ exports[`EditorToolbar should render with status=draft,useOpenAuthoring=true 1`]
849849
role="button"
850850
tabindex="0"
851851
>
852-
editor.editorToolbar.setStatus
852+
editor.editorToolbar.status
853853
</span>
854854
</div>
855855
<div
@@ -1131,7 +1131,7 @@ exports[`EditorToolbar should render with status=pending_publish,useOpenAuthorin
11311131
class="emotion-23 emotion-24"
11321132
>
11331133
<mock-link
1134-
classname="css-1e27f5b-ToolbarSectionBackLink-toolbarSection evqrzhe8"
1134+
classname="css-i3q6wb-ToolbarSectionBackLink-toolbarSection evqrzhe8"
11351135
to=""
11361136
>
11371137
<div
@@ -1182,7 +1182,7 @@ exports[`EditorToolbar should render with status=pending_publish,useOpenAuthorin
11821182
role="button"
11831183
tabindex="0"
11841184
>
1185-
editor.editorToolbar.setStatus
1185+
editor.editorToolbar.status
11861186
</span>
11871187
</div>
11881188
</div>
@@ -1447,7 +1447,7 @@ exports[`EditorToolbar should render with status=pending_publish,useOpenAuthorin
14471447
class="emotion-28 emotion-29"
14481448
>
14491449
<mock-link
1450-
classname="css-1e27f5b-ToolbarSectionBackLink-toolbarSection evqrzhe8"
1450+
classname="css-i3q6wb-ToolbarSectionBackLink-toolbarSection evqrzhe8"
14511451
to=""
14521452
>
14531453
<div
@@ -1493,7 +1493,7 @@ exports[`EditorToolbar should render with status=pending_publish,useOpenAuthorin
14931493
role="button"
14941494
tabindex="0"
14951495
>
1496-
editor.editorToolbar.setStatus
1496+
editor.editorToolbar.status
14971497
</span>
14981498
</div>
14991499
<div
@@ -1770,7 +1770,7 @@ exports[`EditorToolbar should render with status=pending_review,useOpenAuthoring
17701770
class="emotion-23 emotion-24"
17711771
>
17721772
<mock-link
1773-
classname="css-1e27f5b-ToolbarSectionBackLink-toolbarSection evqrzhe8"
1773+
classname="css-i3q6wb-ToolbarSectionBackLink-toolbarSection evqrzhe8"
17741774
to=""
17751775
>
17761776
<div
@@ -1821,7 +1821,7 @@ exports[`EditorToolbar should render with status=pending_review,useOpenAuthoring
18211821
role="button"
18221822
tabindex="0"
18231823
>
1824-
editor.editorToolbar.setStatus
1824+
editor.editorToolbar.status
18251825
</span>
18261826
</div>
18271827
</div>
@@ -2104,7 +2104,7 @@ exports[`EditorToolbar should render with status=pending_review,useOpenAuthoring
21042104
class="emotion-30 emotion-31"
21052105
>
21062106
<mock-link
2107-
classname="css-1e27f5b-ToolbarSectionBackLink-toolbarSection evqrzhe8"
2107+
classname="css-i3q6wb-ToolbarSectionBackLink-toolbarSection evqrzhe8"
21082108
to=""
21092109
>
21102110
<div
@@ -2150,7 +2150,7 @@ exports[`EditorToolbar should render with status=pending_review,useOpenAuthoring
21502150
role="button"
21512151
tabindex="0"
21522152
>
2153-
editor.editorToolbar.setStatus
2153+
editor.editorToolbar.status
21542154
</span>
21552155
</div>
21562156
<div
@@ -2375,7 +2375,7 @@ exports[`EditorToolbar should render with workflow controls hasUnpublishedChange
23752375
class="emotion-18 emotion-19"
23762376
>
23772377
<mock-link
2378-
classname="css-1e27f5b-ToolbarSectionBackLink-toolbarSection evqrzhe8"
2378+
classname="css-i3q6wb-ToolbarSectionBackLink-toolbarSection evqrzhe8"
23792379
to=""
23802380
>
23812381
<div
@@ -2580,7 +2580,7 @@ exports[`EditorToolbar should render with workflow controls hasUnpublishedChange
25802580
class="emotion-16 emotion-17"
25812581
>
25822582
<mock-link
2583-
classname="css-1e27f5b-ToolbarSectionBackLink-toolbarSection evqrzhe8"
2583+
classname="css-i3q6wb-ToolbarSectionBackLink-toolbarSection evqrzhe8"
25842584
to=""
25852585
>
25862586
<div
@@ -2805,7 +2805,7 @@ exports[`EditorToolbar should render with workflow controls hasUnpublishedChange
28052805
class="emotion-18 emotion-19"
28062806
>
28072807
<mock-link
2808-
classname="css-1e27f5b-ToolbarSectionBackLink-toolbarSection evqrzhe8"
2808+
classname="css-i3q6wb-ToolbarSectionBackLink-toolbarSection evqrzhe8"
28092809
to=""
28102810
>
28112811
<div
@@ -3035,7 +3035,7 @@ exports[`EditorToolbar should render with workflow controls hasUnpublishedChange
30353035
class="emotion-18 emotion-19"
30363036
>
30373037
<mock-link
3038-
classname="css-1e27f5b-ToolbarSectionBackLink-toolbarSection evqrzhe8"
3038+
classname="css-i3q6wb-ToolbarSectionBackLink-toolbarSection evqrzhe8"
30393039
to=""
30403040
>
30413041
<div
@@ -3265,7 +3265,7 @@ exports[`EditorToolbar should render with workflow controls hasUnpublishedChange
32653265
class="emotion-18 emotion-19"
32663266
>
32673267
<mock-link
3268-
classname="css-1e27f5b-ToolbarSectionBackLink-toolbarSection evqrzhe8"
3268+
classname="css-i3q6wb-ToolbarSectionBackLink-toolbarSection evqrzhe8"
32693269
to=""
32703270
>
32713271
<div
@@ -3495,7 +3495,7 @@ exports[`EditorToolbar should render with workflow controls hasUnpublishedChange
34953495
class="emotion-18 emotion-19"
34963496
>
34973497
<mock-link
3498-
classname="css-1e27f5b-ToolbarSectionBackLink-toolbarSection evqrzhe8"
3498+
classname="css-i3q6wb-ToolbarSectionBackLink-toolbarSection evqrzhe8"
34993499
to=""
35003500
>
35013501
<div

packages/netlify-cms-core/src/reducers/entryDraft.js

+20
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@ import {
2424
UNPUBLISHED_ENTRY_PERSIST_REQUEST,
2525
UNPUBLISHED_ENTRY_PERSIST_SUCCESS,
2626
UNPUBLISHED_ENTRY_PERSIST_FAILURE,
27+
UNPUBLISHED_ENTRY_STATUS_CHANGE_REQUEST,
28+
UNPUBLISHED_ENTRY_STATUS_CHANGE_SUCCESS,
29+
UNPUBLISHED_ENTRY_STATUS_CHANGE_FAILURE,
30+
UNPUBLISHED_ENTRY_PUBLISH_REQUEST,
31+
UNPUBLISHED_ENTRY_PUBLISH_SUCCESS,
32+
UNPUBLISHED_ENTRY_PUBLISH_FAILURE,
2733
} from '../actions/editorialWorkflow';
2834
import { selectFolderEntryExtension, selectHasMetaPath } from './collections';
2935
import { getDataPath, duplicateI18nFields } from '../lib/i18n';
@@ -136,6 +142,20 @@ function entryDraftReducer(state = Map(), action) {
136142
return state.deleteIn(['entry', 'isPersisting']);
137143
}
138144

145+
case UNPUBLISHED_ENTRY_STATUS_CHANGE_REQUEST:
146+
return state.setIn(['entry', 'isUpdatingStatus'], true);
147+
148+
case UNPUBLISHED_ENTRY_STATUS_CHANGE_FAILURE:
149+
case UNPUBLISHED_ENTRY_STATUS_CHANGE_SUCCESS:
150+
return state.deleteIn(['entry', 'isUpdatingStatus']);
151+
152+
case UNPUBLISHED_ENTRY_PUBLISH_REQUEST:
153+
return state.setIn(['entry', 'isPublishing'], true);
154+
155+
case UNPUBLISHED_ENTRY_PUBLISH_SUCCESS:
156+
case UNPUBLISHED_ENTRY_PUBLISH_FAILURE:
157+
return state.deleteIn(['entry', 'isPublishing']);
158+
139159
case ENTRY_PERSIST_SUCCESS:
140160
case UNPUBLISHED_ENTRY_PERSIST_SUCCESS:
141161
return state.withMutations(state => {

packages/netlify-cms-locales/src/bg/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ const bg = {
135135
save: 'Запази',
136136
deleting: 'Изтриване...',
137137
updating: 'Актуализиране...',
138-
setStatus: 'Задайте състояние',
138+
status: 'Cъстояние: %{status}',
139139
backCollection: 'Записване в %{collectionLabel} колекция',
140140
unsavedChanges: 'Незапазени Промени',
141141
changesSaved: 'Запазени промени',

packages/netlify-cms-locales/src/ca/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ const ca = {
134134
save: 'Guardar',
135135
deleting: 'Eliminant...',
136136
updating: 'Actualizant...',
137-
setStatus: 'Actualizar estat',
137+
status: 'Estat: %{status}',
138138
backCollection: ' Escrivint a la colecció %{collectionLabel}',
139139
unsavedChanges: 'Canvis no guardats',
140140
changesSaved: 'Canvis guardats',

packages/netlify-cms-locales/src/cs/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ const cs = {
134134
save: 'Uložit',
135135
deleting: 'Vymazávání…',
136136
updating: 'Aktualizace…',
137-
setStatus: 'Změnit status',
137+
status: 'Status: %{status}',
138138
backCollection: ' Píšete v kolekci %{collectionLabel}',
139139
unsavedChanges: 'Neuložené změny',
140140
changesSaved: 'Změny uloženy',

packages/netlify-cms-locales/src/da/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ const da = {
131131
save: 'Gem',
132132
deleting: 'Sletter...',
133133
updating: 'Updaterer...',
134-
setStatus: 'Sæt status',
134+
status: 'Status: %{status}',
135135
backCollection: ' Skriver til %{collectionLabel} samlingen',
136136
unsavedChanges: 'Ugemte ændringer',
137137
changesSaved: 'Ændringer gemt',

packages/netlify-cms-locales/src/de/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ const de = {
126126
save: 'Speichern',
127127
deleting: 'Löschen...',
128128
updating: 'Aktualisieren...',
129-
setStatus: 'Status setzen',
129+
status: 'Status: %{status}',
130130
backCollection: 'Zurück zu allen %{collectionLabel}',
131131
unsavedChanges: 'Ungespeicherte Änderungen',
132132
changesSaved: 'Änderungen gespeichert',

packages/netlify-cms-locales/src/en/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ const en = {
137137
'Entry is being reviewed, no further actions are required. However, you can still make additional changes while it is being reviewed.',
138138
deleting: 'Deleting...',
139139
updating: 'Updating...',
140-
setStatus: 'Set status',
140+
status: 'Status: %{status}',
141141
backCollection: ' Writing in %{collectionLabel} collection',
142142
unsavedChanges: 'Unsaved Changes',
143143
changesSaved: 'Changes saved',

packages/netlify-cms-locales/src/es/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ const es = {
115115
save: 'Guardar',
116116
deleting: 'Eliminando...',
117117
updating: 'Actualizando...',
118-
setStatus: 'Actualizar estado',
118+
status: 'Estado: %{status}',
119119
backCollection: ' Escribiendo en la colección %{collectionLabel}',
120120
unsavedChanges: 'Cambios no guardados',
121121
changesSaved: 'Cambios guardados',

packages/netlify-cms-locales/src/fr/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ const fr = {
136136
save: 'Enregistrer',
137137
deleting: 'Suppression...',
138138
updating: 'Mise à jour...',
139-
setStatus: 'Définir le statut',
139+
status: 'Statut: %{status}',
140140
backCollection: ' Écriture dans la collection %{collectionLabel}',
141141
unsavedChanges: 'Modifications non enregistrées',
142142
changesSaved: 'Modifications enregistrées',

packages/netlify-cms-locales/src/gr/index.js

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

packages/netlify-cms-locales/src/hr/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ const hr = {
130130
save: 'Spremi',
131131
deleting: 'Brisanje...',
132132
updating: 'Ažuriranje...',
133-
setStatus: 'Postavi status',
133+
status: 'Status: %{status}',
134134
backCollection: 'Pisanje u %{collectionLabel} zbirci',
135135
unsavedChanges: 'Nespremljene promjene',
136136
changesSaved: 'Promjene spremljene',

packages/netlify-cms-locales/src/hu/index.js

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

packages/netlify-cms-locales/src/it/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ const it = {
9898
save: 'Salva',
9999
deleting: 'Cancellando...',
100100
updating: 'Aggiornando...',
101-
setStatus: 'Imposta status',
101+
status: 'Status: %{status}',
102102
backCollection: ' Scrivendo nella sezione %{collectionLabel}',
103103
unsavedChanges: 'Modifiche non salvate',
104104
changesSaved: 'Modifiche salvate',

packages/netlify-cms-locales/src/ja/index.js

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

packages/netlify-cms-locales/src/ko/index.js

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

packages/netlify-cms-locales/src/lt/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ const lt = {
132132
save: 'Išsaugoti',
133133
deleting: 'Trinama...',
134134
updating: 'Atnaujinama...',
135-
setStatus: 'Nustatyti statusą',
135+
status: 'Statusą: %{status}',
136136
backCollection: ' Rašoma %{collectionLabel} kolekcijoje',
137137
unsavedChanges: 'Neišsaugoti pakeitimai',
138138
changesSaved: 'Pakeitimai išsauogti',

0 commit comments

Comments
 (0)