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

feat(web): fix database & storage bug #595

Merged
merged 6 commits into from
Jan 3, 2023
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
feat(web): extract common code
  • Loading branch information
kongwy229 committed Jan 3, 2023
commit 8fe5e7724322b6fb7f26f5323e36133263229ece
25 changes: 5 additions & 20 deletions web/src/pages/app/storages/mods/CreateBucketModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ function CreateBucketModal(props: { storage?: TBucket; children: React.ReactElem
storage: parseInt(storage?.spec.storage || "", 10),
};

const maxStorage = store.maxStorage + (defaultValues.storage || 0);
const { register, handleSubmit, reset, setFocus } = useForm<{
shortName: string;
policy: string;
Expand Down Expand Up @@ -116,29 +117,17 @@ function CreateBucketModal(props: { storage?: TBucket; children: React.ReactElem
</FormControl>

<FormControl isRequired>
<FormLabel htmlFor="storage">
容量(最大容量
{defaultValues.storage
? store.maxStorage + defaultValues.storage
: store.maxStorage}
GB)
</FormLabel>
<FormLabel htmlFor="storage">容量(最大容量{maxStorage}GB)</FormLabel>
<InputGroup>
<Input
{...register("storage", {
required: true,
max: defaultValues.storage
? store.maxStorage + defaultValues.storage
: store.maxStorage,
max: maxStorage,
min: 0,
})}
type="number"
min="0"
max={
defaultValues.storage
? store.maxStorage + defaultValues.storage
: store.maxStorage
}
max={maxStorage}
variant="filled"
className="w-1"
/>
Expand All @@ -153,11 +142,7 @@ function CreateBucketModal(props: { storage?: TBucket; children: React.ReactElem
{t("Common.Dialog.Cancel")}
</Button>
<Button
disabled={
(defaultValues.storage
? store.maxStorage + defaultValues.storage
: store.maxStorage) === 0
}
disabled={maxStorage === 0}
colorScheme="blue"
type="submit"
onClick={handleSubmit(onSubmit)}
Expand Down