-
Notifications
You must be signed in to change notification settings - Fork 893
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] add datasource container #7157
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
feat: | ||
- Query editor and dataframes datasources container ([#7157](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/7157)) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,6 +25,7 @@ export interface QueryEditorProps { | |
indexPatterns: Array<IIndexPattern | string>; | ||
dataSource?: DataSource; | ||
query: Query; | ||
dataSourceContainerRef?: React.RefCallback<HTMLDivElement>; | ||
containerRef?: React.RefCallback<HTMLDivElement>; | ||
settings: Settings; | ||
disableAutoFocus?: boolean; | ||
|
@@ -54,6 +55,7 @@ interface Props extends QueryEditorProps { | |
|
||
interface State { | ||
isDataSourcesVisible: boolean; | ||
isDataSetsVisible: boolean; | ||
isSuggestionsVisible: boolean; | ||
index: number | null; | ||
suggestions: QuerySuggestion[]; | ||
|
@@ -77,7 +79,8 @@ const KEY_CODES = { | |
// eslint-disable-next-line import/no-default-export | ||
export default class QueryEditorUI extends Component<Props, State> { | ||
public state: State = { | ||
isDataSourcesVisible: true, | ||
isDataSourcesVisible: false, | ||
isDataSetsVisible: true, | ||
isSuggestionsVisible: false, | ||
index: null, | ||
suggestions: [], | ||
|
@@ -212,7 +215,10 @@ export default class QueryEditorUI extends Component<Props, State> { | |
: undefined; | ||
this.onChange(newQuery, dateRange); | ||
this.onSubmit(newQuery, dateRange); | ||
this.setState({ isDataSourcesVisible: enhancement?.searchBar?.showDataSourceSelector ?? true }); | ||
this.setState({ isDataSetsVisible: enhancement?.searchBar?.showDataSetsSelector ?? true }); | ||
this.setState({ | ||
isDataSourcesVisible: enhancement?.searchBar?.showDataSourcesSelector ?? true, | ||
}); | ||
Comment on lines
+218
to
+221
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is it better to combine the setStates into one call? I forgot if react optimizes this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you're right that would be the better approach i'll fast follow |
||
}; | ||
|
||
private initPersistedLog = () => { | ||
|
@@ -227,10 +233,19 @@ export default class QueryEditorUI extends Component<Props, State> { | |
|
||
const isDataSourcesVisible = | ||
this.props.settings.getQueryEnhancements(this.props.query.language)?.searchBar | ||
?.showDataSourceSelector ?? true; | ||
?.showDataSourcesSelector ?? true; | ||
this.setState({ isDataSourcesVisible }); | ||
}; | ||
|
||
private initDataSetsVisibility = () => { | ||
if (this.componentIsUnmounting) return; | ||
|
||
const isDataSetsVisible = | ||
this.props.settings.getQueryEnhancements(this.props.query.language)?.searchBar | ||
?.showDataSetsSelector ?? true; | ||
this.setState({ isDataSetsVisible }); | ||
}; | ||
|
||
public onMouseEnterSuggestion = (index: number) => { | ||
this.setState({ index }); | ||
}; | ||
|
@@ -246,6 +261,7 @@ export default class QueryEditorUI extends Component<Props, State> { | |
this.initPersistedLog(); | ||
// this.fetchIndexPatterns().then(this.updateSuggestions); | ||
this.initDataSourcesVisibility(); | ||
this.initDataSetsVisibility(); | ||
} | ||
|
||
public componentDidUpdate(prevProps: Props) { | ||
|
@@ -280,6 +296,11 @@ export default class QueryEditorUI extends Component<Props, State> { | |
<EuiFlexItem grow={false}> | ||
<EuiFlexGroup gutterSize="xs" alignItems="center" className={`${className}__wrapper`}> | ||
<EuiFlexItem grow={false}>{this.props.prepend}</EuiFlexItem> | ||
{this.state.isDataSourcesVisible && ( | ||
<EuiFlexItem grow={false} className={`${className}__dataSourceWrapper`}> | ||
<div ref={this.props.dataSourceContainerRef} /> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what's the consideration to expose a ref rather than directly rendering the component here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. thanks for asking this one: i'm using the data source management plugin for that component. so to avoid a circular dependency and not introduce datasourcemanagements as a required bundle. i do it in the query enhancements which can take that optional depedency |
||
</EuiFlexItem> | ||
)} | ||
<EuiFlexItem grow={false} className={`${className}__languageWrapper`}> | ||
<QueryLanguageSelector | ||
language={this.props.query.language} | ||
|
@@ -288,8 +309,8 @@ export default class QueryEditorUI extends Component<Props, State> { | |
appName={this.services.appName} | ||
/> | ||
</EuiFlexItem> | ||
{this.state.isDataSourcesVisible && ( | ||
<EuiFlexItem grow={false} className={`${className}__dataSourceWrapper`}> | ||
{this.state.isDataSetsVisible && ( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should this be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. scared me. had to check. yeah i modified it for this because plural makes sense for me like its the selector which can select multiple datasets. But tbh, I was on the fence too. I just wanted to updated in this file so its both plural. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. got it, it's minor but i wasn't sure if it's on purpose. if it's plural should it be |
||
<EuiFlexItem grow={false} className={`${className}__dataSetWrapper`}> | ||
<div ref={this.props.containerRef} /> | ||
</EuiFlexItem> | ||
)} | ||
|
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
!important
is used in many places already, is it avoidable?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.
it's actually the OUI combo box. I would like to avoid it but some of the classes everywhere have like added padded so this is to avoid the height of the flex box getting pushed around