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

[Lens] Config panel design #42980

Merged
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import React from 'react';
import { render } from 'react-dom';
import { EuiForm, EuiFormRow, EuiPanel } from '@elastic/eui';
import { EuiForm, EuiFormRow, EuiPanel, EuiSpacer } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import { I18nProvider } from '@kbn/i18n/react';
import { MultiColumnEditor } from '../multi_column_editor';
Expand Down Expand Up @@ -57,32 +57,31 @@ export function DataTableLayer({
}: { layer: LayerState } & VisualizationProps<DatatableVisualizationState>) {
const datasource = frame.datasourceLayers[layer.layerId];
return (
<EuiPanel className="lnsConfigPanel">
<>
<NativeRenderer
render={datasource.renderLayerPanel}
nativeProps={{ layerId: layer.layerId }}
<EuiPanel className="lnsConfigPanel__panel" paddingSize="s">
<NativeRenderer
render={datasource.renderLayerPanel}
nativeProps={{ layerId: layer.layerId }}
/>

<EuiSpacer size="s" />
<EuiFormRow
className="lnsConfigPanel__axis"
label={i18n.translate('xpack.lens.datatable.columns', { defaultMessage: 'Columns' })}
>
<MultiColumnEditor
accessors={layer.columns}
datasource={datasource}
dragDropContext={dragDropContext}
filterOperations={allOperations}
layerId={layer.layerId}
onAdd={() => setState(updateColumns(state, layer, columns => [...columns, generateId()]))}
onRemove={column =>
setState(updateColumns(state, layer, columns => columns.filter(c => c !== column)))
}
testSubj="datatable_columns"
data-test-subj="datatable_multicolumnEditor"
/>
<EuiFormRow
label={i18n.translate('xpack.lens.datatable.columns', { defaultMessage: 'Columns' })}
>
<MultiColumnEditor
accessors={layer.columns}
datasource={datasource}
dragDropContext={dragDropContext}
filterOperations={allOperations}
layerId={layer.layerId}
onAdd={() =>
setState(updateColumns(state, layer, columns => [...columns, generateId()]))
}
onRemove={column =>
setState(updateColumns(state, layer, columns => columns.filter(c => c !== column)))
}
testSubj="datatable_columns"
data-test-subj="datatable_multicolumnEditor"
/>
</EuiFormRow>
</>
</EuiFormRow>
</EuiPanel>
);
}
Expand All @@ -105,7 +104,7 @@ export const datatableVisualization: Visualization<

