From 0047c9d9b959913aa6335f1d4f6d964ec7b43c52 Mon Sep 17 00:00:00 2001 From: Oleg Fedak Date: Tue, 28 May 2024 04:22:50 +0300 Subject: [PATCH 01/10] fix: remove field error in Editor after the field is changed --- packages/decap-cms-core/src/actions/entries.ts | 7 +++++-- .../components/Editor/EditorControlPane/EditorControl.js | 8 +++++--- packages/decap-cms-core/src/reducers/entryDraft.js | 3 ++- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/packages/decap-cms-core/src/actions/entries.ts b/packages/decap-cms-core/src/actions/entries.ts index d7971b854d06..e8529b7c20b0 100644 --- a/packages/decap-cms-core/src/actions/entries.ts +++ b/packages/decap-cms-core/src/actions/entries.ts @@ -431,8 +431,11 @@ export function changeDraftFieldValidation( }; } -export function clearFieldErrors() { - return { type: DRAFT_CLEAR_ERRORS }; +export function clearFieldErrors(uniqueFieldId: string) { + return { + type: DRAFT_CLEAR_ERRORS, + payload: { uniqueFieldId }, + }; } export function localBackupRetrieved(entry: EntryValue) { diff --git a/packages/decap-cms-core/src/components/Editor/EditorControlPane/EditorControl.js b/packages/decap-cms-core/src/components/Editor/EditorControlPane/EditorControl.js index d11915139657..de9f94600c1c 100644 --- a/packages/decap-cms-core/src/components/Editor/EditorControlPane/EditorControl.js +++ b/packages/decap-cms-core/src/components/Editor/EditorControlPane/EditorControl.js @@ -62,7 +62,6 @@ const styleStrings = { disabled: ` pointer-events: none; opacity: 0.5; - background: #ccc; `, hidden: ` visibility: hidden; @@ -91,7 +90,7 @@ const ControlErrorsList = styled.ul` export const ControlHint = styled.p` margin-bottom: 0; - padding: 3px 0; + padding: 6px 6x 0; font-size: 12px; color: ${props => props.error ? colors.errorText : props.active ? colors.active : colors.controlLabel}; @@ -305,7 +304,10 @@ class EditorControl extends React.Component { value={value} mediaPaths={mediaPaths} metadata={metadata} - onChange={(newValue, newMetadata) => onChange(field, newValue, newMetadata)} + onChange={(newValue, newMetadata) => { + onChange(field, newValue, newMetadata); + clearFieldErrors(this.uniqueFieldId); // Видаляємо помилки лише для цього поля + }} onValidate={onValidate && partial(onValidate, this.uniqueFieldId)} onOpenMediaLibrary={openMediaLibrary} onClearMediaControl={clearMediaControl} diff --git a/packages/decap-cms-core/src/reducers/entryDraft.js b/packages/decap-cms-core/src/reducers/entryDraft.js index 5a6baa068156..e82e2603f0da 100644 --- a/packages/decap-cms-core/src/reducers/entryDraft.js +++ b/packages/decap-cms-core/src/reducers/entryDraft.js @@ -129,7 +129,8 @@ function entryDraftReducer(state = Map(), action) { } case DRAFT_CLEAR_ERRORS: { - return state.set('fieldsErrors', Map()); + const { uniqueFieldId } = action.payload; + return state.deleteIn(['fieldsErrors', uniqueFieldId]); } case ENTRY_PERSIST_REQUEST: From 90e6be32a80ddbc42e98a0b5e95ad0b77995b005 Mon Sep 17 00:00:00 2001 From: Oleg Fedak Date: Tue, 28 May 2024 07:00:42 +0300 Subject: [PATCH 02/10] fix: add px to control hint --- .../src/components/Editor/EditorControlPane/EditorControl.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/decap-cms-core/src/components/Editor/EditorControlPane/EditorControl.js b/packages/decap-cms-core/src/components/Editor/EditorControlPane/EditorControl.js index de9f94600c1c..953b962c0b19 100644 --- a/packages/decap-cms-core/src/components/Editor/EditorControlPane/EditorControl.js +++ b/packages/decap-cms-core/src/components/Editor/EditorControlPane/EditorControl.js @@ -90,7 +90,7 @@ const ControlErrorsList = styled.ul` export const ControlHint = styled.p` margin-bottom: 0; - padding: 6px 6x 0; + padding: 6px 6px 0; font-size: 12px; color: ${props => props.error ? colors.errorText : props.active ? colors.active : colors.controlLabel}; From 06062a4c19a031c6bc1aaf3c39433af9a16e1cce Mon Sep 17 00:00:00 2001 From: Oleg Fedak Date: Tue, 28 May 2024 21:46:35 +0300 Subject: [PATCH 03/10] fix: add ControlTopbar for correct error display at widget --- .../Editor/EditorControlPane/EditorControl.js | 59 +++++++++++-------- 1 file changed, 33 insertions(+), 26 deletions(-) diff --git a/packages/decap-cms-core/src/components/Editor/EditorControlPane/EditorControl.js b/packages/decap-cms-core/src/components/Editor/EditorControlPane/EditorControl.js index 953b962c0b19..58dcd65e4241 100644 --- a/packages/decap-cms-core/src/components/Editor/EditorControlPane/EditorControl.js +++ b/packages/decap-cms-core/src/components/Editor/EditorControlPane/EditorControl.js @@ -76,21 +76,26 @@ const ControlContainer = styled.div` } `; +const ControlTopbar = styled.div` + display: flex; + justify-content: space-between; + gap: 20px; + align-items: end; +`; const ControlErrorsList = styled.ul` list-style-type: none; font-size: 12px; color: ${colors.errorText}; - margin-bottom: 5px; text-align: right; text-transform: uppercase; - position: relative; font-weight: 600; - top: 20px; + margin: 0; + padding: 2px 0 3px; `; export const ControlHint = styled.p` margin-bottom: 0; - padding: 6px 6px 0; + padding: 6px 0 0; font-size: 12px; color: ${props => props.error ? colors.errorText : props.active ? colors.active : colors.controlLabel}; @@ -240,28 +245,30 @@ class EditorControl extends React.Component { ${isHidden && styleStrings.hidden}; `} > - {widget.globalStyles && } - {errors && ( - - {errors.map( - error => - error.message && - typeof error.message === 'string' && ( -
  • - {error.message} -
  • - ), - )} -
    - )} - + + {widget.globalStyles && } + + {errors && ( + + {errors.map( + error => + error.message && + typeof error.message === 'string' && ( +
  • + {error.message} +
  • + ), + )} +
    + )} +
    Date: Thu, 4 Jul 2024 20:57:34 +0300 Subject: [PATCH 04/10] chore: update after tests --- package-lock.json | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/package-lock.json b/package-lock.json index 14270bc640ff..91c85f130706 100644 --- a/package-lock.json +++ b/package-lock.json @@ -7186,11 +7186,6 @@ "redux": "^4.0.5" } }, - "node_modules/@types/retry": { - "version": "0.12.0", - "dev": true, - "license": "MIT" - }, "node_modules/@types/scheduler": { "version": "0.16.5", "license": "MIT" @@ -25432,6 +25427,12 @@ "node": ">=8" } }, + "node_modules/p-retry/node_modules/@types/retry": { + "version": "0.12.0", + "resolved": "https://registry.npmjs.org/@types/retry/-/retry-0.12.0.tgz", + "integrity": "sha512-wWKOClTTiizcZhXnPY4wikVAwmdYHp8q6DmC+EJUzAMsycb7HB32Kh9RN4+0gExjmPmZSAQjgURXIGATPegAvA==", + "dev": true + }, "node_modules/p-timeout": { "version": "3.2.0", "resolved": "https://registry.npmjs.org/p-timeout/-/p-timeout-3.2.0.tgz", From e9f60cc1241ea77c88f6338a9ac381b4753cf5ab Mon Sep 17 00:00:00 2001 From: Oleg Fedak Date: Sun, 4 Aug 2024 05:30:08 +0300 Subject: [PATCH 05/10] chore: update caniuse-lite --- package-lock.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 806f0fec8e7a..6cb3a592ce7e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10259,9 +10259,9 @@ } }, "node_modules/caniuse-lite": { - "version": "1.0.30001587", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001587.tgz", - "integrity": "sha512-HMFNotUmLXn71BQxg8cijvqxnIAofforZOwGsxyXJ0qugTdspUF4sPSJ2vhgprHCB996tIDzEq1ubumPDV8ULA==", + "version": "1.0.30001647", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001647.tgz", + "integrity": "sha512-n83xdNiyeNcHpzWY+1aFbqCK7LuLfBricc4+alSQL2Xb6OR3XpnQAmlDG+pQcdTfiHRuLcQ96VOfrPSGiNJYSg==", "dev": true, "funding": [ { From db4771217fdede1297fdeb1e98b2b20dada21499 Mon Sep 17 00:00:00 2001 From: Oleg Fedak Date: Sun, 4 Aug 2024 05:30:59 +0300 Subject: [PATCH 06/10] fix: child list element should have key prop --- .../src/components/Editor/EditorToolbar.js | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/packages/decap-cms-core/src/components/Editor/EditorToolbar.js b/packages/decap-cms-core/src/components/Editor/EditorToolbar.js index e909e93055b1..c4be48281c07 100644 --- a/packages/decap-cms-core/src/components/Editor/EditorToolbar.js +++ b/packages/decap-cms-core/src/components/Editor/EditorToolbar.js @@ -594,11 +594,20 @@ export class EditorToolbar extends React.Component { , currentStatus ? [ - this.renderWorkflowStatusControls(), - this.renderNewEntryWorkflowPublishControls({ canCreate, canPublish }), + + {this.renderWorkflowStatusControls()} + {!hasChanged && this.renderNewEntryWorkflowPublishControls({ canCreate, canPublish })} + , ] - : !isNewEntry && - this.renderExistingEntryWorkflowPublishControls({ canCreate, canPublish, canDelete }), + : !isNewEntry && ( + + {this.renderExistingEntryWorkflowPublishControls({ + canCreate, + canPublish, + canDelete, + })} + + ), (!showDelete || useOpenAuthoring) && !hasUnpublishedChanges && !isModification ? null : ( Date: Sun, 4 Aug 2024 05:53:00 +0300 Subject: [PATCH 07/10] chore: update formatting --- .../Editor/EditorControlPane/EditorControl.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/decap-cms-core/src/components/Editor/EditorControlPane/EditorControl.js b/packages/decap-cms-core/src/components/Editor/EditorControlPane/EditorControl.js index 22136b1fe18e..6bad03f219a1 100644 --- a/packages/decap-cms-core/src/components/Editor/EditorControlPane/EditorControl.js +++ b/packages/decap-cms-core/src/components/Editor/EditorControlPane/EditorControl.js @@ -84,11 +84,11 @@ const ControlTopbar = styled.div` `; const ControlErrorsList = styled.ul` list-style-type: none; - font-size: 12px; - color: ${colors.errorText}; - margin-bottom: 8px; - text-align: right; - font-weight: 600; + font-size: 12px; + color: ${colors.errorText}; + margin-bottom: 8px; + text-align: right; + font-weight: 600; `; export const ControlHint = styled.p` From b45dc66815d6c46b4f7c457d9433ae87f07e6978 Mon Sep 17 00:00:00 2001 From: Oleg Fedak Date: Wed, 14 Aug 2024 03:51:10 +0300 Subject: [PATCH 08/10] fix: add ControlTopbar margin and padding --- .../src/components/Editor/EditorControlPane/EditorControl.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/decap-cms-core/src/components/Editor/EditorControlPane/EditorControl.js b/packages/decap-cms-core/src/components/Editor/EditorControlPane/EditorControl.js index 6bad03f219a1..58dcd65e4241 100644 --- a/packages/decap-cms-core/src/components/Editor/EditorControlPane/EditorControl.js +++ b/packages/decap-cms-core/src/components/Editor/EditorControlPane/EditorControl.js @@ -86,9 +86,11 @@ const ControlErrorsList = styled.ul` list-style-type: none; font-size: 12px; color: ${colors.errorText}; - margin-bottom: 8px; text-align: right; + text-transform: uppercase; font-weight: 600; + margin: 0; + padding: 2px 0 3px; `; export const ControlHint = styled.p` From 0a312167e9311c1aafd2759766b4e9e5ad8c7975 Mon Sep 17 00:00:00 2001 From: Oleg Fedak Date: Thu, 15 Aug 2024 20:12:03 +0300 Subject: [PATCH 09/10] fix: add changes to the tests --- .../e2e/markdown_widget_code_block_spec.js | 3 ++- cypress/utils/steps.js | 23 +++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/cypress/e2e/markdown_widget_code_block_spec.js b/cypress/e2e/markdown_widget_code_block_spec.js index 1b835f67ac39..4ecce19bf10f 100644 --- a/cypress/e2e/markdown_widget_code_block_spec.js +++ b/cypress/e2e/markdown_widget_code_block_spec.js @@ -77,7 +77,8 @@ function codeBlock(content) {
    -
    +
    +
    diff --git a/cypress/utils/steps.js b/cypress/utils/steps.js index 464365f802b6..b24ef33d44f4 100644 --- a/cypress/utils/steps.js +++ b/cypress/utils/steps.js @@ -69,6 +69,7 @@ function assertColorOn(cssProperty, color, opts) { } else { (opts.scope ? opts.scope : cy) .contains('label', opts.label) + .parents() .next() .should(assertion); } @@ -518,23 +519,31 @@ function validateNestedListFields() { cy.contains('button', 'hotel locations').click(); cy.contains('button', 'cities').click(); cy.contains('label', 'City') + .parents() .next() + .first() // Вибрати перший елемент після parents() .type('Washington DC'); cy.contains('label', 'Number of Hotels in City') + .parents() .next() + .first() // Вибрати перший елемент після parents() .type('5'); cy.contains('button', 'city locations').click(); // add second city list item cy.contains('button', 'cities').click(); cy.contains('label', 'Cities') + .parents() .next() + .first() // Вибрати перший елемент після parents() .find('div[class*=SortableListItem]') .eq(2) .as('secondCitiesListControl'); cy.get('@secondCitiesListControl') .contains('label', 'City') + .parents() .next() + .first() // Вибрати перший елемент після parents() .type('Boston'); cy.get('@secondCitiesListControl') .contains('button', 'city locations') @@ -561,21 +570,25 @@ function validateNestedListFields() { // list control aliases cy.contains('label', 'Hotel Locations') + .parents() .next() .find('div[class*=SortableListItem]') .first() .as('hotelLocationsListControl'); cy.contains('label', 'Cities') + .parents() .next() .find('div[class*=SortableListItem]') .eq(0) .as('firstCitiesListControl'); cy.contains('label', 'City Locations') + .parents() .next() .find('div[class*=SortableListItem]') .eq(0) .as('firstCityLocationsListControl'); cy.contains('label', 'Cities') + .parents() .next() .find('div[class*=SortableListItem]') .eq(3) @@ -589,7 +602,9 @@ function validateNestedListFields() { assertListControlErrorStatus([colorError, colorError], '@secondCityLocationsListControl'); cy.contains('label', 'Hotel Name') + .parents() .next() + .first() .type('The Ritz Carlton'); cy.contains('button', 'Save').click(); assertNotification(notifications.error.missingField); @@ -598,12 +613,20 @@ function validateNestedListFields() { // fill out rest of form and save cy.get('@secondCitiesListControl') .contains('label', 'Number of Hotels in City') + .parents() + .next() + .first() .type(3); cy.get('@secondCitiesListControl') .contains('label', 'Hotel Name') + .parents() + .next() + .first() .type('Grand Hyatt'); cy.contains('label', 'Country') + .parents() .next() + .first() .type('United States'); flushClockAndSave(); assertNotification(notifications.saved); From 4cfaf9fcb7d30dd3229e7459b2ea7d51068fe627 Mon Sep 17 00:00:00 2001 From: Oleg Fedak Date: Thu, 22 Aug 2024 03:35:55 +0300 Subject: [PATCH 10/10] fix: remove the comments --- cypress/utils/steps.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cypress/utils/steps.js b/cypress/utils/steps.js index b24ef33d44f4..e392ed8c8acb 100644 --- a/cypress/utils/steps.js +++ b/cypress/utils/steps.js @@ -521,12 +521,12 @@ function validateNestedListFields() { cy.contains('label', 'City') .parents() .next() - .first() // Вибрати перший елемент після parents() + .first() .type('Washington DC'); cy.contains('label', 'Number of Hotels in City') .parents() .next() - .first() // Вибрати перший елемент після parents() + .first() .type('5'); cy.contains('button', 'city locations').click(); @@ -535,7 +535,7 @@ function validateNestedListFields() { cy.contains('label', 'Cities') .parents() .next() - .first() // Вибрати перший елемент після parents() + .first() .find('div[class*=SortableListItem]') .eq(2) .as('secondCitiesListControl'); @@ -543,7 +543,7 @@ function validateNestedListFields() { .contains('label', 'City') .parents() .next() - .first() // Вибрати перший елемент після parents() + .first() .type('Boston'); cy.get('@secondCitiesListControl') .contains('button', 'city locations')