diff --git a/x-pack/plugins/observability_solution/dataset_quality/public/hooks/use_redirect_link.ts b/x-pack/plugins/observability_solution/dataset_quality/public/hooks/use_redirect_link.ts index 638af464a87cd..d1e55d488ba5c 100644 --- a/x-pack/plugins/observability_solution/dataset_quality/public/hooks/use_redirect_link.ts +++ b/x-pack/plugins/observability_solution/dataset_quality/public/hooks/use_redirect_link.ts @@ -5,8 +5,12 @@ * 2.0. */ +import { map } from 'rxjs'; import { useMemo } from 'react'; +import useObservable from 'react-use/lib/useObservable'; +import { AppStatus } from '@kbn/core-application-browser'; import { + OBSERVABILITY_LOGS_EXPLORER_APP_ID, SINGLE_DATASET_LOCATOR_ID, SingleDatasetLocatorParams, } from '@kbn/deeplinks-observability'; @@ -34,7 +38,7 @@ export const useRedirectLink = ({ sendTelemetry: SendTelemetryFn; }) => { const { - services: { share }, + services: { share, application }, } = useKibanaContextForPlugin(); const { from, to } = timeRangeConfig; @@ -42,12 +46,24 @@ export const useRedirectLink = ({ const logsExplorerLocator = share.url.locators.get(SINGLE_DATASET_LOCATOR_ID); + const isLogsExplorerAppAccessible = useObservable( + application.applications$.pipe( + map( + (apps) => + (apps.get(OBSERVABILITY_LOGS_EXPLORER_APP_ID)?.status ?? AppStatus.inaccessible) === + AppStatus.accessible + ) + ), + false + ); + return useMemo<{ linkProps: RouterLinkProps; navigate: () => void; isLogsExplorerAvailable: boolean; }>(() => { - const isLogsExplorerAvailable = !!logsExplorerLocator && dataStreamStat.type === 'logs'; + const isLogsExplorerAvailable = + isLogsExplorerAppAccessible && !!logsExplorerLocator && dataStreamStat.type === 'logs'; const config = isLogsExplorerAvailable ? buildLogsExplorerConfig({ locator: logsExplorerLocator, @@ -95,6 +111,7 @@ export const useRedirectLink = ({ query, sendTelemetry, share.url.locators, + isLogsExplorerAppAccessible, ]); }; diff --git a/x-pack/plugins/observability_solution/dataset_quality/tsconfig.json b/x-pack/plugins/observability_solution/dataset_quality/tsconfig.json index 934c0e434d9a5..f0d82fadb54ad 100644 --- a/x-pack/plugins/observability_solution/dataset_quality/tsconfig.json +++ b/x-pack/plugins/observability_solution/dataset_quality/tsconfig.json @@ -59,7 +59,8 @@ "@kbn/telemetry-plugin", "@kbn/usage-collection-plugin", "@kbn/rison", - "@kbn/task-manager-plugin" + "@kbn/task-manager-plugin", + "@kbn/core-application-browser" ], "exclude": [ "target/**/*"