diff --git a/components/dashboard/src/data/configurations/configuration-queries.ts b/components/dashboard/src/data/configurations/configuration-queries.ts index 772672ecc97414..0b752d618d1ff6 100644 --- a/components/dashboard/src/data/configurations/configuration-queries.ts +++ b/components/dashboard/src/data/configurations/configuration-queries.ts @@ -60,17 +60,19 @@ export const useConfiguration = (configurationId: string) => { }); }; -export const useDeleteConfiguration = (configurationId: string) => { +type DeleteConfigurationArgs = { + configurationId: string; +}; +export const useDeleteConfiguration = () => { const queryClient = useQueryClient(); - return useMutation({ - mutationKey: getConfigurationQueryKey(configurationId), - mutationFn: async () => { - await configurationClient.deleteConfiguration({ + return useMutation({ + mutationFn: async ({ configurationId }: DeleteConfigurationArgs) => { + return await configurationClient.deleteConfiguration({ configurationId, }); }, - onSuccess: () => { + onSuccess: (_, { configurationId }) => { queryClient.invalidateQueries({ queryKey: ["configurations", "list"] }); queryClient.invalidateQueries({ queryKey: getConfigurationQueryKey(configurationId) }); }, diff --git a/components/dashboard/src/repositories/detail/ConfigurationDetailGeneral.tsx b/components/dashboard/src/repositories/detail/ConfigurationDetailGeneral.tsx index 942ce484fdcb89..43c4c37c5a5b94 100644 --- a/components/dashboard/src/repositories/detail/ConfigurationDetailGeneral.tsx +++ b/components/dashboard/src/repositories/detail/ConfigurationDetailGeneral.tsx @@ -6,10 +6,10 @@ import { FC } from "react"; import { useParams } from "react-router"; -import { ConfigurationNameForm } from "./ConfigurationName"; +import { ConfigurationNameForm } from "./general/ConfigurationName"; import { ConfigurationDetailPage } from "./ConfigurationDetailPage"; import { useConfiguration } from "../../data/configurations/configuration-queries"; -import { RemoveConfiguration } from "./RemoveConfiguration"; +import { RemoveConfiguration } from "./general/RemoveConfiguration"; type PageRouteParams = { id: string; diff --git a/components/dashboard/src/repositories/detail/ConfigurationName.tsx b/components/dashboard/src/repositories/detail/general/ConfigurationName.tsx similarity index 86% rename from components/dashboard/src/repositories/detail/ConfigurationName.tsx rename to components/dashboard/src/repositories/detail/general/ConfigurationName.tsx index e5bfd3eade4249..aba73416bcc2f1 100644 --- a/components/dashboard/src/repositories/detail/ConfigurationName.tsx +++ b/components/dashboard/src/repositories/detail/general/ConfigurationName.tsx @@ -8,12 +8,12 @@ import type { Configuration } from "@gitpod/public-api/lib/gitpod/v1/configurati import { Button } from "@podkit/buttons/Button"; import { LoadingButton } from "@podkit/buttons/LoadingButton"; import { FC, useCallback } from "react"; -import { TextInputField } from "../../components/forms/TextInputField"; -import { useToast } from "../../components/toasts/Toasts"; -import { useUpdateProject } from "../../data/projects/project-queries"; -import { useOnBlurError } from "../../hooks/use-onblur-error"; -import { ConfigurationSettingsField } from "./ConfigurationSettingsField"; -import { useDirtyState } from "../../hooks/use-dirty-state"; +import { TextInputField } from "../../../components/forms/TextInputField"; +import { useToast } from "../../../components/toasts/Toasts"; +import { useUpdateProject } from "../../../data/projects/project-queries"; +import { useOnBlurError } from "../../../hooks/use-onblur-error"; +import { ConfigurationSettingsField } from "../ConfigurationSettingsField"; +import { useDirtyState } from "../../../hooks/use-dirty-state"; const MAX_LENGTH = 100; diff --git a/components/dashboard/src/repositories/detail/RemoveConfiguration.tsx b/components/dashboard/src/repositories/detail/general/RemoveConfiguration.tsx similarity index 91% rename from components/dashboard/src/repositories/detail/RemoveConfiguration.tsx rename to components/dashboard/src/repositories/detail/general/RemoveConfiguration.tsx index 62e7c9533fe9dc..477567eed34328 100644 --- a/components/dashboard/src/repositories/detail/RemoveConfiguration.tsx +++ b/components/dashboard/src/repositories/detail/general/RemoveConfiguration.tsx @@ -5,12 +5,12 @@ */ import { Heading2, Subheading } from "@podkit/typography/Headings"; -import { Button } from "../../components/Button"; +import { Button } from "../../../components/Button"; import { RemoveConfigurationModal } from "./RemoveConfigurationModal"; import { useHistory } from "react-router"; import { useCallback, useState } from "react"; import type { Configuration } from "@gitpod/public-api/lib/gitpod/v1/configuration_pb"; -import { ConfigurationSettingsField } from "./ConfigurationSettingsField"; +import { ConfigurationSettingsField } from "../ConfigurationSettingsField"; interface Props { configuration: Configuration; @@ -21,7 +21,7 @@ export const RemoveConfiguration = ({ configuration }: Props) => { const history = useHistory(); const onProjectRemoved = useCallback(() => { - history.push("/projects"); + history.push("/repositories"); }, [history]); return ( diff --git a/components/dashboard/src/repositories/detail/RemoveConfigurationModal.tsx b/components/dashboard/src/repositories/detail/general/RemoveConfigurationModal.tsx similarity index 73% rename from components/dashboard/src/repositories/detail/RemoveConfigurationModal.tsx rename to components/dashboard/src/repositories/detail/general/RemoveConfigurationModal.tsx index 468daa2bb796f3..85ab0fbf0b6fc1 100644 --- a/components/dashboard/src/repositories/detail/RemoveConfigurationModal.tsx +++ b/components/dashboard/src/repositories/detail/general/RemoveConfigurationModal.tsx @@ -5,9 +5,9 @@ */ import { FunctionComponent, useCallback } from "react"; -import ConfirmationModal from "../../components/ConfirmationModal"; +import ConfirmationModal from "../../../components/ConfirmationModal"; import type { Configuration } from "@gitpod/public-api/lib/gitpod/v1/configuration_pb"; -import { useDeleteConfiguration } from "../../data/configurations/configuration-queries"; +import { useDeleteConfiguration } from "../../../data/configurations/configuration-queries"; type RemoveProjectModalProps = { configuration: Configuration; @@ -20,13 +20,16 @@ export const RemoveConfigurationModal: FunctionComponent { - const removeConfigMutation = useDeleteConfiguration(configuration.id); + const removeConfigMutation = useDeleteConfiguration(); const removeProject = useCallback(async () => { - removeConfigMutation.mutate(undefined, { - onSuccess: () => onRemoved(), - }); - }, [removeConfigMutation, onRemoved]); + removeConfigMutation.mutate( + { configurationId: configuration.id }, + { + onSuccess: () => onRemoved(), + }, + ); + }, [removeConfigMutation, configuration.id, onRemoved]); return (