@backstage/plugin-app 0.5.2-next.1 → 0.5.2-next.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # @backstage/plugin-app
2
2
 
3
+ ## 0.5.2-next.2
4
+
5
+ ### Patch Changes
6
+
7
+ - 2dd51e6: Fixed config-driven route redirects to preserve the query string and fragment from the original URL. Previously, redirects declared under `app.extensions[].app/routes.config.redirects` silently dropped everything after `?` or `#` in the incoming URL.
8
+ - Updated dependencies
9
+ - @backstage/frontend-plugin-api@0.18.0-next.0
10
+ - @backstage/plugin-app-react@0.2.6-next.0
11
+ - @backstage/core-plugin-api@1.12.9-next.0
12
+ - @backstage/core-components@0.18.13-next.2
13
+ - @backstage/integration-react@1.2.21-next.1
14
+ - @backstage/plugin-permission-react@0.5.4-next.0
15
+
3
16
  ## 0.5.2-next.1
4
17
 
5
18
  ### Patch Changes
@@ -1,10 +1,11 @@
1
1
  import { jsx } from 'react/jsx-runtime';
2
2
  import { z } from 'zod/v4';
3
3
  import { createExtension, coreExtensionData, createExtensionInput, NotFoundErrorPage } from '@backstage/frontend-plugin-api';
4
- import { useRoutes, useParams, Navigate } from 'react-router-dom';
4
+ import { useRoutes, useParams, useLocation, Navigate } from 'react-router-dom';
5
5
 
