From 13b256dd86ad0c20d7684437992b6ed74eb8ea69 Mon Sep 17 00:00:00 2001 From: Alex Ford Date: Wed, 5 Apr 2023 10:50:29 +0100 Subject: [PATCH 1/8] Fix 'preceding' typo --- .../core/content-type-builder/admin/src/translations/en.json | 2 +- packages/core/strapi/lib/core/domain/content-type/validator.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/core/content-type-builder/admin/src/translations/en.json b/packages/core/content-type-builder/admin/src/translations/en.json index 8718ec2e3d..b47b776e81 100644 --- a/packages/core/content-type-builder/admin/src/translations/en.json +++ b/packages/core/content-type-builder/admin/src/translations/en.json @@ -60,7 +60,7 @@ "error.contentTypeName.reserved-name": "This name cannot be used in your project as it might break other functionalities", "error.validation.enum-duplicate": "Duplicate values are not allowed (only alphanumeric characters are taken into account).", "error.validation.enum-empty-string": "Empty strings are not allowed", - "error.validation.enum-regex": "At least one value is invalid. Values should have at least one alphabetical character preceeding the first occurence of a number.", + "error.validation.enum-regex": "At least one value is invalid. Values should have at least one alphabetical character preceding the first occurence of a number.", "error.validation.minSupMax": "Can't be superior", "error.validation.positive": "Must be a positive number", "error.validation.regex": "Regex pattern is invalid", diff --git a/packages/core/strapi/lib/core/domain/content-type/validator.js b/packages/core/strapi/lib/core/domain/content-type/validator.js index 85f248dd79..487cb9f482 100644 --- a/packages/core/strapi/lib/core/domain/content-type/validator.js +++ b/packages/core/strapi/lib/core/domain/content-type/validator.js @@ -61,7 +61,7 @@ const contentTypeSchemaValidator = yup.object().shape({ // should match the GraphQL regex if (!regressedValues.every((value) => GRAPHQL_ENUM_REGEX.test(value))) { - const message = `Invalid enumeration value. Values should have at least one alphabetical character preceeding the first occurence of a number. Update your enumeration '${attrName}'.`; + const message = `Invalid enumeration value. Values should have at least one alphabetical character preceding the first occurence of a number. Update your enumeration '${attrName}'.`; return this.createError({ message }); } From 5bb143b23de94ee6cdb34561898ffe52d74d482d Mon Sep 17 00:00:00 2001 From: Josh <37798644+joshuaellis@users.noreply.github.com> Date: Wed, 12 Apr 2023 11:06:26 +0100 Subject: [PATCH 2/8] chore: only use node 18 for lint --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 93e1fdc4dd..ff42dc63c1 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -23,7 +23,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - node: [14, 16, 18] + node: [18] steps: - uses: actions/checkout@v3 with: From 09c824e1b1aad239567f33e7c47d819b9d201287 Mon Sep 17 00:00:00 2001 From: Gustav Hansen Date: Fri, 14 Apr 2023 17:33:13 +0200 Subject: [PATCH 3/8] Settings: Track didViewWorkflow event only when component mounts --- .../SettingsPage/pages/ReviewWorkflows/ReviewWorkflows.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/core/admin/ee/admin/pages/SettingsPage/pages/ReviewWorkflows/ReviewWorkflows.js b/packages/core/admin/ee/admin/pages/SettingsPage/pages/ReviewWorkflows/ReviewWorkflows.js index 3a09b93dfc..c2cfafbdf3 100644 --- a/packages/core/admin/ee/admin/pages/SettingsPage/pages/ReviewWorkflows/ReviewWorkflows.js +++ b/packages/core/admin/ee/admin/pages/SettingsPage/pages/ReviewWorkflows/ReviewWorkflows.js @@ -122,7 +122,8 @@ export function ReviewWorkflowsPage() { useEffect(() => { trackUsage('didViewWorkflow'); - }, [trackUsage]); + // eslint-disable-next-line react-hooks/exhaustive-deps + }, []); return ( From 50db2e4402e1ee16e4a6fab5591b04db4778135a Mon Sep 17 00:00:00 2001 From: Ben Irvin Date: Fri, 14 Apr 2023 17:39:05 +0200 Subject: [PATCH 4/8] remove out of date lerna references --- .../core/admin/link-strapi-design-system.md | 2 +- docs/docs/how-to-install-packages.md | 23 ------------------- docs/sidebars.js | 9 -------- 3 files changed, 1 insertion(+), 33 deletions(-) delete mode 100644 docs/docs/how-to-install-packages.md diff --git a/docs/docs/core/admin/link-strapi-design-system.md b/docs/docs/core/admin/link-strapi-design-system.md index 31bdaca868..f08c5f9519 100644 --- a/docs/docs/core/admin/link-strapi-design-system.md +++ b/docs/docs/core/admin/link-strapi-design-system.md @@ -21,5 +21,5 @@ Alternatively, you can use [`yarn link`](https://classic.yarnpkg.com/lang/en/doc Once the link is setup, run the following command from the root of the monorepo ``` -yarn lerna clean && yarn setup +yarn clean && yarn setup ``` diff --git a/docs/docs/how-to-install-packages.md b/docs/docs/how-to-install-packages.md deleted file mode 100644 index a8881d996a..0000000000 --- a/docs/docs/how-to-install-packages.md +++ /dev/null @@ -1,23 +0,0 @@ ---- -title: How to install packages -slug: /how-to-install-packages -tags: - - lerna - - packages ---- - -# Best practices for installing packages in Strapi - -When working with the Strapi monorepo, it's important to follow best practices for installing packages to avoid potential issues and ensure consistent results. Instead of using the standard **`yarn add`** command, we recommend using **`yarn lerna add --scope @strapi/`** for installing packages. Actually, you may encounter the following error using `yarn add`: - -`An unexpected error occurred: "expected workspace package to exist for \"@typescript-eslint/typescript-estree\'` - -This approach uses Lerna, a tool for managing JavaScript projects with multiple packages, to ensure that the package is installed in the correct location(s) and version across all modules that include it. The **`--scope`** flag specifies the specific module(s) that the package should be installed in, ensuring that it's only installed where it's needed. - -By using this method, Strapi developers can avoid issues with mismatched package versions or unnecessary dependencies in certain modules. This can help to keep the codebase clean and maintainable, and reduce the potential for conflicts or issues in the future. - -Overall, we recommend using **`yarn lerna add`** with the **`--scope`** flag for installing packages in the Strapi mono repo, to ensure consistent and reliable results. - -## Resources - -- [Lerna Docs](https://futurestud.io/tutorials/lerna-install-dependencies-for-a-specific-package) diff --git a/docs/sidebars.js b/docs/sidebars.js index 5a689ff292..787b6fc5ff 100644 --- a/docs/sidebars.js +++ b/docs/sidebars.js @@ -188,15 +188,6 @@ const sidebars = { }, items: [], }, - { - type: 'category', - label: 'How to install packages in a module', - link: { - type: 'doc', - id: 'how-to-install-packages', - }, - items: [], - }, ], api: [{ type: 'autogenerated', dirName: 'api' }], community: [{ type: 'autogenerated', dirName: 'community' }], From 8d6c3d4cad5f1ffdd36e08424cf42d7f6b745231 Mon Sep 17 00:00:00 2001 From: Marc-Roig Date: Fri, 14 Apr 2023 18:25:42 +0200 Subject: [PATCH 5/8] fix: clear transaction context just before committing --- packages/core/database/lib/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/core/database/lib/index.js b/packages/core/database/lib/index.js index f85e4ce873..c76581278c 100644 --- a/packages/core/database/lib/index.js +++ b/packages/core/database/lib/index.js @@ -57,15 +57,15 @@ class Database { async function commit() { if (notNestedTransaction) { - await trx.commit(); transactionCtx.clear(); + await trx.commit(); } } async function rollback() { if (notNestedTransaction) { - await trx.rollback(); transactionCtx.clear(); + await trx.rollback(); } } From c6d4cf00d2a52d6eb70a4d594ba06ab41db4d3ca Mon Sep 17 00:00:00 2001 From: Fernando Chavez Date: Mon, 17 Apr 2023 10:10:51 +0200 Subject: [PATCH 6/8] fix a keys problem with the social links --- packages/core/admin/admin/src/pages/HomePage/SocialLinks.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/core/admin/admin/src/pages/HomePage/SocialLinks.js b/packages/core/admin/admin/src/pages/HomePage/SocialLinks.js index 50046810b7..6951fcee8c 100644 --- a/packages/core/admin/admin/src/pages/HomePage/SocialLinks.js +++ b/packages/core/admin/admin/src/pages/HomePage/SocialLinks.js @@ -187,7 +187,7 @@ const SocialLinks = () => { {socialLinksExtended.map(({ icon, link, name }) => { return ( - + {formatMessage(name)} From 75d5ac7bba454cfe05fa4b598164cf7b644ca075 Mon Sep 17 00:00:00 2001 From: Gustav Hansen Date: Mon, 17 Apr 2023 11:05:16 +0200 Subject: [PATCH 7/8] CM: Apply partial entity update after a stage has been updated --- .../sharedReducers/crudReducer/actions.js | 6 +++ .../sharedReducers/crudReducer/constants.js | 1 + .../sharedReducers/crudReducer/reducer.js | 5 +++ .../crudReducer/tests/crudReducer.test.js | 39 ++++++++++++++++++- .../InformationBox/InformationBoxEE.js | 4 +- 5 files changed, 52 insertions(+), 3 deletions(-) diff --git a/packages/core/admin/admin/src/content-manager/sharedReducers/crudReducer/actions.js b/packages/core/admin/admin/src/content-manager/sharedReducers/crudReducer/actions.js index 6ab1651c05..949403b427 100644 --- a/packages/core/admin/admin/src/content-manager/sharedReducers/crudReducer/actions.js +++ b/packages/core/admin/admin/src/content-manager/sharedReducers/crudReducer/actions.js @@ -2,6 +2,7 @@ import { GET_DATA, GET_DATA_SUCCEEDED, INIT_FORM, + UPDATE_PARTIAL_DATA, RESET_PROPS, SET_DATA_STRUCTURES, SET_STATUS, @@ -47,3 +48,8 @@ export const submitSucceeded = (data) => ({ export const clearSetModifiedDataOnly = () => ({ type: CLEAR_SET_MODIFIED_DATA_ONLY, }); + +export const updatePartialData = (data) => ({ + type: UPDATE_PARTIAL_DATA, + data, +}); diff --git a/packages/core/admin/admin/src/content-manager/sharedReducers/crudReducer/constants.js b/packages/core/admin/admin/src/content-manager/sharedReducers/crudReducer/constants.js index fab8f9f361..5520a39057 100644 --- a/packages/core/admin/admin/src/content-manager/sharedReducers/crudReducer/constants.js +++ b/packages/core/admin/admin/src/content-manager/sharedReducers/crudReducer/constants.js @@ -7,3 +7,4 @@ export const SET_STATUS = 'ContentManager/CrudReducer/SET_STATUS'; export const SUBMIT_SUCCEEDED = 'ContentManager/CrudReducer/SUBMIT_SUCCEEDED'; export const CLEAR_SET_MODIFIED_DATA_ONLY = 'ContentManager/CrudReducer/CLEAR_SET_MODIFIED_DATA_ONLY'; +export const UPDATE_PARTIAL_DATA = 'ContentManager/CrudReducer/PARTIAL_DATA_UPDATE'; diff --git a/packages/core/admin/admin/src/content-manager/sharedReducers/crudReducer/reducer.js b/packages/core/admin/admin/src/content-manager/sharedReducers/crudReducer/reducer.js index ba6d2106b1..0f1815901a 100644 --- a/packages/core/admin/admin/src/content-manager/sharedReducers/crudReducer/reducer.js +++ b/packages/core/admin/admin/src/content-manager/sharedReducers/crudReducer/reducer.js @@ -12,6 +12,7 @@ import { GET_DATA, GET_DATA_SUCCEEDED, INIT_FORM, + UPDATE_PARTIAL_DATA, RESET_PROPS, SET_DATA_STRUCTURES, SET_STATUS, @@ -53,6 +54,10 @@ const crudReducer = (state = crudInitialState, action) => draftState.data = state.contentTypeDataStructure; break; } + case UPDATE_PARTIAL_DATA: { + draftState.data = { ...state.data, ...action.data }; + break; + } case RESET_PROPS: { return crudInitialState; } diff --git a/packages/core/admin/admin/src/content-manager/sharedReducers/crudReducer/tests/crudReducer.test.js b/packages/core/admin/admin/src/content-manager/sharedReducers/crudReducer/tests/crudReducer.test.js index 59465c486f..f1def237c4 100644 --- a/packages/core/admin/admin/src/content-manager/sharedReducers/crudReducer/tests/crudReducer.test.js +++ b/packages/core/admin/admin/src/content-manager/sharedReducers/crudReducer/tests/crudReducer.test.js @@ -3,6 +3,7 @@ import { GET_DATA, GET_DATA_SUCCEEDED, INIT_FORM, + UPDATE_PARTIAL_DATA, SET_DATA_STRUCTURES, SET_STATUS, SUBMIT_SUCCEEDED, @@ -95,7 +96,7 @@ describe('CONTENT MANAGER | sharedReducers | crudReducer', () => { expect(crudReducer(state, action)).toEqual(expected); }); - it('should handle the SUBMIt_SUCCEEDED action correctly', () => { + it('should handle the SUBMIT_SUCCEEDED action correctly', () => { const action = { type: SUBMIT_SUCCEEDED, data: 'test' }; const expected = produce(state, (draft) => { @@ -104,4 +105,40 @@ describe('CONTENT MANAGER | sharedReducers | crudReducer', () => { expect(crudReducer(state, action)).toEqual(expected); }); + + it('should set data using the UPDATE_PARTIAL_DATA action', () => { + const action = { type: UPDATE_PARTIAL_DATA, data: { new: true } }; + + expect(crudReducer(state, action)).toEqual( + expect.objectContaining({ + data: expect.objectContaining({ + new: true, + }), + }) + ); + }); + + it('should merge data using the UPDATE_PARTIAL_DATA action', () => { + const setupAction = { + type: GET_DATA_SUCCEEDED, + data: { + something: true, + }, + }; + + state = crudReducer(state, setupAction); + + const action = { type: UPDATE_PARTIAL_DATA, data: { new: true } }; + + state = crudReducer(state, action); + + expect(state).toEqual( + expect.objectContaining({ + data: expect.objectContaining({ + something: true, + new: true, + }), + }) + ); + }); }); diff --git a/packages/core/admin/ee/admin/content-manager/pages/EditView/InformationBox/InformationBoxEE.js b/packages/core/admin/ee/admin/content-manager/pages/EditView/InformationBox/InformationBoxEE.js index 83482a1779..2f19e0a1e4 100644 --- a/packages/core/admin/ee/admin/content-manager/pages/EditView/InformationBox/InformationBoxEE.js +++ b/packages/core/admin/ee/admin/content-manager/pages/EditView/InformationBox/InformationBoxEE.js @@ -13,7 +13,7 @@ import { useDispatch } from 'react-redux'; import { useReviewWorkflows } from '../../../../pages/SettingsPage/pages/ReviewWorkflows/hooks/useReviewWorkflows'; import Information from '../../../../../../admin/src/content-manager/pages/EditView/Information'; -import { submitSucceeded } from '../../../../../../admin/src/content-manager/sharedReducers/crudReducer/actions'; +import { updatePartialData } from '../../../../../../admin/src/content-manager/sharedReducers/crudReducer/actions'; const ATTRIBUTE_NAME = 'strapi_reviewWorkflows_stage'; @@ -50,7 +50,7 @@ export function InformationBoxEE() { data: { id: stageId }, }); - dispatch(submitSucceeded(createdEntity)); + dispatch(updatePartialData({ [ATTRIBUTE_NAME]: createdEntity[ATTRIBUTE_NAME] })); return createdEntity; }, From 353240af4e0ce169a51e1cb1bba2b5de75de5803 Mon Sep 17 00:00:00 2001 From: Gustav Hansen Date: Mon, 17 Apr 2023 11:58:14 +0200 Subject: [PATCH 8/8] CM: Set value instead of defaultValue to account for i18n re-renders --- .../pages/EditView/InformationBox/InformationBoxEE.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/core/admin/ee/admin/content-manager/pages/EditView/InformationBox/InformationBoxEE.js b/packages/core/admin/ee/admin/content-manager/pages/EditView/InformationBox/InformationBoxEE.js index 83482a1779..5a3ddc2562 100644 --- a/packages/core/admin/ee/admin/content-manager/pages/EditView/InformationBox/InformationBoxEE.js +++ b/packages/core/admin/ee/admin/content-manager/pages/EditView/InformationBox/InformationBoxEE.js @@ -111,7 +111,6 @@ export function InformationBoxEE() { components={{ LoadingIndicator: () => , }} - defaultValue={{ value: activeWorkflowStage?.id, label: activeWorkflowStage?.name }} error={formattedError} inputId={ATTRIBUTE_NAME} isLoading={isLoading} @@ -122,6 +121,7 @@ export function InformationBoxEE() { options={ workflow ? workflow.stages.map(({ id, name }) => ({ value: id, label: name })) : [] } + value={{ value: activeWorkflowStage?.id, label: activeWorkflowStage?.name }} />