From e86642a797a40978203f6451074c823592879f93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladan=20Tomi=C4=87?= Date: Wed, 20 Sep 2023 13:06:19 +0200 Subject: [PATCH] fix: disable upload button when pod not selected --- .../DriveActionBar/DriveActionBar.tsx | 1 + .../DriveActionBar/DriveActionBarMobile.tsx | 13 +++++++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/components/NavigationBars/DriveActionBar/DriveActionBar.tsx b/src/components/NavigationBars/DriveActionBar/DriveActionBar.tsx index 846d133a..bbc23206 100644 --- a/src/components/NavigationBars/DriveActionBar/DriveActionBar.tsx +++ b/src/components/NavigationBars/DriveActionBar/DriveActionBar.tsx @@ -42,6 +42,7 @@ const DriveActionBar = ({ type="button" variant="primary" className="mx-1 p-0" + disabled={!activePod} onClick={onFileUploadClick} > diff --git a/src/components/NavigationBars/DriveActionBar/DriveActionBarMobile.tsx b/src/components/NavigationBars/DriveActionBar/DriveActionBarMobile.tsx index 08970eb6..844dfc56 100644 --- a/src/components/NavigationBars/DriveActionBar/DriveActionBarMobile.tsx +++ b/src/components/NavigationBars/DriveActionBar/DriveActionBarMobile.tsx @@ -22,6 +22,7 @@ import CreateFolderLightIcon from '@media/UI/create-folder-light.svg'; import CreateFolderDarkIcon from '@media/UI/create-folder-dark.svg'; import { UpdateDriveProps } from '@interfaces/handlers'; import { useLocales } from '@context/LocalesContext'; +import PodContext from '@context/PodContext'; export interface DriveActionBarMobileProps extends UpdateDriveProps { refreshPods?: () => void; @@ -32,12 +33,13 @@ const DriveActionBarItem = ( label: string, imageLight: JSX.Element, imageDark: JSX.Element, - onClick: () => void + onClick: () => void, + disabled = false ) => { return (
{theme === 'light' ? imageLight : imageDark} @@ -55,6 +57,7 @@ const DriveActionBarMobile: FC = ({ refreshPods, }) => { const { theme } = useContext(ThemeContext); + const { activePod } = useContext(PodContext); const [showCreatePodModal, setShowCreatePodModal] = useState(false); const [showUploadFileModal, setShowUploadFileModal] = useState(false); @@ -77,7 +80,8 @@ const DriveActionBarMobile: FC = ({ intl.get('UPLOAD'), , , - () => setShowUploadFileModal(true) + () => setShowUploadFileModal(true), + !activePod )} {DriveActionBarItem( theme, @@ -91,7 +95,8 @@ const DriveActionBarMobile: FC = ({ intl.get('FOLDER'), , , - () => setShowCreateFolderModal(true) + () => setShowCreateFolderModal(true), + !activePod )} {showCreatePodModal ? (