@@ -19,7 +19,11 @@ 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
+ SEARCH_RELEVANCE_EXPERIMENTAL_WORKBENCH_UI_EXPERIENCE_ENABLED ,
26
+ } from '../../common' ;
23
27
import { SearchRelevanceContextProvider } from '../contexts' ;
24
28
import { Home as QueryCompareHome } from './query_compare/home' ;
25
29
import { useOpenSearchDashboards } from '../../../../src/plugins/opensearch_dashboards_react/public' ;
@@ -61,7 +65,7 @@ interface SearchRelevanceAppDeps {
61
65
dataSourceManagement : DataSourceManagementPluginSetup ;
62
66
setActionMenu : ( menuMount : MountPoint | undefined ) => void ;
63
67
application : CoreStart [ 'application' ] ;
64
- isNewExperienceEnabled ?: boolean ;
68
+ uiSettings : CoreStart [ 'uiSettings' ] ;
65
69
}
66
70
67
71
const SearchRelevancePage = ( { history } ) => {
@@ -355,46 +359,12 @@ export const SearchRelevanceApp = ({
355
359
setActionMenu,
356
360
dataSourceManagement,
357
361
application,
362
+ uiSettings,
358
363
} : SearchRelevanceAppDeps ) => {
359
364
// Move all useState declarations to the top
360
- const [ isNewExperienceEnabled , setIsNewExperienceEnabled ] = useState < boolean > ( false ) ;
361
- const [ isLoading , setIsLoading ] = useState < boolean > ( true ) ;
362
365
const [ toasts , setToasts ] = useState < Toast [ ] > ( [ ] ) ;
363
366
const [ toastRightSide , setToastRightSide ] = useState < boolean > ( true ) ;
364
367
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
368
const getNavGroupEnabled = chrome . navGroup . getNavGroupEnabled ( ) ;
399
369
400
370
const parentBreadCrumbs = getNavGroupEnabled
@@ -407,9 +377,10 @@ export const SearchRelevanceApp = ({
407
377
setToasts ( [ ...toasts , { id : new Date ( ) . toISOString ( ) , title, text, color } as Toast ] ) ;
408
378
} ;
409
379
410
- if ( isLoading ) {
411
- return < EuiLoadingSpinner size = "xl" /> ;
412
- }
380
+ // UI Experience are controlled by ui settings
381
+ const isNewExperienceEnabled = Boolean (
382
+ uiSettings ?. get ( SEARCH_RELEVANCE_EXPERIMENTAL_WORKBENCH_UI_EXPERIENCE_ENABLED )
383
+ ) ;
413
384
414
385
const renderNewExperience = ( ) => (
415
386
< HashRouter >
0 commit comments