-
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
Refactor Timelion expression suggestion logic for clarity. #11285
Refactor Timelion expression suggestion logic for clarity. #11285
Conversation
This comment isn't a review of this pull, just a good place to leave some notes about suggestions. Timelion's autocomplete has always been one of those "Well, its better than nothing" sort of things. There's a quick digest of how I'd like to see autocompletion work here: https://github.com/cjcenizal/kibana/blob/ed3862e0abb35a2e7e69355d6993a0af166de3ea/src/core_plugins/timelion/public/directives/expression_directive.js#L14-L37 This pull should help with that process as it breaks out the logic for finding and inserting into the helpers file. Just needs someone to sit down and sort it out. Its probably not that hard to implement, the AST already has all of the lookup objects to make determining context for caret position simple.
Basically we just need to take the caret position and compare it to the |
ed3862e
to
1bb4a89
Compare
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.
This changes the behavior of the "other" selection in the interval chooser, it now opens a 2nd dropdown instead of making the existing dropdown appear to be editable
1bb4a89
to
11bb7c5
Compare
@rashidkpc Thanks for catching that. Fixed: |
<timelion-interval | ||
model="state.interval" | ||
in-header="true" | ||
></timelion-interval> |
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.
should we />
as there is nothing inside the timelion-interval element ?
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.
Angular requires you to actually use a closing tag for custom directives.
@@ -9,6 +9,7 @@ app.directive('timelionInterval', function ($compile, $timeout) { | |||
restrict: 'E', | |||
scope: { | |||
model: '=', // The interval model | |||
inHeader: '=', |
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.
how/where is this used ?
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.
This is used to differentiate between this UI in the context of the Timelion app and the Visualize app (when you create a Timelion vis). I can add a comment about this.
|
||
<select class="form-control timelion-interval timelion-interval--select" | ||
<select | ||
class="timelion-interval" | ||
ng-options="i for i in intervalOptions" |
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 for i
(leaves everyone blind) ... you can probably drop one i
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 think this is the syntax ng-options expects. Is there a different expression we should use?
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 you are right, maybe just rename to intervalOption ?
009cf44
to
c76e7d6
Compare
@ppisljar Thanks for the review! I addressed your comments. Which browser did you use when you found that select bug? I can't repro in Chrome on OS X. Would you mind checking out 3e53525 and letting me know if the select bug exists in that commit? If so, then it's a pre-existing bug and I think we should mark it in an issue and address it in another PR. |
Thanks @rashidkpc. I tweaked your suggestion a bit and landed on this: I don't want to remove the border from the select because it makes the focus state look funky, and also makes the hit area harder to see. Could you take another look? |
That works for me |
- Create timelionExpressionInput directive. - Create timelionExpressionSuggestions directive. - Create expression_directive_helpers service.
1ad3a9f
to
fb02de0
Compare
jenkins test this |
@cjcenizal the dropdown issue is not present in 3e53525 (it works ok there). it happens in latest chrome, looks better in firefox. also another small issue i found: when you click the dropdown (in firefox) you can see the "focus border" on the input that you don't really see .... |
…1285) * Refactor Timelion expression suggestion logic for clarity. - Create timelionExpressionInput directive. - Create timelionExpressionSuggestions directive. - Create expression_directive_helpers service.
Extracts some work from #11164.
Overview
The current version of this logic involves DOM manipulation from within a directive. We can simplify this by leveraging Angular's directives.
Changes