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

changing vis.API.events #25280

Merged
merged 3 commits into from
Nov 16, 2018
Merged

Conversation

ppisljar
Copy link
Member

@ppisljar ppisljar commented Nov 7, 2018

Summary

Moves filtering functions out of Vis.

preparation for #23185

QA: no functional canges

Dev-Docs

filtering inside your visualization will need to be updated

vis.API.events.addFilter no longer exists, instead you should rather call vis.API.events.filter({ table, column, row, value })

Checklist

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

For maintainers

@ppisljar ppisljar added the WIP Work in progress label Nov 7, 2018
@ppisljar ppisljar changed the title [WIP] moving filtering out of Vis [WIP] changing vis.API.events Nov 7, 2018
@elasticmachine
Copy link
Contributor

💔 Build Failed

@ppisljar ppisljar force-pushed the ref/filteringEmbeddable branch from 76bd2dd to af833ed Compare November 7, 2018 13:15
@ppisljar ppisljar changed the title [WIP] changing vis.API.events changing vis.API.events Nov 7, 2018
@elasticmachine
Copy link
Contributor

💔 Build Failed

@elasticmachine
Copy link
Contributor

💔 Build Failed

@ppisljar ppisljar force-pushed the ref/filteringEmbeddable branch from ed27206 to fa8dec9 Compare November 8, 2018 06:41
@ppisljar ppisljar added review v7.0.0 v6.6.0 Feature:ExpressionLanguage Interpreter expression language (aka canvas pipeline) Team:Visualizations Visualization editors, elastic-charts and infrastructure and removed WIP Work in progress labels Nov 8, 2018
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-app

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Copy link
Member

@markov00 markov00 left a comment

Choose a reason for hiding this comment

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

Code LGTM. Some minor comments.
Tested on chrome/osx using brushes and filters

const _defaults = {
// name, title, description, icon, image
category: CATEGORY.OTHER,
visualization: null, // must be a class with render/resize/destroy methods
Copy link
Member

Choose a reason for hiding this comment

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

nit: Can we remove this visualization default? We already have a check on opts thats trows an exception if visualization is a falsy value.

What about checking if the visualization object has the required methods?

Copy link
Member Author

Choose a reason for hiding this comment

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

no idea why this shows as added code .... it was just indented

defaultAction: visFilters.addFilter,
}
},
stage: 'production',
Copy link
Member

Choose a reason for hiding this comment

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

nit: What about having the stage default as lab, so we don't accidentally create a production vis?

Copy link
Member Author

Choose a reason for hiding this comment

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

no idea why this shows as added code .... it was just indented

shouldMarkAsExperimentalInUI() {
//we are not making a distinction in the UI if a plugin is experimental and/or labs.
//we just want to indicate it is special. the current flask icon is sufficient for that.
return this.stage === 'experimental' || this.stage === 'lab';
Copy link
Member

Choose a reason for hiding this comment

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

nit: What about move these strings to an enum similar to:

const STAGE_TYPES = {
  LAB: 'lab',
  EXPERIMENTAL: 'experimental',
  PRODUCTION: 'production',
}

Copy link
Member Author

Choose a reason for hiding this comment

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

no idea why this shows as added code .... it was just indented

this.events$ = this.vis.eventsSubject.asObservable().pipe(share());
this.events$.subscribe(event => {
if (this.actions[event.name]) {
this.actions[event.name](event.data);
Copy link
Member

Choose a reason for hiding this comment

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

q: do we enforce actions to be functions somewhere?

Copy link
Member Author

Choose a reason for hiding this comment

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

we don't, we need to better type this

@@ -75,12 +72,8 @@ export function VisProvider(Private, indexPatterns, getAppState) {
events: {
// the filter method will be removed in the near feature
// you should rather use addFilter method below
Copy link
Member

Choose a reason for hiding this comment

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

I'm a bit confused what is the right one, this:

vis.API.events.addFilter no longer exists, instead you should rather call vis.API.events.filter({ table, column, row, value })

or

the filter method will be removed in the near feature you should rather use addFilter method below

Copy link
Member Author

Choose a reason for hiding this comment

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

ha :) i need to remove that comment

@@ -41,26 +42,26 @@ const getTerms = (table, columnIndex, rowIndex) => {
}))];
};

export function VisFiltersProvider(Private, getAppState) {
const createFilter = (data, columnIndex, rowIndex, cellValue) => {
Copy link
Member

Choose a reason for hiding this comment

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

nit: Is there a reason to use arrow function here? can't we use named functions?

Copy link
Member Author

Choose a reason for hiding this comment

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

is there a reason not to use arrow functions ?

Copy link
Member

Choose a reason for hiding this comment

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

touché

@@ -128,6 +130,23 @@ export class EmbeddedVisualizeHandler {
this.vis.openInspector = this.openInspector;
this.vis.hasInspector = this.hasInspector;

// init default actions
forEach(this.vis.type.events, (event, eventName) => {
Copy link
Member

Choose a reason for hiding this comment

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

nit: can we get rid of lodash here? Object.keys(this.vis.type.events).forEach

onBrushEvent(event, getAppState());
}
filter: event => this.eventsSubject.next({ name: 'filterBucket', data: event }),
brush: event => this.eventsSubject.next({ name: 'brush', data: event }),
Copy link
Member

Choose a reason for hiding this comment

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

To naming this consistently it's better to rewrite this as:

filter: data => this.eventsSubject.next({ name: 'filterBucket', data }),
brush: data => this.eventsSubject.next({ name: 'brush', data }),

So your event is an object with {name, data} as it's used on the subscriptions

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Copy link
Member

@lukeelmers lukeelmers left a comment

Choose a reason for hiding this comment

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

Code LGTM. Pulled down and tested, no apparent functional issues.

@ppisljar ppisljar force-pushed the ref/filteringEmbeddable branch from 4b1b834 to 88e6af8 Compare November 16, 2018 11:40
@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@ppisljar ppisljar merged commit 6dd2c1c into elastic:master Nov 16, 2018
@ppisljar ppisljar deleted the ref/filteringEmbeddable branch November 16, 2018 14:00
ppisljar added a commit to ppisljar/kibana that referenced this pull request Nov 16, 2018
ppisljar added a commit that referenced this pull request Nov 18, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:ExpressionLanguage Interpreter expression language (aka canvas pipeline) review Team:Visualizations Visualization editors, elastic-charts and infrastructure v6.6.0 v7.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants