feat(commit-list): stop task.
This commit is contained in:
parent
6bc9f787f3
commit
dee2c97ba4
@ -3,6 +3,7 @@ import { Link, useResponse, useRouter } from "@curi/react-dom";
|
|||||||
import { faPlayCircle, faVial } from "@fortawesome/free-solid-svg-icons";
|
import { faPlayCircle, faVial } from "@fortawesome/free-solid-svg-icons";
|
||||||
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
||||||
import {
|
import {
|
||||||
|
Backdrop,
|
||||||
CircularProgress,
|
CircularProgress,
|
||||||
Collapse,
|
Collapse,
|
||||||
IconButton,
|
IconButton,
|
||||||
@ -14,12 +15,14 @@ import {
|
|||||||
ListItemText,
|
ListItemText,
|
||||||
makeStyles,
|
makeStyles,
|
||||||
useTheme,
|
useTheme,
|
||||||
|
withStyles,
|
||||||
} from "@material-ui/core";
|
} from "@material-ui/core";
|
||||||
import {
|
import {
|
||||||
Cancel,
|
Cancel,
|
||||||
CheckCircle,
|
CheckCircle,
|
||||||
CloudDownload,
|
CloudDownload,
|
||||||
ShoppingCart,
|
ShoppingCart,
|
||||||
|
Stop,
|
||||||
Timer,
|
Timer,
|
||||||
} from "@material-ui/icons";
|
} from "@material-ui/icons";
|
||||||
import { format } from "date-fns";
|
import { format } from "date-fns";
|
||||||
@ -28,6 +31,7 @@ import { complement, equals, find, propEq, takeWhile } from "ramda";
|
|||||||
import {
|
import {
|
||||||
FC,
|
FC,
|
||||||
Fragment,
|
Fragment,
|
||||||
|
MouseEventHandler,
|
||||||
ReactNode,
|
ReactNode,
|
||||||
useCallback,
|
useCallback,
|
||||||
useMemo,
|
useMemo,
|
||||||
@ -41,7 +45,7 @@ import {
|
|||||||
TaskStatuses,
|
TaskStatuses,
|
||||||
PipelineUnits,
|
PipelineUnits,
|
||||||
} from "../generated/graphql";
|
} from "../generated/graphql";
|
||||||
import { CREATE_PIPELINE_TASK } from "./mutations";
|
import { CREATE_PIPELINE_TASK, STOP_PIPELINE_TASK } from "./mutations";
|
||||||
import { COMMITS } from "./queries";
|
import { COMMITS } from "./queries";
|
||||||
import { SYNC_COMMITS } from "./subscriptions";
|
import { SYNC_COMMITS } from "./subscriptions";
|
||||||
|
|
||||||
@ -229,6 +233,20 @@ const TaskItem: FC<{ task: PipelineTask }> = ({ task }) => {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
|
const [stopTask, { loading: stopTaskWaiting }] = useMutation(
|
||||||
|
STOP_PIPELINE_TASK,
|
||||||
|
{
|
||||||
|
variables: { taskId: task.id },
|
||||||
|
}
|
||||||
|
);
|
||||||
|
const stop: MouseEventHandler = useCallback(
|
||||||
|
(event) => {
|
||||||
|
event.stopPropagation();
|
||||||
|
event.preventDefault();
|
||||||
|
stopTask();
|
||||||
|
},
|
||||||
|
[stopTask]
|
||||||
|
);
|
||||||
return (
|
return (
|
||||||
<ListItem button className={classes.nested}>
|
<ListItem button className={classes.nested}>
|
||||||
<ListItemIcon>{statusIcon}</ListItemIcon>
|
<ListItemIcon>{statusIcon}</ListItemIcon>
|
||||||
@ -237,6 +255,20 @@ const TaskItem: FC<{ task: PipelineTask }> = ({ task }) => {
|
|||||||
task.startedAt && format(task.startedAt, "yyyy-MM-dd HH:mm:ss")
|
task.startedAt && format(task.startedAt, "yyyy-MM-dd HH:mm:ss")
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
|
<ListItemSecondaryAction>
|
||||||
|
{task.status === TaskStatuses.Working && (
|
||||||
|
<IconButton edge="end" aria-label="stop" onClick={stop}>
|
||||||
|
<Stop />
|
||||||
|
</IconButton>
|
||||||
|
)}
|
||||||
|
</ListItemSecondaryAction>
|
||||||
|
<LimitedBackdrop open={stopTaskWaiting} />
|
||||||
</ListItem>
|
</ListItem>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
const LimitedBackdrop = withStyles({
|
||||||
|
root: {
|
||||||
|
position: "absolute",
|
||||||
|
zIndex: 1,
|
||||||
|
},
|
||||||
|
})(Backdrop);
|
||||||
|
@ -9,4 +9,9 @@ export const CREATE_PIPELINE_TASK = gql`
|
|||||||
endedAt
|
endedAt
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
`
|
`;
|
||||||
|
export const STOP_PIPELINE_TASK = gql`
|
||||||
|
mutation StopPipelineTask($taskId: String!) {
|
||||||
|
stopPipelineTask(id: $taskId)
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
@ -1144,6 +1144,22 @@
|
|||||||
},
|
},
|
||||||
"isDeprecated": false,
|
"isDeprecated": false,
|
||||||
"deprecationReason": null
|
"deprecationReason": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "runOn",
|
||||||
|
"description": null,
|
||||||
|
"args": [],
|
||||||
|
"type": {
|
||||||
|
"kind": "NON_NULL",
|
||||||
|
"name": null,
|
||||||
|
"ofType": {
|
||||||
|
"kind": "SCALAR",
|
||||||
|
"name": "String",
|
||||||
|
"ofType": null
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"isDeprecated": false,
|
||||||
|
"deprecationReason": null
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"inputFields": null,
|
"inputFields": null,
|
||||||
|
@ -138,6 +138,7 @@ export type PipelineTask = {
|
|||||||
status: TaskStatuses;
|
status: TaskStatuses;
|
||||||
startedAt?: Maybe<Scalars['DateTime']>;
|
startedAt?: Maybe<Scalars['DateTime']>;
|
||||||
endedAt?: Maybe<Scalars['DateTime']>;
|
endedAt?: Maybe<Scalars['DateTime']>;
|
||||||
|
runOn: Scalars['String'];
|
||||||
};
|
};
|
||||||
|
|
||||||
export type PipelineTaskEvent = {
|
export type PipelineTaskEvent = {
|
||||||
|
Loading…
Reference in New Issue
Block a user