diff --git a/react/src/components/AssetDetail/AssetButton.tsx b/react/src/components/AssetDetail/AssetButton.tsx index 6a75563e..3d9dbbd0 100644 --- a/react/src/components/AssetDetail/AssetButton.tsx +++ b/react/src/components/AssetDetail/AssetButton.tsx @@ -31,11 +31,8 @@ const AssetButton: React.FC = ({ /* Uncomment when WG-422 polling is merged const notification = useNotification();*/ const featureId = selectedFeature.id; - const { - mutate: importFeatureAsset, - isPending: isImporting, - isSuccess: isImportingSuccess, - } = useImportFeatureAsset(projectId, featureId); + const { mutate: importFeatureAsset, isPending: isImporting } = + useImportFeatureAsset(projectId, featureId); const handleSubmit = (files: TapisFilePath[]) => { for (const file of files) { @@ -82,7 +79,7 @@ const AssetButton: React.FC = ({ type="primary" onClick={() => setIsModalOpen(true)} isLoading={isImporting} - disabled={isImportingSuccess} + disabled={isImporting} > Add Asset from DesignSafe diff --git a/react/src/components/FileBrowserModal/FileBrowserModal.tsx b/react/src/components/FileBrowserModal/FileBrowserModal.tsx index 04eca824..17cf65ce 100644 --- a/react/src/components/FileBrowserModal/FileBrowserModal.tsx +++ b/react/src/components/FileBrowserModal/FileBrowserModal.tsx @@ -1,8 +1,10 @@ -import React, { useState } from 'react'; +import React, { useState, useMemo } from 'react'; import { Modal, Button, Layout, Typography } from 'antd'; import { FileListing } from '../Files'; import { File, TapisFilePath } from '@hazmapper/types'; import { convertFilesToTapisPaths } from '@hazmapper/utils/fileUtils'; +import { IMPORTABLE_FEATURE_ASSET_TYPES } from '@hazmapper/utils/fileUtils'; +import { SectionMessage } from '@tacc/core-components'; type FileBrowserModalProps = { isOpen: boolean; @@ -21,6 +23,15 @@ const FileBrowserModal = ({ allowedFileExtensions = [], }: FileBrowserModalProps) => { const [selectedFiles, setSelectedFiles] = useState([]); + const [isMultiSelectError, setIsMultiSelectError] = useState(false); + const isSingleSelectMode = useMemo(() => { + return ( + JSON.stringify(allowedFileExtensions.sort()) === + JSON.stringify(IMPORTABLE_FEATURE_ASSET_TYPES.sort()) + ); + }, [allowedFileExtensions]); + + console.log(isSingleSelectMode); const handleClose = () => { parentToggle(); @@ -31,6 +42,10 @@ const FileBrowserModal = ({ }; const handleImport = () => { + setIsMultiSelectError(false); + if (isSingleSelectMode && selectedFiles.length > 1) { + setIsMultiSelectError(true); + } if (onImported) { const tapisFilePaths = convertFilesToTapisPaths(selectedFiles); onImported(tapisFilePaths); @@ -45,6 +60,11 @@ const FileBrowserModal = ({ onCancel={handleClose} footer={[ + {isSingleSelectMode && selectedFiles.length > 1 && ( + + Adding multiple asset to a feature is not supported. + + )} {selectedFiles.length > 0 && `${selectedFiles.length} files selected`} , ,