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