@@ -37,10 +37,11 @@ import ExportConfigButton from "./ExportConfigButton";
3737import ImportConfigButton from "./ImportConfigButton" ;
3838import { Box } from "@mui/material" ;
3939import HelpMenu from "../../HelpMenu" ;
40- import { setHelpName } from "../../../../systemSlice" ;
40+ import { setErrorSnackMessage , setHelpName } from "../../../../systemSlice" ;
4141import { useAppDispatch } from "../../../../store" ;
4242import { api } from "../../../../api" ;
4343import { IElement } from "../types" ;
44+ import { errorToHandler } from "../../../../api/errors" ;
4445
4546interface IConfigurationOptions {
4647 classes : any ;
@@ -66,17 +67,18 @@ const getRoutePath = (path: string) => {
6667 return `${ IAM_PAGES . SETTINGS } /${ path } ` ;
6768} ;
6869
69- //region would not be part of config subsystem list.
70+ // region is not part of config subsystem list.
7071const NON_SUB_SYS_CONFIG_ITEMS = [ "region" ] ;
71- const IGNORED_CONFIG_SUB_SYS = [ "cache" ] ; //cahe config is un supported.
72+ const IGNORED_CONFIG_SUB_SYS = [ "cache" ] ; // cache config is not supported.
7273
7374const ConfigurationOptions = ( { classes } : IConfigurationOptions ) => {
7475 const { pathname = "" } = useLocation ( ) ;
76+ const dispatch = useAppDispatch ( ) ;
7577
7678 const [ configSubSysList , setConfigSubSysList ] = useState < string [ ] > ( [ ] ) ;
7779 const fetchConfigSubSysList = useCallback ( async ( ) => {
7880 api . configs
79- . listConfig ( ) //get all available config subsystems.
81+ . listConfig ( ) // get a list of available config subsystems.
8082 . then ( ( res ) => {
8183 if ( res && res ?. data && res ?. data ?. configurations ) {
8284 const confSubSysList = ( res ?. data ?. configurations || [ ] ) . reduce (
@@ -92,14 +94,13 @@ const ConfigurationOptions = ({ classes }: IConfigurationOptions) => {
9294 setConfigSubSysList ( confSubSysList ) ;
9395 }
9496 } )
95- . catch ( ( ) => {
96- console . log ( "Error in retrieving config subsystem list." ) ;
97+ . catch ( ( err ) => {
98+ dispatch ( setErrorSnackMessage ( errorToHandler ( err ) ) ) ;
9799 } ) ;
98- } , [ ] ) ;
100+ } , [ dispatch ] ) ;
99101
100102 let selConfigTab = pathname . substring ( pathname . lastIndexOf ( "/" ) + 1 ) ;
101103 selConfigTab = selConfigTab === "settings" ? "region" : selConfigTab ;
102- const dispatch = useAppDispatch ( ) ;
103104 useEffect ( ( ) => {
104105 fetchConfigSubSysList ( ) ;
105106 dispatch ( setHelpName ( "settings_Region" ) ) ;
0 commit comments