-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Dataset quality] Open in Log explorer action (#173272)
Closes #170236. ### Changes This PR focuses on adding an action per dataset + namespace to navigate to Observability log explorer. At the same time I took the opportunity to update `Open in discover` link to include the controls present in `Observability Log Explorer` state (atm just `namespace`) 1. Extracted `getRouterLinkProps` to a new package for reusability. 2. New `Actions` column was added to table. 3. `LogExplorerLink ` component was introduced, to reuse the navigation logic between the table and the flyout. 4. `getDiscoverFiltersFromState` was added to combine state filters and controls into discover state when navigating to discover #### Demo https://github.com/elastic/kibana/assets/1313018/a3f38615-d8ae-432b-ba7b-05a6901f870c --------- Co-authored-by: kibanamachine <[email protected]>
- Loading branch information
1 parent
0cccd5f
commit ce293db
Showing
25 changed files
with
280 additions
and
70 deletions.
There are no files selected for viewing
Validating CODEOWNERS rules …
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# @kbn/router-utils | ||
|
||
This package provides util functions when working with the router. | ||
|
||
## getRouterLinkProps | ||
|
||
Useful to generate link component properties for HTML elements, this link properties will allow them to behave as native links and handle events such as open in a new tab, or client-side navigation without refreshing the whole page. | ||
|
||
### Example | ||
|
||
We want a button to both navigate to Discover client-side or open on a new window. | ||
|
||
```ts | ||
const DiscoverLink = (discoverLinkParams) => { | ||
const discoverUrl = discover.locator?.getRedirectUrl(discoverLinkParams); | ||
|
||
const navigateToDiscover = () => { | ||
discover.locator?.navigate(discoverLinkParams); | ||
}; | ||
|
||
const linkProps = getRouterLinkProps({ | ||
href: discoverUrl, | ||
onClick: navigateToDiscover, | ||
}); | ||
|
||
return ( | ||
<> | ||
<EuiButton {...linkProps}> | ||
{discoverLinkTitle} | ||
</EuiButton> | ||
</> | ||
); | ||
}; | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
export { getRouterLinkProps } from './src/get_router_link_props'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
module.exports = { | ||
preset: '@kbn/test', | ||
rootDir: '../..', | ||
roots: ['<rootDir>/packages/kbn-router-utils'], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"type": "shared-common", | ||
"id": "@kbn/router-utils", | ||
"owner": "@elastic/obs-ux-logs-team" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"name": "@kbn/router-utils", | ||
"private": true, | ||
"version": "1.0.0", | ||
"license": "SSPL-1.0 OR Elastic License 2.0" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"extends": "../../tsconfig.base.json", | ||
"compilerOptions": { | ||
"outDir": "target/types", | ||
"types": [ | ||
"jest", | ||
"node", | ||
"react" | ||
] | ||
}, | ||
"include": [ | ||
"**/*.ts", | ||
"**/*.tsx", | ||
], | ||
"exclude": [ | ||
"target/**/*" | ||
], | ||
"kbn_references": [] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
x-pack/plugins/dataset_quality/public/components/log_explorer_link.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { EuiLink } from '@elastic/eui'; | ||
import React from 'react'; | ||
import { getRouterLinkProps } from '@kbn/router-utils'; | ||
import { | ||
SingleDatasetLocatorParams, | ||
SINGLE_DATASET_LOCATOR_ID, | ||
} from '@kbn/deeplinks-observability'; | ||
import { DataStreamStat } from '../../common/data_streams_stats/data_stream_stat'; | ||
import { useKibanaContextForPlugin } from '../utils'; | ||
|
||
export const LogExplorerLink = React.memo( | ||
({ dataStreamStat, title }: { dataStreamStat: DataStreamStat; title: string }) => { | ||
const { | ||
services: { share }, | ||
} = useKibanaContextForPlugin(); | ||
const params: SingleDatasetLocatorParams = { | ||
dataset: dataStreamStat.name, | ||
timeRange: { | ||
from: 'now-1d', | ||
to: 'now', | ||
}, | ||
integration: dataStreamStat.integration?.name, | ||
filterControls: { | ||
namespace: { | ||
mode: 'include', | ||
values: [dataStreamStat.namespace], | ||
}, | ||
}, | ||
}; | ||
|
||
const singleDatasetLocator = | ||
share.url.locators.get<SingleDatasetLocatorParams>(SINGLE_DATASET_LOCATOR_ID); | ||
|
||
const urlToLogExplorer = singleDatasetLocator?.getRedirectUrl(params); | ||
|
||
const navigateToLogExplorer = () => { | ||
singleDatasetLocator?.navigate(params) as Promise<void>; | ||
}; | ||
|
||
const logExplorerLinkProps = getRouterLinkProps({ | ||
href: urlToLogExplorer, | ||
onClick: navigateToLogExplorer, | ||
}); | ||
|
||
return <EuiLink {...logExplorerLinkProps}>{title}</EuiLink>; | ||
} | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.