Skip to content

Commit

Permalink
[UI] [Serve Replica] Making the log link works (#36659)
Browse files Browse the repository at this point in the history
Perviously, the log link could not jump to the task page.
Now, add a React Route in ServeReplicaDetailPage to make the log link jumping works
  • Loading branch information
chaowanggg authored Jun 30, 2023
1 parent fb087d6 commit 00d4461
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 26 deletions.
8 changes: 6 additions & 2 deletions dashboard/client/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import {
} from "./pages/serve/ServeApplicationDetailPage";
import { ServeApplicationsListPage } from "./pages/serve/ServeApplicationsListPage";
import { ServeLayout, ServeSideTabLayout } from "./pages/serve/ServeLayout";
import { ServeReplicaDetailLayout } from "./pages/serve/ServeReplicaDetailLayout";
import { ServeReplicaDetailPage } from "./pages/serve/ServeReplicaDetailPage";
import {
ServeControllerDetailPage,
Expand Down Expand Up @@ -263,9 +264,12 @@ const App = () => {
>
<Route element={<ServeApplicationDetailPage />} path="" />
<Route
element={<ServeReplicaDetailPage />}
element={<ServeReplicaDetailLayout />}
path=":deploymentName/:replicaId"
/>
>
<Route element={<ServeReplicaDetailPage />} path="" />
<Route path="tasks/:taskId" element={<TaskPage />} />
</Route>
</Route>
</Route>
<Route element={<LogsLayout />} path="logs">
Expand Down
47 changes: 47 additions & 0 deletions dashboard/client/src/pages/serve/ServeReplicaDetailLayout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import { Typography } from "@material-ui/core";
import React from "react";
import { Outlet, useParams } from "react-router-dom";
import Loading from "../../components/Loading";
import { MainNavPageInfo } from "../layout/mainNavContext";
import { useServeReplicaDetails } from "./hook/useServeApplications";

export const ServeReplicaDetailLayout = () => {
const { applicationName, deploymentName, replicaId } = useParams();
const { loading, application, deployment, replica, error } =
useServeReplicaDetails(applicationName, deploymentName, replicaId);

if (error) {
return <Typography color="error">{error.toString()}</Typography>;
}

if (loading) {
return <Loading loading />;
} else if (!replica || !deployment || !application) {
return (
<Typography color="error">
{applicationName} / {deploymentName} / {replicaId} not found.
</Typography>
);
}

const appName = application.name ? application.name : "-";
const { replica_id } = replica;

return (
<div>
<MainNavPageInfo
pageInfo={{
id: "serveReplicaDetail",
title: replica_id,
pageTitle: `${replica_id} | Serve Replica`,
path: `/serve/applications/${encodeURIComponent(
appName,
)}/${encodeURIComponent(deployment.name)}/${encodeURIComponent(
replica_id,
)}`,
}}
/>
<Outlet />
</div>
);
};
30 changes: 6 additions & 24 deletions dashboard/client/src/pages/serve/ServeReplicaDetailPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,9 @@ import {
MultiTabLogViewerTabDetails,
} from "../../common/MultiTabLogViewer";
import { Section } from "../../common/Section";
import Loading from "../../components/Loading";
import { MetadataSection } from "../../components/MetadataSection";
import { StatusChip } from "../../components/StatusChip";
import { ServeReplica } from "../../type/serve";
import { MainNavPageInfo } from "../layout/mainNavContext";
import TaskList from "../state/task";
import { useServeReplicaDetails } from "./hook/useServeApplications";
import { ServeReplicaMetricsSection } from "./ServeDeploymentMetricsSection";
Expand All @@ -35,24 +33,20 @@ export const ServeReplicaDetailPage = () => {
const { applicationName, deploymentName, replicaId } = useParams();
const classes = useStyles();

const { loading, application, deployment, replica, error } =
useServeReplicaDetails(applicationName, deploymentName, replicaId);

if (error) {
return <Typography color="error">{error.toString()}</Typography>;
}
const { application, deployment, replica } = useServeReplicaDetails(
applicationName,
deploymentName,
replicaId,
);

if (loading) {
return <Loading loading />;
} else if (!replica || !deployment || !application) {
if (!replica || !deployment || !application) {
return (
<Typography color="error">
{applicationName} / {deploymentName} / {replicaId} not found.
</Typography>
);
}

const appName = application.name ? application.name : "-";
const {
replica_id,
state,
Expand All @@ -65,18 +59,6 @@ export const ServeReplicaDetailPage = () => {
} = replica;
return (
<div className={classes.root}>
<MainNavPageInfo
pageInfo={{
id: "serveReplicaDetail",
title: replica_id,
pageTitle: `${replica_id} | Serve Replica`,
path: `/serve/applications/${encodeURIComponent(
appName,
)}/${encodeURIComponent(deployment.name)}/${encodeURIComponent(
replica_id,
)}`,
}}
/>
<MetadataSection
metadataList={[
{
Expand Down

0 comments on commit 00d4461

Please sign in to comment.