-
Notifications
You must be signed in to change notification settings - Fork 894
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
[Discover-next] query editor and UI settings toggle #7001
[Discover-next] query editor and UI settings toggle #7001
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #7001 +/- ##
==========================================
+ Coverage 67.45% 67.46% +0.01%
==========================================
Files 3442 3444 +2
Lines 67816 67865 +49
Branches 11027 11027
==========================================
+ Hits 45742 45786 +44
- Misses 19408 19416 +8
+ Partials 2666 2663 -3
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
dd03ab9
to
0237362
Compare
I think i understand how this keeps the new experience isolated from the existing one, but might be worth it to call it out in the PR how you test the change and how it safeguards against regressions. |
3d377bb
to
e882983
Compare
d269095
to
cee212d
Compare
src/plugins/data/public/ui/query_string_input/language_switcher.tsx
Outdated
Show resolved
Hide resolved
src/plugins/data/public/ui/query_string_input/language_switcher.test.tsx
Outdated
Show resolved
Hide resolved
src/plugins/data/public/ui/query_string_input/legacy_language_switcher.test.tsx
Outdated
Show resolved
Hide resolved
src/plugins/data/public/ui/query_string_input/legacy_language_switcher.tsx
Outdated
Show resolved
Hide resolved
Adds new query editor in replacement of query string input. Utilizing: ``` data.enhancements.enabled: true ``` And enabling the Advanced Setting: `query:enhancements:enabled` Also, cleans up the toggling since it is now two different components. Related issue: opensearch-project#6067 Signed-off-by: Kawika Avilla <kavilla414@gmail.com>
8d6b16e
to
8a59bfe
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.
please note: this is actually restoring the language switcher to it's state before 2.14. Because the conditional logic renders different components then removed the query enhancements stuff and just having the switcher how it was before. This can be considered safe.
This changes can be considered safe.
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.
please note: this is actually restoring the language switcher to it's state before 2.14. Because the conditional logic renders different components then removed the query enhancements stuff and just having the switcher how it was before. This can be considered safe.
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.
please note: this isn't actually deleting the logic. this file was new for 2.14 to house the pre-2.14 code. this file is unneeded. since i'm restoring the language switcher in the original file (to retain the git history).
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.
please note: this isn't actually deleting the logic. this file was new for 2.14 to house the pre-2.14 code. this file is unneeded. since i'm restoring the language switcher in the original file (to retain the git history).
import { monaco } from '@osd/monaco'; | ||
|
||
import darkTheme from '@elastic/eui/dist/eui_theme_dark.json'; | ||
import lightTheme from '@elastic/eui/dist/eui_theme_light.json'; | ||
|
||
// NOTE: For talk around where this theme information will ultimately live, | ||
// please see this discuss issue: https://github.com/elastic/kibana/issues/43814 | ||
const standardizeColor = (color: string) => new Color(color).hex().toLowerCase(); |
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.
required, Monaco doesn't support shorthand hex code and will crash.
.globalQueryEditor { | ||
padding: 0 $euiSizeXS $euiSizeXS $euiSizeXS; | ||
} | ||
|
||
.globalQueryEditor:first-child { | ||
padding-top: $euiSizeXS; | ||
} | ||
|
||
.globalQueryEditor:not(:empty) { | ||
padding-bottom: $euiSizeXS; | ||
} | ||
|
||
.globalFilterGroup__filterBar { |
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 this the right file? I guess kept here because other query bar styles are here?
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.
correct. this isn't the right file and should be in it's own file along with the query bar style. i opted to going this route for 2.15 so that we can be more holistic in the clean up. along with even more refactoring related to search bar.
i've added a line item: #6957
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
.osdQueryEditor__wrap { |
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.
curious, what's the difference between the osd query editor and the global query editor?
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.
ported over from query bar but i agree this location and names of these are not accurate for their uses.
added here:
#6957
.osdQueryEditorHeader { | ||
max-height: 400px; | ||
|
||
// TODO fix styling: with "overflow: auto" the scroll bar appears although the content is below max-height |
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.
Do we have a mechanism to track todos to avoid long lived dead code?
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.
good catch: ive added an item here to do start the ball rolling: #6957
} | ||
} | ||
|
||
// IE specific fix for the datepicker to not collapse |
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.
Do we support IE or is this for Edge in IE mode?
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 Edge: https://opensearch.org/docs/1.2/dashboards/browser-compatibility/
But I can't find new doc about browser compatibility so I should check . Added an issue here to clean up this stuff and verify: #6957
index: number | null; | ||
suggestions: QuerySuggestion[]; | ||
indexPatterns: IIndexPattern[]; | ||
queryEditorRect: DOMRect | undefined; |
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.
any reason for undefined over null?
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 work might be unneeded based on what we do with suggestions and the query assist but reason between undefined over null is based on what the suggestions is expecting.
will make sure to track it here:
#6957
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.
queryEditorRect can be undefined? so it is not required? should we use queryEditorRect?: DOMRect
to show it is optional?
} | ||
|
||
public componentWillUnmount() { | ||
if (this.abortController) this.abortController.abort(); |
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 code style not to use braces on single line ifs? personally think they should be required (e.g. apple's tls bug)
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 part was pretty much ported over.
i agree. one of things that we forked was the ability for plugins that have unrestricted control.
our repo has linters defined here https://github.com/opensearch-project/OpenSearch-Dashboards/tree/main/packages/opensearch-eslint-config-opensearch-dashboards
which we can add this rule (and more rules) but in the past worried about updating this. any plugin that uses our rules then will also have to update their code. And we tried our best to avoid breaking them by opening an issue in each repo and letting them know ahead of time.
i've added a line item for code clean up in both components:
#6957
} | ||
|
||
this.initPersistedLog(); | ||
// this.fetchIndexPatterns().then(this.updateSuggestions); |
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.
dead code?
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.
Didn't want to delete this code since this where we will get suggestions once query assist is added. Right now the suggestions is not wired up into the query editor but will be used once assistant work is added.
thanks for catching. added to this issue for tracking:
#6957
onChange={this.onQueryBarChange} | ||
isDirty={this.isDirty()} | ||
customSubmitButton={ | ||
this.props.customSubmitButton ? this.props.customSubmitButton : undefined |
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: this.props.customSubmitButton || undefined
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.
+1,
added here when we do clean up of both components:
#6957
Signed-off-by: Kawika Avilla <kavilla414@gmail.com>
} | ||
this.isEnabled = enabled; | ||
this.enabledQueryEnhancementsUpdated$.next(this.isEnabled); | ||
return true; |
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. it feels to me that these return true statement are redundant as we are not having other conditional statement / async CURD operations to return false, and the set operation will always be true.
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.
true i did this to mimic the other settings files within the repo. i think it's a little bit redundant as well. we should consider doing an audit
export function createSettings({ storage, queryEnhancements }: Deps) { | ||
return new Settings(storage, queryEnhancements); | ||
export function createSettings({ config, search, storage, queryEnhancements }: Deps) { | ||
return new Settings(config, search, storage, queryEnhancements); |
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.
do we want to also passing params as an object to make it more scalable?
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.
makes sense. added to tracker issue. hopefully we don't have to add any more params here but if we do ive tracked an action item for us to convert to an object.
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.
just did a local try out. approve as 2nd reviewer to unblock.
|
||
const LazyQueryEditorTopRow = React.lazy(() => import('./query_editor_top_row')); | ||
export const QueryEditorTopRow = (props: QueryEditorTopRowProps) => ( | ||
<React.Suspense fallback={<Fallback />}> |
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: instead of an empty
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.
that's fair i feel like a fallback globally could be more helpful. added to the tracker issue
onChange={handleLanguageChange} | ||
singleSelection={{ asPlainText: true }} | ||
isClearable={false} | ||
async |
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.
don't know there is an async for EuiComboBox.. good learning for me
} | ||
}, [noDataPopoverDismissed, showNoDataPopover]); | ||
|
||
return ( |
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 see we are repeating query_string_input 's context in query_editor. I know that there are there are three cases that we use query string input and only one with both settings enabled to use query editor, so if that is the case can't we just simply reuse these repeat component from query_string_input? why duplicate these component?
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.
yeah good catch. part of this issue: #6957.
the goal here was to release to this for 2.15, it would keep the query string input completely intact (even restored some of the files to their pre-2.14 state). to ensure the code paths are completely separate in case users toggle it on and off.
then targeting 2.16, with more automated testing start cleaning up these components.
settings={settings} | ||
containerRef={containerRef} |
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.
So the containerRef is added to access a DOM element within a QueryEditorUI?. or is there use cases that will cause DOM to lose?
* [Discover-next] query editor and UI settings toggle Adds new query editor in replacement of query string input. Utilizing: ``` data.enhancements.enabled: true ``` And enabling the Advanced Setting: `query:enhancements:enabled` Also, cleans up the toggling since it is now two different components. Related issue: #6067 Signed-off-by: Kawika Avilla <kavilla414@gmail.com> * Remove commented out code Signed-off-by: Kawika Avilla <kavilla414@gmail.com> --------- Signed-off-by: Kawika Avilla <kavilla414@gmail.com> (cherry picked from commit a4aa682) Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
name: i18n.translate('data.advancedSettings.query.enhancements.enableTitle', { | ||
defaultMessage: 'Enable query enhancements', | ||
}), | ||
value: false, |
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 still needs user to set data.enhancements.enabled
in osd config yml, would it be confusing if user only sets it to true here and see enhancements are still disabled because yml is not set?
* [Discover-next] query editor and UI settings toggle Adds new query editor in replacement of query string input. Utilizing: ``` data.enhancements.enabled: true ``` And enabling the Advanced Setting: `query:enhancements:enabled` Also, cleans up the toggling since it is now two different components. Related issue: #6067 * Remove commented out code --------- (cherry picked from commit a4aa682) Signed-off-by: Kawika Avilla <kavilla414@gmail.com> Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Description
Adds new query editor in replacement of query string input.
Utilizing:
And enabling the Advanced Setting:
query:enhancements:enabled
Also, cleans up the toggling since it is now two different components.
More information:
For 2.14, the query enhancements were nested within query string input bar.
For 2.15, query enhancements included the Monaco query editor.
This made the conditional logic for the query enhancements easier since we do not render even majority of the work if query enhancements are disabled.
data.enhancements.enabled
if it the feature is enabled (by default it is not).query:enhancements:enabled
if it is enabled (by default it is not).If user toggles on the setting in Advanced Settings, and queries a non-Native (DQL or Lucene) filter language from the language selector it will be treated as native query language. Existing features like local storage typeahead, userQueryString, and userQueryLanguage will support the new languages. However, when the users toggles off the setting in Advanced Setting, we will reset the these to be
kuery
and empty query string to reset the state. However, there exists an Advanced Setting for query language so we should consider best next steps here to improve this experience because we force this default state regardless if the user even used these extra langauges.Issues Related:
#6067
Screenshot
Testing the changes
Changelog
Check List
yarn test:jest
yarn test:jest_integration