apache-airflow-providers-edge3 1.2.0__py3-none-any.whl → 1.3.0rc1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- airflow/providers/edge3/__init__.py +1 -1
- airflow/providers/edge3/cli/edge_command.py +43 -0
- airflow/providers/edge3/cli/worker.py +40 -40
- airflow/providers/edge3/models/edge_worker.py +13 -8
- airflow/providers/edge3/openapi/v2-edge-generated.yaml +249 -0
- airflow/providers/edge3/plugins/www/dist/main.umd.cjs +53 -19
- airflow/providers/edge3/plugins/www/openapi-gen/queries/common.ts +7 -0
- airflow/providers/edge3/plugins/www/openapi-gen/queries/queries.ts +44 -1
- airflow/providers/edge3/plugins/www/openapi-gen/requests/schemas.gen.ts +14 -0
- airflow/providers/edge3/plugins/www/openapi-gen/requests/services.gen.ts +158 -1
- airflow/providers/edge3/plugins/www/openapi-gen/requests/types.gen.ts +155 -0
- airflow/providers/edge3/plugins/www/package.json +14 -10
- airflow/providers/edge3/plugins/www/pnpm-lock.yaml +601 -457
- airflow/providers/edge3/plugins/www/src/components/AddQueueButton.tsx +138 -0
- airflow/providers/edge3/plugins/www/src/components/MaintenanceEditCommentButton.tsx +106 -0
- airflow/providers/edge3/plugins/www/src/components/MaintenanceEnterButton.tsx +102 -0
- airflow/providers/edge3/plugins/www/src/components/MaintenanceExitButton.tsx +92 -0
- airflow/providers/edge3/plugins/www/src/components/RemoveQueueButton.tsx +151 -0
- airflow/providers/edge3/plugins/www/src/components/WorkerDeleteButton.tsx +104 -0
- airflow/providers/edge3/plugins/www/src/components/WorkerOperations.tsx +85 -0
- airflow/providers/edge3/plugins/www/src/components/WorkerShutdownButton.tsx +104 -0
- airflow/providers/edge3/plugins/www/src/components/WorkerStateBadge.tsx +33 -0
- airflow/providers/edge3/plugins/www/src/components/ui/ScrollToAnchor.tsx +49 -0
- airflow/providers/edge3/plugins/www/src/components/ui/createToaster.ts +24 -0
- airflow/providers/edge3/plugins/www/src/components/ui/index.ts +2 -0
- airflow/providers/edge3/plugins/www/src/context/colorMode/ColorModeProvider.tsx +1 -2
- airflow/providers/edge3/plugins/www/src/context/colorMode/useColorMode.tsx +2 -5
- airflow/providers/edge3/plugins/www/src/pages/JobsPage.tsx +52 -15
- airflow/providers/edge3/plugins/www/src/pages/WorkerPage.tsx +52 -22
- airflow/providers/edge3/plugins/www/src/theme.ts +378 -130
- airflow/providers/edge3/plugins/www/vite.config.ts +2 -0
- airflow/providers/edge3/worker_api/datamodels_ui.py +12 -0
- airflow/providers/edge3/worker_api/routes/ui.py +193 -3
- {apache_airflow_providers_edge3-1.2.0.dist-info → apache_airflow_providers_edge3-1.3.0rc1.dist-info}/METADATA +7 -7
- {apache_airflow_providers_edge3-1.2.0.dist-info → apache_airflow_providers_edge3-1.3.0rc1.dist-info}/RECORD +37 -27
- {apache_airflow_providers_edge3-1.2.0.dist-info → apache_airflow_providers_edge3-1.3.0rc1.dist-info}/WHEEL +0 -0
- {apache_airflow_providers_edge3-1.2.0.dist-info → apache_airflow_providers_edge3-1.3.0rc1.dist-info}/entry_points.txt +0 -0
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Licensed to the Apache Software Foundation (ASF) under one
|
|
3
|
+
* or more contributor license agreements. See the NOTICE file
|
|
4
|
+
* distributed with this work for additional information
|
|
5
|
+
* regarding copyright ownership. The ASF licenses this file
|
|
6
|
+
* to you under the Apache License, Version 2.0 (the
|
|
7
|
+
* "License"); you may not use this file except in compliance
|
|
8
|
+
* with the License. You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing,
|
|
13
|
+
* software distributed under the License is distributed on an
|
|
14
|
+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
15
|
+
* KIND, either express or implied. See the License for the
|
|
16
|
+
* specific language governing permissions and limitations
|
|
17
|
+
* under the License.
|
|
18
|
+
*/
|
|
19
|
+
import {
|
|
20
|
+
Button,
|
|
21
|
+
CloseButton,
|
|
22
|
+
Dialog,
|
|
23
|
+
Input,
|
|
24
|
+
IconButton,
|
|
25
|
+
Portal,
|
|
26
|
+
Text,
|
|
27
|
+
useDisclosure,
|
|
28
|
+
VStack,
|
|
29
|
+
} from "@chakra-ui/react";
|
|
30
|
+
import { useUiServiceAddWorkerQueue } from "openapi/queries";
|
|
31
|
+
import { useState } from "react";
|
|
32
|
+
import { LuListPlus } from "react-icons/lu";
|
|
33
|
+
|
|
34
|
+
interface AddQueueButtonProps {
|
|
35
|
+
onQueueUpdate: (toast: Record<string, string>) => void;
|
|
36
|
+
workerName: string;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export const AddQueueButton = ({ onQueueUpdate, workerName }: AddQueueButtonProps) => {
|
|
40
|
+
const { onClose, onOpen, open } = useDisclosure();
|
|
41
|
+
const [queueName, setQueueName] = useState("");
|
|
42
|
+
|
|
43
|
+
const addQueueMutation = useUiServiceAddWorkerQueue({
|
|
44
|
+
onError: (error) => {
|
|
45
|
+
onQueueUpdate({
|
|
46
|
+
description: `Unable to add queue to worker ${workerName}: ${error}`,
|
|
47
|
+
title: "Add Queue Failed",
|
|
48
|
+
type: "error",
|
|
49
|
+
});
|
|
50
|
+
},
|
|
51
|
+
onSuccess: () => {
|
|
52
|
+
onQueueUpdate({
|
|
53
|
+
description: `Queue "${queueName}" was added to worker ${workerName}.`,
|
|
54
|
+
title: "Queue Added",
|
|
55
|
+
type: "success",
|
|
56
|
+
});
|
|
57
|
+
onClose();
|
|
58
|
+
setQueueName("");
|
|
59
|
+
},
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
const handleAddQueue = () => {
|
|
63
|
+
if (!queueName.trim()) {
|
|
64
|
+
onQueueUpdate({
|
|
65
|
+
description: "Please enter a queue name.",
|
|
66
|
+
title: "Invalid Input",
|
|
67
|
+
type: "error",
|
|
68
|
+
});
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
addQueueMutation.mutate({
|
|
73
|
+
queueName: queueName.trim(),
|
|
74
|
+
workerName,
|
|
75
|
+
});
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
return (
|
|
79
|
+
<>
|
|
80
|
+
<IconButton
|
|
81
|
+
size="sm"
|
|
82
|
+
variant="ghost"
|
|
83
|
+
onClick={onOpen}
|
|
84
|
+
aria-label="Add Queue"
|
|
85
|
+
title="Add Queue"
|
|
86
|
+
colorPalette="success"
|
|
87
|
+
>
|
|
88
|
+
<LuListPlus />
|
|
89
|
+
</IconButton>
|
|
90
|
+
|
|
91
|
+
<Dialog.Root onOpenChange={onClose} open={open} size="md">
|
|
92
|
+
<Portal>
|
|
93
|
+
<Dialog.Backdrop />
|
|
94
|
+
<Dialog.Positioner>
|
|
95
|
+
<Dialog.Content>
|
|
96
|
+
<Dialog.Header>
|
|
97
|
+
<Dialog.Title>Add Queue to {workerName}</Dialog.Title>
|
|
98
|
+
</Dialog.Header>
|
|
99
|
+
<Dialog.Body>
|
|
100
|
+
<VStack gap={4} align="stretch">
|
|
101
|
+
<Text>Enter the name of the queue to add to this worker:</Text>
|
|
102
|
+
<Input
|
|
103
|
+
placeholder="Queue name"
|
|
104
|
+
value={queueName}
|
|
105
|
+
onChange={(e) => setQueueName(e.target.value)}
|
|
106
|
+
onKeyDown={(e) => {
|
|
107
|
+
if (e.key === "Enter") {
|
|
108
|
+
handleAddQueue();
|
|
109
|
+
}
|
|
110
|
+
}}
|
|
111
|
+
/>
|
|
112
|
+
</VStack>
|
|
113
|
+
</Dialog.Body>
|
|
114
|
+
<Dialog.Footer>
|
|
115
|
+
<Dialog.ActionTrigger asChild>
|
|
116
|
+
<Button variant="outline">Cancel</Button>
|
|
117
|
+
</Dialog.ActionTrigger>
|
|
118
|
+
<Button
|
|
119
|
+
onClick={handleAddQueue}
|
|
120
|
+
colorPalette="success"
|
|
121
|
+
loading={addQueueMutation.isPending}
|
|
122
|
+
loadingText="Adding queue..."
|
|
123
|
+
disabled={!queueName.trim()}
|
|
124
|
+
>
|
|
125
|
+
<LuListPlus />
|
|
126
|
+
Add Queue
|
|
127
|
+
</Button>
|
|
128
|
+
</Dialog.Footer>
|
|
129
|
+
<Dialog.CloseTrigger asChild>
|
|
130
|
+
<CloseButton size="sm" />
|
|
131
|
+
</Dialog.CloseTrigger>
|
|
132
|
+
</Dialog.Content>
|
|
133
|
+
</Dialog.Positioner>
|
|
134
|
+
</Portal>
|
|
135
|
+
</Dialog.Root>
|
|
136
|
+
</>
|
|
137
|
+
);
|
|
138
|
+
};
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Licensed to the Apache Software Foundation (ASF) under one
|
|
3
|
+
* or more contributor license agreements. See the NOTICE file
|
|
4
|
+
* distributed with this work for additional information
|
|
5
|
+
* regarding copyright ownership. The ASF licenses this file
|
|
6
|
+
* to you under the Apache License, Version 2.0 (the
|
|
7
|
+
* "License"); you may not use this file except in compliance
|
|
8
|
+
* with the License. You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing,
|
|
13
|
+
* software distributed under the License is distributed on an
|
|
14
|
+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
15
|
+
* KIND, either express or implied. See the License for the
|
|
16
|
+
* specific language governing permissions and limitations
|
|
17
|
+
* under the License.
|
|
18
|
+
*/
|
|
19
|
+
import { Button, CloseButton, Dialog, IconButton, Portal, Textarea, useDisclosure } from "@chakra-ui/react";
|
|
20
|
+
import { useUiServiceUpdateWorkerMaintenance } from "openapi/queries";
|
|
21
|
+
import { useState } from "react";
|
|
22
|
+
import { FiEdit } from "react-icons/fi";
|
|
23
|
+
|
|
24
|
+
interface MaintenanceEditCommentButtonProps {
|
|
25
|
+
onEditComment: (toast: Record<string, string>) => void;
|
|
26
|
+
workerName: string;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export const MaintenanceEditCommentButton = ({
|
|
30
|
+
onEditComment,
|
|
31
|
+
workerName,
|
|
32
|
+
}: MaintenanceEditCommentButtonProps) => {
|
|
33
|
+
const { onClose, onOpen, open } = useDisclosure();
|
|
34
|
+
const [comment, setComment] = useState("");
|
|
35
|
+
|
|
36
|
+
const editCommentMutation = useUiServiceUpdateWorkerMaintenance({
|
|
37
|
+
onError: (error) => {
|
|
38
|
+
onEditComment({
|
|
39
|
+
description: `Unable to update comments for worker ${workerName}: ${error}`,
|
|
40
|
+
title: "Updating Comments failed",
|
|
41
|
+
type: "error",
|
|
42
|
+
});
|
|
43
|
+
},
|
|
44
|
+
onSuccess: () => {
|
|
45
|
+
onEditComment({
|
|
46
|
+
description: `Worker maintenance comments for ${workerName} were updated.`,
|
|
47
|
+
title: "Maintenance Comments updated",
|
|
48
|
+
type: "success",
|
|
49
|
+
});
|
|
50
|
+
onClose();
|
|
51
|
+
},
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
const editComment = () => {
|
|
55
|
+
editCommentMutation.mutate({ requestBody: { maintenance_comment: comment }, workerName });
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
return (
|
|
59
|
+
<>
|
|
60
|
+
<IconButton
|
|
61
|
+
size="sm"
|
|
62
|
+
variant="ghost"
|
|
63
|
+
aria-label="Edit Comments"
|
|
64
|
+
title="Edit Comments"
|
|
65
|
+
onClick={onOpen}
|
|
66
|
+
colorPalette="warning"
|
|
67
|
+
>
|
|
68
|
+
<FiEdit />
|
|
69
|
+
</IconButton>
|
|
70
|
+
|
|
71
|
+
<Dialog.Root onOpenChange={onClose} open={open} size="md">
|
|
72
|
+
<Portal>
|
|
73
|
+
<Dialog.Backdrop />
|
|
74
|
+
<Dialog.Positioner>
|
|
75
|
+
<Dialog.Content>
|
|
76
|
+
<Dialog.Header>
|
|
77
|
+
<Dialog.Title>Edit maintenance comments for worker {workerName}</Dialog.Title>
|
|
78
|
+
</Dialog.Header>
|
|
79
|
+
<Dialog.Body>
|
|
80
|
+
<Textarea
|
|
81
|
+
placeholder="Change maintenance comment (required)"
|
|
82
|
+
value={comment}
|
|
83
|
+
onChange={(e) => setComment(e.target.value)}
|
|
84
|
+
required
|
|
85
|
+
maxLength={1024}
|
|
86
|
+
size="sm"
|
|
87
|
+
/>
|
|
88
|
+
</Dialog.Body>
|
|
89
|
+
<Dialog.Footer>
|
|
90
|
+
<Dialog.ActionTrigger asChild>
|
|
91
|
+
<Button variant="outline">Cancel</Button>
|
|
92
|
+
</Dialog.ActionTrigger>
|
|
93
|
+
<Button onClick={editComment} disabled={!comment.trim()}>
|
|
94
|
+
Update Comments
|
|
95
|
+
</Button>
|
|
96
|
+
</Dialog.Footer>
|
|
97
|
+
<Dialog.CloseTrigger asChild>
|
|
98
|
+
<CloseButton size="sm" />
|
|
99
|
+
</Dialog.CloseTrigger>
|
|
100
|
+
</Dialog.Content>
|
|
101
|
+
</Dialog.Positioner>
|
|
102
|
+
</Portal>
|
|
103
|
+
</Dialog.Root>
|
|
104
|
+
</>
|
|
105
|
+
);
|
|
106
|
+
};
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Licensed to the Apache Software Foundation (ASF) under one
|
|
3
|
+
* or more contributor license agreements. See the NOTICE file
|
|
4
|
+
* distributed with this work for additional information
|
|
5
|
+
* regarding copyright ownership. The ASF licenses this file
|
|
6
|
+
* to you under the Apache License, Version 2.0 (the
|
|
7
|
+
* "License"); you may not use this file except in compliance
|
|
8
|
+
* with the License. You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing,
|
|
13
|
+
* software distributed under the License is distributed on an
|
|
14
|
+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
15
|
+
* KIND, either express or implied. See the License for the
|
|
16
|
+
* specific language governing permissions and limitations
|
|
17
|
+
* under the License.
|
|
18
|
+
*/
|
|
19
|
+
import { Button, CloseButton, Dialog, IconButton, Portal, Textarea, useDisclosure } from "@chakra-ui/react";
|
|
20
|
+
import { useUiServiceRequestWorkerMaintenance } from "openapi/queries";
|
|
21
|
+
import { useState } from "react";
|
|
22
|
+
import { HiOutlineWrenchScrewdriver } from "react-icons/hi2";
|
|
23
|
+
|
|
24
|
+
interface MaintenanceEnterButtonProps {
|
|
25
|
+
onEnterMaintenance: (toast: Record<string, string>) => void;
|
|
26
|
+
workerName: string;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export const MaintenanceEnterButton = ({ onEnterMaintenance, workerName }: MaintenanceEnterButtonProps) => {
|
|
30
|
+
const { onClose, onOpen, open } = useDisclosure();
|
|
31
|
+
const [comment, setComment] = useState("");
|
|
32
|
+
|
|
33
|
+
const enterMaintenanceMutation = useUiServiceRequestWorkerMaintenance({
|
|
34
|
+
onError: (error) => {
|
|
35
|
+
onEnterMaintenance({
|
|
36
|
+
description: `Unable to set worker ${workerName} to maintenance mode: ${error}`,
|
|
37
|
+
title: "Setting Maintenance Mode failed",
|
|
38
|
+
type: "error",
|
|
39
|
+
});
|
|
40
|
+
},
|
|
41
|
+
onSuccess: () => {
|
|
42
|
+
onEnterMaintenance({
|
|
43
|
+
description: `Worker ${workerName} was requested to be in maintenance mode.`,
|
|
44
|
+
title: "Maintenance Mode activated",
|
|
45
|
+
type: "success",
|
|
46
|
+
});
|
|
47
|
+
},
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
const enterMaintenance = () => {
|
|
51
|
+
enterMaintenanceMutation.mutate({ requestBody: { maintenance_comment: comment }, workerName });
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
return (
|
|
55
|
+
<>
|
|
56
|
+
<IconButton
|
|
57
|
+
size="sm"
|
|
58
|
+
variant="ghost"
|
|
59
|
+
aria-label="Enter Maintenance"
|
|
60
|
+
title="Enter Maintenance"
|
|
61
|
+
onClick={onOpen}
|
|
62
|
+
colorPalette="warning"
|
|
63
|
+
>
|
|
64
|
+
<HiOutlineWrenchScrewdriver />
|
|
65
|
+
</IconButton>
|
|
66
|
+
|
|
67
|
+
<Dialog.Root onOpenChange={onClose} open={open} size="md">
|
|
68
|
+
<Portal>
|
|
69
|
+
<Dialog.Backdrop />
|
|
70
|
+
<Dialog.Positioner>
|
|
71
|
+
<Dialog.Content>
|
|
72
|
+
<Dialog.Header>
|
|
73
|
+
<Dialog.Title>Set maintenance for worker {workerName}</Dialog.Title>
|
|
74
|
+
</Dialog.Header>
|
|
75
|
+
<Dialog.Body>
|
|
76
|
+
<Textarea
|
|
77
|
+
placeholder="Enter maintenance comment (required)"
|
|
78
|
+
value={comment}
|
|
79
|
+
onChange={(e) => setComment(e.target.value)}
|
|
80
|
+
required
|
|
81
|
+
maxLength={1024}
|
|
82
|
+
size="sm"
|
|
83
|
+
/>
|
|
84
|
+
</Dialog.Body>
|
|
85
|
+
<Dialog.Footer>
|
|
86
|
+
<Dialog.ActionTrigger asChild>
|
|
87
|
+
<Button variant="outline">Cancel</Button>
|
|
88
|
+
</Dialog.ActionTrigger>
|
|
89
|
+
<Button onClick={enterMaintenance} disabled={!comment.trim()}>
|
|
90
|
+
Confirm Maintenance
|
|
91
|
+
</Button>
|
|
92
|
+
</Dialog.Footer>
|
|
93
|
+
<Dialog.CloseTrigger asChild>
|
|
94
|
+
<CloseButton size="sm" />
|
|
95
|
+
</Dialog.CloseTrigger>
|
|
96
|
+
</Dialog.Content>
|
|
97
|
+
</Dialog.Positioner>
|
|
98
|
+
</Portal>
|
|
99
|
+
</Dialog.Root>
|
|
100
|
+
</>
|
|
101
|
+
);
|
|
102
|
+
};
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Licensed to the Apache Software Foundation (ASF) under one
|
|
3
|
+
* or more contributor license agreements. See the NOTICE file
|
|
4
|
+
* distributed with this work for additional information
|
|
5
|
+
* regarding copyright ownership. The ASF licenses this file
|
|
6
|
+
* to you under the Apache License, Version 2.0 (the
|
|
7
|
+
* "License"); you may not use this file except in compliance
|
|
8
|
+
* with the License. You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing,
|
|
13
|
+
* software distributed under the License is distributed on an
|
|
14
|
+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
15
|
+
* KIND, either express or implied. See the License for the
|
|
16
|
+
* specific language governing permissions and limitations
|
|
17
|
+
* under the License.
|
|
18
|
+
*/
|
|
19
|
+
import { Button, CloseButton, Dialog, IconButton, Portal, Text, useDisclosure } from "@chakra-ui/react";
|
|
20
|
+
import { useUiServiceExitWorkerMaintenance } from "openapi/queries";
|
|
21
|
+
import { IoMdExit } from "react-icons/io";
|
|
22
|
+
|
|
23
|
+
interface MaintenanceExitButtonProps {
|
|
24
|
+
onExitMaintenance: (toast: Record<string, string>) => void;
|
|
25
|
+
workerName: string;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export const MaintenanceExitButton = ({ onExitMaintenance, workerName }: MaintenanceExitButtonProps) => {
|
|
29
|
+
const { onClose, onOpen, open } = useDisclosure();
|
|
30
|
+
|
|
31
|
+
const exitMaintenanceMutation = useUiServiceExitWorkerMaintenance({
|
|
32
|
+
onError: (error) => {
|
|
33
|
+
onExitMaintenance({
|
|
34
|
+
description: `Unable to exit ${workerName} from maintenance mode: ${error}`,
|
|
35
|
+
title: "Exit Maintenance Mode failed",
|
|
36
|
+
type: "error",
|
|
37
|
+
});
|
|
38
|
+
},
|
|
39
|
+
onSuccess: () => {
|
|
40
|
+
onExitMaintenance({
|
|
41
|
+
description: `Worker ${workerName} was requested to exit maintenance mode.`,
|
|
42
|
+
title: "Maintenance Mode deactivated",
|
|
43
|
+
type: "success",
|
|
44
|
+
});
|
|
45
|
+
onClose();
|
|
46
|
+
},
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
const exitMaintenance = () => {
|
|
50
|
+
exitMaintenanceMutation.mutate({ workerName });
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
return (
|
|
54
|
+
<>
|
|
55
|
+
<IconButton
|
|
56
|
+
size="sm"
|
|
57
|
+
variant="ghost"
|
|
58
|
+
onClick={onOpen}
|
|
59
|
+
aria-label="Exit Maintenance"
|
|
60
|
+
title="Exit Maintenance"
|
|
61
|
+
colorPalette="warning"
|
|
62
|
+
>
|
|
63
|
+
<IoMdExit />
|
|
64
|
+
</IconButton>
|
|
65
|
+
|
|
66
|
+
<Dialog.Root onOpenChange={onClose} open={open} size="md">
|
|
67
|
+
<Portal>
|
|
68
|
+
<Dialog.Backdrop />
|
|
69
|
+
<Dialog.Positioner>
|
|
70
|
+
<Dialog.Content>
|
|
71
|
+
<Dialog.Header>
|
|
72
|
+
<Dialog.Title>Exit maintenance for worker {workerName}</Dialog.Title>
|
|
73
|
+
</Dialog.Header>
|
|
74
|
+
<Dialog.Body>
|
|
75
|
+
<Text>Are you sure you want to exit maintenance mode for worker {workerName}?</Text>
|
|
76
|
+
</Dialog.Body>
|
|
77
|
+
<Dialog.Footer>
|
|
78
|
+
<Dialog.ActionTrigger asChild>
|
|
79
|
+
<Button variant="outline">No</Button>
|
|
80
|
+
</Dialog.ActionTrigger>
|
|
81
|
+
<Button onClick={exitMaintenance}>Yes</Button>
|
|
82
|
+
</Dialog.Footer>
|
|
83
|
+
<Dialog.CloseTrigger asChild>
|
|
84
|
+
<CloseButton size="sm" />
|
|
85
|
+
</Dialog.CloseTrigger>
|
|
86
|
+
</Dialog.Content>
|
|
87
|
+
</Dialog.Positioner>
|
|
88
|
+
</Portal>
|
|
89
|
+
</Dialog.Root>
|
|
90
|
+
</>
|
|
91
|
+
);
|
|
92
|
+
};
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Licensed to the Apache Software Foundation (ASF) under one
|
|
3
|
+
* or more contributor license agreements. See the NOTICE file
|
|
4
|
+
* distributed with this work for additional information
|
|
5
|
+
* regarding copyright ownership. The ASF licenses this file
|
|
6
|
+
* to you under the Apache License, Version 2.0 (the
|
|
7
|
+
* "License"); you may not use this file except in compliance
|
|
8
|
+
* with the License. You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing,
|
|
13
|
+
* software distributed under the License is distributed on an
|
|
14
|
+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
15
|
+
* KIND, either express or implied. See the License for the
|
|
16
|
+
* specific language governing permissions and limitations
|
|
17
|
+
* under the License.
|
|
18
|
+
*/
|
|
19
|
+
import {
|
|
20
|
+
Button,
|
|
21
|
+
CloseButton,
|
|
22
|
+
Dialog,
|
|
23
|
+
IconButton,
|
|
24
|
+
Portal,
|
|
25
|
+
Text,
|
|
26
|
+
useDisclosure,
|
|
27
|
+
VStack,
|
|
28
|
+
For,
|
|
29
|
+
} from "@chakra-ui/react";
|
|
30
|
+
import { useUiServiceRemoveWorkerQueue } from "openapi/queries";
|
|
31
|
+
import type { Worker } from "openapi/requests/types.gen";
|
|
32
|
+
import { useState } from "react";
|
|
33
|
+
import { LuListMinus } from "react-icons/lu";
|
|
34
|
+
|
|
35
|
+
interface RemoveQueueButtonProps {
|
|
36
|
+
onQueueUpdate: (toast: Record<string, string>) => void;
|
|
37
|
+
worker: Worker;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export const RemoveQueueButton = ({ onQueueUpdate, worker }: RemoveQueueButtonProps) => {
|
|
41
|
+
const { onClose, onOpen, open } = useDisclosure();
|
|
42
|
+
const [selectedQueue, setSelectedQueue] = useState<string>("");
|
|
43
|
+
|
|
44
|
+
const removeQueueMutation = useUiServiceRemoveWorkerQueue({
|
|
45
|
+
onError: (error) => {
|
|
46
|
+
onQueueUpdate({
|
|
47
|
+
description: `Unable to remove queue from worker ${worker.worker_name}: ${error}`,
|
|
48
|
+
title: "Remove Queue Failed",
|
|
49
|
+
type: "error",
|
|
50
|
+
});
|
|
51
|
+
},
|
|
52
|
+
onSuccess: () => {
|
|
53
|
+
onQueueUpdate({
|
|
54
|
+
description: `Queue "${selectedQueue}" was removed from worker ${worker.worker_name}.`,
|
|
55
|
+
title: "Queue Removed",
|
|
56
|
+
type: "success",
|
|
57
|
+
});
|
|
58
|
+
onClose();
|
|
59
|
+
setSelectedQueue("");
|
|
60
|
+
},
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
const handleRemoveQueue = () => {
|
|
64
|
+
if (!selectedQueue) {
|
|
65
|
+
onQueueUpdate({
|
|
66
|
+
description: "Please select a queue to remove.",
|
|
67
|
+
title: "Invalid Selection",
|
|
68
|
+
type: "error",
|
|
69
|
+
});
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
removeQueueMutation.mutate({
|
|
74
|
+
queueName: selectedQueue,
|
|
75
|
+
workerName: worker.worker_name,
|
|
76
|
+
});
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
const availableQueues = worker.queues || [];
|
|
80
|
+
|
|
81
|
+
// Don't render the button if there are no queues to remove
|
|
82
|
+
if (availableQueues.length === 0) {
|
|
83
|
+
return null;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
return (
|
|
87
|
+
<>
|
|
88
|
+
<IconButton
|
|
89
|
+
size="sm"
|
|
90
|
+
variant="ghost"
|
|
91
|
+
onClick={onOpen}
|
|
92
|
+
aria-label="Remove Queue"
|
|
93
|
+
title="Remove Queue"
|
|
94
|
+
colorPalette="danger"
|
|
95
|
+
>
|
|
96
|
+
<LuListMinus />
|
|
97
|
+
</IconButton>
|
|
98
|
+
|
|
99
|
+
<Dialog.Root onOpenChange={onClose} open={open} size="md">
|
|
100
|
+
<Portal>
|
|
101
|
+
<Dialog.Backdrop />
|
|
102
|
+
<Dialog.Positioner>
|
|
103
|
+
<Dialog.Content>
|
|
104
|
+
<Dialog.Header>
|
|
105
|
+
<Dialog.Title>Remove Queue from {worker.worker_name}</Dialog.Title>
|
|
106
|
+
</Dialog.Header>
|
|
107
|
+
<Dialog.Body>
|
|
108
|
+
<VStack gap={4} align="stretch">
|
|
109
|
+
<Text>Select a queue to remove from this worker:</Text>
|
|
110
|
+
<VStack gap={2} align="stretch">
|
|
111
|
+
<For each={availableQueues}>
|
|
112
|
+
{(queue) => (
|
|
113
|
+
<Button
|
|
114
|
+
key={queue}
|
|
115
|
+
variant={selectedQueue === queue ? "solid" : "outline"}
|
|
116
|
+
colorPalette={selectedQueue === queue ? "blue" : "gray"}
|
|
117
|
+
onClick={() => setSelectedQueue(queue)}
|
|
118
|
+
justifyContent="flex-start"
|
|
119
|
+
>
|
|
120
|
+
{queue}
|
|
121
|
+
</Button>
|
|
122
|
+
)}
|
|
123
|
+
</For>
|
|
124
|
+
</VStack>
|
|
125
|
+
</VStack>
|
|
126
|
+
</Dialog.Body>
|
|
127
|
+
<Dialog.Footer>
|
|
128
|
+
<Dialog.ActionTrigger asChild>
|
|
129
|
+
<Button variant="outline">Cancel</Button>
|
|
130
|
+
</Dialog.ActionTrigger>
|
|
131
|
+
<Button
|
|
132
|
+
onClick={handleRemoveQueue}
|
|
133
|
+
colorPalette="danger"
|
|
134
|
+
loading={removeQueueMutation.isPending}
|
|
135
|
+
loadingText="Removing queue..."
|
|
136
|
+
disabled={!selectedQueue}
|
|
137
|
+
>
|
|
138
|
+
<LuListMinus />
|
|
139
|
+
Remove Queue
|
|
140
|
+
</Button>
|
|
141
|
+
</Dialog.Footer>
|
|
142
|
+
<Dialog.CloseTrigger asChild>
|
|
143
|
+
<CloseButton size="sm" />
|
|
144
|
+
</Dialog.CloseTrigger>
|
|
145
|
+
</Dialog.Content>
|
|
146
|
+
</Dialog.Positioner>
|
|
147
|
+
</Portal>
|
|
148
|
+
</Dialog.Root>
|
|
149
|
+
</>
|
|
150
|
+
);
|
|
151
|
+
};
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Licensed to the Apache Software Foundation (ASF) under one
|
|
3
|
+
* or more contributor license agreements. See the NOTICE file
|
|
4
|
+
* distributed with this work for additional information
|
|
5
|
+
* regarding copyright ownership. The ASF licenses this file
|
|
6
|
+
* to you under the Apache License, Version 2.0 (the
|
|
7
|
+
* "License"); you may not use this file except in compliance
|
|
8
|
+
* with the License. You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing,
|
|
13
|
+
* software distributed under the License is distributed on an
|
|
14
|
+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
15
|
+
* KIND, either express or implied. See the License for the
|
|
16
|
+
* specific language governing permissions and limitations
|
|
17
|
+
* under the License.
|
|
18
|
+
*/
|
|
19
|
+
import { Button, CloseButton, Dialog, IconButton, Portal, Text, useDisclosure } from "@chakra-ui/react";
|
|
20
|
+
import { useUiServiceDeleteWorker } from "openapi/queries";
|
|
21
|
+
import { FaRegTrashCan } from "react-icons/fa6";
|
|
22
|
+
|
|
23
|
+
interface WorkerDeleteButtonProps {
|
|
24
|
+
onDelete: (toast: Record<string, string>) => void;
|
|
25
|
+
workerName: string;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export const WorkerDeleteButton = ({ onDelete, workerName }: WorkerDeleteButtonProps) => {
|
|
29
|
+
const { onClose, onOpen, open } = useDisclosure();
|
|
30
|
+
|
|
31
|
+
const deleteMutation = useUiServiceDeleteWorker({
|
|
32
|
+
onError: (error) => {
|
|
33
|
+
onDelete({
|
|
34
|
+
description: `Unable to delete worker ${workerName}: ${error}`,
|
|
35
|
+
title: "Delete Worker Failed",
|
|
36
|
+
type: "error",
|
|
37
|
+
});
|
|
38
|
+
},
|
|
39
|
+
onSuccess: () => {
|
|
40
|
+
onDelete({
|
|
41
|
+
description: `Worker ${workerName} has been deleted from the system.`,
|
|
42
|
+
title: "Worker Deleted",
|
|
43
|
+
type: "success",
|
|
44
|
+
});
|
|
45
|
+
onClose();
|
|
46
|
+
},
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
const handleDelete = () => {
|
|
50
|
+
deleteMutation.mutate({ workerName });
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
return (
|
|
54
|
+
<>
|
|
55
|
+
<IconButton
|
|
56
|
+
size="sm"
|
|
57
|
+
variant="ghost"
|
|
58
|
+
onClick={onOpen}
|
|
59
|
+
aria-label="Delete Worker"
|
|
60
|
+
title="Delete Worker"
|
|
61
|
+
colorPalette="danger"
|
|
62
|
+
>
|
|
63
|
+
<FaRegTrashCan />
|
|
64
|
+
</IconButton>
|
|
65
|
+
|
|
66
|
+
<Dialog.Root onOpenChange={onClose} open={open} size="md">
|
|
67
|
+
<Portal>
|
|
68
|
+
<Dialog.Backdrop />
|
|
69
|
+
<Dialog.Positioner>
|
|
70
|
+
<Dialog.Content>
|
|
71
|
+
<Dialog.Header>
|
|
72
|
+
<Dialog.Title>Delete worker {workerName}</Dialog.Title>
|
|
73
|
+
</Dialog.Header>
|
|
74
|
+
<Dialog.Body>
|
|
75
|
+
<Text>Are you sure you want to delete worker {workerName}?</Text>
|
|
76
|
+
<Text fontSize="sm" color="red.500" mt={2}>
|
|
77
|
+
This will permanently remove the worker record from the system. This action cannot be
|
|
78
|
+
undone.
|
|
79
|
+
</Text>
|
|
80
|
+
</Dialog.Body>
|
|
81
|
+
<Dialog.Footer>
|
|
82
|
+
<Dialog.ActionTrigger asChild>
|
|
83
|
+
<Button variant="outline">Cancel</Button>
|
|
84
|
+
</Dialog.ActionTrigger>
|
|
85
|
+
<Button
|
|
86
|
+
onClick={handleDelete}
|
|
87
|
+
colorPalette="danger"
|
|
88
|
+
loading={deleteMutation.isPending}
|
|
89
|
+
loadingText="Deleting..."
|
|
90
|
+
>
|
|
91
|
+
<FaRegTrashCan style={{ marginRight: "8px" }} />
|
|
92
|
+
Delete Worker
|
|
93
|
+
</Button>
|
|
94
|
+
</Dialog.Footer>
|
|
95
|
+
<Dialog.CloseTrigger asChild>
|
|
96
|
+
<CloseButton size="sm" />
|
|
97
|
+
</Dialog.CloseTrigger>
|
|
98
|
+
</Dialog.Content>
|
|
99
|
+
</Dialog.Positioner>
|
|
100
|
+
</Portal>
|
|
101
|
+
</Dialog.Root>
|
|
102
|
+
</>
|
|
103
|
+
);
|
|
104
|
+
};
|