UNPKG

@kinvolk/headlamp-plugin

Version:

The needed infrastructure for building Headlamp plugins.

45 lines (44 loc) 2.48 kB
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime"; /* * Copyright 2025 The Kubernetes Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import Button from '@mui/material/Button'; import MuiDialog from '@mui/material/Dialog'; import DialogActions from '@mui/material/DialogActions'; import DialogContent from '@mui/material/DialogContent'; import DialogContentText from '@mui/material/DialogContentText'; import React from 'react'; import { useTranslation } from 'react-i18next'; import { DialogTitle } from './Dialog'; export function ConfirmDialog(props) { const { onConfirm, open, handleClose, title, description, cancelLabel, confirmLabel, hideCancelButton = false, } = props; const { t } = useTranslation(); function onConfirmationClicked() { handleClose(); onConfirm(); } const focusedRef = React.useCallback((node) => { if (node !== null) { node.setAttribute('tabindex', '-1'); node.focus(); } }, []); return (_jsx("div", { children: _jsxs(MuiDialog, { open: open, onClose: handleClose, "aria-labelledby": "alert-dialog-title", "aria-describedby": "alert-dialog-description", PaperProps: { sx: { minWidth: 'clamp(280px, 25vw, 600px)', }, }, children: [_jsx(DialogTitle, { id: "alert-dialog-title", children: title }), _jsx(DialogContent, { ref: focusedRef, sx: { py: 1 }, children: _jsx(DialogContentText, { id: "alert-dialog-description", component: "div", children: description }) }), _jsxs(DialogActions, { children: [!hideCancelButton && (_jsx(Button, { onClick: handleClose, "aria-label": "cancel-button", color: "secondary", variant: "contained", children: cancelLabel || t('No') })), _jsx(Button, { onClick: onConfirmationClicked, "aria-label": "confirm-button", color: "primary", variant: "contained", children: confirmLabel || t('Yes') })] })] }) })); } export default ConfirmDialog;