Skip to content

Commit f9ebd44

Browse files
Jillian InapurapuJillian Inapurapu
authored andcommitted
Added indcator with HelpTip to show that expiryUnit can be changed under relevant conditions, informative error text if inappropriate value used for lifecycleDays
1 parent 750f255 commit f9ebd44

File tree

1 file changed

+42
-31
lines changed

1 file changed

+42
-31
lines changed

portal-ui/src/screens/Console/Buckets/BucketDetails/AddLifecycleModal.tsx

Lines changed: 42 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ import React, { Fragment, useEffect, useState } from "react";
1919
import get from "lodash/get";
2020
import {
2121
Accordion,
22+
AlertIcon,
23+
Box,
2224
Button,
2325
FormLayout,
2426
Grid,
@@ -43,6 +45,7 @@ import ModalWrapper from "../../Common/ModalWrapper/ModalWrapper";
4345
import QueryMultiSelector from "../../Common/FormComponents/QueryMultiSelector/QueryMultiSelector";
4446
import InputUnitMenu from "../../Common/FormComponents/InputUnitMenu/InputUnitMenu";
4547
import { IAM_PAGES } from "common/SecureComponent/permissions";
48+
import { ArrowBack } from "@mui/icons-material";
4649

4750
interface IReplicationModal {
4851
open: boolean;
@@ -197,7 +200,7 @@ const AddLifecycleModal = ({
197200
dispatch(setModalErrorSnackMessage(errorToHandler(err)));
198201
});
199202
};
200-
203+
const testSwitch = true;
201204
return (
202205
<ModalWrapper
203206
modalOpen={open}
@@ -274,10 +277,6 @@ const AddLifecycleModal = ({
274277
label="Object Version"
275278
onChange={(value) => {
276279
setTargetVersion(value as "current" | "noncurrent");
277-
console.log(
278-
"setTargetVersion(value as 'current' | 'noncurrent'):",
279-
value,
280-
);
281280
}}
282281
options={[
283282
{ value: "current", label: "Current Version" },
@@ -302,10 +301,12 @@ const AddLifecycleModal = ({
302301

303302
<InputBox
304303
error={
305-
targetVersion === "current" || ilmType !== "expiry"
306-
? ""
307-
: !isFormValid
308-
? "Number of noncurrent versions to retain must be greater than zero"
304+
lifecycleDays && !isFormValid
305+
? parseInt(lifecycleDays) <= 0
306+
? `Number of ${expiryUnit} to retain must be greater than zero`
307+
: parseInt(lifecycleDays) > 2147483647
308+
? `Number of ${expiryUnit} must be less than max int32`
309+
: ""
309310
: ""
310311
}
311312
id="expiry_days"
@@ -319,28 +320,38 @@ const AddLifecycleModal = ({
319320
label="After"
320321
value={lifecycleDays}
321322
overlayObject={
322-
<Tooltip
323-
tooltip={
324-
ilmType === "expiry" &&
325-
targetVersion === "noncurrent" &&
326-
"Select expiry based on days or number of newer noncurrent versions"
327-
}
328-
>
329-
<InputUnitMenu
330-
id={"expire-current-unit"}
331-
unitSelected={expiryUnit}
332-
unitsList={[
333-
{ label: "Days", value: "days" },
334-
{ label: "Versions", value: "versions" },
335-
]}
336-
disabled={
337-
targetVersion !== "noncurrent" || ilmType !== "expiry"
338-
}
339-
onUnitChange={(newValue) => {
340-
setExpiryUnit(newValue);
341-
}}
342-
/>
343-
</Tooltip>
323+
<Fragment>
324+
<Grid container sx={{ justifyContent: "center" }}>
325+
<InputUnitMenu
326+
id={"expire-current-unit"}
327+
unitSelected={expiryUnit}
328+
unitsList={[
329+
{ label: "Days", value: "days" },
330+
{ label: "Versions", value: "versions" },
331+
]}
332+
disabled={
333+
targetVersion !== "noncurrent" || ilmType !== "expiry"
334+
}
335+
onUnitChange={(newValue) => {
336+
setExpiryUnit(newValue);
337+
}}
338+
/>
339+
{ilmType === "expiry" && targetVersion === "noncurrent" && (
340+
<HelpTip
341+
content={
342+
<Fragment>
343+
Select to set expiry by days or newer noncurrent
344+
versions
345+
</Fragment>
346+
}
347+
placement="right"
348+
>
349+
{" "}
350+
<AlertIcon style={{ width: 15, height: 15 }} />
351+
</HelpTip>
352+
)}
353+
</Grid>
354+
</Fragment>
344355
}
345356
/>
346357

0 commit comments

Comments
 (0)