- {
- if (dimensionContainerState.isOpen) {
- setDimensionContainerState(initialDimensionContainerState);
- } else {
- setDimensionContainerState({
- isOpen: true,
- openId: newId,
- addingToGroupId: group.groupId,
- });
- }
- }}
- >
-
-
- }
- panelTitle={i18n.translate('xpack.lens.configure.configurePanelTitle', {
- defaultMessage: '{groupLabel} configuration',
- values: {
- groupLabel: group.groupLabel,
- },
- })}
- panel={
- {
- props.updateAll(
- datasourceId,
- newState,
- activeVisualization.setDimension({
- layerId,
- groupId: group.groupId,
- columnId: newId,
- prevState: props.visualizationState,
- })
- );
- setDimensionContainerState({
- isOpen: true,
- openId: newId,
- addingToGroupId: null, // clear now that dimension exists
- });
- },
- }}
- />
- }
- />
+ {
+ if (activeId) {
+ setActiveDimension(initialActiveDimensionState);
+ } else {
+ setActiveDimension({
+ isNew: true,
+ activeGroup: group,
+ activeId: newId,
+ });
+ }
+ }}
+ >
+
+
) : null}
@@ -472,6 +378,60 @@ export function LayerPanel(
);
})}
+ setActiveDimension(initialActiveDimensionState)}
+ panel={
+ <>
+ {activeGroup && activeId && (
+ {
+ props.updateAll(
+ datasourceId,
+ newState,
+ activeVisualization.setDimension({
+ layerId,
+ groupId: activeGroup.groupId,
+ columnId: activeId,
+ prevState: props.visualizationState,
+ })
+ );
+ setActiveDimension({
+ ...activeDimension,
+ isNew: false,
+ });
+ },
+ }}
+ />
+ )}
+ {activeGroup &&
+ activeId &&
+ !activeDimension.isNew &&
+ activeVisualization.renderDimensionEditor &&
+ activeGroup?.enableDimensionEditor && (
+
+
+
+ )}
+ >
+ }
+ />
diff --git a/x-pack/plugins/lens/public/editor_frame_service/editor_frame/config_panel/types.ts b/x-pack/plugins/lens/public/editor_frame_service/editor_frame/config_panel/types.ts
index d42c5c3b99e53..c172c6da6848c 100644
--- a/x-pack/plugins/lens/public/editor_frame_service/editor_frame/config_panel/types.ts
+++ b/x-pack/plugins/lens/public/editor_frame_service/editor_frame/config_panel/types.ts
@@ -10,6 +10,7 @@ import {
FramePublicAPI,
Datasource,
DatasourceDimensionEditorProps,
+ VisualizationDimensionGroupConfig,
} from '../../../types';
export interface ConfigPanelWrapperProps {
@@ -30,8 +31,8 @@ export interface ConfigPanelWrapperProps {
core: DatasourceDimensionEditorProps['core'];
}
-export interface DimensionContainerState {
- isOpen: boolean;
- openId: string | null;
- addingToGroupId: string | null;
+export interface ActiveDimensionState {
+ isNew: boolean;
+ activeId?: string;
+ activeGroup?: VisualizationDimensionGroupConfig;
}