[8.x] [Dataset Quality] Hide unreachable links (#196302) (#196452)

# Backport

This will backport the following commits from `main` to `8.x`:
- [[Dataset Quality] Hide unreachable links
(#196302)](https://github.com/elastic/kibana/pull/196302)

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

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

<!--BACKPORT
[{"author":{"name":"mohamedhamed-ahmed","email":"mohamed.ahmed@elastic.co"},"sourceCommit":{"committedDate":"2024-10-15T22:07:38Z","message":"[Dataset
Quality] Hide unreachable links (#196302)\n\ncloses
5cec1296-a17a-43bb-8530-99e7261a189a","sha":"5fbec1febc0050b2faaba7a25cf4aba9bf0cea1f","branchLabelMapping":{"^v9.0.0$":"main","^v8.16.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] Hide unreachable
links","number":196302,"url":"https://github.com/elastic/kibana/pull/196302","mergeCommit":{"message":"[Dataset
Quality] Hide unreachable links (#196302)\n\ncloses
5cec1296-a17a-43bb-8530-99e7261a189a","sha":"5fbec1febc0050b2faaba7a25cf4aba9bf0cea1f"}},"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/196302","number":196302,"mergeCommit":{"message":"[Dataset
Quality] Hide unreachable links (#196302)\n\ncloses
5cec1296-a17a-43bb-8530-99e7261a189a","sha":"5fbec1febc0050b2faaba7a25cf4aba9bf0cea1f"}}]}]
BACKPORT-->

Co-authored-by: mohamedhamed-ahmed <mohamed.ahmed@elastic.co>
This commit is contained in:
Kibana Machine 2024-10-16 10:48:30 +11:00 committed by GitHub
parent 9513867b11
commit 2a288431d3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 29 additions and 18 deletions

View file

@ -270,13 +270,12 @@ const DatasetQualityLink = React.memo(
urlService: BrowserUrlService;
dataStream: string | undefined;
}) => {
if (!dataStream) {
return null;
}
const locator = urlService.locators.get<DataQualityDetailsLocatorParams>(
DATA_QUALITY_DETAILS_LOCATOR_ID
);
if (!locator || !dataStream) return null;
const datasetQualityUrl = locator?.getRedirectUrl({ dataStream });
const navigateToDatasetQuality = () => {

View file

@ -8,7 +8,7 @@
import { EuiHeaderLink } from '@elastic/eui';
import { LogsExplorerPublicState } from '@kbn/logs-explorer-plugin/public';
import { getRouterLinkProps } from '@kbn/router-utils';
import { BrowserUrlService } from '@kbn/share-plugin/public';
import { LocatorPublic } from '@kbn/share-plugin/public';
import { MatchedStateFromActor } from '@kbn/xstate-utils';
import { useActor } from '@xstate/react';
import React from 'react';
@ -20,20 +20,28 @@ import {
} from '../state_machines/observability_logs_explorer/src';
import { useKibanaContextForPlugin } from '../utils/use_kibana';
export const ConnectedDatasetQualityLink = React.memo(() => {
export const ConnectedDatasetQualityLink = () => {
const {
services: {
share: { url },
},
} = useKibanaContextForPlugin();
const [pageState] = useActor(useObservabilityLogsExplorerPageStateContext());
const locator = url.locators.get<DataQualityLocatorParams>(DATA_QUALITY_LOCATOR_ID);
if (pageState.matches({ initialized: 'validLogsExplorerState' })) {
return <DatasetQualityLink urlService={url} pageState={pageState} />;
} else {
return <DatasetQualityLink urlService={url} />;
if (!locator) {
return null;
}
});
return (
<DatasetQualityLink
locator={locator}
pageState={
pageState.matches({ initialized: 'validLogsExplorerState' }) ? pageState : undefined
}
/>
);
};
type InitializedPageState = MatchedStateFromActor<
ObservabilityLogsExplorerService,
@ -62,14 +70,12 @@ const constructLocatorParams = (
export const DatasetQualityLink = React.memo(
({
urlService,
locator,
pageState,
}: {
urlService: BrowserUrlService;
locator: LocatorPublic<DataQualityLocatorParams>;
pageState?: InitializedPageState;
}) => {
const locator = urlService.locators.get<DataQualityLocatorParams>(DATA_QUALITY_LOCATOR_ID);
const locatorParams: DataQualityLocatorParams = pageState
? constructLocatorParams(pageState.context.logsExplorerState)
: {};

View file

@ -70,8 +70,7 @@ const ProjectTopNav = () => {
<EuiHeaderSectionItem>
<EuiHeaderLinks gutterSize="xs">
<ConnectedDiscoverLink />
<VerticalRule />
<ConnectedDatasetQualityLink />
<ConditionalVerticalRule Component={ConnectedDatasetQualityLink()} />
<VerticalRule />
<FeedbackLink />
<VerticalRule />
@ -147,8 +146,7 @@ const ClassicTopNav = () => {
<EuiHeaderSectionItem>
<EuiHeaderLinks gutterSize="xs">
<ConnectedDiscoverLink />
<VerticalRule />
<ConnectedDatasetQualityLink />
<ConditionalVerticalRule Component={ConnectedDatasetQualityLink()} />
<VerticalRule />
<AlertsPopover />
<VerticalRule />
@ -165,3 +163,11 @@ const VerticalRule = styled.span`
height: 20px;
background-color: ${euiThemeVars.euiColorLightShade};
`;
const ConditionalVerticalRule = ({ Component }: { Component: JSX.Element | null }) =>
Component && (
<>
<VerticalRule />
{Component}
</>
);