Skip to content

Commit 07cdbc4

Browse files
committed
feat: batch workspace updates
1 parent 05eac64 commit 07cdbc4

File tree

4 files changed

+26
-3
lines changed

4 files changed

+26
-3
lines changed

site/src/pages/WorkspacesPage/BatchActions.tsx

+18-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,12 @@ import "dayjs/plugin/relativeTime";
66
import { type Interpolation, type Theme } from "@emotion/react";
77
import { type FC, type ReactNode, useState } from "react";
88
import { useMutation } from "react-query";
9-
import { deleteWorkspace, startWorkspace, stopWorkspace } from "api/api";
9+
import {
10+
deleteWorkspace,
11+
startWorkspace,
12+
stopWorkspace,
13+
updateWorkspace,
14+
} from "api/api";
1015
import type { Workspace } from "api/typesGenerated";
1116
import { ConfirmDialog } from "components/Dialogs/ConfirmDialog/ConfirmDialog";
1217
import { displayError } from "components/GlobalSnackbar/utils";
@@ -50,14 +55,25 @@ export function useBatchActions(options: UseBatchActionsProps) {
5055
},
5156
onSuccess,
5257
onError: () => {
53-
displayError("Failed to delete workspaces");
58+
displayError("Failed to delete some workspaces");
59+
},
60+
});
61+
62+
const updateAllMutation = useMutation({
63+
mutationFn: async (workspaces: Workspace[]) => {
64+
return Promise.all(workspaces.map((w) => updateWorkspace(w)));
65+
},
66+
onSuccess,
67+
onError: () => {
68+
displayError("Failed to update some workspaces");
5469
},
5570
});
5671

5772
return {
5873
startAll: startAllMutation.mutateAsync,
5974
stopAll: stopAllMutation.mutateAsync,
6075
deleteAll: deleteAllMutation.mutateAsync,
76+
updateAll: updateAllMutation.mutateAsync,
6177
isLoading:
6278
startAllMutation.isLoading ||
6379
stopAllMutation.isLoading ||

site/src/pages/WorkspacesPage/WorkspacesPage.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ const WorkspacesPage: FC = () => {
9999
onDeleteAll={() => {
100100
setIsConfirmingDeleteAll(true);
101101
}}
102+
onUpdateAll={() => batchActions.updateAll(checkedWorkspaces)}
102103
onStartAll={() => batchActions.startAll(checkedWorkspaces)}
103104
onStopAll={() => batchActions.stopAll(checkedWorkspaces)}
104105
/>

site/src/pages/WorkspacesPage/WorkspacesPageView.tsx

+6
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import { WorkspacesButton } from "./WorkspacesButton";
1515
import { UseQueryResult } from "react-query";
1616
import StopOutlined from "@mui/icons-material/StopOutlined";
1717
import PlayArrowOutlined from "@mui/icons-material/PlayArrowOutlined";
18+
import CloudQueue from "@mui/icons-material/CloudQueue";
1819
import {
1920
MoreMenu,
2021
MoreMenuContent,
@@ -51,6 +52,7 @@ export interface WorkspacesPageViewProps {
5152
onCheckChange: (checkedWorkspaces: Workspace[]) => void;
5253
isRunningBatchAction: boolean;
5354
onDeleteAll: () => void;
55+
onUpdateAll: () => void;
5456
onStartAll: () => void;
5557
onStopAll: () => void;
5658
canCheckWorkspaces: boolean;
@@ -71,6 +73,7 @@ export const WorkspacesPageView = ({
7173
checkedWorkspaces,
7274
onCheckChange,
7375
onDeleteAll,
76+
onUpdateAll,
7477
onStopAll,
7578
onStartAll,
7679
isRunningBatchAction,
@@ -150,6 +153,9 @@ export const WorkspacesPageView = ({
150153
<StopOutlined /> Stop
151154
</MoreMenuItem>
152155
<Divider />
156+
<MoreMenuItem onClick={onUpdateAll}>
157+
<CloudQueue /> Update&hellip;
158+
</MoreMenuItem>
153159
<MoreMenuItem danger onClick={onDeleteAll}>
154160
<DeleteOutlined /> Delete&hellip;
155161
</MoreMenuItem>

site/src/theme/light/mui.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const muiTheme = createTheme({
1010
mode: "light",
1111
primary: {
1212
main: tw.sky[600],
13-
contrastText: tw.sky[50],
13+
contrastText: tw.sky[950],
1414
light: tw.sky[400],
1515
dark: tw.sky[500],
1616
},

0 commit comments

Comments
 (0)