Skip to content

Commit 72bb9d0

Browse files
authored
Update Settings Page components (#2986)
Signed-off-by: Benjamin Perez <[email protected]>
1 parent 93bd0d6 commit 72bb9d0

File tree

10 files changed

+189
-404
lines changed

10 files changed

+189
-404
lines changed

portal-ui/src/screens/Console/Common/VerticalTabs/VerticalTabs.tsx

Lines changed: 0 additions & 181 deletions
This file was deleted.

portal-ui/src/screens/Console/Configurations/ConfigurationPanels/ConfigurationOptions.tsx

Lines changed: 69 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -15,54 +15,38 @@
1515
// along with this program. If not, see <http://www.gnu.org/licenses/>.
1616

1717
import React, { Fragment, useCallback, useEffect, useState } from "react";
18-
import { Theme } from "@mui/material/styles";
19-
import createStyles from "@mui/styles/createStyles";
20-
import withStyles from "@mui/styles/withStyles";
21-
import Grid from "@mui/material/Grid";
18+
import {
19+
Box,
20+
Grid,
21+
HelpBox,
22+
PageLayout,
23+
ScreenTitle,
24+
SettingsIcon,
25+
Tabs,
26+
} from "mds";
2227

2328
import { configurationElements } from "../utils";
2429
import {
25-
actionsTray,
26-
containerForHeader,
27-
searchField,
28-
} from "../../Common/FormComponents/common/styleLibrary";
29-
import { HelpBox, PageLayout, SettingsIcon } from "mds";
30-
import { Link, Navigate, Route, Routes, useLocation } from "react-router-dom";
31-
import VerticalTabs from "../../Common/VerticalTabs/VerticalTabs";
32-
import ScreenTitle from "../../Common/ScreenTitle/ScreenTitle";
30+
Navigate,
31+
Route,
32+
Routes,
33+
useLocation,
34+
useNavigate,
35+
} from "react-router-dom";
36+
3337
import ConfigurationForm from "./ConfigurationForm";
3438
import { IAM_PAGES } from "../../../../common/SecureComponent/permissions";
3539
import PageHeaderWrapper from "../../Common/PageHeaderWrapper/PageHeaderWrapper";
3640
import ExportConfigButton from "./ExportConfigButton";
3741
import ImportConfigButton from "./ImportConfigButton";
38-
import { Box } from "@mui/material";
42+
3943
import HelpMenu from "../../HelpMenu";
4044
import { setErrorSnackMessage, setHelpName } from "../../../../systemSlice";
4145
import { useAppDispatch } from "../../../../store";
4246
import { api } from "../../../../api";
4347
import { IElement } from "../types";
4448
import { errorToHandler } from "../../../../api/errors";
4549

