Skip to content

Commit 5f7541e

Browse files
[D&D] Adds Bar line and Area charts to Wizard (#2266) (#2291)
Description * Adds Bar line and Area charts to Wizard * Adds resizable right nav to Wizard * E2E tests for bar chart and chart switching Issues Resolved: #1616 #1617 #1618 Co-authored-by: Josh Romero <[email protected]> Signed-off-by: Ashwin Pc <[email protected]>
1 parent 3e7e41d commit 5f7541e

35 files changed

+811
-80
lines changed

src/plugins/vis_type_vislib/public/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,6 @@ export function plugin(initializerContext: PluginInitializerContext) {
3535
return new Plugin(initializerContext);
3636
}
3737

38+
export { getConfigCollections } from './utils/collections';
39+
3840
export * from './types';

src/plugins/vis_type_vislib/public/types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,3 +106,5 @@ export interface BasicVislibParams extends CommonVislibParams {
106106
times: TimeMarker[];
107107
type: string;
108108
}
109+
110+
export { Positions };

src/plugins/visualizations/public/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export { Vis } from './vis';
4343
export { TypesService } from './vis_types/types_service';
4444
export { VISUALIZE_EMBEDDABLE_TYPE, VIS_EVENT_TO_TRIGGER } from './embeddable';
4545
export { VisualizationContainer, VisualizationNoResults } from './components';
46-
export { getSchemas as getVisSchemas } from './legacy/build_pipeline';
46+
export { getSchemas as getVisSchemas, buildVislibDimensions } from './legacy/build_pipeline';
4747

4848
/** @public types */
4949
export { VisualizationsSetup, VisualizationsStart };

src/plugins/wizard/opensearch_dashboards.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
"dashboard",
1717
"visualizations",
1818
"opensearchUiShared",
19-
"visDefaultEditor"
19+
"visDefaultEditor",
20+
"visTypeVislib"
2021
],
2122
"optionalPlugins": []
2223
}

src/plugins/wizard/public/application/_variables.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@
66
@import "@elastic/eui/src/global_styling/variables/form";
77

88
$osdHeaderOffset: $euiHeaderHeightCompensation;
9-
$wizSideNavWidth: 470px;
9+
$wizLeftNavWidth: 462px;

src/plugins/wizard/public/application/app.scss

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,18 @@
88
padding: 0;
99
display: grid;
1010
grid-template:
11-
"topNav topNav topNav" min-content
12-
"leftNav workspace rightNav" 1fr / #{$wizSideNavWidth} 1fr #{$wizSideNavWidth};
11+
"topNav topNav" min-content
12+
"leftNav workspaceNav" 1fr / #{$wizLeftNavWidth} 1fr;
1313
height: calc(100vh - #{$osdHeaderOffset});
14+
15+
&__resizeContainer {
16+
min-height: 0;
17+
background-color: $euiColorEmptyShade;
18+
}
19+
20+
&__resizeButton {
21+
transform: translateX(-$euiSizeM / 2);
22+
}
1423
}
1524

