diff --git a/.changeset/seven-heads-live.md b/.changeset/seven-heads-live.md new file mode 100644 index 00000000..11f31e18 --- /dev/null +++ b/.changeset/seven-heads-live.md @@ -0,0 +1,5 @@ +--- +"strapi-plugin-webtools": minor +--- + +fix: make the url_alias field invisible by setting the strapi peer dep to 5.42.1 diff --git a/packages/core/admin/components/WebtoolsPanel/index.tsx b/packages/core/admin/components/WebtoolsPanel/index.tsx index 3d43c48a..e9c71518 100644 --- a/packages/core/admin/components/WebtoolsPanel/index.tsx +++ b/packages/core/admin/components/WebtoolsPanel/index.tsx @@ -1,4 +1,4 @@ -import React, { useEffect } from 'react'; +import React from 'react'; import { useQuery } from 'react-query'; import type { PanelComponent } from '@strapi/content-manager/strapi-admin'; import { @@ -36,30 +36,6 @@ const WebtoolsPanel: PanelComponent = () => { const locale = urlParams.get('plugins[i18n][locale]'); const aliases = useQuery(`aliases-${model}-${id}-${locale}`, async () => get(`/webtools/url-alias/findFrom?model=${model}&documentId=${id}&locale=${locale}`), { enabled: false }); - /** - * Ideally the url_alias field would be hidden, but doing so will cause an issue. - * The issue can be prevented by setting the field to visible. To make sure the user - * doesn't see the url_alias field, we just remove it from the dom. - * - * @see https://github.com/strapi/strapi/issues/23039 - * @see https://github.com/strapi/strapi/issues/22975 - */ - useEffect(() => { - const label = Array.from(document.querySelectorAll('label')).find((l) => l.textContent.startsWith('url_alias')); - if (label) { - let parentDiv = label.closest('div'); - for (let i = 0; i < 2; i++) { - if (parentDiv) { - // @ts-expect-error - parentDiv = parentDiv.parentElement; - } - } - if (parentDiv) { - parentDiv.remove(); - } - } - }, []); - // Early return if the user has no permissions to view the sidebar. if (!canSidebar) return null; diff --git a/packages/core/package.json b/packages/core/package.json index 6da2356b..40fd7629 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -40,24 +40,24 @@ "eslint:fix": "eslint --fix './**/*.{js,jsx,ts,tsx}'" }, "peerDependencies": { - "@strapi/admin": "^5.0.0", + "@strapi/admin": "^5.42.1", "@strapi/design-system": "^2.0.0", "@strapi/icons": "^2.0.0", - "@strapi/strapi": "^5.0.0", - "@strapi/utils": "^5.0.0", + "@strapi/strapi": "^5.42.1", + "@strapi/utils": "^5.42.1", "react": "^17.0.0 || ^18.0.0", "react-dom": "^17.0.0 || ^18.0.0", "react-router-dom": "^6.0.0", "styled-components": "^6.0.0" }, "devDependencies": { - "@strapi/admin": "^5.0.0", + "@strapi/admin": "5.42.1", "@strapi/design-system": "^2.0.0", "@strapi/icons": "^2.0.0", "@strapi/pack-up": "^5.0.0", "@strapi/sdk-plugin": "^5.0.0", - "@strapi/strapi": "^5.0.0", - "@strapi/utils": "^5.0.0", + "@strapi/strapi": "5.42.1", + "@strapi/utils": "5.42.1", "@types/koa": "^2.15.0", "@types/lodash": "^4", "@types/qs": "^6", diff --git a/packages/core/server/middlewares/__tests__/middlewares.test.js b/packages/core/server/middlewares/__tests__/middlewares.test.js index 795741ae..1385c8e0 100644 --- a/packages/core/server/middlewares/__tests__/middlewares.test.js +++ b/packages/core/server/middlewares/__tests__/middlewares.test.js @@ -304,7 +304,6 @@ describe('Query layer decorator', () => { populate: ['url_alias'], }); - console.log(category); expect(category).toHaveProperty('url_alias[0].url_path', '/category/a-category'); const updatedCategory = await strapi.documents('api::category.category').update({ diff --git a/packages/core/server/register.ts b/packages/core/server/register.ts index 035af344..4b72b7eb 100644 --- a/packages/core/server/register.ts +++ b/packages/core/server/register.ts @@ -28,14 +28,7 @@ export default ({ strapi }: { strapi: Core.Strapi }) => { private: false, configurable: false, editable: false, - /** - * Ideally this field would be hidden, but doing so will cause an issue. - * The issue can be prevented by setting the field to visible. - * - * @see https://github.com/strapi/strapi/issues/23039 - * @see https://github.com/strapi/strapi/issues/22975 - */ - visible: true, + visible: false, default: null, type: 'relation', relation: 'oneToMany', diff --git a/playground/package.json b/playground/package.json index 40f58278..07966785 100644 --- a/playground/package.json +++ b/playground/package.json @@ -12,9 +12,9 @@ "sitemap": "strapi-sitemap" }, "dependencies": { - "@strapi/plugin-cloud": "^5.42.1", - "@strapi/plugin-users-permissions": "^5.42.1", - "@strapi/strapi": "^5.42.1", + "@strapi/plugin-cloud": "5.42.1", + "@strapi/plugin-users-permissions": "5.42.1", + "@strapi/strapi": "5.42.1", "better-sqlite3": "11.3.0", "react": "^18.0.0", "react-dom": "^18.0.0", diff --git a/playground/yarn.lock b/playground/yarn.lock index 61e7835d..eddb9278 100644 --- a/playground/yarn.lock +++ b/playground/yarn.lock @@ -3949,7 +3949,7 @@ __metadata: languageName: node linkType: hard -"@strapi/plugin-cloud@npm:^5.42.1": +"@strapi/plugin-cloud@npm:5.42.1": version: 5.42.1 resolution: "@strapi/plugin-cloud@npm:5.42.1" dependencies: @@ -3967,7 +3967,7 @@ __metadata: languageName: node linkType: hard -"@strapi/plugin-users-permissions@npm:^5.42.1": +"@strapi/plugin-users-permissions@npm:5.42.1": version: 5.42.1 resolution: "@strapi/plugin-users-permissions@npm:5.42.1" dependencies: @@ -4047,7 +4047,7 @@ __metadata: languageName: node linkType: hard -"@strapi/strapi@npm:^5.42.1": +"@strapi/strapi@npm:5.42.1": version: 5.42.1 resolution: "@strapi/strapi@npm:5.42.1" dependencies: @@ -12014,9 +12014,9 @@ __metadata: version: 0.0.0-use.local resolution: "playground-5@workspace:." dependencies: - "@strapi/plugin-cloud": "npm:^5.42.1" - "@strapi/plugin-users-permissions": "npm:^5.42.1" - "@strapi/strapi": "npm:^5.42.1" + "@strapi/plugin-cloud": "npm:5.42.1" + "@strapi/plugin-users-permissions": "npm:5.42.1" + "@strapi/strapi": "npm:5.42.1" "@types/node": "npm:^20" "@types/pg": "npm:^8" "@types/react": "npm:^18" diff --git a/yarn.lock b/yarn.lock index e86a4b58..2ff391a0 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7991,7 +7991,7 @@ __metadata: languageName: node linkType: hard -"@strapi/admin@npm:5.42.1, @strapi/admin@npm:^5.0.0": +"@strapi/admin@npm:5.42.1": version: 5.42.1 resolution: "@strapi/admin@npm:5.42.1" dependencies: @@ -8583,7 +8583,7 @@ __metadata: languageName: node linkType: hard -"@strapi/strapi@npm:^5.0.0": +"@strapi/strapi@npm:5.42.1, @strapi/strapi@npm:^5.0.0": version: 5.42.1 resolution: "@strapi/strapi@npm:5.42.1" dependencies: @@ -28203,13 +28203,13 @@ __metadata: version: 0.0.0-use.local resolution: "strapi-plugin-webtools@workspace:packages/core" dependencies: - "@strapi/admin": "npm:^5.0.0" + "@strapi/admin": "npm:5.42.1" "@strapi/design-system": "npm:^2.0.0" "@strapi/icons": "npm:^2.0.0" "@strapi/pack-up": "npm:^5.0.0" "@strapi/sdk-plugin": "npm:^5.0.0" - "@strapi/strapi": "npm:^5.0.0" - "@strapi/utils": "npm:^5.0.0" + "@strapi/strapi": "npm:5.42.1" + "@strapi/utils": "npm:5.42.1" "@types/koa": "npm:^2.15.0" "@types/lodash": "npm:^4" "@types/qs": "npm:^6" @@ -28228,11 +28228,11 @@ __metadata: yalc: "npm:^1.0.0-pre.53" yup: "npm:^0.32.9" peerDependencies: - "@strapi/admin": ^5.0.0 + "@strapi/admin": ^5.42.1 "@strapi/design-system": ^2.0.0 "@strapi/icons": ^2.0.0 - "@strapi/strapi": ^5.0.0 - "@strapi/utils": ^5.0.0 + "@strapi/strapi": ^5.42.1 + "@strapi/utils": ^5.42.1 react: ^17.0.0 || ^18.0.0 react-dom: ^17.0.0 || ^18.0.0 react-router-dom: ^6.0.0