-
Notifications
You must be signed in to change notification settings - Fork 8.6k
[ES|QL Controls] Highlight related panels on click, refactor Related Panels system #264426
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
base: main
Are you sure you want to change the base?
Changes from 34 commits
965ec55
f0ca65c
7ccad3b
e7264f2
b0c3745
2d8d7c9
19ad17b
1bb43e0
e478e82
8d857bd
452834a
5344093
d8d1108
6e76e34
045453d
0042842
ea6c92c
5d9bf7c
43dcf2e
9f1a0dc
e771d3d
a394bf6
a9f4f58
b51a10f
ea947dc
18ab5f2
88becd8
f22f0de
ced9948
4c6e808
2a22acb
46eec2c
de765f2
14e6349
4a73f7d
50dbf49
521f47c
aac5372
3bdca02
272c6b7
c0773ff
01fc9aa
e98887a
273f040
cf0af2c
807e937
f0cd795
8f48868
a385cb5
8329dc5
a3e7c4c
cb6179f
ed37f59
6e3f83e
c7fe38c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| /* | ||
| * 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", the "GNU Affero General Public License v3.0 only", 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", the "GNU Affero General Public | ||
| * License v3.0 only", or the "Server Side Public License, v 1". | ||
| */ | ||
|
|
||
| import { EuiToolTip, EuiBadge, type EuiToolTipProps } from '@elastic/eui'; | ||
| import { i18n } from '@kbn/i18n'; | ||
| import React from 'react'; | ||
|
|
||
| interface RelatedPanelProps { | ||
| canIndicateRelatedPanels: boolean; | ||
| isIndicatingRelatedPanels: boolean; | ||
| numberOfRelatedPanels?: number; | ||
| } | ||
| // Throw a typescript error if one, but not all, of the related panel props are defined | ||
| // Prevents us from e.g. setting canIndicateRelatedPanels to true and forgetting to pass isIndicatingRelatedPanels | ||
| type AllRelatedPanelPropsOrNone = RelatedPanelProps | { [K in keyof RelatedPanelProps]?: never }; | ||
|
|
||
| type Props = Omit<Partial<EuiToolTipProps>, 'children'> & { | ||
| panelLabel?: string; | ||
| panelTooltipLabel?: string; | ||
| children: EuiToolTipProps['children']; | ||
| } & AllRelatedPanelPropsOrNone; | ||
|
|
||
| export const ControlLabelTooltip = ({ | ||
| canIndicateRelatedPanels, | ||
| isIndicatingRelatedPanels, | ||
| numberOfRelatedPanels, | ||
| panelLabel, | ||
| panelTooltipLabel, | ||
| children, | ||
| ...rest | ||
| }: Props) => { | ||
| const relatedPanelCountBadge = | ||
| canIndicateRelatedPanels && numberOfRelatedPanels !== undefined ? ( | ||
| <EuiBadge color="hollow"> | ||
| {i18n.translate('controls.controlGroup.numberOfRelatedPanels', { | ||
| defaultMessage: '{numberOfRelatedPanels, plural, one {# panel} other {# panels}}', | ||
| values: { numberOfRelatedPanels }, | ||
| })} | ||
| </EuiBadge> | ||
| ) : null; | ||
|
|
||
| const tooltipContent = | ||
| numberOfRelatedPanels === 0 | ||
| ? i18n.translate('controls.controlGroup.noRelatedPanels', { | ||
| defaultMessage: | ||
| // In practice, this message can only appear for ES|QL controls | ||
| "This variable isn't used in any visualizations.", | ||
|
Zacqary marked this conversation as resolved.
Outdated
|
||
| }) | ||
| : isIndicatingRelatedPanels | ||
| ? i18n.translate('controls.controlGroup.clickToStopHighlighting', { | ||
| defaultMessage: 'Click to stop highlighting panels.', | ||
| }) | ||
| : i18n.translate('controls.controlGroup.clickToHighlight', { | ||
| defaultMessage: 'Click to highlight panels.', | ||
|
Zacqary marked this conversation as resolved.
Outdated
|
||
| }); | ||
|
|
||
| const tooltipProps = canIndicateRelatedPanels | ||
| ? { | ||
| title: ( | ||
| <> | ||
| {panelTooltipLabel ?? panelLabel} {relatedPanelCountBadge} | ||
| </> | ||
| ), | ||
| content: tooltipContent, | ||
| } | ||
| : { content: panelTooltipLabel ?? panelLabel }; | ||
|
|
||
| return ( | ||
| <EuiToolTip {...tooltipProps} {...rest} id={rest.id}> | ||
| {children} | ||
| </EuiToolTip> | ||
| ); | ||
| }; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are we okay that ES|QL controls cannot be dragged from their label now? cc @andreadelrio Screen.Recording.2026-05-05.at.4.47.38.PM.mov
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Zacqary is it possible to preserve the drag behavior for ES|QL controls?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @andreadelrio I can probably figure something out to detect the difference between a click and a drag on the label by checking if the user moves their mouse a significant amount before releasing the mouse button. Might involve fighting EUI a bit, and I won't be able to get the cursor to change to If it ends up being more complicated than I expect, is it acceptable to ship this where the user now has to grab the drag handle explicitly instead of being able to drag from the entire label? |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| /* | ||
| * 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", the "GNU Affero General Public License v3.0 only", 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", the "GNU Affero General Public | ||
| * License v3.0 only", or the "Server Side Public License, v 1". | ||
| */ | ||
|
|
||
| export { useIndicateRelatedPanelsSelector } from './use_indicate_related_panels_selector'; |
Uh oh!
There was an error while loading. Please reload this page.