From 17969f1d70b7e9257e31672fe4f757ffc9f31157 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20Adel=C3=B6w?= Date: Mon, 20 Feb 2023 11:47:47 +0100 Subject: [PATCH 1/2] update react-router MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Fredrik Adelöw --- yarn.lock | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/yarn.lock b/yarn.lock index 2dab236124..ae630be19a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -12787,10 +12787,10 @@ __metadata: languageName: node linkType: hard -"@remix-run/router@npm:1.2.1": - version: 1.2.1 - resolution: "@remix-run/router@npm:1.2.1" - checksum: 71c947f83e130bf006226332aca395f626ad599b6d35dfe936f6a8f139cf37278bc1b36bce38c30f6062724402358296329f31c385b11ae59b13b76a2716d701 +"@remix-run/router@npm:1.3.2": + version: 1.3.2 + resolution: "@remix-run/router@npm:1.3.2" + checksum: ee2108b87d4a1241cdea137dd7e1741ee679228bd33fd81e22a6bb2940f81186cefe9a85e26d60cc49bbcc1bdbc57d1954b7d4d62f8a51ef69feddfc899f55fa languageName: node linkType: hard @@ -33321,26 +33321,26 @@ __metadata: linkType: hard "react-router-dom-stable@npm:react-router-dom@^6.3.0, react-router-dom@npm:^6.3.0": - version: 6.6.2 - resolution: "react-router-dom@npm:6.6.2" + version: 6.8.1 + resolution: "react-router-dom@npm:6.8.1" dependencies: - "@remix-run/router": 1.2.1 - react-router: 6.6.2 + "@remix-run/router": 1.3.2 + react-router: 6.8.1 peerDependencies: react: ">=16.8" react-dom: ">=16.8" - checksum: e0ee89a2b3768d2eb406ecefedfa24b55428145359b4138f6d38b8a99b60a4f275418910f4cdb12c069ed0237711acced3787b0c7febfa6568d7ea9cd624ff3b + checksum: fb1a9f5c7e4c83536ee7e6493f3c13f6abda66da69f9191fb8b087ab188ecc18a3a32575813a280cbeca67bcb8b0dcb6dbcef7ed599e03f38a44d694f4abcf14 languageName: node linkType: hard -"react-router-stable@npm:react-router@^6.3.0, react-router@npm:6.6.2": - version: 6.6.2 - resolution: "react-router@npm:6.6.2" +"react-router-stable@npm:react-router@^6.3.0, react-router@npm:6.8.1": + version: 6.8.1 + resolution: "react-router@npm:6.8.1" dependencies: - "@remix-run/router": 1.2.1 + "@remix-run/router": 1.3.2 peerDependencies: react: ">=16.8" - checksum: 5960d774bb3a8f697a57ee2e82a3eb0a300b7186a62b27e02773c94f1682e59435bd876d6162a08cc8daf27cac72aaab66d348fcc4d8f59240a63a911cf0050b + checksum: 8e7cc7a516adeb6060911861af99d9b512893c15ec732cbf8574872919be4f3fe439ffa8c0876d1bcbced880d081bfeda3c01cb505b5a243565d10500ee0ac36 languageName: node linkType: hard From 122a37a880e851aa374af4f1200e300ac005d68a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20Adel=C3=B6w?= Date: Mon, 20 Feb 2023 15:11:03 +0100 Subject: [PATCH 2/2] fixup MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Fredrik Adelöw --- .changeset/rare-pandas-hope.md | 5 +++++ .../PlaylistPage/AddEntitiesDrawer.tsx | 22 +++++++++++-------- 2 files changed, 18 insertions(+), 9 deletions(-) create mode 100644 .changeset/rare-pandas-hope.md diff --git a/.changeset/rare-pandas-hope.md b/.changeset/rare-pandas-hope.md new file mode 100644 index 0000000000..6e8e81fcfb --- /dev/null +++ b/.changeset/rare-pandas-hope.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-playlist': patch +--- + +Internal update to work with newer versions of react-router diff --git a/plugins/playlist/src/components/PlaylistPage/AddEntitiesDrawer.tsx b/plugins/playlist/src/components/PlaylistPage/AddEntitiesDrawer.tsx index 05dd4da231..fe08870bcd 100644 --- a/plugins/playlist/src/components/PlaylistPage/AddEntitiesDrawer.tsx +++ b/plugins/playlist/src/components/PlaylistPage/AddEntitiesDrawer.tsx @@ -102,12 +102,16 @@ export const AddEntitiesDrawer = ({ const entityRoute = useRouteRef(entityRouteRef); const entityLocationRegex = useMemo(() => { const forwardSlashRegex = new RegExp('/', 'g'); + // We need to do this in two steps, since entityRoute will ruin some special chars, like question marks const locationRegex = entityRoute({ - namespace: '(?.+?)', - kind: '(?.+?)', - name: '(?.+?)', - }).replace(forwardSlashRegex, '\\/'); - + namespace: '__REPLACE_WITH_NAMESPACE__', + kind: '__REPLACE_WITH_KIND__', + name: '__REPLACE_WITH_NAME__', + }) + .replace('__REPLACE_WITH_NAMESPACE__', '(?.+?)') + .replace('__REPLACE_WITH_KIND__', '(?.+?)') + .replace('__REPLACE_WITH_NAME__', '(?.+?)') + .replace(forwardSlashRegex, '\\/'); return new RegExp(`${locationRegex}$`); }, [entityRoute]); @@ -127,12 +131,12 @@ export const AddEntitiesDrawer = ({ const addEntity = useCallback( entityResult => { - // TODO (kuangp): this parsing of the location is not great. Ideally `CatalogEntityDocument` + // TODO(kuangp): this parsing of the location is not great. Ideally `CatalogEntityDocument` // contains the `metadata.name` field so we can derive the full ref and we only fall back to // parsing location if it's missing (ie. for older versions) - const { groups } = entityResult.location.match(entityLocationRegex); - if (groups) { - onAdd(stringifyEntityRef(groups)); + const match = entityResult.location.match(entityLocationRegex); + if (match?.groups) { + onAdd(stringifyEntityRef(match?.groups)); } else { // eslint-disable-next-line no-console console.error(