Skip to content

Commit 0043833

Browse files
authored
Migrated Date Selectors & Chart Tooltips styles (#3107)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
1 parent 3ad3bcc commit 0043833

File tree

5 files changed

+228
-284
lines changed

5 files changed

+228
-284
lines changed

portal-ui/src/screens/Console/Buckets/ListBuckets/Objects/ObjectDetails/SetRetention.tsx

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ const SetRetention = ({
179179
onSubmit(e);
180180
}}
181181
>
182-
<FormLayout>
182+
<FormLayout withBorders={false} containerPadding={false}>
183183
<Box className={"inputItem"}>
184184
<strong>Selected Object</strong>: {objectName}
185185
</Box>
@@ -212,22 +212,20 @@ const SetRetention = ({
212212
{ label: "Compliance", value: ObjectRetentionMode.Compliance },
213213
]}
214214
/>
215-
<Box className={"inputItem"}>
216-
<DateSelector
217-
id="date"
218-
label="Date"
219-
disableOptions={dateFieldDisabled()}
220-
ref={dateElement}
221-
value={date}
222-
borderBottom={true}
223-
onDateChange={(date: string, isValid: boolean) => {
224-
setIsDateValid(isValid);
225-
if (isValid) {
226-
setDate(date);
227-
}
228-
}}
229-
/>
230-
</Box>
215+
<DateSelector
216+
id="date"
217+
label="Date"
218+
disableOptions={dateFieldDisabled()}
219+
ref={dateElement}
220+
value={date}
221+
borderBottom={true}
222+
onDateChange={(date: string, isValid: boolean) => {
223+
setIsDateValid(isValid);
224+
if (isValid) {
225+
setDate(date);
226+
}
227+
}}
228+
/>
231229
<Grid item xs={12} sx={modalStyleUtils.modalButtonBar}>
232230
<Button
233231
id={"reset"}

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

Lines changed: 41 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -20,35 +20,13 @@ import React, {
2020
useImperativeHandle,
2121
useState,
2222
} from "react";
23-
import clsx from "clsx";
24-
import { Box, Grid, HelpIcon, InputLabel, Select, Switch, Tooltip } from "mds";
25-
import { Theme } from "@mui/material/styles";
26-
import createStyles from "@mui/styles/createStyles";
27-
import withStyles from "@mui/styles/withStyles";
28-
import { fieldBasic, tooltipHelper } from "../common/styleLibrary";
23+
import { Box, HelpIcon, InputLabel, Select, Tooltip } from "mds";
2924
import { days, months, validDate, years } from "./utils";
3025

31-
const styles = (theme: Theme) =>
32-
createStyles({
33-
...fieldBasic,
34-
...tooltipHelper,
35-
fieldContainer: {
36-
...fieldBasic.fieldContainer,
37-
display: "flex",
38-
alignItems: "center",
39-
justifyContent: "space-between",
40-
paddingBottom: 10,
41-
marginTop: 11,
42-
marginBottom: 6,
43-
},
44-
});
45-
4626
interface IDateSelectorProps {
47-
classes: any;
4827
id: string;
4928
label: string;
5029
disableOptions?: boolean;
51-
addSwitch?: boolean;
5230
tooltip?: string;
5331
borderBottom?: boolean;
5432
value?: string;
@@ -58,11 +36,9 @@ interface IDateSelectorProps {
5836
const DateSelector = forwardRef(
5937
(
6038
{
61-
classes,
6239
id,
6340
label,
6441
disableOptions = false,
65-
addSwitch = false,
6642
tooltip = "",
6743
borderBottom = false,
6844
onDateChange,
@@ -72,7 +48,6 @@ const DateSelector = forwardRef(
7248
) => {
7349
useImperativeHandle(ref, () => ({ resetDate }));
7450

75-
const [dateEnabled, setDateEnabled] = useState<boolean>(false);
7651
const [month, setMonth] = useState<string>("");
7752
const [day, setDay] = useState<string>("");
7853
const [year, setYear] = useState<string>("");
@@ -104,8 +79,6 @@ const DateSelector = forwardRef(
10479
const isDateDisabled = () => {
10580
if (disableOptions) {
10681
return disableOptions;
107-
} else if (addSwitch) {
108-
return !dateEnabled;
10982
} else {
11083
return false;
11184
}
@@ -116,45 +89,43 @@ const DateSelector = forwardRef(
11689
const yearsForDrop = [{ value: "", label: "<Year>" }, ...years];
11790

11891
return (
119-
<Grid
120-
item
121-
xs={12}
122-
className={clsx(classes.fieldContainer, {
123-
[classes.fieldContainerBorder]: borderBottom,
124-
})}
125-
>
126-
<div className={classes.labelContainer}>
127-
<Grid container>
128-
<InputLabel htmlFor={id}>
129-
<span>{label}</span>
130-
{tooltip !== "" && (
131-
<div className={classes.tooltipContainer}>
132-
<Tooltip tooltip={tooltip} placement="top">
133-
<div className={classes.tooltip}>
134-
<HelpIcon />
135-
</div>
136-
</Tooltip>
137-
</div>
138-
)}
139-
</InputLabel>
140-
{addSwitch && (
141-
<Switch
142-
indicatorLabels={["Specific Date", "Default (7 Days)"]}
143-
checked={dateEnabled}
144-
value={"date_enabled"}
145-
id="date-status"
146-
name="date-status"
147-
onChange={(e) => {
148-
setDateEnabled(e.target.checked);
149-
if (!e.target.checked) {
150-
onDateChange("", true);
151-
}
92+
<Box className={"inputItem"}>
93+
<Box
94+
sx={{
95+
display: "flex",
96+
alignItems: "center",
97+
gap: 5,
98+
marginBottom: 5,
99+
}}
100+
>
101+
<InputLabel htmlFor={id}>
102+
<span>{label}</span>
103+
{tooltip !== "" && (
104+
<Box
105+
sx={{
106+
marginLeft: 5,
107+
display: "flex",
108+
alignItems: "center",
109+
"& .min-icon": {
110+
width: 13,
111+
},
152112
}}
153-
switchOnly
154-
/>
113+
>
114+
<Tooltip tooltip={tooltip} placement="top">
115+
<Box
116+
sx={{
117+
"& .min-icon": {
118+
width: 13,
119+
},
120+
}}
121+
>
122+
<HelpIcon />
123+
</Box>
124+
</Tooltip>
125+
</Box>
155126
)}
156-
</Grid>
157-
</div>
127+
</InputLabel>
128+
</Box>
158129
<Box sx={{ display: "flex", gap: 12 }}>
159130
<Select
160131
id={`${id}-month`}
@@ -190,11 +161,14 @@ const DateSelector = forwardRef(
190161
options={yearsForDrop}
191162
label={""}
192163
disabled={isDateDisabled()}
164+
sx={{
165+
marginBottom: 12,
166+
}}
193167
/>
194168
</Box>
195-
</Grid>
169+
</Box>
196170
);
197171
},
198172
);
199173

200-
export default withStyles(styles)(DateSelector);
174+
export default DateSelector;

0 commit comments

Comments
 (0)