-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Lens] Move configuration popover to flyout (#76046)
* Moving to a Flyout implementation * Fix up inner layout of flyout * Fix up form rows
- Loading branch information
Showing
31 changed files
with
525 additions
and
429 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 0 additions & 2 deletions
2
x-pack/plugins/lens/public/editor_frame_service/editor_frame/config_panel/_index.scss
This file was deleted.
Oops, something went wrong.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
...ugins/lens/public/editor_frame_service/editor_frame/config_panel/dimension_container.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
@import '@elastic/eui/src/components/flyout/variables'; | ||
@import '@elastic/eui/src/components/flyout/mixins'; | ||
|
||
.lnsDimensionContainer { | ||
// Use the EuiFlyout style | ||
@include euiFlyout; | ||
// But with custom positioning to keep it within the sidebar contents | ||
position: absolute; | ||
right: 0; | ||
left: 0; | ||
top: 0; | ||
bottom: 0; | ||
animation: euiFlyout $euiAnimSpeedNormal $euiAnimSlightResistance; | ||
} | ||
|
||
.lnsDimensionContainer--noAnimation { | ||
animation: none; | ||
} | ||
|
||
.lnsDimensionContainer__footer, | ||
.lnsDimensionContainer__header { | ||
padding: $euiSizeS; | ||
} | ||
|
||
.lnsDimensionContainer__trigger { | ||
width: 100%; | ||
display: block; | ||
word-break: break-word; | ||
} |
134 changes: 134 additions & 0 deletions
134
...lugins/lens/public/editor_frame_service/editor_frame/config_panel/dimension_container.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
import './dimension_container.scss'; | ||
|
||
import React, { useState, useEffect } from 'react'; | ||
import { | ||
EuiFlyoutHeader, | ||
EuiFlyoutFooter, | ||
EuiTitle, | ||
EuiButtonEmpty, | ||
EuiFlexItem, | ||
EuiFocusTrap, | ||
} from '@elastic/eui'; | ||
|
||
import classNames from 'classnames'; | ||
import { i18n } from '@kbn/i18n'; | ||
import { VisualizationDimensionGroupConfig } from '../../../types'; | ||
import { DimensionContainerState } from './types'; | ||
|
||
export function DimensionContainer({ | ||
dimensionContainerState, | ||
setDimensionContainerState, | ||
groups, | ||
accessor, | ||
groupId, | ||
trigger, | ||
panel, | ||
panelTitle, | ||
}: { | ||
dimensionContainerState: DimensionContainerState; | ||
setDimensionContainerState: (newState: DimensionContainerState) => void; | ||
groups: VisualizationDimensionGroupConfig[]; | ||
accessor: string; | ||
groupId: string; | ||
trigger: React.ReactElement; | ||
panel: React.ReactElement; | ||
panelTitle: React.ReactNode; | ||
}) { | ||
const [openByCreation, setIsOpenByCreation] = useState( | ||
dimensionContainerState.openId === accessor | ||
); | ||
const [focusTrapIsEnabled, setFocusTrapIsEnabled] = useState(false); | ||
const [flyoutIsVisible, setFlyoutIsVisible] = useState(false); | ||
|
||
const noMatch = dimensionContainerState.isOpen | ||
? !groups.some((d) => d.accessors.includes(accessor)) | ||
: false; | ||
|
||
const closeFlyout = () => { | ||
setDimensionContainerState({ | ||
isOpen: false, | ||
openId: null, | ||
addingToGroupId: null, | ||
}); | ||
setIsOpenByCreation(false); | ||
setFocusTrapIsEnabled(false); | ||
setFlyoutIsVisible(false); | ||
}; | ||
|
||
const openFlyout = () => { | ||
setFlyoutIsVisible(true); | ||
setTimeout(() => { | ||
setFocusTrapIsEnabled(true); | ||
}, 255); | ||
}; | ||
|
||
const flyoutShouldBeOpen = | ||
dimensionContainerState.isOpen && | ||
(dimensionContainerState.openId === accessor || | ||
(noMatch && dimensionContainerState.addingToGroupId === groupId)); | ||
|
||
useEffect(() => { | ||
if (flyoutShouldBeOpen) { | ||
openFlyout(); | ||
} | ||
}); | ||
|
||
useEffect(() => { | ||
if (!flyoutShouldBeOpen) { | ||
if (flyoutIsVisible) { | ||
setFlyoutIsVisible(false); | ||
} | ||
if (focusTrapIsEnabled) { | ||
setFocusTrapIsEnabled(false); | ||
} | ||
} | ||
}, [flyoutShouldBeOpen, flyoutIsVisible, focusTrapIsEnabled]); | ||
|
||
const flyout = flyoutIsVisible && ( | ||
<EuiFocusTrap disabled={!focusTrapIsEnabled} clickOutsideDisables={true}> | ||
<div | ||
role="dialog" | ||
aria-labelledby="lnsDimensionContainerTitle" | ||
className={classNames('lnsDimensionContainer', { | ||
'lnsDimensionContainer--noAnimation': openByCreation, | ||
})} | ||
> | ||
<EuiFlyoutHeader hasBorder className="lnsDimensionContainer__header"> | ||
<EuiTitle size="xs"> | ||
<EuiButtonEmpty | ||
onClick={closeFlyout} | ||
data-test-subj="lns-indexPattern-dimensionContainerTitle" | ||
id="lnsDimensionContainerTitle" | ||
iconType="sortLeft" | ||
flush="left" | ||
> | ||
<strong>{panelTitle}</strong> | ||
</EuiButtonEmpty> | ||
</EuiTitle> | ||
</EuiFlyoutHeader> | ||
<EuiFlexItem className="eui-yScrollWithShadows" grow={1}> | ||
{panel} | ||
</EuiFlexItem> | ||
<EuiFlyoutFooter className="lnsDimensionContainer__footer"> | ||
<EuiButtonEmpty flush="left" size="s" iconType="cross" onClick={closeFlyout}> | ||
{i18n.translate('xpack.lens.dimensionContainer.close', { | ||
defaultMessage: 'Close', | ||
})} | ||
</EuiButtonEmpty> | ||
</EuiFlyoutFooter> | ||
</div> | ||
</EuiFocusTrap> | ||
); | ||
|
||
return ( | ||
<> | ||
<div className="lnsDimensionContainer__trigger">{trigger}</div> | ||
{flyout} | ||
</> | ||
); | ||
} |
18 changes: 0 additions & 18 deletions
18
...plugins/lens/public/editor_frame_service/editor_frame/config_panel/dimension_popover.scss
This file was deleted.
Oops, something went wrong.
50 changes: 0 additions & 50 deletions
50
.../plugins/lens/public/editor_frame_service/editor_frame/config_panel/dimension_popover.tsx
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,6 +52,5 @@ | |
} | ||
|
||
.lnsLayerPanel__styleEditor { | ||
width: $euiSize * 30; | ||
padding: $euiSizeS; | ||
padding: 0 $euiSizeS $euiSizeS; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.