@@ -15,15 +15,21 @@ const SearchApplicationSettings: React.FC = () => {
1515 const { showToast} = useToast ( ) ;
1616
1717 const fetchPersonaOptions = async ( ) => {
18- const identitiesIndex = ".search-acl-filter-search-sharepoint" //TODO fix hardcoded
19- const identitiesPath = searchEndpoint + "/" + identitiesIndex + "/_search"
20- const response = await fetch ( identitiesPath , { headers : { "Authorization" : "ApiKey " + apiKey } } ) ;
21- const jsonData = await response . json ( ) ;
22- const ids = jsonData . hits . hits . map ( ( hit ) => hit . _id )
23- return ids
18+ try {
19+ const identitiesIndex = ".search-acl-filter-search-sharepoint" //TODO fix hardcoded
20+ const identitiesPath = searchEndpoint + "/" + identitiesIndex + "/_search"
21+ const response = await fetch ( identitiesPath , { headers : { "Authorization" : "ApiKey " + apiKey } } ) ;
22+ const jsonData = await response . json ( ) ;
23+ const ids = jsonData . hits . hits . map ( ( hit ) => hit . _id )
24+ return ids
25+ } catch ( e ) {
26+ console . log ( "Something went wrong tying to fetch ACL identities" )
27+ console . log ( e )
28+ return [ "admin" ]
29+ }
2430 }
2531
26- const [ searchPersonaOptions , setSearchPersonaOptions ] = useState ( [ "admin" , "user" ] ) ;
32+ const [ searchPersonaOptions , setSearchPersonaOptions ] = useState ( [ "admin" ] ) ;
2733
2834 useEffect ( ( ) => {
2935 ( async ( ) => {
@@ -128,10 +134,11 @@ const SearchApplicationSettings: React.FC = () => {
128134 < div className = "relative" >
129135 < select
130136 onChange = { ( event ) => handlePersonaChange ( event . target . value ) }
137+ value = { searchPersona }
131138 className = "flex items-center space-x-2 p-2 bg-white rounded border border-gray-300 focus:outline-none focus:border-blue-500"
132139 >
133140 { searchPersonaOptions . map ( ( option , index ) => (
134- < option value = { option } selected = { option == searchPersona } className = "block text-left p-2 hover:bg-gray-100 cursor-pointer" >
141+ < option value = { option } key = { option } className = "block text-left p-2 hover:bg-gray-100 cursor-pointer" >
135142 { option }
136143 </ option >
137144 ) ) }
0 commit comments