/****************************************************************************** * Copyright (c) 2026 Contributors to the Eclipse Foundation. * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License 2.0 which is available at * https://www.eclipse.org/legal/epl-2.0. * * SPDX-License-Identifier: EPL-2.0 *****************************************************************************/ import { FunctionComponent, useContext } from 'react'; import { Button, Dialog, DialogActions, DialogContent, DialogContentText, DialogTitle } from '@mui/material'; import { ButtonWithProgress } from '../../components/button-with-progress'; import { Namespace } from '../../extension-registry-types'; import { MainContext } from '../../context'; import { useDeleteNamespace } from './use-namespace-admin'; export interface NamespaceDeleteDialogProps { open: boolean; onClose: () => void; onDelete: () => void; namespace: Namespace; setLoadingState: (loading: boolean) => void; } export const NamespaceDeleteDialog: FunctionComponent = props => { const { open, onClose, onDelete, namespace } = props; const { handleError } = useContext(MainContext); const { mutateAsync: deleteNamespace, isPending: working } = useDeleteNamespace(); const handleDeleteNamespace = async () => { if (!props.namespace) { return; } props.setLoadingState(true); try { await deleteNamespace(props.namespace.name); props.setLoadingState(false); onDelete(); } catch (err) { props.setLoadingState(false); handleError(err); } }; return ( <> Delete Namespace Are you sure you want to delete the namespace {namespace.name}? Delete Namespace ); };