Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: disable upload button when pod not selected #519

Merged
merged 1 commit into from
Sep 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ const DriveActionBar = ({
type="button"
variant="primary"
className="mx-1 p-0"
disabled={!activePod}
onClick={onFileUploadClick}
>
<span className="mr-2">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -32,12 +33,13 @@ const DriveActionBarItem = (
label: string,
imageLight: JSX.Element,
imageDark: JSX.Element,
onClick: () => void
onClick: () => void,
disabled = false
) => {
return (
<div
className="py-2 w-24 block md:hidden sm:w-full py-1 flex-shrink-0 md:py-4 shadow cursor-pointer hover:bg-color-shade-dark-4-day dark:hover:bg-color-shade-dark-2-night"
onClick={onClick}
onClick={disabled ? undefined : onClick}
>
<a className="flex flex-col justify-center items-center">
{theme === 'light' ? imageLight : imageDark}
Expand All @@ -55,6 +57,7 @@ const DriveActionBarMobile: FC<DriveActionBarMobileProps> = ({
refreshPods,
}) => {
const { theme } = useContext(ThemeContext);
const { activePod } = useContext(PodContext);

const [showCreatePodModal, setShowCreatePodModal] = useState(false);
const [showUploadFileModal, setShowUploadFileModal] = useState(false);
Expand All @@ -77,7 +80,8 @@ const DriveActionBarMobile: FC<DriveActionBarMobileProps> = ({
intl.get('UPLOAD'),
<UploadLightIcon height="22" />,
<UploadDarkIcon height="22" />,
() => setShowUploadFileModal(true)
() => setShowUploadFileModal(true),
!activePod
)}
{DriveActionBarItem(
theme,
Expand All @@ -91,7 +95,8 @@ const DriveActionBarMobile: FC<DriveActionBarMobileProps> = ({
intl.get('FOLDER'),
<CreateFolderLightIcon height="22" />,
<CreateFolderDarkIcon height="22" />,
() => setShowCreateFolderModal(true)
() => setShowCreateFolderModal(true),
!activePod
)}
{showCreatePodModal ? (
<CreatePodModal
Expand Down