6
6
  function RedirectWithParams({ to }) {
7
7
  const params = useParams();
8
+ const { search, hash } = useLocation();
8
9
  let target = to;
9
10
  for (const [name, value] of Object.entries(params)) {
10
11
  target = target.replace(
@@ -12,7 +13,23 @@ function RedirectWithParams({ to }) {
12
13
  value ?? ""
13
14
  );
14
15
  }
15
- return /* @__PURE__ */ jsx(Navigate, { to: target, replace: true });
16
+ const hashIndex = target.indexOf("#");
17
+ const beforeHash = hashIndex === -1 ? target : target.slice(0, hashIndex);
18
+ const targetHash = hashIndex === -1 ? "" : target.slice(hashIndex);
19
+ const queryIndex = beforeHash.indexOf("?");
20
+ const path = queryIndex === -1 ? beforeHash : beforeHash.slice(0, queryIndex);
21
+ const targetSearch = queryIndex === -1 ? "" : beforeHash.slice(queryIndex);
22
+ return /* @__PURE__ */ jsx(
23
+ Navigate,
24
+ {
25
+ to: {
26
+ pathname: path,
27
+ search: targetSearch || search,
28
+ hash: targetHash || hash
29
+ },
30
+ replace: true
31
+ }
32
+ );
16
33
  }
17
34
  const AppRoutes = createExtension({
18
35
  name: "routes",
@@ -1 +1 @@
1
- {"version":3,"file":"AppRoutes.esm.js","sources":["../../src/extensions/AppRoutes.tsx"],"sourcesContent":["/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { z } from 'zod/v4';\nimport {\n createExtension,\n coreExtensionData,\n createExtensionInput,\n NotFoundErrorPage,\n} from '@backstage/frontend-plugin-api';\nimport { Navigate, useParams, useRoutes } from 'react-router-dom';\n\nfunction RedirectWithParams({ to }: { to: string }) {\n const params = useParams() as Record<string, string>;\n let target = to;\n for (const [name, value] of Object.entries(params)) {\n // Use \\b (word boundary) for named params so that `:a` doesn't\n // accidentally match inside `:ab` when both are present.\n target = target.replace(\n name === '*' ? /\\*/g : new RegExp(`:${name}\\\\b`, 'g'),\n value ?? '',\n );\n }\n return <Navigate to={target} replace />;\n}\n\nexport const AppRoutes = createExtension({\n name: 'routes',\n attachTo: { id: 'app/layout', input: 'content' },\n inputs: {\n routes: createExtensionInput([\n coreExtensionData.routePath,\n coreExtensionData.routeRef.optional(),\n coreExtensionData.reactElement,\n ]),\n },\n configSchema: {\n redirects: z\n .array(\n z.object({\n from: z.string(),\n to: z.string(),\n }),\n )\n .optional(),\n },\n output: [coreExtensionData.reactElement],\n factory({ inputs, config }) {\n const redirects = config.redirects ?? [];\n\n const Routes = () => {\n const element = useRoutes([\n ...redirects.map(redirect => ({\n path:\n redirect.from === '/'\n ? redirect.from\n : `${redirect.from.replace(/\\/$/, '')}/*`,\n element: <RedirectWithParams to={redirect.to} />,\n })),\n ...inputs.routes.map(route => {\n const routePath = route.get(coreExtensionData.routePath);\n\n return {\n path:\n routePath === '/'\n ? routePath\n : `${routePath.replace(/\\/$/, '')}/*`,\n\n element: route.get(coreExtensionData.reactElement),\n };\n }),\n {\n path: '*',\n element: <NotFoundErrorPage />,\n },\n ]);\n\n return element;\n };\n\n return [coreExtensionData.reactElement(<Routes />)];\n },\n});\n"],"names":[],"mappings":";;;;;AAyBA,SAAS,kBAAA,CAAmB,EAAE,EAAA,EAAG,EAAmB;AAClD,EAAA,MAAM,SAAS,SAAA,EAAU;AACzB,EAAA,IAAI,MAAA,GAAS,EAAA;AACb,EAAA,KAAA,MAAW,CAAC,IAAA,EAAM,KAAK,KAAK,MAAA,CAAO,OAAA,CAAQ,MAAM,CAAA,EAAG;AAGlD,IAAA,MAAA,GAAS,MAAA,CAAO,OAAA;AAAA,MACd,IAAA,KAAS,MAAM,KAAA,GAAQ,IAAI,OAAO,CAAA,CAAA,EAAI,IAAI,OAAO,GAAG,CAAA;AAAA,MACpD,KAAA,IAAS;AAAA,KACX;AAAA,EACF;AACA,EAAA,uBAAO,GAAA,CAAC,QAAA,EAAA,EAAS,EAAA,EAAI,MAAA,EAAQ,SAAO,IAAA,EAAC,CAAA;AACvC;AAEO,MAAM,YAAY,eAAA,CAAgB;AAAA,EACvC,IAAA,EAAM,QAAA;AAAA,EACN,QAAA,EAAU,EAAE,EAAA,EAAI,YAAA,EAAc,OAAO,SAAA,EAAU;AAAA,EAC/C,MAAA,EAAQ;AAAA,IACN,QAAQ,oBAAA,CAAqB;AAAA,MAC3B,iBAAA,CAAkB,SAAA;AAAA,MAClB,iBAAA,CAA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AA,WACnD;AAAA,QACF,CAAC,CAAA;AAAA,QACD;AAAA,UACE,IAAA,EAAM,GAAA;AAAA,UACN,OAAA,sBAAU,iBAAA,EAAA,EAAkB;AAAA;AAC9B,OACD,CAAA;AAED,MAAA,OAAO,OAAA;AAAA,IACT,CAAA;AAEA,IAAA,OAAO,CAAC,iBAAA,CAAkB,YAAA,iBAAa,GAAA,CAAC,MAAA,EAAA,EAAO,CAAE,CAAC,CAAA;AAAA,EACpD;AACF,CAAC;;;;"}
1
+ {"version":3,"file":"AppRoutes.esm.js","sources":["../../src/extensions/AppRoutes.tsx"],"sourcesContent":["/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { z } from 'zod/v4';\nimport {\n createExtension,\n coreExtensionData,\n createExtensionInput,\n NotFoundErrorPage,\n} from '@backstage/frontend-plugin-api';\nimport { Navigate, useLocation, useParams, useRoutes } from 'react-router-dom';\n\nfunction RedirectWithParams({ to }: { to: string }) {\n const params = useParams() as Record<string, string>;\n const { search, hash } = useLocation();\n\n let target = to;\n for (const [name, value] of Object.entries(params)) {\n // Use \\b (word boundary) for named params so that `:a` doesn't\n // accidentally match inside `:ab` when both are present.\n target = target.replace(\n name === '*' ? /\\*/g : new RegExp(`:${name}\\\\b`, 'g'),\n value ?? '',\n );\n }\n\n const hashIndex = target.indexOf('#');\n const beforeHash = hashIndex === -1 ? target : target.slice(0, hashIndex);\n const targetHash = hashIndex === -1 ? '' : target.slice(hashIndex);\n\n const queryIndex = beforeHash.indexOf('?');\n const path = queryIndex === -1 ? beforeHash : beforeHash.slice(0, queryIndex);\n const targetSearch = queryIndex === -1 ? '' : beforeHash.slice(queryIndex);\n\n return (\n <Navigate\n to={{\n pathname: path,\n search: targetSearch || search,\n hash: targetHash || hash,\n }}\n replace\n />\n );\n}\n\nexport const AppRoutes = createExtension({\n name: 'routes',\n attachTo: { id: 'app/layout', input: 'content' },\n inputs: {\n routes: createExtensionInput([\n coreExtensionData.routePath,\n coreExtensionData.routeRef.optional(),\n coreExtensionData.reactElement,\n ]),\n },\n configSchema: {\n redirects: z\n .array(\n z.object({\n from: z.string(),\n to: z.string(),\n }),\n )\n .optional(),\n },\n output: [coreExtensionData.reactElement],\n factory({ inputs, config }) {\n const redirects = config.redirects ?? [];\n\n const Routes = () => {\n const element = useRoutes([\n ...redirects.map(redirect => ({\n path:\n redirect.from === '/'\n ? redirect.from\n : `${redirect.from.replace(/\\/$/, '')}/*`,\n element: <RedirectWithParams to={redirect.to} />,\n })),\n ...inputs.routes.map(route => {\n const routePath = route.get(coreExtensionData.routePath);\n\n return {\n path:\n routePath === '/'\n ? routePath\n : `${routePath.replace(/\\/$/, '')}/*`,\n\n element: route.get(coreExtensionData.reactElement),\n };\n }),\n {\n path: '*',\n element: <NotFoundErrorPage />,\n },\n ]);\n\n return element;\n };\n\n return [coreExtensionData.reactElement(<Routes />)];\n },\n});\n"],"names":[],"mappings":";;;;;AAyBA,SAAS,kBAAA,CAAmB,EAAE,EAAA,EAAG,EAAmB;AAClD,EAAA,MAAM,SAAS,SAAA,EAAU;AACzB,EAAA,MAAM,EAAE,MAAA,EAAQ,IAAA,EAAK,GAAI,WAAA,EAAY;AAErC,EAAA,IAAI,MAAA,GAAS,EAAA;AACb,EAAA,KAAA,MAAW,CAAC,IAAA,EAAM,KAAK,KAAK,MAAA,CAAO,OAAA,CAAQ,MAAM,CAAA,EAAG;AAGlD,IAAA,MAAA,GAAS,MAAA,CAAO,OAAA;AAAA,MACd,IAAA,KAAS,MAAM,KAAA,GAAQ,IAAI,OAAO,CAAA,CAAA,EAAI,IAAI,OAAO,GA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,IAAA,OAAO,CAAC,iBAAA,CAAkB,YAAA,iBAAa,GAAA,CAAC,MAAA,EAAA,EAAO,CAAE,CAAC,CAAA;AAAA,EACpD;AACF,CAAC;;;;"}
@@ -1,5 +1,5 @@
1
1
  var name = "@backstage/plugin-app";
2
- var version = "0.5.2-next.1";
2
+ var version = "0.5.2-next.2";
3
3
  var backstage = {
4
4
  role: "frontend-plugin",
5
5
  pluginId: "app",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backstage/plugin-app",
3
- "version": "0.5.2-next.1",
3
+ "version": "0.5.2-next.2",
4
4
  "backstage": {
5
5
  "role": "frontend-plugin",
6
6
  "pluginId": "app",
@@ -63,13 +63,13 @@
63
63
  "test": "backstage-cli package test"
64
64
  },
65
65
  "dependencies": {
66
- "@backstage/core-components": "0.18.13-next.1",
67
- "@backstage/core-plugin-api": "1.12.8",
66
+ "@backstage/core-components": "0.18.13-next.2",
67
+ "@backstage/core-plugin-api": "1.12.9-next.0",
68
68
  "@backstage/filter-predicates": "0.1.4",
69
- "@backstage/frontend-plugin-api": "0.17.3",
70
- "@backstage/integration-react": "1.2.21-next.0",
71
- "@backstage/plugin-app-react": "0.2.5",
72
- "@backstage/plugin-permission-react": "0.5.3",
69
+ "@backstage/frontend-plugin-api": "0.18.0-next.0",
70
+ "@backstage/integration-react": "1.2.21-next.1",
71
+ "@backstage/plugin-app-react": "0.2.6-next.0",
72
+ "@backstage/plugin-permission-react": "0.5.4-next.0",
73
73
  "@backstage/theme": "0.7.3",
74
74
  "@backstage/types": "1.2.2",
75
75
  "@backstage/ui": "0.17.1-next.0",
@@ -87,11 +87,11 @@
87
87
  "zod": "^4.0.0"
88
88
  },
89
89
  "devDependencies": {
90
- "@backstage/cli": "0.36.5-next.0",
91
- "@backstage/dev-utils": "1.1.26-next.1",
92
- "@backstage/frontend-defaults": "0.5.5-next.0",
93
- "@backstage/frontend-test-utils": "0.6.3-next.0",
94
- "@backstage/test-utils": "1.7.21-next.0",
90
+ "@backstage/cli": "0.36.5-next.1",
91
+ "@backstage/dev-utils": "1.1.26-next.2",
92
+ "@backstage/frontend-defaults": "0.5.5-next.1",
93
+ "@backstage/frontend-test-utils": "0.6.3-next.1",
94
+ "@backstage/test-utils": "1.7.21-next.1",
95
95
  "@testing-library/jest-dom": "^6.0.0",
96
96
  "@testing-library/react": "^16.0.0",
97
97
  "@testing-library/user-event": "^14.0.0",