mirror of
https://github.com/hibiken/asynqmon.git
synced 2025-10-26 00:06:13 +08:00
Update QueueBreadcrumb component to show taskId when provided
This commit is contained in:
@@ -31,7 +31,9 @@ interface Props {
|
|||||||
// All queue names.
|
// All queue names.
|
||||||
queues: string[];
|
queues: string[];
|
||||||
// Name of the queue currently selected.
|
// Name of the queue currently selected.
|
||||||
selectedQueue: string;
|
queueName: string;
|
||||||
|
// ID of the task currently selected (optional).
|
||||||
|
taskId?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function QueueBreadcrumbs(props: Props) {
|
export default function QueueBreadcrumbs(props: Props) {
|
||||||
@@ -57,11 +59,12 @@ export default function QueueBreadcrumbs(props: Props) {
|
|||||||
onClick={() => history.push(paths.HOME)}
|
onClick={() => history.push(paths.HOME)}
|
||||||
/>
|
/>
|
||||||
<StyledBreadcrumb
|
<StyledBreadcrumb
|
||||||
label={props.selectedQueue}
|
label={props.queueName}
|
||||||
deleteIcon={<ExpandMoreIcon />}
|
deleteIcon={<ExpandMoreIcon />}
|
||||||
onClick={handleClick}
|
onClick={handleClick}
|
||||||
onDelete={handleClick}
|
onDelete={handleClick}
|
||||||
/>
|
/>
|
||||||
|
{props.taskId && <StyledBreadcrumb label={`task:${props.taskId}`} />}
|
||||||
</Breadcrumbs>
|
</Breadcrumbs>
|
||||||
<Menu
|
<Menu
|
||||||
id="queue-breadcrumb-menu"
|
id="queue-breadcrumb-menu"
|
||||||
|
|||||||
@@ -1,14 +1,16 @@
|
|||||||
import React, { useMemo } from "react";
|
import React, { useMemo, useEffect } from "react";
|
||||||
import { connect, ConnectedProps } from "react-redux";
|
import { connect, ConnectedProps } from "react-redux";
|
||||||
import { makeStyles } from "@material-ui/core/styles";
|
import { makeStyles } from "@material-ui/core/styles";
|
||||||
import Container from "@material-ui/core/Container";
|
import Container from "@material-ui/core/Container";
|
||||||
import Grid from "@material-ui/core/Grid";
|
import Grid from "@material-ui/core/Grid";
|
||||||
import Typography from "@material-ui/core/Typography";
|
import Typography from "@material-ui/core/Typography";
|
||||||
import { useParams } from "react-router-dom";
|
import { useParams } from "react-router-dom";
|
||||||
|
import QueueBreadCrumb from "../components/QueueBreadcrumb";
|
||||||
import { AppState } from "../store";
|
import { AppState } from "../store";
|
||||||
import { getTaskInfoAsync } from "../actions/tasksActions";
|
import { getTaskInfoAsync } from "../actions/tasksActions";
|
||||||
import { TaskDetailsRouteParams } from "../paths";
|
import { TaskDetailsRouteParams } from "../paths";
|
||||||
import { usePolling } from "../hooks";
|
import { usePolling } from "../hooks";
|
||||||
|
import { listQueuesAsync } from "../actions/queuesActions";
|
||||||
|
|
||||||
function mapStateToProps(state: AppState) {
|
function mapStateToProps(state: AppState) {
|
||||||
return {
|
return {
|
||||||
@@ -16,15 +18,22 @@ function mapStateToProps(state: AppState) {
|
|||||||
error: state.tasks.taskInfo.error,
|
error: state.tasks.taskInfo.error,
|
||||||
taskInfo: state.tasks.taskInfo.data,
|
taskInfo: state.tasks.taskInfo.data,
|
||||||
pollInterval: state.settings.pollInterval,
|
pollInterval: state.settings.pollInterval,
|
||||||
|
queues: state.queues.data.map((q) => q.name), // FIXME: This data may not be available
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
const connector = connect(mapStateToProps, { getTaskInfoAsync });
|
const connector = connect(mapStateToProps, {
|
||||||
|
getTaskInfoAsync,
|
||||||
|
listQueuesAsync,
|
||||||
|
});
|
||||||
|
|
||||||
const useStyles = makeStyles((theme) => ({
|
const useStyles = makeStyles((theme) => ({
|
||||||
container: {
|
container: {
|
||||||
paddingTop: theme.spacing(2),
|
paddingTop: theme.spacing(2),
|
||||||
},
|
},
|
||||||
|
breadcrumbs: {
|
||||||
|
marginBottom: theme.spacing(2),
|
||||||
|
},
|
||||||
}));
|
}));
|
||||||
|
|
||||||
type Props = ConnectedProps<typeof connector>;
|
type Props = ConnectedProps<typeof connector>;
|
||||||
@@ -32,7 +41,7 @@ type Props = ConnectedProps<typeof connector>;
|
|||||||
function TaskDetailsView(props: Props) {
|
function TaskDetailsView(props: Props) {
|
||||||
const classes = useStyles();
|
const classes = useStyles();
|
||||||
const { qname, taskId } = useParams<TaskDetailsRouteParams>();
|
const { qname, taskId } = useParams<TaskDetailsRouteParams>();
|
||||||
const { getTaskInfoAsync, pollInterval } = props;
|
const { getTaskInfoAsync, pollInterval, listQueuesAsync } = props;
|
||||||
|
|
||||||
const fetchTaskInfo = useMemo(() => {
|
const fetchTaskInfo = useMemo(() => {
|
||||||
return () => {
|
return () => {
|
||||||
@@ -42,9 +51,21 @@ function TaskDetailsView(props: Props) {
|
|||||||
|
|
||||||
usePolling(fetchTaskInfo, pollInterval);
|
usePolling(fetchTaskInfo, pollInterval);
|
||||||
|
|
||||||
|
// Fetch queues data to populate props.queues
|
||||||
|
useEffect(() => {
|
||||||
|
listQueuesAsync();
|
||||||
|
}, [listQueuesAsync]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Container maxWidth="lg" className={classes.container}>
|
<Container maxWidth="lg" className={classes.container}>
|
||||||
<Grid container spacing={3}>
|
<Grid container spacing={0}>
|
||||||
|
<Grid item xs={12} className={classes.breadcrumbs}>
|
||||||
|
<QueueBreadCrumb
|
||||||
|
queues={props.queues}
|
||||||
|
queueName={qname}
|
||||||
|
taskId={taskId}
|
||||||
|
/>
|
||||||
|
</Grid>
|
||||||
<Grid item xs={12}>
|
<Grid item xs={12}>
|
||||||
<Typography>
|
<Typography>
|
||||||
Task Details View Queue: {qname} TaskID: {taskId}
|
Task Details View Queue: {qname} TaskID: {taskId}
|
||||||
|
|||||||
@@ -51,7 +51,6 @@ function TasksView(props: ConnectedProps<typeof connector>) {
|
|||||||
}
|
}
|
||||||
const { listQueuesAsync } = props;
|
const { listQueuesAsync } = props;
|
||||||
|
|
||||||
// Shoudn't we polling here?
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
listQueuesAsync();
|
listQueuesAsync();
|
||||||
}, [listQueuesAsync]);
|
}, [listQueuesAsync]);
|
||||||
@@ -60,7 +59,7 @@ function TasksView(props: ConnectedProps<typeof connector>) {
|
|||||||
<Container maxWidth="lg">
|
<Container maxWidth="lg">
|
||||||
<Grid container spacing={0} className={classes.container}>
|
<Grid container spacing={0} className={classes.container}>
|
||||||
<Grid item xs={12} className={classes.breadcrumbs}>
|
<Grid item xs={12} className={classes.breadcrumbs}>
|
||||||
<QueueBreadCrumb queues={props.queues} selectedQueue={qname} />
|
<QueueBreadCrumb queues={props.queues} queueName={qname} />
|
||||||
</Grid>
|
</Grid>
|
||||||
<Grid item xs={12} className={classes.banner}>
|
<Grid item xs={12} className={classes.banner}>
|
||||||
<QueueInfoBanner qname={qname} />
|
<QueueInfoBanner qname={qname} />
|
||||||
|
|||||||
Reference in New Issue
Block a user