-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
changing vis.API.events #25280
Conversation
💔 Build Failed |
76bd2dd
to
af833ed
Compare
💔 Build Failed |
💔 Build Failed |
ed27206
to
fa8dec9
Compare
Pinging @elastic/kibana-app |
💚 Build Succeeded |
There was a problem hiding this 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 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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', |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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'; |
There was a problem hiding this comment.
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',
}
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
src/ui/public/vis/vis.js
Outdated
@@ -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 |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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) => { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 ?
There was a problem hiding this comment.
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) => { |
There was a problem hiding this comment.
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
src/ui/public/vis/vis.js
Outdated
onBrushEvent(event, getAppState()); | ||
} | ||
filter: event => this.eventsSubject.next({ name: 'filterBucket', data: event }), | ||
brush: event => this.eventsSubject.next({ name: 'brush', data: event }), |
There was a problem hiding this comment.
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
💚 Build Succeeded |
There was a problem hiding this 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.
4b1b834
to
88e6af8
Compare
💚 Build Succeeded |
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 callvis.API.events.filter({ table, column, row, value })
Checklist
Use
strikethroughsto remove checklist items you don't feel are applicable to this PR.[ ] This was checked for cross-browser compatibility, including a check against IE11[ ] Any text added follows EUI's writing guidelines, uses sentence case text and includes [i18n support](https://github.com/elastic/kibana/blob/master/packages/kbn-i18n/README.md)[ ] Documentation was added for features that require explanation or tutorials[ ] Unit or functional tests were updated or added to match the most common scenarios[ ] This was checked for keyboard-only and screenreader accessibilityFor maintainers
[ ] This includes a feature addition or change that requires a release note and was labeled appropriately