kibana/packages/kbn-router-utils
Yngrid Coello ce293db41b
[Dataset quality] Open in Log explorer action (#173272)
Closes https://github.com/elastic/kibana/issues/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


a3f38615-d8ae-432b-ba7b-05a6901f870c

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
2023-12-18 18:08:54 +01:00
..
src/get_router_link_props [Dataset quality] Open in Log explorer action (#173272) 2023-12-18 18:08:54 +01:00
index.ts [Dataset quality] Open in Log explorer action (#173272) 2023-12-18 18:08:54 +01:00
jest.config.js [Dataset quality] Open in Log explorer action (#173272) 2023-12-18 18:08:54 +01:00
kibana.jsonc [Dataset quality] Open in Log explorer action (#173272) 2023-12-18 18:08:54 +01:00
package.json [Dataset quality] Open in Log explorer action (#173272) 2023-12-18 18:08:54 +01:00
README.md [Dataset quality] Open in Log explorer action (#173272) 2023-12-18 18:08:54 +01:00
tsconfig.json [Dataset quality] Open in Log explorer action (#173272) 2023-12-18 18:08:54 +01:00

@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.

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>
    </>
  );
};