46-
interface IConfigurationOptions {
47-
classes: any;
48-
}
49-
50-
const styles = (theme: Theme) =>
51-
createStyles({
52-
settingsOptionsContainer: {
53-
display: "flex" as const,
54-
flexDirection: "row" as const,
55-
justifyContent: "flex-start" as const,
56-
flexWrap: "wrap" as const,
57-
border: "#E5E5E5 1px solid",
58-
borderRadius: 2,
59-
backgroundColor: "#fff",
60-
},
61-
...searchField,
62-
...actionsTray,
63-
...containerForHeader,
64-
});
65-
6650
const getRoutePath = (path: string) => {
6751
return `${IAM_PAGES.SETTINGS}/${path}`;
6852
};
@@ -71,9 +55,10 @@ const getRoutePath = (path: string) => {
7155
const NON_SUB_SYS_CONFIG_ITEMS = ["region"];
7256
const IGNORED_CONFIG_SUB_SYS = ["cache"]; // cache config is not supported.
7357

74-
const ConfigurationOptions = ({ classes }: IConfigurationOptions) => {
58+
const ConfigurationOptions = () => {
7559
const { pathname = "" } = useLocation();
7660
const dispatch = useAppDispatch();
61+
const navigate = useNavigate();
7762

7863
const [configSubSysList, setConfigSubSysList] = useState<string[]>([]);
7964
const fetchConfigSubSysList = useCallback(async () => {
@@ -99,8 +84,6 @@ const ConfigurationOptions = ({ classes }: IConfigurationOptions) => {
9984
});
10085
}, [dispatch]);
10186

102-
let selConfigTab = pathname.substring(pathname.lastIndexOf("/") + 1);
103-
selConfigTab = selConfigTab === "settings" ? "region" : selConfigTab;
10487
useEffect(() => {
10588
fetchConfigSubSysList();
10689
dispatch(setHelpName("settings_Region"));
@@ -121,59 +104,57 @@ const ConfigurationOptions = ({ classes }: IConfigurationOptions) => {
121104
<Fragment>
122105
<PageHeaderWrapper label={"Settings"} actions={<HelpMenu />} />
123106
<PageLayout>
124-
<Grid item xs={12}>
125-
<div
126-
id="settings-container"
127-
className={classes.settingsOptionsContainer}
128-
>
129-
<ScreenTitle
130-
icon={<SettingsIcon />}
131-
title={"MinIO Configuration:"}
132-
actions={
133-
<Box
134-
sx={{
135-
display: "flex",
136-
gap: 2,
137-
}}
138-
>
139-
<ImportConfigButton />
140-
<ExportConfigButton />
141-
</Box>
142-
}
143-
/>
144-
<VerticalTabs
145-
selectedTab={selConfigTab}
146-
isRouteTabs
147-
routes={
148-
<Routes>
149-
{availableConfigSubSys.map((element) => (
150-
<Route
151-
key={`configItem-${element.configuration_label}`}
152-
path={`${element.configuration_id}`}
153-
element={<ConfigurationForm />}
154-
/>
155-
))}
107+
<Grid item xs={12} id={"settings-container"}>
108+
<ScreenTitle
109+
icon={<SettingsIcon />}
110+
title={"MinIO Configuration:"}
111+
actions={
112+
<Box
113+
sx={{
114+
display: "flex",
115+
gap: 10,
116+
}}
117+
>
118+
<ImportConfigButton />
119+
<ExportConfigButton />
120+
</Box>
121+
}
122+
sx={{ marginBottom: 15 }}
123+
/>
124+
<Tabs
125+
currentTabOrPath={pathname}
126+
onTabClick={(path) => {
127+
navigate(path);
128+
}}
129+
useRouteTabs
130+
options={availableConfigSubSys.map((element) => {
131+
const { configuration_id, configuration_label, icon } = element;
132+
return {
133+
tabConfig: {
134+
id: `settings-tab-${configuration_label}`,
135+
label: configuration_label,
136+
value: configuration_id,
137+
icon: icon,
138+
to: getRoutePath(configuration_id),
139+
},
140+
};
141+
})}
142+
routes={
143+
<Routes>
144+
{availableConfigSubSys.map((element) => (
156145
<Route
157-
path={"/"}
158-
element={<Navigate to={`${IAM_PAGES.SETTINGS}/region`} />}
146+
key={`configItem-${element.configuration_label}`}
147+
path={`${element.configuration_id}`}
148+
element={<ConfigurationForm />}
159149
/>
160-
</Routes>
161-
}
162-
>
163-
{availableConfigSubSys.map((element) => {
164-
const { configuration_id, configuration_label, icon } = element;
165-
return {
166-
tabConfig: {
167-
label: configuration_label,
168-
value: configuration_id,
169-
icon: icon,
170-
component: Link,
171-
to: getRoutePath(configuration_id),
172-
},
173-
};
174-
})}
175-
</VerticalTabs>
176-
</div>
150+
))}
151+
<Route
152+
path={"/"}
153+
element={<Navigate to={`${IAM_PAGES.SETTINGS}/region`} />}
154+
/>
155+
</Routes>
156+
}
157+
/>
177158
</Grid>
178159
<Grid item xs={12} sx={{ paddingTop: "15px" }}>
179160
<HelpBox
@@ -203,4 +184,4 @@ const ConfigurationOptions = ({ classes }: IConfigurationOptions) => {
203184
);
204185
};
205186

206-
export default withStyles(styles)(ConfigurationOptions);
187+
export default ConfigurationOptions;

0 commit comments

Comments
 (0)