Skip to content

Commit 8fe5e77

Browse files
committed
feat(web): extract common code
1 parent 8a107b1 commit 8fe5e77

File tree

1 file changed

+5
-20
lines changed
  • web/src/pages/app/storages/mods/CreateBucketModal

1 file changed

+5
-20
lines changed

web/src/pages/app/storages/mods/CreateBucketModal/index.tsx

+5-20
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ function CreateBucketModal(props: { storage?: TBucket; children: React.ReactElem
4141
storage: parseInt(storage?.spec.storage || "", 10),
4242
};
4343

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

118119
<FormControl isRequired>
119-
<FormLabel htmlFor="storage">
120-
容量(最大容量
121-
{defaultValues.storage
122-
? store.maxStorage + defaultValues.storage
123-
: store.maxStorage}
124-
GB)
125-
</FormLabel>
120+
<FormLabel htmlFor="storage">容量(最大容量{maxStorage}GB)</FormLabel>
126121
<InputGroup>
127122
<Input
128123
{...register("storage", {
129124
required: true,
130-
max: defaultValues.storage
131-
? store.maxStorage + defaultValues.storage
132-
: store.maxStorage,
125+
max: maxStorage,
133126
min: 0,
134127
})}
135128
type="number"
136129
min="0"
137-
max={
138-
defaultValues.storage
139-
? store.maxStorage + defaultValues.storage
140-
: store.maxStorage
141-
}
130+
max={maxStorage}
142131
variant="filled"
143132
className="w-1"
144133
/>
@@ -153,11 +142,7 @@ function CreateBucketModal(props: { storage?: TBucket; children: React.ReactElem
153142
{t("Common.Dialog.Cancel")}
154143
</Button>
155144
<Button
156-
disabled={
157-
(defaultValues.storage
158-
? store.maxStorage + defaultValues.storage
159-
: store.maxStorage) === 0
160-
}
145+
disabled={maxStorage === 0}
161146
colorScheme="blue"
162147
type="submit"
163148
onClick={handleSubmit(onSubmit)}

0 commit comments

Comments
 (0)