1717import React , { Fragment , useEffect , useState } from "react" ;
1818import { useSelector } from "react-redux" ;
1919import { useNavigate , useParams } from "react-router-dom" ;
20- import { Paper } from "@mui/material" ;
21- import Tabs from "@mui/material/Tabs" ;
22- import Tab from "@mui/material/Tab" ;
23-
24- import { TabPanel } from "../../../shared/tabs" ;
25- import TableWrapper from "../../Common/TableWrapper/TableWrapper" ;
20+ import { DataTable , SectionTitle , Tabs } from "mds" ;
21+ import { api } from "api" ;
22+ import { errorToHandler } from "api/errors" ;
2623import {
2724 CONSOLE_UI_RESOURCE ,
2825 IAM_PAGES ,
2926 IAM_SCOPES ,
3027} from "../../../../common/SecureComponent/permissions" ;
31- import PanelTitle from "../../Common/PanelTitle/PanelTitle" ;
3228import {
3329 hasPermission ,
3430 SecureComponent ,
@@ -38,15 +34,6 @@ import { setErrorSnackMessage, setHelpName } from "../../../../systemSlice";
3834import { selBucketDetailsLoading } from "./bucketDetailsSlice" ;
3935import { useAppDispatch } from "../../../../store" ;
4036import { Policy , ServiceAccounts } from "../../../../api/consoleApi" ;
41- import { api } from "api" ;
42- import { errorToHandler } from "api/errors" ;
43-
44- function a11yProps ( index : any ) {
45- return {
46- id : `simple-tab-${ index } ` ,
47- "aria-controls" : `simple-tabpanel-${ index } ` ,
48- } ;
49- }
5037
5138const AccessDetails = ( ) => {
5239 const dispatch = useAppDispatch ( ) ;
@@ -55,7 +42,7 @@ const AccessDetails = () => {
5542
5643 const loadingBucket = useSelector ( selBucketDetailsLoading ) ;
5744
58- const [ curTab , setCurTab ] = useState < number > ( 0 ) ;
45+ const [ curTab , setCurTab ] = useState < string > ( "simple-tab-0" ) ;
5946 const [ loadingPolicies , setLoadingPolicies ] = useState < boolean > ( true ) ;
6047 const [ bucketPolicy , setBucketPolicy ] = useState < Policy [ ] | undefined > ( [ ] ) ;
6148 const [ loadingUsers , setLoadingUsers ] = useState < boolean > ( true ) ;
@@ -158,65 +145,63 @@ const AccessDetails = () => {
158145
159146 return (
160147 < Fragment >
161- < PanelTitle > Access Audit</ PanelTitle >
148+ < SectionTitle separator > Access Audit</ SectionTitle >
162149 < Tabs
163- value = { curTab }
164- onChange = { ( e : React . ChangeEvent < { } > , newValue : number ) => {
150+ currentTabOrPath = { curTab }
151+ onTabClick = { ( newValue : string ) => {
165152 setCurTab ( newValue ) ;
166153 } }
167- indicatorColor = "primary"
168- textColor = "primary"
169- aria-label = "cluster-tabs"
170- variant = "scrollable"
171- scrollButtons = "auto"
172- >
173- { displayPoliciesList && < Tab label = "Policies" { ...a11yProps ( 0 ) } /> }
174- { displayUsersList && < Tab label = "Users" { ...a11yProps ( 1 ) } /> }
175- </ Tabs >
176- < Paper >
177- < TabPanel index = { 0 } value = { curTab } >
178- < SecureComponent
179- scopes = { [ IAM_SCOPES . ADMIN_LIST_USER_POLICIES ] }
180- resource = { bucketName }
181- errorProps = { { disabled : true } }
182- >
183- { bucketPolicy && (
184- < TableWrapper
185- noBackground = { true }
186- itemActions = { PolicyActions }
187- columns = { [ { label : "Name" , elementKey : "name" } ] }
188- isLoading = { loadingPolicies }
189- records = { bucketPolicy }
190- entityName = "Policies"
191- idField = "name"
192- />
193- ) }
194- </ SecureComponent >
195- </ TabPanel >
196-
197- < TabPanel index = { 1 } value = { curTab } >
198- < SecureComponent
199- scopes = { [
200- IAM_SCOPES . ADMIN_GET_POLICY ,
201- IAM_SCOPES . ADMIN_LIST_USERS ,
202- IAM_SCOPES . ADMIN_LIST_GROUPS ,
203- ] }
204- resource = { bucketName }
205- matchAll
206- errorProps = { { disabled : true } }
207- >
208- < TableWrapper
209- noBackground = { true }
210- itemActions = { userTableActions }
211- columns = { [ { label : "User" , elementKey : "accessKey" } ] }
212- isLoading = { loadingUsers }
213- records = { bucketUsers }
214- entityName = "Users"
215- idField = "accessKey"
216- />
217- </ SecureComponent >
218- </ TabPanel >
219- </ Paper >
154+ horizontal
155+ options = { [
156+ {
157+ tabConfig : { label : "Policies" , id : "simple-tab-0" } ,
158+ content : (
159+ < SecureComponent
160+ scopes = { [ IAM_SCOPES . ADMIN_LIST_USER_POLICIES ] }
161+ resource = { bucketName }
162+ errorProps = { { disabled : true } }
163+ >
164+ { bucketPolicy && (
165+ < DataTable
166+ noBackground = { true }
167+ itemActions = { PolicyActions }
168+ columns = { [ { label : "Name" , elementKey : "name" } ] }
169+ isLoading = { loadingPolicies }
170+ records = { bucketPolicy }
171+ entityName = "Policies"
172+ idField = "name"
173+ />
174+ ) }
175+ </ SecureComponent >
176+ ) ,
177+ } ,
178+ {
179+ tabConfig : { label : "Users" , id : "simple-tab-1" } ,
180+ content : (
181+ < SecureComponent
182+ scopes = { [
183+ IAM_SCOPES . ADMIN_GET_POLICY ,
184+ IAM_SCOPES . ADMIN_LIST_USERS ,
185+ IAM_SCOPES . ADMIN_LIST_GROUPS ,
186+ ] }
187+ resource = { bucketName }
188+ matchAll
189+ errorProps = { { disabled : true } }
190+ >
191+ < DataTable
192+ noBackground = { true }
193+ itemActions = { userTableActions }
194+ columns = { [ { label : "User" , elementKey : "accessKey" } ] }
195+ isLoading = { loadingUsers }
196+ records = { bucketUsers }
197+ entityName = "Users"
198+ idField = "accessKey"
199+ />
200+ </ SecureComponent >
201+ ) ,
202+ } ,
203+ ] }
204+ />
220205 </ Fragment >
221206 ) ;
222207} ;
0 commit comments