From a7a70d14a42c8ee0b11f11fa28c114036577caf4 Mon Sep 17 00:00:00 2001 From: SuZhou-Joe Date: Fri, 5 Jul 2024 11:33:21 +0800 Subject: [PATCH] feat: enable data source info in new left navigation Signed-off-by: SuZhou-Joe --- public/apps/configuration/top-nav-menu.tsx | 5 ++++- public/plugin.ts | 10 +++++++--- public/utils/datasource-utils.ts | 4 +++- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/public/apps/configuration/top-nav-menu.tsx b/public/apps/configuration/top-nav-menu.tsx index ee71c71c4..20197d69a 100644 --- a/public/apps/configuration/top-nav-menu.tsx +++ b/public/apps/configuration/top-nav-menu.tsx @@ -17,7 +17,10 @@ import React from 'react'; import { DataSourceSelectableConfig } from 'src/plugins/data_source_management/public'; import { DataSourceOption } from 'src/plugins/data_source_management/public/components/data_source_menu/types'; import { AppDependencies } from '../types'; -import { setDataSourceInUrl, setDataSource as setDataSourceInSubscription } from '../../utils/datasource-utils'; +import { + setDataSourceInUrl, + setDataSource as setDataSourceInSubscription, +} from '../../utils/datasource-utils'; export interface TopNavMenuProps extends AppDependencies { dataSourcePickerReadOnly: boolean; diff --git a/public/plugin.ts b/public/plugin.ts index e5995aa48..52eec6c02 100644 --- a/public/plugin.ts +++ b/public/plugin.ts @@ -53,7 +53,11 @@ import { addTenantToShareURL } from './services/shared-link'; import { interceptError } from './utils/logout-utils'; import { tenantColumn, getNamespacesToRegister } from './apps/configuration/utils/tenant-utils'; import { getDashboardsInfoSafe } from './utils/dashboards-info-utils'; -import { dataSource$, getDataSourceEnabledUrl, getDataSourceFromUrl, setDataSourceInUrl } from './utils/datasource-utils'; +import { + dataSource$, + getDataSourceEnabledUrl, + getDataSourceFromUrl, +} from './utils/datasource-utils'; async function hasApiPermission(core: CoreSetup): Promise { try { @@ -94,9 +98,9 @@ export class SecurityPlugin private updateDefaultRouteOfSecurityApplications: AppUpdater = () => { const url = getDataSourceEnabledUrl(getDataSourceFromUrl()); return { - defaultPath: `?${url.searchParams.toString()}` + defaultPath: `?${url.searchParams.toString()}`, }; - } + }; private appStateUpdater = new BehaviorSubject(this.updateDefaultRouteOfSecurityApplications); diff --git a/public/utils/datasource-utils.ts b/public/utils/datasource-utils.ts index 45eef9a56..508a72a78 100644 --- a/public/utils/datasource-utils.ts +++ b/public/utils/datasource-utils.ts @@ -48,7 +48,9 @@ export function setDataSourceInUrl(dataSource: DataSourceOption) { export const LocalCluster = { label: 'Local cluster', id: '' }; -export const dataSource$ = new BehaviorSubject(getDataSourceFromUrl() || LocalCluster); +export const dataSource$ = new BehaviorSubject( + getDataSourceFromUrl() || LocalCluster +); export function setDataSource(dataSource: DataSourceOption) { dataSource$.next(dataSource);