[8.x] [Dataset Quality] Check if Obs Logs Explorer accessible before linking Logs Explorer (#197020) (#197235)

# Backport

This will backport the following commits from `main` to `8.x`:
- [[Dataset Quality] Check if Obs Logs Explorer accessible before
linking Logs Explorer
(#197020)](https://github.com/elastic/kibana/pull/197020)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Abdul Wahab
Zahid","email":"awahab07@yahoo.com"},"sourceCommit":{"committedDate":"2024-10-22T13:09:48Z","message":"[Dataset
Quality] Check if Obs Logs Explorer accessible before linking Logs
Explorer (#197020)\n\nFixes
https://github.com/elastic/kibana/issues/196506\r\n\r\n##
Summary\r\n\r\nBefore linking to Logs Explorer in Dataset Quality, the
PR checks if\r\n`observability-logs-explorer` is available and
accessible before\r\nconsuming the `SINGLE_DATASET_LOCATOR_ID`
locator.\r\n\r\nObservability Logs Explorer app is not available in
Security and Search\r\nsolution views.\r\n\r\n\r\nAfter the
fix:\r\n\r\n\r\nhttps://github.com/user-attachments/assets/ed36806a-0483-4765-a6f1-85936b92d390\r\n\r\n\r\n\r\nThere's
only one more place, Observability Onboarding,
where\r\n`SINGLE_DATASET_LOCATOR_ID` is consumed. Which being part
of\r\nObservability solution view, it can be assumed that Observability
Logs\r\nExplorer will always be
available.\r\n\r\n\r\n![image](https://github.com/user-attachments/assets/b51bf9b6-a9c4-4fd4-8865-3dda76262a93)\r\n\r\n----\r\n\r\nThe
other Observability Logs Explorer locator
`ALL_DATASETS_LOCATOR_ID`\r\nis only consumed in observability wrapper
apps and `apm` and `infra`\r\nplugins, all of which are only available
under Observability where\r\nObservability Logs Explorer is also
available.\r\n\r\n68b3267ca2/packages/deeplinks/observability/locators/observability_logs_explorer.ts (L24)\r\n\r\n---------\r\n\r\nCo-authored-by:
kibanamachine
<42973632+kibanamachine@users.noreply.github.com>","sha":"c076b7ac45957c2cffb4cbb5f197e8b01a64c8f9","branchLabelMapping":{"^v9.0.0$":"main","^v8.17.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["bug","release_note:skip","v9.0.0","backport:prev-minor","ci:project-deploy-observability","Team:obs-ux-logs"],"title":"[Dataset
Quality] Check if Obs Logs Explorer accessible before linking Logs
Explorer","number":197020,"url":"https://github.com/elastic/kibana/pull/197020","mergeCommit":{"message":"[Dataset
Quality] Check if Obs Logs Explorer accessible before linking Logs
Explorer (#197020)\n\nFixes
https://github.com/elastic/kibana/issues/196506\r\n\r\n##
Summary\r\n\r\nBefore linking to Logs Explorer in Dataset Quality, the
PR checks if\r\n`observability-logs-explorer` is available and
accessible before\r\nconsuming the `SINGLE_DATASET_LOCATOR_ID`
locator.\r\n\r\nObservability Logs Explorer app is not available in
Security and Search\r\nsolution views.\r\n\r\n\r\nAfter the
fix:\r\n\r\n\r\nhttps://github.com/user-attachments/assets/ed36806a-0483-4765-a6f1-85936b92d390\r\n\r\n\r\n\r\nThere's
only one more place, Observability Onboarding,
where\r\n`SINGLE_DATASET_LOCATOR_ID` is consumed. Which being part
of\r\nObservability solution view, it can be assumed that Observability
Logs\r\nExplorer will always be
available.\r\n\r\n\r\n![image](https://github.com/user-attachments/assets/b51bf9b6-a9c4-4fd4-8865-3dda76262a93)\r\n\r\n----\r\n\r\nThe
other Observability Logs Explorer locator
`ALL_DATASETS_LOCATOR_ID`\r\nis only consumed in observability wrapper
apps and `apm` and `infra`\r\nplugins, all of which are only available
under Observability where\r\nObservability Logs Explorer is also
available.\r\n\r\n68b3267ca2/packages/deeplinks/observability/locators/observability_logs_explorer.ts (L24)\r\n\r\n---------\r\n\r\nCo-authored-by:
kibanamachine
<42973632+kibanamachine@users.noreply.github.com>","sha":"c076b7ac45957c2cffb4cbb5f197e8b01a64c8f9"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/197020","number":197020,"mergeCommit":{"message":"[Dataset
Quality] Check if Obs Logs Explorer accessible before linking Logs
Explorer (#197020)\n\nFixes
https://github.com/elastic/kibana/issues/196506\r\n\r\n##
Summary\r\n\r\nBefore linking to Logs Explorer in Dataset Quality, the
PR checks if\r\n`observability-logs-explorer` is available and
accessible before\r\nconsuming the `SINGLE_DATASET_LOCATOR_ID`
locator.\r\n\r\nObservability Logs Explorer app is not available in
Security and Search\r\nsolution views.\r\n\r\n\r\nAfter the
fix:\r\n\r\n\r\nhttps://github.com/user-attachments/assets/ed36806a-0483-4765-a6f1-85936b92d390\r\n\r\n\r\n\r\nThere's
only one more place, Observability Onboarding,
where\r\n`SINGLE_DATASET_LOCATOR_ID` is consumed. Which being part
of\r\nObservability solution view, it can be assumed that Observability
Logs\r\nExplorer will always be
available.\r\n\r\n\r\n![image](https://github.com/user-attachments/assets/b51bf9b6-a9c4-4fd4-8865-3dda76262a93)\r\n\r\n----\r\n\r\nThe
other Observability Logs Explorer locator
`ALL_DATASETS_LOCATOR_ID`\r\nis only consumed in observability wrapper
apps and `apm` and `infra`\r\nplugins, all of which are only available
under Observability where\r\nObservability Logs Explorer is also
available.\r\n\r\n68b3267ca2/packages/deeplinks/observability/locators/observability_logs_explorer.ts (L24)\r\n\r\n---------\r\n\r\nCo-authored-by:
kibanamachine
<42973632+kibanamachine@users.noreply.github.com>","sha":"c076b7ac45957c2cffb4cbb5f197e8b01a64c8f9"}}]}]
BACKPORT-->

Co-authored-by: Abdul Wahab Zahid <awahab07@yahoo.com>
This commit is contained in:
Kibana Machine 2024-10-23 01:51:38 +11:00 committed by GitHub
parent 34fb0f04d3
commit d6df65e969
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 21 additions and 3 deletions

View file

@ -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 = <T extends BasicDataStream>({
sendTelemetry: SendTelemetryFn;
}) => {
const {
services: { share },
services: { share, application },
} = useKibanaContextForPlugin();
const { from, to } = timeRangeConfig;
@ -42,12 +46,24 @@ export const useRedirectLink = <T extends BasicDataStream>({
const logsExplorerLocator =
share.url.locators.get<SingleDatasetLocatorParams>(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 = <T extends BasicDataStream>({
query,
sendTelemetry,
share.url.locators,
isLogsExplorerAppAccessible,
]);
};

View file

@ -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/**/*"