15
15
// along with this program. If not, see <http://www.gnu.org/licenses/>.
16
16
17
17
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" ;
22
27
23
28
import { configurationElements } from "../utils" ;
24
29
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
+
33
37
import ConfigurationForm from "./ConfigurationForm" ;
34
38
import { IAM_PAGES } from "../../../../common/SecureComponent/permissions" ;
35
39
import PageHeaderWrapper from "../../Common/PageHeaderWrapper/PageHeaderWrapper" ;
36
40
import ExportConfigButton from "./ExportConfigButton" ;
37
41
import ImportConfigButton from "./ImportConfigButton" ;
38
- import { Box } from "@mui/material" ;
42
+
39
43
import HelpMenu from "../../HelpMenu" ;
40
44
import { setErrorSnackMessage , setHelpName } from "../../../../systemSlice" ;
41
45
import { useAppDispatch } from "../../../../store" ;
42
46
import { api } from "../../../../api" ;
43
47
import { IElement } from "../types" ;
44
48
import { errorToHandler } from "../../../../api/errors" ;
45
49
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
-
66
50
const getRoutePath = ( path : string ) => {
67
51
return `${ IAM_PAGES . SETTINGS } /${ path } ` ;
68
52
} ;
@@ -71,9 +55,10 @@ const getRoutePath = (path: string) => {
71
55
const NON_SUB_SYS_CONFIG_ITEMS = [ "region" ] ;
72
56
const IGNORED_CONFIG_SUB_SYS = [ "cache" ] ; // cache config is not supported.
73
57
74
- const ConfigurationOptions = ( { classes } : IConfigurationOptions ) => {
58
+ const ConfigurationOptions = ( ) => {
75
59
const { pathname = "" } = useLocation ( ) ;
76
60
const dispatch = useAppDispatch ( ) ;
61
+ const navigate = useNavigate ( ) ;
77
62
78
63
const [ configSubSysList , setConfigSubSysList ] = useState < string [ ] > ( [ ] ) ;
79
64
const fetchConfigSubSysList = useCallback ( async ( ) => {
@@ -99,8 +84,6 @@ const ConfigurationOptions = ({ classes }: IConfigurationOptions) => {
99
84
} ) ;
100
85
} , [ dispatch ] ) ;
101
86
102
- let selConfigTab = pathname . substring ( pathname . lastIndexOf ( "/" ) + 1 ) ;
103
- selConfigTab = selConfigTab === "settings" ? "region" : selConfigTab ;
104
87
useEffect ( ( ) => {
105
88
fetchConfigSubSysList ( ) ;
106
89
dispatch ( setHelpName ( "settings_Region" ) ) ;
@@ -121,59 +104,57 @@ const ConfigurationOptions = ({ classes }: IConfigurationOptions) => {
121
104
< Fragment >
122
105
< PageHeaderWrapper label = { "Settings" } actions = { < HelpMenu /> } />
123
106
< 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 ) => (
156
145
< 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 /> }
159
149
/>
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
+ />
177
158
</ Grid >
178
159
< Grid item xs = { 12 } sx = { { paddingTop : "15px" } } >
179
160
< HelpBox
@@ -203,4 +184,4 @@ const ConfigurationOptions = ({ classes }: IConfigurationOptions) => {
203
184
) ;
204
185
} ;
205
186
206
- export default withStyles ( styles ) ( ConfigurationOptions ) ;
187
+ export default ConfigurationOptions ;
0 commit comments