-
Notifications
You must be signed in to change notification settings - Fork 6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Dashboard] Add Replicas to Serve Dashboard UI #33503
Merged
Merged
Changes from 1 commit
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
7bc893c
[Dashboard] Add Replicas to Serve Dashboard UI
alanwguo b55faf0
fixup
alanwguo b0ff53d
fixup
alanwguo 9416135
Merge branch 'master' into serve-ui-2
alanwguo e25a8e8
Address comments and add tests
alanwguo 0be747d
fix lint
alanwguo 698bf02
fixup
alanwguo e1f20b2
Add tasks history
alanwguo da3551f
Merge branch 'master' into serve-ui-2
alanwguo 912c7d9
fix logs link
alanwguo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
141 changes: 124 additions & 17 deletions
141
dashboard/client/src/pages/serve/ServeDeploymentRow.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,149 @@ | ||
import { TableCell, TableRow } from "@material-ui/core"; | ||
import React from "react"; | ||
import { | ||
createStyles, | ||
makeStyles, | ||
TableCell, | ||
TableRow, | ||
} from "@material-ui/core"; | ||
import AddIcon from "@material-ui/icons/Add"; | ||
import RemoveIcon from "@material-ui/icons/Remove"; | ||
import React, { useState } from "react"; | ||
import { Link } from "react-router-dom"; | ||
import { | ||
CodeDialogButton, | ||
CodeDialogButtonWithPreview, | ||
} from "../../common/CodeDialogButton"; | ||
import { DurationText } from "../../common/DurationText"; | ||
import { formatDateFromTimeMs } from "../../common/formatUtils"; | ||
import { StatusChip } from "../../components/StatusChip"; | ||
import { ServeDeployment } from "../../type/serve"; | ||
import { | ||
ServeApplication, | ||
ServeDeployment, | ||
ServeReplica, | ||
} from "../../type/serve"; | ||
import { ServeReplicaLogsLink } from "./ServeReplicaDetailPage"; | ||
|
||
const useStyles = makeStyles((theme) => | ||
createStyles({ | ||
deploymentName: { | ||
fontWeight: 500, | ||
}, | ||
expandCollapseIcon: { | ||
color: theme.palette.text.secondary, | ||
fontSize: "1.5em", | ||
verticalAlign: "middle", | ||
}, | ||
}), | ||
); | ||
|
||
export type ServeDeployentRowProps = { | ||
deployment: ServeDeployment; | ||
application: ServeApplication; | ||
}; | ||
|
||
export const ServeDeploymentRow = ({ | ||
deployment: { name, status, message, deployment_config }, | ||
deployment, | ||
application: { last_deployed_time_s }, | ||
}: ServeDeployentRowProps) => { | ||
const { name, status, message, deployment_config, replicas } = deployment; | ||
|
||
const classes = useStyles(); | ||
|
||
const [expanded, setExpanded] = useState(false); | ||
|
||
return ( | ||
<React.Fragment> | ||
<TableRow> | ||
<TableCell | ||
align="center" | ||
onClick={() => { | ||
setExpanded(!expanded); | ||
}} | ||
> | ||
{!expanded ? ( | ||
<AddIcon className={classes.expandCollapseIcon} /> | ||
) : ( | ||
<RemoveIcon className={classes.expandCollapseIcon} /> | ||
)} | ||
</TableCell> | ||
<TableCell align="center" className={classes.deploymentName}> | ||
{name} | ||
</TableCell> | ||
<TableCell align="center"> | ||
<StatusChip type="serveDeployment" status={status} /> | ||
</TableCell> | ||
<TableCell align="center"> | ||
{message ? ( | ||
<CodeDialogButtonWithPreview | ||
title="Message details" | ||
code={message} | ||
/> | ||
) : ( | ||
"-" | ||
)} | ||
</TableCell> | ||
<TableCell align="center"> | ||
<CodeDialogButton | ||
title={`Deployment config for ${name}`} | ||
code={deployment_config} | ||
buttonText="Deployment config" | ||
/> | ||
</TableCell> | ||
<TableCell align="center"> | ||
{formatDateFromTimeMs(last_deployed_time_s * 1000)} | ||
</TableCell> | ||
<TableCell align="center"> | ||
<DurationText startTime={last_deployed_time_s * 1000} /> | ||
</TableCell> | ||
<TableCell align="center">{Object.keys(replicas).length}</TableCell> | ||
</TableRow> | ||
{expanded && | ||
replicas.map((replica) => ( | ||
<ServeReplicaRow | ||
key={replica.replica_id} | ||
replica={replica} | ||
deployment={deployment} | ||
/> | ||
))} | ||
</React.Fragment> | ||
); | ||
}; | ||
|
||
export type ServeReplicaRowProps = { | ||
replica: ServeReplica; | ||
deployment: ServeDeployment; | ||
}; | ||
|
||
export const ServeReplicaRow = ({ | ||
replica, | ||
deployment, | ||
}: ServeReplicaRowProps) => { | ||
const { replica_id, state, start_time_s } = replica; | ||
const { name } = deployment; | ||
|
||
return ( | ||
<TableRow> | ||
<TableCell align="center">{name}</TableCell> | ||
<TableCell align="center"></TableCell> | ||
<TableCell align="center"> | ||
<Link | ||
to={`${encodeURIComponent(name)}/${encodeURIComponent(replica_id)}`} | ||
> | ||
{replica_id} | ||
</Link> | ||
</TableCell> | ||
<TableCell align="center"> | ||
<StatusChip type="serveDeployment" status={status} /> | ||
<StatusChip type="serveReplica" status={state} /> | ||
</TableCell> | ||
<TableCell align="center">-</TableCell> | ||
<TableCell align="center"> | ||
{message ? ( | ||
<CodeDialogButtonWithPreview title="Message details" code={message} /> | ||
) : ( | ||
"-" | ||
)} | ||
<ServeReplicaLogsLink replica={replica} deployment={deployment} /> | ||
</TableCell> | ||
<TableCell align="center"> | ||
{/* TODO(aguo): Add number of replicas (instead of target number of replicas) once available from API */} | ||
{deployment_config.num_replicas} | ||
{formatDateFromTimeMs(start_time_s * 1000)} | ||
</TableCell> | ||
<TableCell align="center"> | ||
<CodeDialogButton | ||
title={`Deployment config for ${name}`} | ||
code={deployment_config} | ||
/> | ||
<DurationText startTime={start_time_s * 1000} /> | ||
</TableCell> | ||
<TableCell align="center">-</TableCell> | ||
</TableRow> | ||
); | ||
}; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we put this in
ServeApplicationsListPage
? Although I guess the use of main nav is mainly used to navigate up from the current breadcrumbs levelThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no, this has to be here because Serve Application Page is a parent of ServeReplicaDetails and we need to have this nav bar show up for the detail page.