chore: more deprecations and reworking more routeRefs to subRouteRefs
Signed-off-by: blam <ben@blam.sh>
This commit is contained in:
@@ -17,7 +17,7 @@ import React from 'react';
|
||||
import { Entity } from '@backstage/catalog-model';
|
||||
import { useEntity } from '@backstage/plugin-catalog-react';
|
||||
import { Routes, Route } from 'react-router';
|
||||
import { rootRouteRef, buildRouteRef } from '../routes';
|
||||
import { buildRouteRef } from '../routes';
|
||||
import { WorkflowRunDetails } from './WorkflowRunDetails';
|
||||
import { WorkflowRunsTable } from './WorkflowRunsTable';
|
||||
import { CLOUDBUILD_ANNOTATION } from './useProjectName';
|
||||
@@ -40,15 +40,11 @@ export const Router = (_props: Props) => {
|
||||
}
|
||||
return (
|
||||
<Routes>
|
||||
<Route path="/" element={<WorkflowRunsTable entity={entity} />} />
|
||||
<Route
|
||||
path={`/${rootRouteRef.path}`}
|
||||
element={<WorkflowRunsTable entity={entity} />}
|
||||
/>
|
||||
<Route
|
||||
path={`/${buildRouteRef.path}`}
|
||||
path={`${buildRouteRef.path}`}
|
||||
element={<WorkflowRunDetails entity={entity} />}
|
||||
/>
|
||||
)
|
||||
</Routes>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -17,7 +17,7 @@ import React from 'react';
|
||||
import { Link, Typography, Box, IconButton, Tooltip } from '@material-ui/core';
|
||||
import RetryIcon from '@material-ui/icons/Replay';
|
||||
import GoogleIcon from '@material-ui/icons/CloudCircle';
|
||||
import { Link as RouterLink, generatePath } from 'react-router-dom';
|
||||
import { Link as RouterLink } from 'react-router-dom';
|
||||
import { useWorkflowRuns, WorkflowRun } from '../useWorkflowRuns';
|
||||
import { WorkflowRunStatus } from '../WorkflowRunStatus';
|
||||
import SyncIcon from '@material-ui/icons/Sync';
|
||||
@@ -26,6 +26,7 @@ import { Entity } from '@backstage/catalog-model';
|
||||
import { buildRouteRef } from '../../routes';
|
||||
import { DateTime } from 'luxon';
|
||||
import { Table, TableColumn } from '@backstage/core-components';
|
||||
import { useRouteRef } from '@backstage/core-plugin-api';
|
||||
|
||||
const generatedColumns: TableColumn[] = [
|
||||
{
|
||||
@@ -54,15 +55,19 @@ const generatedColumns: TableColumn[] = [
|
||||
field: 'source',
|
||||
highlight: true,
|
||||
width: '200px',
|
||||
render: (row: Partial<WorkflowRun>) => (
|
||||
<Link
|
||||
component={RouterLink}
|
||||
data-testid="cell-source"
|
||||
to={generatePath(buildRouteRef.path, { id: row.id! })}
|
||||
>
|
||||
{row.message}
|
||||
</Link>
|
||||
),
|
||||
render: (row: Partial<WorkflowRun>) => {
|
||||
// eslint-disable-next-line react-hooks/rules-of-hooks
|
||||
const routeLink = useRouteRef(buildRouteRef);
|
||||
return (
|
||||
<Link
|
||||
component={RouterLink}
|
||||
data-testid="cell-source"
|
||||
to={routeLink({ id: row.id! })}
|
||||
>
|
||||
{row.message}
|
||||
</Link>
|
||||
);
|
||||
},
|
||||
},
|
||||
{
|
||||
title: 'Ref',
|
||||
|
||||
@@ -13,12 +13,14 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { createRouteRef } from '@backstage/core-plugin-api';
|
||||
import { createRouteRef, createSubRouteRef } from '@backstage/core-plugin-api';
|
||||
|
||||
export const rootRouteRef = createRouteRef({
|
||||
id: 'cloudbuild',
|
||||
});
|
||||
|
||||
export const buildRouteRef = createRouteRef({
|
||||
export const buildRouteRef = createSubRouteRef({
|
||||
id: 'cloudbuild/run',
|
||||
path: '/:id',
|
||||
parent: rootRouteRef,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user