Skip to content

Commit 750f255

Browse files
Jillian InapurapuJillian Inapurapu
authored andcommitted
WIP improve UI to show clickable selector, guidance text
1 parent a65564f commit 750f255

File tree

2 files changed

+40
-14
lines changed

2 files changed

+40
-14
lines changed

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

Lines changed: 38 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,14 @@ import {
2222
Button,
2323
FormLayout,
2424
Grid,
25+
HelpTip,
2526
InputBox,
2627
LifecycleConfigIcon,
2728
ProgressBar,
2829
RadioGroup,
2930
Select,
3031
Switch,
32+
Tooltip,
3133
} from "mds";
3234
import { useSelector } from "react-redux";
3335
import { api } from "api";
@@ -120,8 +122,11 @@ const AddLifecycleModal = ({
120122
if (!lifecycleDays || parseInt(lifecycleDays) === 0) {
121123
valid = false;
122124
}
125+
if (parseInt(lifecycleDays) > 2147483647) {
126+
//values over int32 cannot be parsed
127+
valid = false;
128+
}
123129
setIsFormValid(valid);
124-
console.log("set to valid: ", valid, " lifecycledays: ", lifecycleDays);
125130
}, [ilmType, lifecycleDays, storageClass]);
126131

127132
useEffect(() => {
@@ -269,6 +274,10 @@ const AddLifecycleModal = ({
269274
label="Object Version"
270275
onChange={(value) => {
271276
setTargetVersion(value as "current" | "noncurrent");
277+
console.log(
278+
"setTargetVersion(value as 'current' | 'noncurrent'):",
279+
value,
280+
);
272281
}}
273282
options={[
274283
{ value: "current", label: "Current Version" },
@@ -292,6 +301,13 @@ const AddLifecycleModal = ({
292301
)}
293302

294303
<InputBox
304+
error={
305+
targetVersion === "current" || ilmType !== "expiry"
306+
? ""
307+
: !isFormValid
308+
? "Number of noncurrent versions to retain must be greater than zero"
309+
: ""
310+
}
295311
id="expiry_days"
296312
name="expiry_days"
297313
onChange={(e: React.ChangeEvent<HTMLInputElement>) => {
@@ -303,20 +319,28 @@ const AddLifecycleModal = ({
303319
label="After"
304320
value={lifecycleDays}
305321
overlayObject={
306-
<InputUnitMenu
307-
id={"expire-current-unit"}
308-
unitSelected={expiryUnit}
309-
unitsList={[
310-
{ label: "Days", value: "days" },
311-
{ label: "Versions", value: "versions" },
312-
]}
313-
disabled={
314-
targetVersion !== "noncurrent" || ilmType !== "expiry"
322+
<Tooltip
323+
tooltip={
324+
ilmType === "expiry" &&
325+
targetVersion === "noncurrent" &&
326+
"Select expiry based on days or number of newer noncurrent versions"
315327
}
316-
onUnitChange={(newValue) => {
317-
setExpiryUnit(newValue);
318-
}}
319-
/>
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>
320344
}
321345
/>
322346

portal-ui/src/screens/Console/Common/FormComponents/InputUnitMenu/InputUnitMenu.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ interface IInputUnitBox {
2424
unitSelected: string;
2525
unitsList: SelectorType[];
2626
disabled?: boolean;
27+
tooltip?: string;
2728
onUnitChange?: (newValue: string) => void;
2829
}
2930

@@ -40,6 +41,7 @@ const InputUnitMenu = ({
4041
unitSelected,
4142
unitsList,
4243
disabled = false,
44+
tooltip,
4345
onUnitChange,
4446
}: IInputUnitBox) => {
4547
const [anchorEl, setAnchorEl] = React.useState<null | HTMLElement>(null);

0 commit comments

Comments
 (0)