mirror of
https://github.com/rocky-linux/peridot.git
synced 2024-11-21 12:41:27 +00:00
Add Cancel button to running tasks
This commit is contained in:
parent
115bc2df5c
commit
beae4446aa
@ -40,6 +40,7 @@ import { packageApi, taskApi } from 'peridot/ui/src/api';
|
|||||||
import {
|
import {
|
||||||
V1GetTaskResponse,
|
V1GetTaskResponse,
|
||||||
V1TaskType,
|
V1TaskType,
|
||||||
|
V1TaskStatus,
|
||||||
} from 'bazel-bin/peridot/proto/v1/client_typescript';
|
} from 'bazel-bin/peridot/proto/v1/client_typescript';
|
||||||
import { ToolbarHeader } from 'common/mui/ToolbarHeader';
|
import { ToolbarHeader } from 'common/mui/ToolbarHeader';
|
||||||
import Divider from '@mui/material/Divider';
|
import Divider from '@mui/material/Divider';
|
||||||
@ -54,12 +55,14 @@ import TabContext from '@mui/lab/TabContext';
|
|||||||
import TabList from '@mui/lab/TabList';
|
import TabList from '@mui/lab/TabList';
|
||||||
import Box from '@mui/material/Box';
|
import Box from '@mui/material/Box';
|
||||||
import Tab from '@mui/material/Tab';
|
import Tab from '@mui/material/Tab';
|
||||||
|
import Button from '@mui/material/Button';
|
||||||
import TabPanel from '@mui/lab/TabPanel';
|
import TabPanel from '@mui/lab/TabPanel';
|
||||||
import ProjectTaskFullLog from 'peridot/ui/src/components/ProjectTaskFullLog';
|
import ProjectTaskFullLog from 'peridot/ui/src/components/ProjectTaskFullLog';
|
||||||
import { RemoteErrors } from 'common/ui/types';
|
import { RemoteErrors } from 'common/ui/types';
|
||||||
import Tabs from '@mui/material/Tabs';
|
import Tabs from '@mui/material/Tabs';
|
||||||
import Toolbar from '@mui/material/Toolbar';
|
import Toolbar from '@mui/material/Toolbar';
|
||||||
import { ProjectTasksSubtasks } from 'peridot/ui/src/components/ProjectTasksSubtasks';
|
import { ProjectTasksSubtasks } from 'peridot/ui/src/components/ProjectTasksSubtasks';
|
||||||
|
import { reqap } from 'common/ui/reqap';
|
||||||
|
|
||||||
export interface ProjectPackageDetailsRouteProps {
|
export interface ProjectPackageDetailsRouteProps {
|
||||||
id: string;
|
id: string;
|
||||||
@ -77,6 +80,7 @@ export default function (
|
|||||||
V1GetTaskResponse | undefined | null | RemoteErrors
|
V1GetTaskResponse | undefined | null | RemoteErrors
|
||||||
>(undefined);
|
>(undefined);
|
||||||
const [tabValue, setTabValue] = React.useState('1');
|
const [tabValue, setTabValue] = React.useState('1');
|
||||||
|
const [submitting, setSubmitting] = React.useState(false);
|
||||||
|
|
||||||
const handleTabValueChange = (event, newValue) => {
|
const handleTabValueChange = (event, newValue) => {
|
||||||
setTabValue(newValue);
|
setTabValue(newValue);
|
||||||
@ -91,6 +95,26 @@ export default function (
|
|||||||
setTaskRes
|
setTaskRes
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const cancelTask = async () => {
|
||||||
|
if (!confirm('Are you sure you want to cancel this task?')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
setSubmitting(true);
|
||||||
|
const [err, res] = await reqap(() =>
|
||||||
|
taskApi.cancelTask({
|
||||||
|
id: props.match.params.id,
|
||||||
|
projectId: project.id || '',
|
||||||
|
})
|
||||||
|
);
|
||||||
|
if (err) {
|
||||||
|
alert(err);
|
||||||
|
setSubmitting(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
window.location.reload();
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{suspenseRemoteResource(taskRes, (res) => {
|
{suspenseRemoteResource(taskRes, (res) => {
|
||||||
@ -119,6 +143,7 @@ export default function (
|
|||||||
</div>
|
</div>
|
||||||
</ToolbarHeader>
|
</ToolbarHeader>
|
||||||
<Divider />
|
<Divider />
|
||||||
|
<div className="w-full flex items-center justify-between bg-white">
|
||||||
<div className="w-full bg-white flex divide-x divide-gray-100">
|
<div className="w-full bg-white flex divide-x divide-gray-100">
|
||||||
<div className="p-5 w-128 space-y-1">
|
<div className="p-5 w-128 space-y-1">
|
||||||
<h2 className="font-bold text-lg">Type</h2>
|
<h2 className="font-bold text-lg">Type</h2>
|
||||||
@ -145,6 +170,20 @@ export default function (
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
{!parentTask.parentTaskId &&
|
||||||
|
parentTask.status == V1TaskStatus.Running && (
|
||||||
|
<div className="p-5">
|
||||||
|
<Button
|
||||||
|
variant="contained"
|
||||||
|
disabled={submitting}
|
||||||
|
color="error"
|
||||||
|
onClick={cancelTask}
|
||||||
|
>
|
||||||
|
Cancel
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
<Divider />
|
<Divider />
|
||||||
<Box className="bg-white">
|
<Box className="bg-white">
|
||||||
<Tabs value={tabValue} onChange={handleTabValueChange}>
|
<Tabs value={tabValue} onChange={handleTabValueChange}>
|
||||||
|
@ -1 +1 @@
|
|||||||
rules_byc/internal/byc_bundle/tsconfig.json
|
rules_resf/internal/resf_bundle/tsconfig.json
|
Loading…
Reference in New Issue
Block a user