getDescription(state) {
return {
icon: 'empty',
icon: 'visTable',
label: i18n.translate('xpack.lens.datatable.label', {
defaultMessage: 'Datatable',
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ describe('chart_switch', () => {
/>
);

expect(getMenuItem('subvisB', component).prop('betaBadgeIconType')).toEqual('bolt');
expect(getMenuItem('subvisB', component).prop('betaBadgeIconType')).toEqual('alert');
});

it('should indicate data loss if no data will be used', () => {
Expand All @@ -188,7 +188,7 @@ describe('chart_switch', () => {
/>
);

expect(getMenuItem('subvisB', component).prop('betaBadgeIconType')).toEqual('bolt');
expect(getMenuItem('subvisB', component).prop('betaBadgeIconType')).toEqual('alert');
});

it('should not indicate data loss if there is no data', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@ import React, { useState, useMemo } from 'react';
import {
EuiIcon,
EuiPopover,
EuiButton,
EuiPopoverTitle,
EuiKeyPadMenu,
EuiKeyPadMenuItemButton,
EuiButtonEmpty,
EuiTitle,
} from '@elastic/eui';
import { flatten } from 'lodash';
import { i18n } from '@kbn/i18n';
Expand Down Expand Up @@ -61,7 +62,9 @@ function VisualizationSummary(props: Props) {

return (
<>
{description.icon && <EuiIcon type={description.icon} />}
{description.icon && (
<EuiIcon className="lnsChartSwitch__summaryIcon" type={description.icon} />
)}
{description.label}
</>
);
Expand Down Expand Up @@ -183,61 +186,72 @@ export function ChartSwitch(props: Props) {
]
);

return (
<>
<EuiPopover
id="lnsChartSwitchPopover"
ownFocus
initialFocus=".lnsChartSwitchPopoverPanel"
panelClassName="lnsChartSwitchPopoverPanel"
button={
<EuiButton
iconType="arrowDown"
iconSide="right"
onClick={() => setFlyoutOpen(!flyoutOpen)}
data-test-subj="lnsChartSwitchPopover"
>
<VisualizationSummary {...props} />
</EuiButton>
}
isOpen={flyoutOpen}
closePopover={() => setFlyoutOpen(false)}
anchorPosition="leftUp"
>
<EuiPopoverTitle>
{i18n.translate('xpack.lens.configPanel.chooseVisualization', {
defaultMessage: 'Choose a visualization',
const popover = (
<EuiPopover
id="lnsChartSwitchPopover"
ownFocus
initialFocus=".lnsChartSwitchPopoverPanel"
panelClassName="lnsChartSwitchPopoverPanel"
button={
<EuiButtonEmpty
size="xs"
onClick={() => setFlyoutOpen(!flyoutOpen)}
data-test-subj="lnsChartSwitchPopover"
>
(
{i18n.translate('xpack.lens.configPanel.changeVisualization', {
defaultMessage: 'Change',
})}
</EuiPopoverTitle>
<EuiKeyPadMenu>
{(visualizationTypes || []).map(v => (
<EuiKeyPadMenuItemButton
key={`${v.visualizationId}:${v.id}`}
label={<span data-test-subj="visTypeTitle">{v.label}</span>}
role="menuitem"
data-test-subj={`lnsChartSwitchPopover_${v.id}`}
onClick={() => commitSelection(v.selection)}
betaBadgeLabel={
v.selection.dataLoss !== 'nothing'
? i18n.translate('xpack.lens.chartSwitch.dataLossLabel', {
defaultMessage: 'Data loss',
})
: undefined
}
betaBadgeTooltipContent={
v.selection.dataLoss !== 'nothing'
? i18n.translate('xpack.lens.chartSwitch.dataLossDescription', {
defaultMessage: 'Switching to this chart will lose some of the configuration',
})
: undefined
}
betaBadgeIconType={v.selection.dataLoss !== 'nothing' ? 'bolt' : undefined}
>
<EuiIcon type={v.icon || 'empty'} />
</EuiKeyPadMenuItemButton>
))}
</EuiKeyPadMenu>
</EuiPopover>
</>
)
</EuiButtonEmpty>
}
isOpen={flyoutOpen}
closePopover={() => setFlyoutOpen(false)}
anchorPosition="leftUp"
>
<EuiPopoverTitle>
{i18n.translate('xpack.lens.configPanel.chooseVisualization', {
defaultMessage: 'Choose a visualization',
})}
</EuiPopoverTitle>
<EuiKeyPadMenu>
{(visualizationTypes || []).map(v => (
<EuiKeyPadMenuItemButton
key={`${v.visualizationId}:${v.id}`}
label={<span data-test-subj="visTypeTitle">{v.label}</span>}
role="menuitem"
data-test-subj={`lnsChartSwitchPopover_${v.id}`}
onClick={() => commitSelection(v.selection)}
betaBadgeLabel={
v.selection.dataLoss !== 'nothing'
? i18n.translate('xpack.lens.chartSwitch.dataLossLabel', {
defaultMessage: 'Data loss',
})
: undefined
}
betaBadgeTooltipContent={
v.selection.dataLoss !== 'nothing'
? i18n.translate('xpack.lens.chartSwitch.dataLossDescription', {
defaultMessage: 'Switching to this chart will lose some of the configuration',
})
: undefined
}
betaBadgeIconType={v.selection.dataLoss !== 'nothing' ? 'alert' : undefined}
>
<EuiIcon type={v.icon || 'empty'} />
</EuiKeyPadMenuItemButton>
))}
</EuiKeyPadMenu>
</EuiPopover>
);

return (
<div className="lnsSidebar__header">
<EuiTitle size="xs">
<h3>
<VisualizationSummary {...props} /> {popover}
</h3>
</EuiTitle>
</div>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,20 @@
position: relative;
}

.lnsSidebar__header {
padding: $euiSizeS 0;

> * {
display: flex;
align-items: center;
}
}

.lnsChartSwitch__summaryIcon {
margin-right: $euiSizeS;
transform: translateY(-2px);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assume this is to pixel push an alignment?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, we need to work on our icon to text alignments

}

.lnsSidebar--right {
min-width: ($euiSize * 22);
@include euiScrollBar;
Expand Down Expand Up @@ -106,8 +120,5 @@
font-size: 1.2em;
}

.lnsConfigPanelWrapper {
padding: $euiSize 0;
}

@import './suggestion_panel.scss';
@import './suggestion_panel.scss';
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
.lnsConfigPanel__summaryLink {
width: 100%;
display: flex;
align-items: center;
}

.lnsConfigPanel__summaryField {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ describe('IndexPatternDimensionPanel', () => {
.find('[data-test-subj="indexPattern-configure-dimension"]')
.first()
.prop('iconType')
).toEqual('plusInCircle');
).toEqual('plusInCircleFilled');
});

it('should call the filterOperations function', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import _ from 'lodash';
import React, { memo, useMemo } from 'react';
import { EuiFlexItem, EuiFlexGroup, EuiButtonIcon } from '@elastic/eui';
import { EuiButtonIcon } from '@elastic/eui';
import { Storage } from 'ui/storage';
import { i18n } from '@kbn/i18n';
import { DatasourceDimensionPanelProps } from '../../types';
Expand Down Expand Up @@ -125,44 +125,39 @@ export const IndexPatternDimensionPanel = memo(function IndexPatternDimensionPan
);
}}
>
<EuiFlexGroup alignItems="center">
<EuiFlexItem grow={true}>
<PopoverEditor
{...props}
currentIndexPattern={currentIndexPattern}
selectedColumn={selectedColumn}
operationFieldSupportMatrix={operationFieldSupportMatrix}
/>
</EuiFlexItem>
<EuiFlexItem grow={null}>
{selectedColumn && (
<EuiFlexItem>
<EuiButtonIcon
data-test-subj="indexPattern-dimensionPopover-remove"
iconType="cross"
iconSize="s"
size="s"
color="danger"
aria-label={i18n.translate('xpack.lens.indexPattern.removeColumnLabel', {
defaultMessage: 'Remove',
})}
onClick={() => {
props.setState(
deleteColumn({
state: props.state,
layerId,
columnId: props.columnId,
})
);
if (props.onRemove) {
props.onRemove(props.columnId);
}
}}
/>
</EuiFlexItem>
)}
</EuiFlexItem>
</EuiFlexGroup>
<PopoverEditor
{...props}
currentIndexPattern={currentIndexPattern}
selectedColumn={selectedColumn}
operationFieldSupportMatrix={operationFieldSupportMatrix}
/>
{selectedColumn && (
<EuiButtonIcon
data-test-subj="indexPattern-dimensionPopover-remove"
iconType="cross"
iconSize="s"
size="s"
color="danger"
aria-label={i18n.translate('xpack.lens.indexPattern.removeColumnLabel', {
defaultMessage: 'Remove configuration',
})}
title={i18n.translate('xpack.lens.indexPattern.removeColumnLabel', {
defaultMessage: 'Remove configuration',
})}
onClick={() => {
props.setState(
deleteColumn({
state: props.state,
layerId,
columnId: props.columnId,
})
);
if (props.onRemove) {
props.onRemove(props.columnId);
}
}}
/>
)}
</DragDrop>
</ChildDragDropProvider>
);
Expand Down
Loading