1625
.headerIsExpanded .wizLayout {

src/plugins/wizard/public/application/app.tsx

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
import React from 'react';
77
import { I18nProvider } from '@osd/i18n/react';
8-
import { EuiPage } from '@elastic/eui';
8+
import { EuiPage, EuiResizableContainer } from '@elastic/eui';
99
import { DragDropProvider } from './utils/drag_drop/drag_drop_context';
1010
import { LeftNav } from './components/left_nav';
1111
import { TopNav } from './components/top_nav';
@@ -21,8 +21,37 @@ export const WizardApp = () => {
2121
<EuiPage className="wizLayout">
2222
<TopNav />
2323
<LeftNav />
24-
<Workspace />
25-
<RightNav />
24+
<EuiResizableContainer className="wizLayout__resizeContainer">
25+
{(EuiResizablePanel, EuiResizableButton) => (
26+
<>
27+
<EuiResizablePanel
28+
className="wizLayout__workspaceResize"
29+
paddingSize="none"
30+
initialSize={80}
31+
minSize="300px"
32+
mode="main"
33+
>
34+
<Workspace />
35+
</EuiResizablePanel>
36+
<EuiResizableButton className="wizLayout__resizeButton" />
37+
<EuiResizablePanel
38+
className="wizLayout__rightNavResize"
39+
paddingSize="none"
40+
initialSize={20}
41+
minSize="250px"
42+
mode={[
43+
'collapsible',
44+
{
45+
position: 'top',
46+
},
47+
]}
48+
id="wizRightResize"
49+
>
50+
<RightNav />
51+
</EuiResizablePanel>
52+
</>
53+
)}
54+
</EuiResizableContainer>
2655
</EuiPage>
2756
</DragDropProvider>
2857
</I18nProvider>

src/plugins/wizard/public/application/components/data_tab/field_selector.scss

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
overflow-y: auto;
1616
margin-right: -$euiSizeS;
1717
padding-right: $euiSizeS;
18+
margin-left: -$euiSizeS;
19+
padding-left: $euiSizeS;
1820
margin-top: $euiSizeS;
1921
}
2022

src/plugins/wizard/public/application/components/experimental_info.tsx

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,37 +6,35 @@
66
import React, { memo } from 'react';
77
import { EuiCallOut, EuiLink } from '@elastic/eui';
88
import { FormattedMessage } from '@osd/i18n/react';
9+
import { i18n } from '@osd/i18n';
910

1011
export const InfoComponent = () => {
11-
const title = (
12-
<>
12+
return (
13+
<EuiCallOut
14+
className="hide-for-sharing"
15+
data-test-subj="experimentalVisInfo"
16+
size="s"
17+
title={i18n.translate('wizard.experimentalInfoTitle', {
18+
defaultMessage: 'This editor is experimental and should not be used in production',
19+
})}
20+
iconType="beaker"
21+
>
1322
<FormattedMessage
1423
id="wizard.experimentalInfoText"
15-
defaultMessage="This editor is experimental, do not use in production.
16-
For feedback, please create an issue in {githubLink}."
24+
defaultMessage="We want to hear from you about how we can improve your experience. Leave feedback in {githubLink}."
1725
values={{
1826
githubLink: (
1927
<EuiLink
2028
external
21-
href="https://github.com/opensearch-project/OpenSearch-Dashboards/issues/new/choose"
29+
href="https://github.com/opensearch-project/OpenSearch-Dashboards/issues/2280"
2230
target="_blank"
2331
>
24-
GitHub
32+
the GitHub issue
2533
</EuiLink>
2634
),
2735
}}
2836
/>
29-
</>
30-
);
31-
32-
return (
33-
<EuiCallOut
34-
className="hide-for-sharing"
35-
data-test-subj="experimentalVisInfo"
36-
size="s"
37-
title={title}
38-
iconType="beaker"
39-
/>
37+
</EuiCallOut>
4038
);
4139
};
4240

src/plugins/wizard/public/application/components/right_nav.tsx

Lines changed: 47 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,24 @@
33
* SPDX-License-Identifier: Apache-2.0
44
*/
55

6-
import React from 'react';
7-
import { EuiSuperSelect, EuiSuperSelectOption, EuiIcon, IconType } from '@elastic/eui';
6+
import React, { useState } from 'react';
7+
import {
8+
EuiSuperSelect,
9+
EuiSuperSelectOption,
10+
EuiIcon,
11+
IconType,
12+
EuiConfirmModal,
13+
} from '@elastic/eui';
14+
import { i18n } from '@osd/i18n';
15+
import { FormattedMessage } from '@osd/i18n/react';
816
import { useVisualizationType } from '../utils/use';
917
import './side_nav.scss';
1018
import { useOpenSearchDashboards } from '../../../../opensearch_dashboards_react/public';
1119
import { WizardServices } from '../../types';
1220
import { setActiveVisualization, useTypedDispatch } from '../utils/state_management';
1321

1422
export const RightNav = () => {
23+
const [newVisType, setNewVisType] = useState<string>();
1524
const {
1625
services: { types },
1726
} = useOpenSearchDashboards<WizardServices>();
@@ -23,6 +32,7 @@ export const RightNav = () => {
2332
value: name,
2433
inputDisplay: <OptionItem icon={icon} title={title} />,
2534
dropdownDisplay: <OptionItem icon={icon} title={title} />,
35+
'data-test-subj': `visType-${name}`,
2636
}));
2737

2838
return (
@@ -32,19 +42,48 @@ export const RightNav = () => {
3242
options={options}
3343
valueOfSelected={activeVisName}
3444
onChange={(name) => {
35-
dispatch(
36-
setActiveVisualization({
37-
name,
38-
style: types.get(name)?.ui.containerConfig.style.defaults,
39-
})
40-
);
45+
setNewVisType(name);
4146
}}
4247
fullWidth
48+
data-test-subj="chartPicker"
4349
/>
4450
</div>
4551
<div className="wizSidenav__style">
4652
<StyleSection />
4753
</div>
54+
{newVisType && (
55+
<EuiConfirmModal
56+
title={i18n.translate('wizard.rightNav.changeVisType.modalTitle', {
57+
defaultMessage: 'Change visualization type',
58+
})}
59+
confirmButtonText={i18n.translate('wizard.rightNav.changeVisType.confirmText', {
60+
defaultMessage: 'Change type',
61+
})}
62+
cancelButtonText={i18n.translate('wizard.rightNav.changeVisType.cancelText', {
63+
defaultMessage: 'Cancel',
64+
})}
65+
onCancel={() => setNewVisType(undefined)}
66+
onConfirm={() => {
67+
dispatch(
68+
setActiveVisualization({
69+
name: newVisType,
70+
style: types.get(newVisType)?.ui.containerConfig.style.defaults,
71+
})
72+
);
73+
74+
setNewVisType(undefined);
75+
}}
76+
maxWidth="300px"
77+
data-test-subj="confirmVisChangeModal"
78+
>
79+
<p>
80+
<FormattedMessage
81+
id="wizard.rightNav.changeVisType.modalDescription"
82+
defaultMessage="Changing the visualization type will reset all field selections. Do you want to continue?"
83+
/>
84+
</p>
85+
</EuiConfirmModal>
86+
)}
4887
</section>
4988
);
5089
};

0 commit comments

Comments
 (0)