Skip to content

Commit e90f201

Browse files
authored
Merge pull request #12 from andreadelrio/dndFlyouts
Clean up flyouts
2 parents 8a99e89 + 2bec309 commit e90f201

File tree

3 files changed

+51
-43
lines changed

3 files changed

+51
-43
lines changed

src/plugins/presentation_util/public/components/controls/control_group/control_group_strings.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ export const ControlGroupStrings = {
5252
i18n.translate('presentationUtil.inputControls.controlGroup.management.designTitle', {
5353
defaultMessage: 'Design',
5454
}),
55+
getWidthTitle: () =>
56+
i18n.translate('presentationUtil.inputControls.controlGroup.management.widthTitle', {
57+
defaultMessage: 'Width',
58+
}),
5559
getLayoutTitle: () =>
5660
i18n.translate('presentationUtil.inputControls.controlGroup.management.layoutTitle', {
5761
defaultMessage: 'Layout',

src/plugins/presentation_util/public/components/controls/control_group/editor/manage_control.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ export const ManageControlComponent = ({
8686
</EuiFormRow>
8787
<EuiFormRow label={ControlGroupStrings.manageControl.getWidthInputTitle()}>
8888
<EuiButtonGroup
89-
buttonSize="compressed"
89+
color="primary"
9090
legend={ControlGroupStrings.management.controlWidth.getWidthSwitchLegend()}
9191
options={CONTROL_WIDTH_OPTIONS}
9292
idSelected={currentWidth}
@@ -102,17 +102,18 @@ export const ManageControlComponent = ({
102102
controlEditorComponent({ setValidState: setControlEditorValid })}
103103
<EuiSpacer size="l" />
104104
{removeControl && (
105-
<EuiButton
105+
<EuiButtonEmpty
106106
aria-label={`delete-${title}`}
107107
iconType="trash"
108+
flush="left"
108109
color="danger"
109110
onClick={() => {
110111
onCancel();
111112
removeControl();
112113
}}
113114
>
114115
{ControlGroupStrings.management.getDeleteButtonTitle()}
115-
</EuiButton>
116+
</EuiButtonEmpty>
116117
)}
117118
</EuiForm>
118119
</EuiFlyoutBody>

src/plugins/presentation_util/public/components/controls/control_group/editor/manage_control_group_component.tsx

Lines changed: 43 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,12 @@ import {
1313
EuiFlexGroup,
1414
EuiFlexItem,
1515
EuiButtonGroup,
16-
EuiFormLabel,
16+
EuiFormRow,
1717
EuiFlyoutHeader,
1818
EuiTitle,
1919
EuiFlyoutBody,
2020
EuiSpacer,
21+
EuiSwitch,
2122
} from '@elastic/eui';
2223

2324
import { ControlsPanels } from '../types';
@@ -29,6 +30,7 @@ interface ManageControlGroupProps {
2930
panels: ControlsPanels;
3031
controlStyle: ControlStyle;
3132
deleteAllEmbeddables: () => void;
33+
onClose: () => void;
3234
setControlStyle: (style: ControlStyle) => void;
3335
setAllPanelWidths: (newWidth: ControlWidth) => void;
3436
}
@@ -37,11 +39,13 @@ export const ManageControlGroup = ({
3739
panels,
3840
controlStyle,
3941
setControlStyle,
42+
onClose,
4043
setAllPanelWidths,
4144
deleteAllEmbeddables,
4245
}: ManageControlGroupProps) => {
4346
const [currentControlStyle, setCurrentControlStyle] = useState<ControlStyle>(controlStyle);
4447
const [selectedWidth, setSelectedWidth] = useState<ControlWidth>();
48+
const [selectionDisplay, setSelectionDisplay] = useState(false);
4549

4650
useMount(() => {
4751
if (!panels || Object.keys(panels).length === 0) return;
@@ -59,55 +63,54 @@ export const ManageControlGroup = ({
5963
</EuiTitle>
6064
</EuiFlyoutHeader>
6165
<EuiFlyoutBody>
62-
<EuiTitle size="s">
63-
<h3>{ControlGroupStrings.management.getDesignTitle()}</h3>
64-
</EuiTitle>
65-
<EuiSpacer size="s" />
66-
<EuiButtonGroup
67-
legend={ControlGroupStrings.management.controlStyle.getDesignSwitchLegend()}
68-
options={CONTROL_LAYOUT_OPTIONS}
69-
idSelected={currentControlStyle}
70-
onChange={(newControlStyle) => {
71-
setControlStyle(newControlStyle as ControlStyle);
72-
setCurrentControlStyle(newControlStyle as ControlStyle);
73-
}}
74-
/>
66+
<EuiFormRow label={ControlGroupStrings.management.getLayoutTitle()}>
67+
<EuiButtonGroup
68+
color="primary"
69+
legend={ControlGroupStrings.management.controlStyle.getDesignSwitchLegend()}
70+
options={CONTROL_LAYOUT_OPTIONS}
71+
idSelected={currentControlStyle}
72+
onChange={(newControlStyle) => {
73+
setControlStyle(newControlStyle as ControlStyle);
74+
setCurrentControlStyle(newControlStyle as ControlStyle);
75+
}}
76+
/>
77+
</EuiFormRow>
7578
<EuiSpacer size="m" />
76-
<EuiTitle size="s">
77-
<h3>{ControlGroupStrings.management.getLayoutTitle()}</h3>
78-
</EuiTitle>
79-
<EuiSpacer size="s" />
80-
81-
<EuiFlexGroup alignItems="center" justifyContent="flexEnd">
82-
<EuiFlexItem grow={false}>
83-
<EuiFormLabel>
84-
{ControlGroupStrings.management.controlWidth.getChangeAllControlWidthsTitle()}
85-
</EuiFormLabel>
86-
</EuiFlexItem>
87-
<EuiFlexItem grow={false}>
79+
<EuiFormRow label={ControlGroupStrings.management.getWidthTitle()}>
80+
<EuiSwitch
81+
label={ControlGroupStrings.management.controlWidth.getChangeAllControlWidthsTitle()}
82+
checked={selectionDisplay}
83+
onChange={() => setSelectionDisplay(!selectionDisplay)}
84+
/>
85+
</EuiFormRow>
86+
{selectionDisplay ? (
87+
<>
88+
<EuiSpacer size="s" />
8889
<EuiButtonGroup
90+
color="primary"
8991
idSelected={selectedWidth ?? ''}
90-
buttonSize="compressed"
9192
legend={ControlGroupStrings.management.controlWidth.getWidthSwitchLegend()}
9293
options={CONTROL_WIDTH_OPTIONS}
9394
onChange={(newWidth: string) => {
9495
setAllPanelWidths(newWidth as ControlWidth);
9596
setSelectedWidth(newWidth as ControlWidth);
9697
}}
9798
/>
98-
</EuiFlexItem>
99-
<EuiFlexItem grow={false}>
100-
<EuiButtonEmpty
101-
onClick={deleteAllEmbeddables}
102-
aria-label={'delete-all'}
103-
iconType="trash"
104-
color="danger"
105-
size="s"
106-
>
107-
{ControlGroupStrings.management.getDeleteAllButtonTitle()}
108-
</EuiButtonEmpty>
109-
</EuiFlexItem>
110-
</EuiFlexGroup>
99+
</>
100+
) : undefined}
101+
102+
<EuiSpacer size="xl" />
103+
104+
<EuiButtonEmpty
105+
onClick={deleteAllEmbeddables}
106+
aria-label={'delete-all'}
107+
iconType="trash"
108+
flush="left"
109+
color="danger"
110+
size="s"
111+
>
112+
{ControlGroupStrings.management.getDeleteAllButtonTitle()}
113+
</EuiButtonEmpty>
111114
</EuiFlyoutBody>
112115
</>
113116
);

0 commit comments

Comments
 (0)