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

[Vis Editor] EUIfication of agg and agg-group directives #40866

Merged
merged 63 commits into from
Jul 29, 2019

Conversation

maryia-lapata
Copy link
Contributor

@maryia-lapata maryia-lapata commented Jul 11, 2019

Summary

EUIfication of vis-editor-agg and vis-editor-agg-group directives in Default Editor, Data tab.
Part of #30922.

To bind React controls with AngularJS form and to have a proper validation flow, previously ngModel was created for each DefaultEditorAggParams component. This approach is left except that ngModel is created for each DefaultEditorAggGroup component only. Since we need that AngularJS form and React controls still work together, we cannot get rid of ngModel-approach until the main form (visualizeEditor) is migrated to React. Before that we need to migrate option tabs (#38273).

This PR also includes:

  • Getting indexPattern from agg(agg.getIndexPattern()) instead of from vis(vis.indexPattern) thereby getting rid of vis prop in DefaultEditorAgg;
  • Removal of draggable-* directives and dragula dependency since it isn't used anymore. For drag- and-drop functionality Eui components are used (EuiDragDropContext , EuiDroppable, EuiDraggable);
  • Removal of React component wrappers agg_add.js, agg_params.js, agg_controls.js;
  • Removal of keyboardMove directive;
  • TS for aggGroupNameMaps;
  • Removal of unused styles;

This PR also fixes #42054.

Screenshots:

  1. Collapsed aggs:

data

  1. Agg

data

  1. Error

data

Note:

Previously during dragging aggs, an opened agg accordion was collapsed at the moment of drag-and-drop, and agg accordion returned to the state before dragging started (opened/collapsed).

Now an opened agg accordion isn't collapsed at the moment of dragging since EUIAccordion's closed/opened state isn't managed by code (elastic/eui#2130), just by clicking on the caret icon. So a user has to collapse an agg before dragging for convenience.

Checklist

Use strikethroughs to remove checklist items you don't feel are applicable to this PR.

For maintainers

Dev-Docs

Schema.deprecate removed

The deprecate boolean flag on Schema when declaring schemas for visualizations has been removed.

@maryia-lapata maryia-lapata added the release_note:skip Skip the PR/issue when compiling release notes label Jul 11, 2019
@elasticmachine

This comment has been minimized.

@elasticmachine

This comment has been minimized.

@elasticmachine

This comment has been minimized.

@elasticmachine

This comment has been minimized.

@maryia-lapata maryia-lapata requested a review from sulemanof July 15, 2019 08:16
@maryia-lapata
Copy link
Contributor Author

maryia-lapata commented Jul 15, 2019

For this PR EUIAccordion is used inside of other EUIAccordion. And there is an issue with parent accordion height calculation:

When Y-axis accordion calculates the height, it sees the old height of Advanced accordion.

@chandlerprall maybe you have some ideas regarding how to fix that issue?

@elasticmachine

This comment has been minimized.

@elasticmachine

This comment has been minimized.

@elasticmachine

This comment has been minimized.

@maryia-lapata
Copy link
Contributor Author

@cchaos is the title size (Metricks, Buckets) ok?

I'm asking because of the comment in Optional Pie tab (#41901 (comment)). I think that titles on the Data tab and titles on optional tabs should be the same.

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@cchaos
Copy link
Contributor

cchaos commented Jul 25, 2019

@maryia-lapata I agree, they should be the same. I didn't realize they changed here too. Go ahead and make sure they're all EuiTitle size="xs"

@maryia-lapata
Copy link
Contributor Author

I agree, they should be the same. I didn't realize they changed here too. Go ahead and make sure they're all EuiTitle size="xs"

@cchaos thanks.
The PR and screenshots was updated.

@elasticmachine

This comment has been minimized.

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@@ -150,7 +150,6 @@
"d3": "3.5.17",
"d3-cloud": "1.2.5",
"del": "^4.0.0",
"dragula": "3.7.2",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉

value => {
$scope.formIsTouched = value;
},
true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be a boolean value (ngModelCtrl.$touched), so it does not really make sense making a deep object comparison here, we could just get rid of the true I think.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right. Fixed.


const [aggsState, setAggsState] = useReducer(aggGroupReducer, group, initAggsState);

const isGroupValid = Object.entries(aggsState).every(([, item]) => item.valid);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's use Object.values if we're only planning to use the value and not the key.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

setValidity(isGroupValid);
}, [isGroupValid]);

const onDragEnd = ({ source, destination }: any) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any ... 😔

I'll open an issue for EUI to properly export those types. Let's for now at least simply type { source: { index: number }; destination: {index: number} } as a local type in this file.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you.
I added a local type, but there is still an issue with TS, so I disabled TS for one line with comment.

@elasticmachine

This comment has been minimized.

@elasticmachine

This comment has been minimized.

result: { index: number };
provided: { index: number };
}
const onDragEnd = ({ result, provided }: DragDropProps) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This shouldn't be functioning,

result and provided are separate arguments i.e. (result, provided) instead of ({ result, provided })

result doesn't have an index property on it, instead there is source.index and destination.index (destination could also be null or undefined).

provided has the shape:

{
  announce: (message: string) => void
}

Getting the correct shapes here should remove the need for the @ts-ignore below

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's my bad. Thank you for noticing and explanation.

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@timroes timroes added the release_note:plugin_api_changes Contains a Plugin API changes section for the breaking plugin API changes section. label Jul 29, 2019
Copy link
Contributor

@timroes timroes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested on Chrome Linux, seems to work fine. Code LGTM.

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@maryia-lapata maryia-lapata merged commit 85f9ef6 into elastic:master Jul 29, 2019
maryia-lapata added a commit that referenced this pull request Jul 29, 2019
…2126)

* Create default_editor_agg.tsx

* Create default_editor_agg_group

* Apply drag and drop

* Remove unused dragula dependency

* Remove old mocha tests

* Add ts for state

* Update functional tests

* Update touched condition

* Apply styles for accordion button content

* Apply truncate for agg description

* Remove unused styles

* Separate common props

* Move aggGroupNamesMap to agg_group.js

* Update _sidebar.scss

* Pass schemas prop

* Prevent scroll bar and add space

* Remove unused min from stats

* Add OnAggParamsChange type

* Show error as an icon

* Update background color

* Update title size

* Remove Schema.deprecate since it's not used
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backported Feature:Vis Editor Visualization editor issues release_note:plugin_api_changes Contains a Plugin API changes section for the breaking plugin API changes section. release_note:skip Skip the PR/issue when compiling release notes Team:Visualizations Visualization editors, elastic-charts and infrastructure v7.4.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Remove Schema.deprecate
7 participants