Skip to content

Commit f1c4ae4

Browse files
committed
Reset isDirty when user exits page and fix Create button behavior
1 parent 71e6986 commit f1c4ae4

File tree

1 file changed

+9
-2
lines changed
  • portal-ui/src/screens/Console/Buckets/ListBuckets/AddBucket

1 file changed

+9
-2
lines changed

portal-ui/src/screens/Console/Buckets/ListBuckets/AddBucket/AddBucket.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ import { selDistSet, selSiteRep } from "../../../../../systemSlice";
4545
import {
4646
resetForm,
4747
setEnableObjectLocking,
48+
setIsDirty,
49+
setName,
4850
setQuota,
4951
setQuotaSize,
5052
setQuotaUnit,
@@ -165,6 +167,11 @@ const AddBucket = ({ classes }: IsetProps) => {
165167
IAM_SCOPES.S3_PUT_BUCKET_OBJECT_LOCK_CONFIGURATION,
166168
]);
167169

170+
useEffect(() => {
171+
dispatch(setName(""));
172+
dispatch(setIsDirty(false));
173+
}, [])
174+
168175
useEffect(() => {
169176
const bucketNameErrors = [
170177
!(isDirty && (bucketName.length < 3 || bucketName.length > 63)),
@@ -181,7 +188,7 @@ const AddBucket = ({ classes }: IsetProps) => {
181188
];
182189
setValidationResult(bucketNameErrors);
183190
// eslint-disable-next-line react-hooks/exhaustive-deps
184-
}, [bucketName]);
191+
}, [bucketName, isDirty]);
185192

186193
useEffect(() => {
187194
const fetchRecords = () => {
@@ -476,7 +483,7 @@ const AddBucket = ({ classes }: IsetProps) => {
476483
type="submit"
477484
variant="callAction"
478485
color="primary"
479-
disabled={addLoading || invalidFields.length > 0 || hasErrors}
486+
disabled={addLoading || invalidFields.length > 0 || (!isDirty || hasErrors)}
480487
label={"Create Bucket"}
481488
/>
482489
</Grid>

0 commit comments

Comments
 (0)