chore: tidying up a little bit and added changeset

Signed-off-by: blam <ben@blam.sh>
This commit is contained in:
blam
2022-06-09 16:15:13 +02:00
parent f780859eb0
commit f93af969cd
3 changed files with 21 additions and 2 deletions
+6
View File
@@ -0,0 +1,6 @@
---
'@backstage/plugin-scaffolder': minor
'@backstage/plugin-scaffolder-backend': minor
---
Added the ability to support running of templates that are not in the `default` namespace
+12 -2
View File
@@ -14,7 +14,7 @@
* limitations under the License.
*/
import React, { ComponentType } from 'react';
import React, { ComponentType, useEffect } from 'react';
import { Routes, Route, useOutlet, Navigate, useParams } from 'react-router';
import { Entity } from '@backstage/catalog-model';
import { TemplateEntityV1beta3 } from '@backstage/plugin-scaffolder-common';
@@ -101,10 +101,20 @@ export const Router = (props: RouterProps) => {
),
),
];
/**
* This component can be deleted once the older routes have been deprecated.
*/
const RedirectingComponent = () => {
const { templateName } = useParams();
const newLink = useRouteRef(selectedTemplateRouteRef);
// eslint-disable-next-line no-console
useEffect(
() =>
console.warn(
'The route /template/:templateName is deprecated, please use the new /template/:namespace/:templateName route instead',
),
[],
);
return <Navigate to={newLink({ namespace: 'default', templateName })} />;
};
+3
View File
@@ -28,6 +28,9 @@ export const rootRouteRef = createRouteRef({
id: 'scaffolder',
});
/**
* @deprecated This is the old template route, can be deleted before next major release
*/
export const legacySelectedTemplateRouteRef = createSubRouteRef({
id: 'scaffolder/legacy/selected-template',
parent: rootRouteRef,