import React, { useState, useEffect } from "react"; import { Button, ButtonVariant, Divider, Modal, ModalVariant, Stack, StackItem, Text, TextContent, } from "@patternfly/react-core"; import { useTranslation } from "react-i18next"; import { JsonFileUpload, JsonFileUploadEvent, } from "../components/json-file-upload/JsonFileUpload"; export type PartialImportProps = { open: boolean; toggleDialog: () => void; }; export const PartialImportDialog = (props: PartialImportProps) => { const tRealm = useTranslation("realm-settings").t; const { t } = useTranslation("partial-import"); const [importEnabled, setImportEnabled] = useState(false); // when dialog opens or closes, reset importEnabled to false useEffect(() => { setImportEnabled(false); }, [props.open]); const handleFileChange = ( value: string | File, filename: string, event: JsonFileUploadEvent ) => { setImportEnabled(value !== null); // if user pressed clear button reset importEnabled const nativeEvent = event.nativeEvent; if ( nativeEvent instanceof MouseEvent && !(nativeEvent instanceof DragEvent) ) { setImportEnabled(false); } }; return ( { props.toggleDialog(); }} > {t("import")} , , ]} > {t("partialImportHeaderText")} {importEnabled && ( TODO: This section will include{" "} Choose the resources... and{" "} If a resource already exists.... )} ); };