Skip to content

Commit

Permalink
[Vizualize][Lens] Sync tooltips on dashboard level (elastic#130449)
Browse files Browse the repository at this point in the history
  • Loading branch information
stratoula authored and Esteban Beltran committed May 4, 2022
1 parent 3afeb35 commit 4fa3c3d
Show file tree
Hide file tree
Showing 44 changed files with 202 additions and 7 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ describe('XYChart component', () => {
onClickValue,
onSelectRange,
syncColors: false,
syncTooltips: false,
useLegacyTimeAxis: false,
eventAnnotationService: eventAnnotationServiceMock,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import {
BarSeriesProps,
LineSeriesProps,
ColorVariant,
Placement,
} from '@elastic/charts';
import { IconType } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
Expand Down Expand Up @@ -99,6 +100,7 @@ export type XYChartRenderProps = XYChartProps & {
onSelectRange: (data: BrushEvent['data']) => void;
renderMode: RenderMode;
syncColors: boolean;
syncTooltips: boolean;
eventAnnotationService: EventAnnotationServiceType;
};

Expand Down Expand Up @@ -144,6 +146,7 @@ export function XYChart({
onSelectRange,
interactive = true,
syncColors,
syncTooltips,
useLegacyTimeAxis,
}: XYChartRenderProps) {
const {
Expand Down Expand Up @@ -520,6 +523,9 @@ export function XYChart({
<Chart ref={chartRef}>
<Settings
onPointerUpdate={handleCursorUpdate}
externalPointerEvents={{
tooltip: { visible: syncTooltips, placement: Placement.Right },
}}
debugState={window._echDebugStateFlag ?? false}
showLegend={
legend.isVisible && !legend.showSingleSeries
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ export const getXyChartRenderer = ({
onSelectRange={onSelectRange}
renderMode={handlers.getRenderMode()}
syncColors={handlers.isSyncColorsEnabled()}
syncTooltips={handlers.isSyncTooltipsEnabled()}
/>
</div>{' '}
</I18nProvider>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ export interface InheritedChildInput extends IndexSignature {
id: string;
searchSessionId?: string;
syncColors?: boolean;
syncTooltips?: boolean;
executionContext?: KibanaExecutionContext;
}

Expand Down Expand Up @@ -314,6 +315,7 @@ export class DashboardContainer extends Container<InheritedChildInput, Dashboard
filters,
searchSessionId,
syncColors,
syncTooltips,
executionContext,
} = this.input;
let combinedFilters = filters;
Expand All @@ -330,6 +332,7 @@ export class DashboardContainer extends Container<InheritedChildInput, Dashboard
id,
searchSessionId,
syncColors,
syncTooltips,
executionContext,
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ export class DashboardContainerFactoryDefinition
isFullScreenMode: false,
useMargins: true,
syncColors: true,
syncTooltips: true,
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ const getDashboardState = (state?: Partial<DashboardState>): DashboardState => {
hidePanelTitles: false,
useMargins: true,
syncColors: false,
syncTooltips: false,
},
panels: {
panel_1: {
Expand Down Expand Up @@ -97,6 +98,7 @@ describe('Dashboard state diff function', () => {
hidePanelTitles: false,
useMargins: false,
syncColors: false,
syncTooltips: false,
},
})
).toEqual(['options']);
Expand All @@ -108,6 +110,7 @@ describe('Dashboard state diff function', () => {
options: {
useMargins: true,
syncColors: undefined,
syncTooltips: undefined,
} as unknown as DashboardOptions,
})
).toEqual([]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ export const dashboardStateSlice = createSlice({
setSyncColors: (state, action: PayloadAction<boolean>) => {
state.options.syncColors = action.payload;
},
setSyncTooltips: (state, action: PayloadAction<boolean>) => {
state.options.syncTooltips = action.payload;
},
setHidePanelTitles: (state, action: PayloadAction<boolean>) => {
state.options.hidePanelTitles = action.payload;
},
Expand Down Expand Up @@ -114,6 +117,7 @@ export const {
setTimeRestore,
setTimeRange,
setSyncColors,
setSyncTooltips,
setUseMargins,
setViewMode,
setFilters,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ import {
setSavedQueryId,
setStateFromSaveModal,
setSyncColors,
setSyncTooltips,
setUseMargins,
setViewMode,
useDashboardDispatch,
Expand Down Expand Up @@ -396,6 +397,10 @@ export function DashboardTopNav({
onSyncColorsChange: (isChecked: boolean) => {
dispatchDashboardStateChange(setSyncColors(isChecked));
},
syncTooltips: Boolean(currentState.options.syncTooltips),
onSyncTooltipsChange: (isChecked: boolean) => {
dispatchDashboardStateChange(setSyncTooltips(isChecked));
},
hidePanelTitles: currentState.options.hidePanelTitles,
onHidePanelTitlesChange: (isChecked: boolean) => {
dispatchDashboardStateChange(setHidePanelTitles(isChecked));
Expand Down
21 changes: 21 additions & 0 deletions src/plugins/dashboard/public/application/top_nav/options.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,23 @@ interface Props {
onHidePanelTitlesChange: (hideTitles: boolean) => void;
syncColors: boolean;
onSyncColorsChange: (syncColors: boolean) => void;
syncTooltips: boolean;
onSyncTooltipsChange: (syncTooltips: boolean) => void;
}

interface State {
useMargins: boolean;
hidePanelTitles: boolean;
syncColors: boolean;
syncTooltips: boolean;
}

export class OptionsMenu extends Component<Props, State> {
state = {
useMargins: this.props.useMargins,
hidePanelTitles: this.props.hidePanelTitles,
syncColors: this.props.syncColors,
syncTooltips: this.props.syncTooltips,
};

constructor(props: Props) {
Expand All @@ -55,6 +59,12 @@ export class OptionsMenu extends Component<Props, State> {
this.setState({ syncColors: isChecked });
};

handleSyncTooltipsChange = (evt: any) => {
const isChecked = evt.target.checked;
this.props.onSyncTooltipsChange(isChecked);
this.setState({ syncTooltips: isChecked });
};

render() {
return (
<EuiForm data-test-subj="dashboardOptionsMenu">
Expand Down Expand Up @@ -90,6 +100,17 @@ export class OptionsMenu extends Component<Props, State> {
data-test-subj="dashboardSyncColorsCheckbox"
/>
</EuiFormRow>

<EuiFormRow>
<EuiSwitch
label={i18n.translate('dashboard.topNav.options.syncTooltipsBetweenPanelsSwitchLabel', {
defaultMessage: 'Sync tooltips across panels',
})}
checked={this.state.syncTooltips}
onChange={this.handleSyncTooltipsChange}
data-test-subj="dashboardSyncTooltipsCheckbox"
/>
</EuiFormRow>
</EuiForm>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ export interface ShowOptionsPopoverProps {
onUseMarginsChange: (useMargins: boolean) => void;
syncColors: boolean;
onSyncColorsChange: (syncColors: boolean) => void;
syncTooltips: boolean;
onSyncTooltipsChange: (syncTooltips: boolean) => void;
hidePanelTitles: boolean;
onHidePanelTitlesChange: (hideTitles: boolean) => void;
theme$: CoreStart['theme']['theme$'];
Expand All @@ -42,6 +44,8 @@ export function showOptionsPopover({
onHidePanelTitlesChange,
syncColors,
onSyncColorsChange,
syncTooltips,
onSyncTooltipsChange,
theme$,
}: ShowOptionsPopoverProps) {
if (isOpen) {
Expand All @@ -68,6 +72,8 @@ export function showOptionsPopover({
onHidePanelTitlesChange={onHidePanelTitlesChange}
syncColors={syncColors}
onSyncColorsChange={onSyncColorsChange}
syncTooltips={syncTooltips}
onSyncTooltipsChange={onSyncTooltipsChange}
/>
</EuiWrappingPopover>
</KibanaThemeProvider>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ describe('ShowShareModal', () => {
hidePanelTitles: true,
useMargins: true,
syncColors: true,
syncTooltips: true,
},
filters: [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ const defaults = {
// for BWC reasons we can't default dashboards that already exist without this setting to true.
useMargins: true,
syncColors: false,
syncTooltips: false,
hidePanelTitles: false,
} as DashboardOptions),
version: 1,
Expand Down
2 changes: 2 additions & 0 deletions src/plugins/dashboard/public/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ export interface DashboardContainerInput extends ContainerInput {
description?: string;
useMargins: boolean;
syncColors?: boolean;
syncTooltips?: boolean;
viewMode: ViewMode;
filters: Filter[];
title: string;
Expand Down Expand Up @@ -154,6 +155,7 @@ export type DashboardOptions = {
hidePanelTitles: boolean;
useMargins: boolean;
syncColors: boolean;
syncTooltips: boolean;
};

export type DashboardRedirect = (props: RedirectToProps) => void;
Expand Down
5 changes: 5 additions & 0 deletions src/plugins/embeddable/common/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ export type EmbeddableInput = {
*/
syncColors?: boolean;

/**
* Flag whether tooltips should be synced with other panels on hover
*/
syncTooltips?: boolean;

executionContext?: KibanaExecutionContext;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const getGenericEmbeddableState = (state?: Partial<EmbeddableInput>): Embeddable
disableTriggers: false,
enhancements: undefined,
syncColors: false,
syncTooltips: false,
viewMode: ViewMode.VIEW,
title: 'So Very Generic',
id: 'soVeryGeneric',
Expand All @@ -44,6 +45,7 @@ test('Omitting generic embeddable input omits all generic input keys', () => {
'disableTriggers',
'enhancements',
'syncColors',
'syncTooltips',
'viewMode',
'title',
'id',
Expand Down
Loading

0 comments on commit 4fa3c3d

Please sign in to comment.