chore: added some more deprecation fixes for the routeRefs
Signed-off-by: blam <ben@blam.sh>
This commit is contained in:
@@ -17,12 +17,13 @@ import React from 'react';
|
||||
import { Box, IconButton, Link, Typography, Tooltip } from '@material-ui/core';
|
||||
import RetryIcon from '@material-ui/icons/Replay';
|
||||
import JenkinsLogo from '../../../../assets/JenkinsLogo.svg';
|
||||
import { generatePath, Link as RouterLink } from 'react-router-dom';
|
||||
import { Link as RouterLink } from 'react-router-dom';
|
||||
import { JenkinsRunStatus } from '../Status';
|
||||
import { useBuilds } from '../../../useBuilds';
|
||||
import { buildRouteRef } from '../../../../plugin';
|
||||
import { Table, TableColumn } from '@backstage/core-components';
|
||||
import { Project } from '../../../../api/JenkinsApi';
|
||||
import { useRouteRef } from '@backstage/core-plugin-api';
|
||||
|
||||
const FailCount = ({ count }: { count: number }): JSX.Element | null => {
|
||||
if (count !== 0) {
|
||||
@@ -91,6 +92,8 @@ const generatedColumns: TableColumn[] = [
|
||||
field: 'fullName',
|
||||
highlight: true,
|
||||
render: (row: Partial<Project>) => {
|
||||
// eslint-disable-next-line react-hooks/rules-of-hooks
|
||||
const routeLink = useRouteRef(buildRouteRef);
|
||||
if (!row.fullName || !row.lastBuild?.number) {
|
||||
return (
|
||||
<>
|
||||
@@ -105,7 +108,7 @@ const generatedColumns: TableColumn[] = [
|
||||
return (
|
||||
<Link
|
||||
component={RouterLink}
|
||||
to={generatePath(buildRouteRef.path, {
|
||||
to={routeLink({
|
||||
jobFullName: encodeURIComponent(row.fullName),
|
||||
buildNumber: String(row.lastBuild?.number),
|
||||
})}
|
||||
|
||||
@@ -19,7 +19,7 @@ import { useEntity } from '@backstage/plugin-catalog-react';
|
||||
import React from 'react';
|
||||
import { Route, Routes } from 'react-router';
|
||||
import { JENKINS_ANNOTATION, LEGACY_JENKINS_ANNOTATION } from '../constants';
|
||||
import { buildRouteRef, rootRouteRef } from '../plugin';
|
||||
import { buildRouteRef } from '../plugin';
|
||||
import { CITable } from './BuildsPage/lib/CITable';
|
||||
import { DetailedViewPage } from './BuildWithStepsPage/';
|
||||
|
||||
@@ -41,7 +41,7 @@ export const Router = (_props: Props) => {
|
||||
|
||||
return (
|
||||
<Routes>
|
||||
<Route path={`/${rootRouteRef.path}`} element={<CITable />} />
|
||||
<Route path="/" element={<CITable />} />
|
||||
<Route path={`/${buildRouteRef.path}`} element={<DetailedViewPage />} />
|
||||
</Routes>
|
||||
);
|
||||
|
||||
@@ -20,6 +20,7 @@ import {
|
||||
createPlugin,
|
||||
createRoutableExtension,
|
||||
createRouteRef,
|
||||
createSubRouteRef,
|
||||
discoveryApiRef,
|
||||
identityApiRef,
|
||||
} from '@backstage/core-plugin-api';
|
||||
@@ -29,9 +30,10 @@ export const rootRouteRef = createRouteRef({
|
||||
id: 'jenkins',
|
||||
});
|
||||
|
||||
export const buildRouteRef = createRouteRef({
|
||||
export const buildRouteRef = createSubRouteRef({
|
||||
id: 'jenkins/build',
|
||||
params: ['jobFullName', 'buildNumber'],
|
||||
path: '/builds/:jobFullName/:buildNumber',
|
||||
parent: rootRouteRef,
|
||||
});
|
||||
|
||||
export const jenkinsPlugin = createPlugin({
|
||||
|
||||
Reference in New Issue
Block a user