@@ -19,7 +19,12 @@ import {
19
19
import { CoreStart , MountPoint , Toast , ReactChild } from '../../../../src/core/public' ;
20
20
import { DataSourceManagementPluginSetup } from '../../../../src/plugins/data_source_management/public' ;
21
21
import { NavigationPublicPluginStart } from '../../../../src/plugins/navigation/public' ;
22
- import { PLUGIN_NAME , COMPARE_SEARCH_RESULTS_TITLE , ServiceEndpoints } from '../../common' ;
22
+ import {
23
+ PLUGIN_NAME ,
24
+ COMPARE_SEARCH_RESULTS_TITLE ,
25
+ ServiceEndpoints ,
26
+ SEARCH_RELEVANCE_WORKBENCH_UI_EXPERIENCE_ENABLED ,
27
+ } from '../../common' ;
23
28
import { SearchRelevanceContextProvider } from '../contexts' ;
24
29
import { Home as QueryCompareHome } from './query_compare/home' ;
25
30
import { useOpenSearchDashboards } from '../../../../src/plugins/opensearch_dashboards_react/public' ;
@@ -61,7 +66,7 @@ interface SearchRelevanceAppDeps {
61
66
dataSourceManagement : DataSourceManagementPluginSetup ;
62
67
setActionMenu : ( menuMount : MountPoint | undefined ) => void ;
63
68
application : CoreStart [ 'application' ] ;
64
- isNewExperienceEnabled ?: boolean ;
69
+ uiSettings : CoreStart [ 'uiSettings' ] ;
65
70
}
66
71
67
72
const SearchRelevancePage = ( { history } ) => {
@@ -355,46 +360,12 @@ export const SearchRelevanceApp = ({
355
360
setActionMenu,
356
361
dataSourceManagement,
357
362
application,
363
+ uiSettings,
358
364
} : SearchRelevanceAppDeps ) => {
359
365
// Move all useState declarations to the top
360
- const [ isNewExperienceEnabled , setIsNewExperienceEnabled ] = useState < boolean > ( false ) ;
361
- const [ isLoading , setIsLoading ] = useState < boolean > ( true ) ;
362
366
const [ toasts , setToasts ] = useState < Toast [ ] > ( [ ] ) ;
363
367
const [ toastRightSide , setToastRightSide ] = useState < boolean > ( true ) ;
364
368
365
- useEffect ( ( ) => {
366
- const fetchClusterSettings = async ( ) => {
367
- try {
368
- const response = await http . get ( ServiceEndpoints . GetClusterSettings ) ;
369
-
370
- // Check both persistent and defaults settings
371
- const persistentEnabled =
372
- response ?. persistent ?. plugins ?. search_relevance ?. workbench_enabled === 'true' ;
373
- const defaultsEnabled =
374
- response ?. defaults ?. plugins ?. search_relevance ?. workbench_enabled === 'true' ;
375
-
376
- // Use persistent setting if available, otherwise use defaults
377
- const enabled = persistentEnabled || defaultsEnabled ;
378
- setIsNewExperienceEnabled ( enabled ) ;
379
- } catch ( error ) {
380
- console . error ( 'Error fetching cluster settings:' , error ) ;
381
- notifications . toasts . addError ( error as Error , {
382
- title : 'Error fetching cluster settings' ,
383
- toastLifeTimeMs : 5000 ,
384
- } ) ;
385
- setIsNewExperienceEnabled ( false ) ;
386
- } finally {
387
- setIsLoading ( false ) ;
388
- }
389
- } ;
390
-
391
- fetchClusterSettings ( ) ;
392
- } , [ http , notifications ] ) ;
393
-
394
- if ( isLoading ) {
395
- return < EuiLoadingSpinner size = "xl" /> ;
396
- }
397
-
398
369
const getNavGroupEnabled = chrome . navGroup . getNavGroupEnabled ( ) ;
399
370
400
371
const parentBreadCrumbs = getNavGroupEnabled
@@ -407,9 +378,10 @@ export const SearchRelevanceApp = ({
407
378
setToasts ( [ ...toasts , { id : new Date ( ) . toISOString ( ) , title, text, color } as Toast ] ) ;
408
379
} ;
409
380
410
- if ( isLoading ) {
411
- return < EuiLoadingSpinner size = "xl" /> ;
412
- }
381
+ // UI Experience are controlled by ui settings
382
+ const isNewExperienceEnabled = Boolean (
383
+ uiSettings ?. get ( SEARCH_RELEVANCE_WORKBENCH_UI_EXPERIENCE_ENABLED )
384
+ ) ;
413
385
414
386
const renderNewExperience = ( ) => (
415
387
< HashRouter >
0 commit comments