Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tooltips to new discover table call to actions #6889

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ All notable changes to the Wazuh app project will be documented in this file.

### Changed

- Removed embedded discover [#6120](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6120) [#6235](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6235) [#6254](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6254) [#6285](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6285) [#6288](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6288) [#6290](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6290) [#6289](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6289) [#6286](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6286) [#6275](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6275) [#6287](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6287) [#6297](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6297) [#6291](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6287) [#6459](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6459) [#6434](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6434) [#6504](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6504) [#6649](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6649) [#6506](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6506) [#6537](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6537) [#6528](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6528) [#6675](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6675) [#6674](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6674) [#6558](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6558) [#6685](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6685) [#6691](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6691) [#6712](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6712) [#6734](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6734) [#6746](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6746) [#6752](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6752) [#6753](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6753) [#6756](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6756) [#6771](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6771) [#6792](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6792) [#6845](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6845) [#6857](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6857) [#6847](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6847) [#6865](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6865) [#6848](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6848) [#6843](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6843) [#6878](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6878) [#6883](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6883)
- Removed embedded discover [#6120](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6120) [#6235](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6235) [#6254](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6254) [#6285](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6285) [#6288](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6288) [#6290](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6290) [#6289](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6289) [#6286](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6286) [#6275](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6275) [#6287](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6287) [#6297](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6297) [#6291](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6287) [#6459](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6459) [#6434](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6434) [#6504](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6504) [#6649](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6649) [#6506](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6506) [#6537](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6537) [#6528](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6528) [#6675](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6675) [#6674](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6674) [#6558](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6558) [#6685](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6685) [#6691](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6691) [#6712](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6712) [#6734](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6734) [#6746](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6746) [#6752](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6752) [#6753](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6753) [#6756](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6756) [#6771](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6771) [#6792](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6792) [#6845](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6845) [#6857](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6857) [#6847](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6847) [#6865](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6865) [#6848](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6848) [#6843](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6843) [#6878](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6878) [#6883](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6883) [#6889](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6889)
- Allow editing groups for an agent from Endpoints Summary [#6250](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6250)
- Change how the configuration is managed in the backend side [#6337](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6337) [#6519](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6519) [#6573](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6573)
- Change the view of API is down and check connection to Server APIs application [#6337](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6337)
Expand Down
5 changes: 5 additions & 0 deletions plugins/main/docs/wz-link.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,17 @@ When navigating between applications you can use Opensearch Dashboard navigation
</RedirectAppLinks>
```

#### With tooltip

If the component receives the `toolTipProps` object as a prop, then it wraps the link with a tooltip component.

### Implementation

```tsx
<WzLink
appId={<Application-to-go-to>}
path={<Path-to-navigate-to>}
toolTipProps={{content: 'This is a tooltip'}} //Optional prop
otherPropsForTheEuiLink
>
whatever you want to render in the link
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
mitreAttack,
} from '../../../utils/applications';
import { WzLink } from '../../wz-link/wz-link';
import { i18n } from '@osd/i18n';

export const MAX_ENTRIES_PER_QUERY = 10000;

Expand All @@ -22,6 +23,12 @@ const renderMitreTechnique = technique => (
<WzLink
appId={mitreAttack.id}
path={`/overview?tab=mitre&tabView=intelligence&tabRedirect=techniques&idToRedirect=${technique}`}
toolTipProps={{
content: i18n.translate('discover.fieldLinkTooltip.mitreTechnique', {
defaultMessage:
'Navigate to MITRE ATT&CK - Intelligence and see the technique details',
}),
}}
>
{technique}
</WzLink>
Expand All @@ -39,6 +46,11 @@ export const wzDiscoverRenderColumns: tDataGridRenderColumn[] = [
<WzLink
appId={endpointSummary.id}
path={`/agents?tab=welcome&agent=${value}`}
toolTipProps={{
content: i18n.translate('discover.fieldLinkTooltip.agent', {
defaultMessage: 'Navigate to the agent details',
}),
}}
>
{value}
</WzLink>
Expand All @@ -56,6 +68,11 @@ export const wzDiscoverRenderColumns: tDataGridRenderColumn[] = [
<WzLink
appId={endpointSummary.id}
path={`/agents?tab=welcome&agent=${row.agent.id}`}
toolTipProps={{
content: i18n.translate('discover.fieldLinkTooltip.agent', {
defaultMessage: 'Navigate to the agent details',
}),
}}
>
{value}
</WzLink>
Expand All @@ -68,6 +85,11 @@ export const wzDiscoverRenderColumns: tDataGridRenderColumn[] = [
<WzLink
appId={rules.id}
path={`/manager/?tab=rules&redirectRule=${value}`}
toolTipProps={{
content: i18n.translate('discover.fieldLinkTooltip.rule', {
defaultMessage: 'Navigate to the rule details',
}),
}}
>
{value}
</WzLink>
Expand Down
15 changes: 12 additions & 3 deletions plugins/main/public/components/wz-link/wz-link.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useEffect, useState } from 'react';
import { RedirectAppLinks } from '../../../../../src/plugins/opensearch_dashboards_react/public';
import { EuiLink } from '@elastic/eui';
import { EuiLink, EuiToolTip, EuiToolTipProps } from '@elastic/eui';
import { getCore } from '../../kibana-services';
import NavigationService from '../../react-services/navigation-service';
import useObservable from 'react-use/lib/useObservable';
Expand All @@ -9,10 +9,11 @@ type tWzLinkProps = {
appId: string;
path: string;
children: React.ReactNode;
toolTipProps?: EuiToolTipProps;
};

export const WzLink = (props: tWzLinkProps) => {
const { appId, path, children, ...otherProps } = props;
const { appId, path, children, toolTipProps, ...otherProps } = props;

const [isCurrentApp, setIsCurrentApp] = useState(false);
const currentAppId$ = useObservable(
Expand All @@ -36,6 +37,7 @@ export const WzLink = (props: tWzLinkProps) => {
</EuiLink>
</RedirectAppLinks>
);

const linkSameApp = (
<EuiLink
{...otherProps}
Expand All @@ -46,5 +48,12 @@ export const WzLink = (props: tWzLinkProps) => {
{children}
</EuiLink>
);
return isCurrentApp ? linkSameApp : linkDiferentApps;

const finalLink = isCurrentApp ? linkSameApp : linkDiferentApps;

return toolTipProps ? (
<EuiToolTip {...toolTipProps}>{finalLink}</EuiToolTip>
) : (
finalLink
);
};
Loading