Skip to content

feat(web): disabled upload button when fileList is empty #589

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

Merged
merged 1 commit into from
Dec 28, 2022
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
5 changes: 3 additions & 2 deletions web/src/pages/app/storages/mods/CreateFolderModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,19 @@ import {
} from "@chakra-ui/react";
import { t } from "i18next";

import useStorageStore, { TFile } from "../../store";
import useStorageStore from "../../store";

function CreateModal() {
const { isOpen, onOpen, onClose } = useDisclosure();
const { prefix, setPrefix } = useStorageStore();
const { prefix, setPrefix, currentStorage } = useStorageStore();

const { register, setFocus, handleSubmit } = useForm<{ prefix: string }>();

return (
<>
<Button
size="xs"
disabled={currentStorage === undefined}
onClick={() => {
onOpen();
setTimeout(() => {
Expand Down
2 changes: 2 additions & 0 deletions web/src/pages/app/storages/mods/StorageListPanel/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ export default function StorageListPanel() {
onSuccess(data) {
if (data?.data?.items?.length) {
if (!store.currentStorage) store.setCurrentStorage(data?.data?.items[0]);
} else {
store.setCurrentStorage(undefined);
}
},
});
Expand Down
7 changes: 6 additions & 1 deletion web/src/pages/app/storages/mods/UploadButton/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,12 @@ function UploadButton({ onUploadSuccess }: { onUploadSuccess: () => void }) {
return (
<div>
<Menu placement="bottom-start">
<MenuButton size="xs" as={Button} rightIcon={<ChevronDownIcon />}>
<MenuButton
size="xs"
as={Button}
rightIcon={<ChevronDownIcon />}
disabled={currentStorage === undefined}
>
上传
</MenuButton>
<MenuList>
Expand Down
4 changes: 2 additions & 2 deletions web/src/pages/app/storages/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ export type TFile = {
};

type State = {
currentStorage?: TBucket;
setCurrentStorage: (currentStorage: TBucket) => void;
currentStorage?: TBucket | undefined;
setCurrentStorage: (currentStorage: TBucket | undefined) => void;
prefix?: string;
setPrefix: (prefix: string) => void;
};
Expand Down