import React from 'react'; import { connect } from 'react-redux'; import { css, Label, spacing, Banner, ConfirmationModal, Icon, Body, TextInput, } from '@mongodb-js/compass-components'; import { toggleIsVisible } from '../../modules/is-visible'; import { nameChanged } from '../../modules/drop-index/name'; import { changeConfirmName } from '../../modules/drop-index/confirm-name'; import { handleError, clearError } from '../../modules/error'; import { dropIndex } from '../../modules/drop-index'; import { resetForm } from '../../modules/reset-form'; import type { RootState } from '../../modules/drop-index'; const messageStyles = css({ display: 'flex', gap: spacing[1], marginTop: spacing[3], marginBottom: spacing[3], }); const bannerStyles = css({ margin: `${spacing[3]}px 0`, }); const iconStyles = css({ flexShrink: 0 }); const messageTextStyles = css({ display: '-webkit-box', WebkitBoxOrient: 'vertical', WebkitLineClamp: 3, textOverflow: 'ellipsis', overflow: 'hidden', }); export type DropIndexFormProps = { isVisible: boolean; inProgress: boolean; error?: string | null; name: string; confirmName: string; toggleIsVisible: (isVisible: boolean) => void; toggleInProgress: () => void; changeConfirmName: (name: string) => void; resetForm: () => void; dropIndex: (name: string) => void; clearError: () => void; }; /** * Drop index modal. */ export function DropIndexModal({ isVisible, inProgress, error, name, confirmName, toggleIsVisible, changeConfirmName, resetForm, dropIndex, clearError, }: DropIndexFormProps) { const onFormSubmit = (evt: React.FormEvent) => { evt.preventDefault(); evt.stopPropagation(); }; const handleClose = () => { toggleIsVisible(false); resetForm(); }; const handleConfirm = () => { dropIndex(name); }; const renderError = () => { if (!error) { return; } return (