Path: blob/main/components/dashboard/src/repositories/detail/variables/ConfigurationRemoveVariableModal.tsx
2502 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 { FunctionComponent, useCallback } from "react";7import { useToast } from "../../../components/toasts/Toasts";8import ConfirmationModal from "../../../components/ConfirmationModal";9import { useDeleteConfigurationVariable } from "../../../data/configurations/configuration-queries";10import type { ConfigurationEnvironmentVariable } from "@gitpod/public-api/lib/gitpod/v1/envvar_pb";1112type Props = {13variable: ConfigurationEnvironmentVariable;14configurationId: string;15onClose(): void;16};17export const ConfigurationDeleteVariableModal: FunctionComponent<Props> = ({ variable, configurationId, onClose }) => {18const deleteVariable = useDeleteConfigurationVariable();19const { toast } = useToast();2021const handleConfirmation = useCallback(() => {22deleteVariable.mutate(23{ variableId: variable.id, configurationId },24{25onSuccess: () => {26toast("Your variable was deleted");27onClose();28},29onError: (err) => {30toast(`Could not delete variable: ${err.message}`);31},32},33);34}, [configurationId, deleteVariable, onClose, toast, variable.id]);3536return (37<ConfirmationModal38title="Delete variable"39areYouSureText="Are you sure you want to delete this variable?"40children={{41name: variable.name,42}}43buttonText="Delete variable"44warningText={deleteVariable.isError ? "There was a problem deleting this variable." : undefined}45onClose={onClose}46onConfirm={handleConfirmation}47visible48/>49);50};515253