Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
gitpod-io
GitHub Repository: gitpod-io/gitpod
Path: blob/main/components/dashboard/src/data/workspaces/update-workspace-mutation.ts
2501 views
1
/**
2
* Copyright (c) 2023 Gitpod GmbH. All rights reserved.
3
* Licensed under the GNU Affero General Public License (AGPL).
4
* See License.AGPL.txt in the project root for license information.
5
*/
6
7
import { useMutation } from "@tanstack/react-query";
8
import { useUpdateWorkspaceInCache } from "./list-workspaces-query";
9
import { UpdateWorkspaceRequest } from "@gitpod/public-api/lib/gitpod/v1/workspace_pb";
10
import { PartialMessage } from "@bufbuild/protobuf";
11
import { workspaceClient } from "../../service/public-api";
12
13
export const useUpdateWorkspaceMutation = () => {
14
const updateWorkspace = useUpdateWorkspaceInCache();
15
16
return useMutation({
17
mutationFn: async (data: PartialMessage<UpdateWorkspaceRequest>) => {
18
return await workspaceClient.updateWorkspace(data);
19
},
20
onSuccess: (data) => {
21
if (data.workspace) {
22
updateWorkspace(data.workspace);
23
}
24
},
25
});
26
};
27
28