Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat: batch workspace updates#11583

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
aslilac merged 14 commits intomainfrombatch-update
Jan 18, 2024
Merged
Show file tree
Hide file tree
Changes from1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
NextNext commit
feat: batch workspace updates
  • Loading branch information
@aslilac
aslilac committedJan 11, 2024
commit07cdbc47c3e66fa9c42985c2f8eff63eb2600e31
20 changes: 18 additions & 2 deletionssite/src/pages/WorkspacesPage/BatchActions.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -6,7 +6,12 @@ import "dayjs/plugin/relativeTime";
import { type Interpolation, type Theme } from "@emotion/react";
import { type FC, type ReactNode, useState } from "react";
import { useMutation } from "react-query";
import { deleteWorkspace, startWorkspace, stopWorkspace } from "api/api";
import {
deleteWorkspace,
startWorkspace,
stopWorkspace,
updateWorkspace,
} from "api/api";
import type { Workspace } from "api/typesGenerated";
import { ConfirmDialog } from "components/Dialogs/ConfirmDialog/ConfirmDialog";
import { displayError } from "components/GlobalSnackbar/utils";
Expand DownExpand Up@@ -50,14 +55,25 @@ export function useBatchActions(options: UseBatchActionsProps) {
},
onSuccess,
onError: () => {
displayError("Failed to delete workspaces");
displayError("Failed to delete some workspaces");
},
});

const updateAllMutation = useMutation({
mutationFn: async (workspaces: Workspace[]) => {
return Promise.all(workspaces.map((w) => updateWorkspace(w)));
},
onSuccess,
onError: () => {
displayError("Failed to update some workspaces");
},
});

return {
startAll: startAllMutation.mutateAsync,
stopAll: stopAllMutation.mutateAsync,
deleteAll: deleteAllMutation.mutateAsync,
updateAll: updateAllMutation.mutateAsync,
isLoading:
startAllMutation.isLoading ||
stopAllMutation.isLoading ||
Expand Down
1 change: 1 addition & 0 deletionssite/src/pages/WorkspacesPage/WorkspacesPage.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -99,6 +99,7 @@ const WorkspacesPage: FC = () => {
onDeleteAll={() => {
setIsConfirmingDeleteAll(true);
}}
onUpdateAll={() => batchActions.updateAll(checkedWorkspaces)}
onStartAll={() => batchActions.startAll(checkedWorkspaces)}
onStopAll={() => batchActions.stopAll(checkedWorkspaces)}
/>
Expand Down
6 changes: 6 additions & 0 deletionssite/src/pages/WorkspacesPage/WorkspacesPageView.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -15,6 +15,7 @@ import { WorkspacesButton } from "./WorkspacesButton";
import { UseQueryResult } from "react-query";
import StopOutlined from "@mui/icons-material/StopOutlined";
import PlayArrowOutlined from "@mui/icons-material/PlayArrowOutlined";
import CloudQueue from "@mui/icons-material/CloudQueue";
import {
MoreMenu,
MoreMenuContent,
Expand DownExpand Up@@ -51,6 +52,7 @@ export interface WorkspacesPageViewProps {
onCheckChange: (checkedWorkspaces: Workspace[]) => void;
isRunningBatchAction: boolean;
onDeleteAll: () => void;
onUpdateAll: () => void;
onStartAll: () => void;
onStopAll: () => void;
canCheckWorkspaces: boolean;
Expand All@@ -71,6 +73,7 @@ export const WorkspacesPageView = ({
checkedWorkspaces,
onCheckChange,
onDeleteAll,
onUpdateAll,
onStopAll,
onStartAll,
isRunningBatchAction,
Expand DownExpand Up@@ -150,6 +153,9 @@ export const WorkspacesPageView = ({
<StopOutlined /> Stop
</MoreMenuItem>
<Divider />
<MoreMenuItem onClick={onUpdateAll}>
<CloudQueue /> Update&hellip;
</MoreMenuItem>
<MoreMenuItem danger onClick={onDeleteAll}>
<DeleteOutlined /> Delete&hellip;
</MoreMenuItem>
Expand Down
2 changes: 1 addition & 1 deletionsite/src/theme/light/mui.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -10,7 +10,7 @@ const muiTheme = createTheme({
mode: "light",
primary: {
main: tw.sky[600],
contrastText: tw.sky[50],
contrastText: tw.sky[950],
light: tw.sky[400],
dark: tw.sky[500],
},
Expand Down

[8]ページ先頭

©2009-2026 Movatter.jp