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

[Graph] Empty workspace overlay #45547

Merged
merged 202 commits into from
Oct 3, 2019
Merged
Show file tree
Hide file tree
Changes from 195 commits
Commits
Show all changes
202 commits
Select commit Hold shift + click to select a range
067158a
create graph listing page
flash1293 Aug 26, 2019
5fddc10
clean up app folder
flash1293 Aug 26, 2019
95f003b
remove inline loading menu
flash1293 Aug 27, 2019
ae44388
also add badge to workspace route
flash1293 Aug 27, 2019
2f1056f
fix tests
flash1293 Aug 27, 2019
5d637f5
fix graph spaces functional test
flash1293 Aug 27, 2019
9d17862
generate documentation for new breadcrumb property
flash1293 Aug 27, 2019
db1d740
fix test subject names
flash1293 Aug 27, 2019
e09b70d
remove unused translations
flash1293 Aug 27, 2019
2dab994
start implementing save modal flow for Graph
flash1293 Aug 27, 2019
c34d845
fix spaces functional test
flash1293 Aug 27, 2019
2d775e6
wip save modal
flash1293 Aug 27, 2019
ebe80d1
wip save modal
flash1293 Aug 27, 2019
fab1577
add and style save modal
flash1293 Aug 28, 2019
a9d31c8
add placeholder to description field
flash1293 Aug 28, 2019
9d2822e
Merge remote-tracking branch 'upstream/master' into graph/listing-page
flash1293 Aug 28, 2019
d0b9247
Merge remote-tracking branch 'upstream/master' into graph/listing-page
flash1293 Aug 29, 2019
d187eae
disable dirty check on breadcrumb navigation and fix delete function
flash1293 Aug 29, 2019
21ba056
Merge branch 'graph/listing-page' into graph/savemodal
flash1293 Aug 29, 2019
5d87a6a
reactify most of settings
flash1293 Aug 29, 2019
a289d7d
improve onClick typing on breadcrumb
flash1293 Aug 29, 2019
989481c
Merge branch 'graph/listing-page' into graph/savemodal
flash1293 Aug 29, 2019
be1e59a
fix newline error and use new types in dashboard app controller
flash1293 Aug 29, 2019
6ba958b
Merge branch 'graph/savemodal' into graph/settings
flash1293 Aug 29, 2019
4057edb
EUIify drilldown
flash1293 Aug 29, 2019
611214e
EUIify drilldown
flash1293 Aug 29, 2019
c5ac49b
fix translation errors
flash1293 Aug 30, 2019
8d6cec1
fix i18n translation for real
flash1293 Aug 30, 2019
0472505
Merge remote-tracking branch 'upstream/master' into graph/savemodal
flash1293 Aug 30, 2019
8012ac8
Merge branch 'graph/savemodal' into graph/settings
flash1293 Aug 30, 2019
70d2d29
fix icon and work on autoreplace template logic
flash1293 Aug 30, 2019
1047e48
use switch instead of checkbox
flash1293 Sep 2, 2019
173804a
code review
flash1293 Sep 2, 2019
54e9a7b
Merge remote-tracking branch 'upstream/master' into graph/savemodal
flash1293 Sep 2, 2019
6f1bbca
fix i18n phrases
flash1293 Sep 2, 2019
2c48e21
Merge branch 'graph/savemodal' into graph/settings
flash1293 Sep 2, 2019
7c94337
remove fragments
flash1293 Sep 2, 2019
46f51e6
Merge branch 'graph/savemodal' into graph/settings
flash1293 Sep 2, 2019
d74fb9b
add KQL encoder to be able to drill down to discover
flash1293 Sep 2, 2019
d289803
fix flyout overflow issue
flash1293 Sep 2, 2019
06bacb0
delete old settings logic
flash1293 Sep 2, 2019
ad2297f
remove obsolete files
flash1293 Sep 2, 2019
a810321
fix tests
flash1293 Sep 3, 2019
ebf38ec
fix i18n phrase typo
flash1293 Sep 3, 2019
04ff9ff
fix most translations
flash1293 Sep 4, 2019
f489b07
Merge remote-tracking branch 'upstream/master' into graph/savemodal
flash1293 Sep 4, 2019
dfcb49d
start implementing review comments
flash1293 Sep 4, 2019
d0f8ed4
Merge remote-tracking branch 'upstream/master' into graph/settings
flash1293 Sep 4, 2019
5afd65a
continue implementing review
flash1293 Sep 4, 2019
dd18ab9
continue cleanup of settings forms
flash1293 Sep 5, 2019
bcc280f
remove unnecessary max-width and add commentary
flash1293 Sep 5, 2019
a578814
move to async syntax
flash1293 Sep 5, 2019
4897b52
clean up implementation
flash1293 Sep 5, 2019
7b2b91b
use description instead of title
flash1293 Sep 5, 2019
208b4db
Merge remote-tracking branch 'upstream/master' into graph/savemodal
flash1293 Sep 5, 2019
43added
Merge branch 'graph/savemodal' into graph/settings
flash1293 Sep 5, 2019
6b89af4
work on settings form
flash1293 Sep 5, 2019
e4b9aa0
fix snapshot
flash1293 Sep 5, 2019
4df5c97
fix drilldown list
flash1293 Sep 5, 2019
d8062cb
Merge branch 'graph/savemodal' into graph/settings
flash1293 Sep 5, 2019
b4516c4
add tests for use_list_keys
flash1293 Sep 5, 2019
a1ec761
rename stuff and add documentation
flash1293 Sep 5, 2019
8a83c3c
fix translatiojns
flash1293 Sep 5, 2019
ad6d633
fix some rename references
flash1293 Sep 5, 2019
d8c12b8
start typing saving and loading
flash1293 Sep 5, 2019
89c7ad7
typing persistence stuff
flash1293 Sep 5, 2019
1195f36
adress review comments and set width for all save modals
flash1293 Sep 5, 2019
f6ca136
Merge branch 'graph/savemodal' into graph/settings
flash1293 Sep 5, 2019
4d29ee2
Merge branch 'graph/savemodal' into graph/type-persistence
flash1293 Sep 5, 2019
c15aebc
type serializing logic
flash1293 Sep 5, 2019
372f3b4
fix bug and improve typing
flash1293 Sep 5, 2019
3de7e4f
fix classname
flash1293 Sep 5, 2019
7ae8b1f
wip
flash1293 Sep 5, 2019
64a36bc
wip
flash1293 Sep 5, 2019
32eaf17
Merge branch 'graph/savemodal' into graph/settings
flash1293 Sep 5, 2019
cb2096b
add notes
flash1293 Sep 5, 2019
ca03356
style blacklist group
flash1293 Sep 6, 2019
211c4e2
Merge remote-tracking branch 'upstream/master' into graph/settings
flash1293 Sep 6, 2019
f4d9c42
remove merge marker
flash1293 Sep 6, 2019
4c287ab
improve icon rendering
flash1293 Sep 6, 2019
22994d7
wip
flash1293 Sep 6, 2019
e444ac1
start refactoring
flash1293 Sep 6, 2019
0766ee6
remove js implementation
flash1293 Sep 6, 2019
a7e9032
Merge remote-tracking branch 'upstream/master' into graph/type-persis…
flash1293 Sep 6, 2019
d653eb1
remove js implementation
flash1293 Sep 6, 2019
879475a
remove duplicate file
flash1293 Sep 6, 2019
7a3ab4e
add some tests
flash1293 Sep 6, 2019
5837953
Design cleanup
Sep 6, 2019
ae23e9a
Fix SASS files
Sep 6, 2019
891032f
Merge remote-tracking branch 'upstream/master' into graph/settings
flash1293 Sep 9, 2019
e96ed34
Merge pull request #3 from cchaos/graph/settings/design
flash1293 Sep 9, 2019
654e6f8
Merge branch 'graph/settings' of github.com:flash1293/kibana into gra…
flash1293 Sep 9, 2019
55a0185
revert style fixes in app.js
flash1293 Sep 9, 2019
43ec456
implement todos
flash1293 Sep 9, 2019
f62b1d7
fix errors and prematurely enabling inspect panel
flash1293 Sep 9, 2019
a16375f
deselect icon after clicking again
flash1293 Sep 9, 2019
cdfd7fd
fix types
flash1293 Sep 9, 2019
cadcb22
make icon list accessible
flash1293 Sep 10, 2019
639e012
Merge remote-tracking branch 'upstream/master' into graph/type-persis…
flash1293 Sep 10, 2019
9f5e918
clean up and add some more tests
flash1293 Sep 10, 2019
8ccf000
improve number handling
flash1293 Sep 10, 2019
308f8ff
fix deserialization
flash1293 Sep 10, 2019
fb35a66
start implementing indexpattern modal
flash1293 Sep 10, 2019
7b2a0a1
Merge remote-tracking branch 'upstream/master' into graph/indexpatter…
flash1293 Sep 11, 2019
ee21e9e
Merge remote-tracking branch 'upstream/master' into graph/settings
flash1293 Sep 11, 2019
4c7ebb3
Merge remote-tracking branch 'upstream/master' into graph/type-persis…
flash1293 Sep 11, 2019
196c1f8
polishing drilldown-ui
flash1293 Sep 11, 2019
158c3ac
rename types
flash1293 Sep 11, 2019
7f67468
style search bar
flash1293 Sep 11, 2019
663293a
add tooltip
flash1293 Sep 11, 2019
b28a547
remove unused translations
flash1293 Sep 11, 2019
c34cbc5
fix initial query handling
flash1293 Sep 11, 2019
e901c5e
clean up imports
flash1293 Sep 11, 2019
e27f668
Merge remote-tracking branch 'upstream/master' into graph/type-persis…
flash1293 Sep 11, 2019
d6cae5c
implement field manager WIP
flash1293 Sep 11, 2019
8202d74
Merge branch 'graph/type-persistence' into graph/settings
flash1293 Sep 11, 2019
31feeec
fix tests
flash1293 Sep 11, 2019
1d89528
Merge remote-tracking branch 'upstream/master' into graph/settings
flash1293 Sep 11, 2019
1539f6c
Merge remote-tracking branch 'upstream/master' into graph/indexpatter…
flash1293 Sep 11, 2019
7e31dd2
Merge remote-tracking branch 'upstream/master' into graph/field-manager
flash1293 Sep 11, 2019
8583e86
Merge branch 'graph/settings' into graph/field-manager
flash1293 Sep 11, 2019
07c5095
wip
flash1293 Sep 11, 2019
e7867de
continue implementing field manager
flash1293 Sep 12, 2019
62f0cb3
add comment
flash1293 Sep 12, 2019
0ee038c
add handling for canEditDrillDowns setting
flash1293 Sep 12, 2019
db59eed
Merge remote-tracking branch 'upstream/master' into graph/settings
flash1293 Sep 12, 2019
de5e764
Merge branch 'graph/settings' into graph/field-manager
flash1293 Sep 12, 2019
03dd692
implement and style field manager
flash1293 Sep 12, 2019
e13e2f9
propagate changes to workspace client
flash1293 Sep 12, 2019
746fe99
Merge branch 'graph/settings' into graph/field-manager
flash1293 Sep 12, 2019
aa607f5
style new field manager
flash1293 Sep 12, 2019
a6418dc
start implementing overlays
flash1293 Sep 12, 2019
cc95842
add tests
flash1293 Sep 12, 2019
c9def6b
Merge branch 'graph/indexpattern_modal' into graph/call-to-action
flash1293 Sep 13, 2019
639c008
continue implementing overlays
flash1293 Sep 13, 2019
eafe3bd
Merge remote-tracking branch 'upstream/master' into graph/field-manager
flash1293 Sep 13, 2019
6fe0340
add tests
flash1293 Sep 13, 2019
65a9bcf
add tests
flash1293 Sep 13, 2019
b89d260
Merge branch 'graph/field-manager' of github.com:flash1293/kibana int…
flash1293 Sep 13, 2019
e35f97c
Merge remote-tracking branch 'upstream/master' into graph/field-manager
flash1293 Sep 13, 2019
9b0481c
fix errors
flash1293 Sep 13, 2019
1d08e2b
ui polish
flash1293 Sep 13, 2019
e0dd43c
add missing license header
flash1293 Sep 15, 2019
336df72
Merge remote-tracking branch 'upstream/master' into graph/field-manager
flash1293 Sep 15, 2019
2ddad53
Merge remote-tracking branch 'upstream/master' into graph/call-to-action
flash1293 Sep 15, 2019
256976d
quick and dirty version of prepopulating the graph
flash1293 Sep 15, 2019
f51196a
remove unused translations
flash1293 Sep 15, 2019
2ea0318
Merge remote-tracking branch 'upstream/master' into graph/field-manager
flash1293 Sep 16, 2019
13da923
Merge branch 'graph/field-manager' into graph/call-to-action
flash1293 Sep 16, 2019
56e1c0d
Merge branch 'graph/prepopulate-graph' into graph/call-to-action
flash1293 Sep 16, 2019
8df309f
improve overlays
flash1293 Sep 16, 2019
3459adf
fix some bugs
flash1293 Sep 16, 2019
ee1715b
Merge remote-tracking branch 'upstream/master' into graph/field-manager
flash1293 Sep 17, 2019
0d0bab9
fix conflicts
flash1293 Sep 17, 2019
eab90bc
fix wrong export name
flash1293 Sep 17, 2019
0a39f5d
Merge remote-tracking branch 'upstream/master' into graph/field-manager
flash1293 Sep 18, 2019
3e05b76
Merge remote-tracking branch 'upstream/master' into graph/field-manager
flash1293 Sep 18, 2019
a609c9d
Merge remote-tracking branch 'upstream/master' into graph/field-manager
flash1293 Sep 18, 2019
0382fd6
Merge remote-tracking branch 'upstream/master' into graph/field-manager
flash1293 Sep 18, 2019
20af44a
Merge remote-tracking branch 'upstream/master' into graph/field-manager
flash1293 Sep 19, 2019
b3c6ed5
improve field picker
flash1293 Sep 19, 2019
1d81469
remove badge tooltip
flash1293 Sep 19, 2019
e24c53e
Merge remote-tracking branch 'upstream/master' into graph/field-manager
flash1293 Sep 19, 2019
dcea147
resolve conflicts
flash1293 Sep 19, 2019
62c7b6d
remove unused imports
flash1293 Sep 19, 2019
fbfe2d4
address feedback
flash1293 Sep 20, 2019
da1271a
use eui colors
flash1293 Sep 20, 2019
22fd9e3
fix type bugs
flash1293 Sep 20, 2019
00cd140
Merge remote-tracking branch 'upstream/master' into graph/field-manager
flash1293 Sep 20, 2019
550bc91
fix integration bug and colors
flash1293 Sep 20, 2019
371cac1
fix small css bugs
flash1293 Sep 20, 2019
4999825
Updated badge styling
Sep 20, 2019
34bb4f6
Compressed field editor form
Sep 20, 2019
eb4b5af
Compressed and gave some spacing to field list popover
Sep 20, 2019
35d342b
Fix some class names
Sep 20, 2019
d590985
Merge pull request #4 from cchaos/graph/field-manager/design
flash1293 Sep 23, 2019
20751be
Merge remote-tracking branch 'upstream/master' into graph/field-manager
flash1293 Sep 23, 2019
c922e3d
Merge branch 'graph/field-manager' into graph/call-to-action
flash1293 Sep 23, 2019
72b08a0
disabled add button when no datasource selected
flash1293 Sep 23, 2019
7bd0a40
Merge branch 'graph/field-manager' into graph/call-to-action
flash1293 Sep 23, 2019
ff0d8fd
wip
flash1293 Sep 23, 2019
4288106
wip
flash1293 Sep 23, 2019
aeb1f1a
set aria role
flash1293 Sep 23, 2019
5b92eb7
Merge branch 'graph/field-manager' into graph/call-to-action
flash1293 Sep 23, 2019
1a3f1d4
clean up styling and add tests
flash1293 Sep 23, 2019
7e6a065
remove unused styling
flash1293 Sep 23, 2019
4162cf6
Merge remote-tracking branch 'upstream/master' into graph/call-to-action
flash1293 Sep 24, 2019
acb9cd6
add error handling and correct field icon
flash1293 Sep 24, 2019
b37f543
clean up
flash1293 Sep 24, 2019
5b5910b
Merge branch 'master' into graph/call-to-action
elasticmachine Sep 25, 2019
eaac0f7
Merge remote-tracking branch 'upstream/master' into graph/call-to-action
flash1293 Sep 27, 2019
2f676ce
address feedback
flash1293 Sep 27, 2019
a32e92a
Merge branch 'master' into graph/call-to-action
elasticmachine Sep 30, 2019
00e59ad
emphasize completed steps
flash1293 Sep 30, 2019
7ac17cf
Merge branch 'graph/call-to-action' of github.com:flash1293/kibana in…
flash1293 Sep 30, 2019
4a6fdf6
have separate styling for done items
flash1293 Sep 30, 2019
60926f8
Merge remote-tracking branch 'upstream/master' into graph/call-to-action
flash1293 Oct 1, 2019
e0724c2
wrap list items in EuiText
flash1293 Oct 1, 2019
ab23657
Merge remote-tracking branch 'upstream/master' into graph/call-to-action
flash1293 Oct 2, 2019
89638c8
Merge remote-tracking branch 'upstream/master' into graph/call-to-action
flash1293 Oct 2, 2019
c0b100f
Merge remote-tracking branch 'upstream/master' into graph/call-to-action
flash1293 Oct 3, 2019
456dc39
eslint fix
flash1293 Oct 3, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1200,11 +1200,14 @@ module.exports = (function () {
}


//Add missing links between existing nodes
this.fillInGraph = function () {
/**
* Add missing links between existing nodes
* @param maxNewEdges Max number of new edges added. Avoid adding too many new edges
* at once into the graph otherwise disorientating
*/
this.fillInGraph = function (maxNewEdges = 10) {
let nodesForLinking = self.getSelectedOrAllTopNodes();

const maxNewEdges = 10; // Avoid adding too many new edges at once into the graph otherwise disorientating
const maxNumVerticesSearchable = 100;


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,16 @@
http="pluginDependencies.http"
overlays="pluginDependencies.overlays"
is-loading="loading"
is-initialized="!!workspace || savedWorkspace.id"
initial-query="initialQuery"
state="reduxState"
dispatch="reduxDispatch"
on-fill-workspace="fillWorkspace"
></graph-app>

<div class="gphGraph__container" id="GraphSvgContainer">
<!-- The graph svg container has to be there from the start because of some listeners being registered,
this is why it's using ng-show instead of ng-if -->
<div class="gphGraph__container" id="GraphSvgContainer" ng-show="workspace">
<svg class="gphGraph" width="100%" height="100%" pointer-events="all" id="graphSvg" ng-click="hideAllConfigPanels()">
<g id="svgRootGroup">
<g>
Expand Down
30 changes: 27 additions & 3 deletions x-pack/legacy/plugins/graph/public/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ import { urlTemplateRegex } from './helpers/url_template';
import {
asAngularSyncedObservable,
} from './helpers/as_observable';
import { fetchTopNodes } from './services/fetch_top_nodes';
import {
createGraphStore,
loadFields,
Expand Down Expand Up @@ -110,6 +111,8 @@ app.directive('graphApp', function (reactDirective) {
return reactDirective(GraphApp, [
['state', { watchDepth: 'reference' }],
['dispatch', { watchDepth: 'reference' }],
['onFillWorkspace', { watchDepth: 'reference' }],
['isInitialized', { watchDepth: 'reference' }],
['currentIndexPattern', { watchDepth: 'reference' }],
['isLoading', { watchDepth: 'reference' }],
['onIndexPatternSelected', { watchDepth: 'reference' }],
Expand Down Expand Up @@ -435,6 +438,30 @@ app.controller('graphuiPlugin', function (
});
};

$scope.fillWorkspace = async () => {
try {
const fields = selectedFieldsSelector(store.getState());
const topTermNodes = await fetchTopNodes(
npStart.core.http.post,
$scope.selectedIndex.title,
fields
);
initWorkspaceIfRequired();
$scope.workspace.mergeGraph({
nodes: topTermNodes,
edges: []
});
$scope.workspace.fillInGraph(fields.length * 10);
} catch (e) {
toastNotifications.addDanger({
title: i18n.translate(
'xpack.graph.fillWorkspaceError',
{ defaultMessage: 'Fetching top terms failed: {message}', values: { message: e.message } }
),
});
}
};

$scope.submit = function (searchTerm) {
initWorkspaceIfRequired();
const numHops = 2;
Expand Down Expand Up @@ -859,9 +886,6 @@ app.controller('graphuiPlugin', function (
} else {
$route.current.locals.SavedWorkspacesProvider.get().then(function (newWorkspace) {
$scope.savedWorkspace = newWorkspace;
openSourceModal(npStart.core, indexPattern => {
$scope.indexSelected(indexPattern);
});
});
}

Expand Down
2 changes: 2 additions & 0 deletions x-pack/legacy/plugins/graph/public/components/_index.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
@import './app';
@import './search_bar';
@import './source_modal';
@import './guidance_panel/index';
@import './venn_diagram/index';
@import './settings/index';
@import './legacy_icon/index';
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.gphSourceModal {
width: 720px;
min-height: 530px;
}
50 changes: 38 additions & 12 deletions x-pack/legacy/plugins/graph/public/components/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,49 @@
*/

import { EuiFlexGroup, EuiFlexItem } from '@elastic/eui';
import React from 'react';
import React, { useState } from 'react';
import { I18nProvider } from '@kbn/i18n/react';
import { FieldManagerProps, FieldManager } from './field_manager';
import { SearchBarProps, SearchBar } from './search_bar';
import { GuidancePanel } from './guidance_panel';
import { selectedFieldsSelector } from '../state_management';
import { openSourceModal } from '../services/source_modal';

export interface GraphAppProps extends FieldManagerProps, SearchBarProps {}
export interface GraphAppProps extends FieldManagerProps, SearchBarProps {
onFillWorkspace: () => void;
isInitialized: boolean;
}

export function GraphApp(props: GraphAppProps) {
const [pickerOpen, setPickerOpen] = useState(false);

return (
<div className="gphGraph__bar">
<EuiFlexGroup direction="column" gutterSize="s">
<EuiFlexItem>
<SearchBar {...props} />
</EuiFlexItem>
<EuiFlexItem>
<FieldManager {...props} />
</EuiFlexItem>
</EuiFlexGroup>
</div>
<I18nProvider>
<>
<div className="gphGraph__bar">
<EuiFlexGroup direction="column" gutterSize="s">
<EuiFlexItem>
<SearchBar {...props} />
</EuiFlexItem>
<EuiFlexItem>
<FieldManager {...props} pickerOpen={pickerOpen} setPickerOpen={setPickerOpen} />
</EuiFlexItem>
</EuiFlexGroup>
</div>
{!props.isInitialized && (
<GuidancePanel
hasDatasource={Boolean(props.currentIndexPattern)}
hasFields={selectedFieldsSelector(props.state).length > 0}
onFillWorkspace={props.onFillWorkspace}
onOpenFieldPicker={() => {
setPickerOpen(true);
}}
onOpenDatasourcePicker={() => {
openSourceModal(props, props.onIndexPatternSelected);
}}
/>
)}
</>
</I18nProvider>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ function getIconForDataType(dataType: string) {
boolean: 'invert',
date: 'calendar',
geo_point: 'globe',
ip: 'link',
ip: 'storage',
};
return icons[dataType] || ICON_TYPES.find(t => t === dataType) || 'document';
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ describe('field_manager', () => {
let store: GraphStore;
let instance: ShallowWrapper;
let dispatchSpy: jest.Mock;
let openSpy: jest.Mock;

beforeEach(() => {
store = createGraphStore();
Expand Down Expand Up @@ -52,8 +53,16 @@ describe('field_manager', () => {
);

dispatchSpy = jest.fn(store.dispatch);

instance = shallow(<FieldManager state={store.getState()} dispatch={dispatchSpy} />);
openSpy = jest.fn();

instance = shallow(
<FieldManager
state={store.getState()}
dispatch={dispatchSpy}
pickerOpen={false}
setPickerOpen={openSpy}
/>
);
});

function update() {
Expand All @@ -80,13 +89,19 @@ describe('field_manager', () => {
});

it('should select fields from picker', () => {
const fieldPicker = instance.find(FieldPicker).dive();

act(() => {
(fieldPicker.find(EuiPopover).prop('button')! as ReactElement).props.onClick();
(instance
.find(FieldPicker)
.dive()
.find(EuiPopover)
.prop('button')! as ReactElement).props.onClick();
});

fieldPicker.update();
expect(openSpy).toHaveBeenCalled();

instance.setProps({ pickerOpen: true });

const fieldPicker = instance.find(FieldPicker).dive();

expect(
fieldPicker
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { I18nProvider } from '@kbn/i18n/react';
import React from 'react';
import { EuiFlexGroup, EuiFlexItem } from '@elastic/eui';
import { bindActionCreators } from 'redux';
Expand All @@ -24,9 +23,11 @@ import {
export interface FieldManagerProps {
state: GraphState;
dispatch: GraphDispatch;
pickerOpen: boolean;
setPickerOpen: (open: boolean) => void;
}

export function FieldManager({ state, dispatch }: FieldManagerProps) {
export function FieldManager({ state, dispatch, pickerOpen, setPickerOpen }: FieldManagerProps) {
const fieldMap = fieldMapSelector(state);
const allFields = fieldsSelector(state);
const selectedFields = selectedFieldsSelector(state);
Expand All @@ -41,17 +42,20 @@ export function FieldManager({ state, dispatch }: FieldManagerProps) {
);

return (
<I18nProvider>
<EuiFlexGroup gutterSize="s" className="gphFieldManager" alignItems="center" wrap>
{selectedFields.map(field => (
<EuiFlexItem key={field.name} grow={false}>
<FieldEditor allFields={allFields} {...actionCreators} field={field} />
</EuiFlexItem>
))}
<EuiFlexItem grow={false}>
<FieldPicker fieldMap={fieldMap} {...actionCreators} />
<EuiFlexGroup gutterSize="s" className="gphFieldManager" alignItems="center" wrap>
{selectedFields.map(field => (
<EuiFlexItem key={field.name} grow={false}>
<FieldEditor allFields={allFields} {...actionCreators} field={field} />
</EuiFlexItem>
</EuiFlexGroup>
</I18nProvider>
))}
<EuiFlexItem grow={false}>
<FieldPicker
open={pickerOpen}
setOpen={setPickerOpen}
fieldMap={fieldMap}
{...actionCreators}
/>
</EuiFlexItem>
</EuiFlexGroup>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,17 @@ export interface FieldPickerProps {
fieldMap: Record<string, WorkspaceField>;
selectField: (fieldName: string) => void;
deselectField: (fieldName: string) => void;
open: boolean;
setOpen: (open: boolean) => void;
}

export function FieldPicker({ fieldMap, selectField, deselectField }: FieldPickerProps) {
const [open, setOpen] = useState(false);

export function FieldPicker({
fieldMap,
selectField,
deselectField,
open,
setOpen,
}: FieldPickerProps) {
const allFields = Object.values(fieldMap);
const unselectedFields = allFields.filter(field => !field.selected);
const hasSelectedFields = unselectedFields.length < allFields.length;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
.gphGuidancePanel {
max-width: 580px;
margin: $euiSizeL 0;
}

.gphGuidancePanel__list {
list-style: none;
margin: 0;
padding: 0;
}

.gphGuidancePanel__item {
display: block;
max-width: 420px;
position: relative;
padding-left: $euiSizeXL;
margin-bottom: $euiSizeL;

button {
// make buttons wrap lines like regular text
display: contents;
}
}

.gphGuidancePanel__item--disabled {
color: $euiColorMediumShade;
pointer-events: none;

button {
color: $euiColorDarkShade !important;
}
}

.gphGuidancePanel__itemIcon {
position: absolute;
left: 0;
top: -$euiSizeXS;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@import './_guidance_panel';
Loading