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

[Security Solution] expandable flyout - add tooltip to expandable panel link titles #166737

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,17 @@ export const AnalyzerPreviewContainer: React.FC = () => {
/>
),
iconType: 'timeline',
...(isEnabled && { callback: goToAnalyzerTab }),
...(isEnabled && {
link: {
callback: goToAnalyzerTab,
tooltip: (
<FormattedMessage
id="xpack.securitySolution.flyout.right.visualizations.analyzerPreview.analyzerPreviewTooltip"
defaultMessage="Show analyzer graph"
/>
),
},
}),
}}
data-test-subj={ANALYZER_PREVIEW_TEST_ID}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,15 @@ export const CorrelationsOverview: React.FC = () => {
defaultMessage="Correlations"
/>
),
callback: goToCorrelationsTab,
link: {
callback: goToCorrelationsTab,
tooltip: (
<FormattedMessage
id="xpack.securitySolution.flyout.right.insights.correlations.overviewTooltip"
defaultMessage="Show all correlations"
/>
),
},
iconType: 'arrowStart',
}}
data-test-subj={INSIGHTS_CORRELATIONS_TEST_ID}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,15 @@ export const EntitiesOverview: React.FC = () => {
defaultMessage="Entities"
/>
),
callback: goToEntitiesTab,
link: {
callback: goToEntitiesTab,
tooltip: (
<FormattedMessage
id="xpack.securitySolution.flyout.right.insights.entities.entitiesTooltip"
defaultMessage="View all entities"
PhilippeOberti marked this conversation as resolved.
Show resolved Hide resolved
/>
),
},
iconType: 'arrowStart',
}}
data-test-subj={INSIGHTS_ENTITIES_TEST_ID}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export const PrevalenceOverview: FC = () => {
useRightPanelContext();
const { openLeftPanel } = useExpandableFlyoutContext();

const goToCorrelationsTab = useCallback(() => {
const goPrevalenceTab = useCallback(() => {
openLeftPanel({
id: LeftPanelKey,
path: {
Expand Down Expand Up @@ -76,7 +76,15 @@ export const PrevalenceOverview: FC = () => {
defaultMessage="Prevalence"
/>
),
callback: goToCorrelationsTab,
link: {
callback: goPrevalenceTab,
tooltip: (
<FormattedMessage
id="xpack.securitySolution.flyout.right.insights.prevalence.prevalenceTooltip"
defaultMessage="Show all prevalence"
/>
),
},
iconType: 'arrowStart',
}}
content={{ loading, error }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,17 @@ export const SessionPreviewContainer: FC = () => {
/>
),
iconType: 'timeline',
...(isEnabled && { callback: goToSessionViewTab }),
...(isEnabled && {
link: {
callback: goToSessionViewTab,
tooltip: (
<FormattedMessage
id="xpack.securitySolution.flyout.right.visualizations.sessionPreview.sessionPreviewTooltip"
defaultMessage="Show session viewer"
/>
),
},
}),
}}
data-test-subj={SESSION_PREVIEW_TEST_ID}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,15 @@ export const ThreatIntelligenceOverview: FC = () => {
defaultMessage="Threat intelligence"
/>
),
callback: goToThreatIntelligenceTab,
link: {
callback: goToThreatIntelligenceTab,
tooltip: (
<FormattedMessage
id="xpack.securitySolution.flyout.right.insights.threatIntelligence.threatIntelligenceTooltip"
defaultMessage="Show all threat intelligence"
/>
),
},
iconType: 'arrowStart',
}}
data-test-subj={INSIGHTS_THREAT_INTELLIGENCE_TEST_ID}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
EuiText,
EuiLoadingSpinner,
useEuiTheme,
EuiToolTip,
} from '@elastic/eui';
import type { IconType } from '@elastic/eui';
import { css } from '@emotion/react';
Expand All @@ -28,10 +29,16 @@ export interface ExpandablePanelPanelProps {
* String value of the title to be displayed in the header of panel
*/
title: string | React.ReactNode;
/**
* Callback function to be called when the title is clicked
*/
callback?: () => void;
link?: {
/**
* Callback function to be called when the title is clicked
*/
callback: () => void;
/**
* Tooltip text to be displayed around the title link
*/
tooltip: React.ReactNode;
};
/**
* Icon string for displaying the specified icon in the header
*/
Expand Down Expand Up @@ -74,7 +81,7 @@ export interface ExpandablePanelPanelProps {
* The component can be expanded or collapsed by clicking on the chevron icon on the left of the title.
*/
export const ExpandablePanel: React.FC<ExpandablePanelPanelProps> = ({
header: { title, callback, iconType, headerContent },
header: { title, link, iconType, headerContent },
content: { loading, error } = { loading: false, error: false },
expand: { expandable, expandedOnFirstRender } = {
expandable: false,
Expand Down Expand Up @@ -116,7 +123,7 @@ export const ExpandablePanel: React.FC<ExpandablePanelPanelProps> = ({
<EuiFlexItem grow={false}>{expandable && children && toggleIcon}</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiIcon
color={callback ? 'primary' : 'text'}
color={link?.callback ? 'primary' : 'text'}
type={iconType}
css={css`
margin: ${euiTheme.size.s} 0;
Expand All @@ -125,17 +132,19 @@ export const ExpandablePanel: React.FC<ExpandablePanelPanelProps> = ({
/>
</EuiFlexItem>
<EuiFlexItem grow={false}>
{callback ? (
<EuiLink
css={css`
font-size: 12px;
font-weight: 700;
`}
data-test-subj={`${dataTestSubj}TitleLink`}
onClick={callback}
>
{title}
</EuiLink>
{link?.callback ? (
<EuiToolTip content={link?.tooltip}>
<EuiLink
css={css`
font-size: 12px;
font-weight: 700;
`}
data-test-subj={`${dataTestSubj}TitleLink`}
onClick={link?.callback}
>
{title}
</EuiLink>
</EuiToolTip>
) : (
<EuiTitle size="xxxs">
<EuiText data-test-subj={`${dataTestSubj}TitleText`}>{title}</EuiText>
Expand All @@ -145,7 +154,17 @@ export const ExpandablePanel: React.FC<ExpandablePanelPanelProps> = ({
</EuiFlexGroup>
</EuiFlexItem>
),
[dataTestSubj, expandable, children, toggleIcon, callback, iconType, euiTheme.size.s, title]
[
dataTestSubj,
expandable,
children,
toggleIcon,
link?.callback,
iconType,
euiTheme.size.s,
link?.tooltip,
title,
]
);

const headerRightSection = useMemo(
Expand Down