Skip to content

Commit

Permalink
return utils in setup
Browse files Browse the repository at this point in the history
Signed-off-by: tygao <[email protected]>
  • Loading branch information
raintygao committed May 29, 2024
1 parent 0327dab commit e1b567b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/plugins/data_source_management/public/components/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,12 +133,12 @@ export function getFilteredDataSources(

export function getDefaultDataSourceId(uiSettings?: IUiSettingsClient) {
if (!uiSettings) return null;
return uiSettings.get(DEFAULT_DATA_SOURCE_UI_SETTINGS_ID, null);
return uiSettings.get<string | null>(DEFAULT_DATA_SOURCE_UI_SETTINGS_ID, null);
}

export function getDefaultDataSourceId$(uiSettings?: IUiSettingsClient) {
if (!uiSettings) return null;
return uiSettings.get$(DEFAULT_DATA_SOURCE_UI_SETTINGS_ID, null);
return uiSettings.get$<string | null>(DEFAULT_DATA_SOURCE_UI_SETTINGS_ID, null);
}

export function getDefaultDataSource(
Expand Down
12 changes: 11 additions & 1 deletion src/plugins/data_source_management/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,13 @@ import { noAuthCredentialAuthMethod, sigV4AuthMethod, usernamePasswordAuthMethod
import { DataSourceSelectorProps } from './components/data_source_selector/data_source_selector';
import { createDataSourceMenu } from './components/data_source_menu/create_data_source_menu';
import { DataSourceMenuProps } from './components/data_source_menu';
import { setApplication, setHideLocalCluster, setUiSettings } from './components/utils';
import {
setApplication,
setHideLocalCluster,
setUiSettings,
getDefaultDataSourceId,
getDefaultDataSourceId$,
} from './components/utils';

export interface DataSourceManagementSetupDependencies {
management: ManagementSetup;
Expand All @@ -34,6 +40,8 @@ export interface DataSourceManagementPluginSetup {
ui: {
DataSourceSelector: React.ComponentType<DataSourceSelectorProps>;
getDataSourceMenu: <T>() => React.ComponentType<DataSourceMenuProps<T>>;
getDefaultDataSourceId: typeof getDefaultDataSourceId;
getDefaultDataSourceId$: typeof getDefaultDataSourceId$;
};
}

Expand Down Expand Up @@ -111,6 +119,8 @@ export class DataSourceManagementPlugin
DataSourceSelector: createDataSourceSelector(uiSettings, dataSource),
getDataSourceMenu: <T>() => createDataSourceMenu<T>(),
},
getDefaultDataSourceId,
getDefaultDataSourceId$,
};
}

Expand Down

0 comments on commit e1b567b

Please sign in to comment.