-
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] Clean up enhanced search API #8226
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 @@ | ||
fix: | ||
- Remove unused enhancements APIs, clean up, and error handling ([#8226](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/8226)) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
*/ | ||
|
||
import { HttpSetup, SavedObjectsClientContract } from 'opensearch-dashboards/public'; | ||
import { trimEnd } from 'lodash'; | ||
import { | ||
DATA_STRUCTURE_META_TYPES, | ||
DEFAULT_DATA, | ||
|
@@ -14,7 +15,7 @@ | |
DatasetField, | ||
} from '../../../data/common'; | ||
import { DatasetTypeConfig, IDataPluginServices } from '../../../data/public'; | ||
import { DATASET, handleQueryStatus } from '../../common'; | ||
import { API, DATASET, handleQueryStatus } from '../../common'; | ||
import S3_ICON from '../assets/s3_mark.svg'; | ||
|
||
export const s3TypeConfig: DatasetTypeConfig = { | ||
|
@@ -115,7 +116,9 @@ | |
try { | ||
const response = await handleQueryStatus({ | ||
fetchStatus: () => | ||
http.fetch('../../api/enhancements/datasource/jobs', { | ||
http.fetch({ | ||
method: 'GET', | ||
path: trimEnd(`${API.DATA_SOURCE.ASYNC_JOBS}`), | ||
query: { | ||
id: dataSource?.id, | ||
queryId: meta.queryId, | ||
|
@@ -171,9 +174,13 @@ | |
http: HttpSetup, | ||
dataSource: DataStructure | ||
): Promise<DataStructure[]> => { | ||
const query = (dataSource.meta as DataStructureCustomMeta).query; | ||
const response = await http.fetch(`../../api/enhancements/datasource/external`, { | ||
query, | ||
const abortController = new AbortController(); | ||
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 do we do with this abort controller? 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. need to verify if using it correctly yet. but in the case of the user selecting a connection accidentally and then selecting another connection immediately aborting the previous call |
||
const query = | ||
dataSource.id !== '' ? (dataSource.meta as DataStructureCustomMeta).query : undefined; | ||
const response = await http.fetch({ | ||
method: 'GET', | ||
path: trimEnd(`${API.DATA_SOURCE.CONNECTIONS}/${query?.id || ''}`), | ||
signal: abortController.signal, | ||
}); | ||
|
||
return response | ||
|
@@ -190,10 +197,13 @@ | |
}; | ||
|
||
const fetchDatabases = async (http: HttpSetup, path: DataStructure[]): Promise<DataStructure[]> => { | ||
const abortController = new AbortController(); | ||
const dataSource = path.find((ds) => ds.type === 'DATA_SOURCE'); | ||
const connection = path[path.length - 1]; | ||
const meta = connection.meta as DataStructureCustomMeta; | ||
const response = await http.post(`../../api/enhancements/datasource/jobs`, { | ||
const response = await http.fetch({ | ||
method: 'POST', | ||
path: trimEnd(`${API.DATA_SOURCE.ASYNC_JOBS}`), | ||
body: JSON.stringify({ | ||
lang: 'sql', | ||
query: `SHOW DATABASES in ${connection.title}`, | ||
|
@@ -203,6 +213,7 @@ | |
query: { | ||
id: dataSource?.id, | ||
}, | ||
signal: abortController.signal, | ||
}); | ||
|
||
connection.meta = setMeta(connection, response); | ||
|
@@ -211,11 +222,14 @@ | |
}; | ||
|
||
const fetchTables = async (http: HttpSetup, path: DataStructure[]): Promise<DataStructure[]> => { | ||
const abortController = new AbortController(); | ||
const dataSource = path.find((ds) => ds.type === 'DATA_SOURCE'); | ||
const connection = path.find((ds) => ds.type === 'CONNECTION'); | ||
const sessionId = (connection?.meta as DataStructureCustomMeta).sessionId; | ||
const database = path[path.length - 1]; | ||
const response = await http.post(`../../api/enhancements/datasource/jobs`, { | ||
const response = await http.fetch({ | ||
method: 'POST', | ||
path: trimEnd(`${API.DATA_SOURCE.ASYNC_JOBS}`), | ||
body: JSON.stringify({ | ||
lang: 'sql', | ||
query: `SHOW TABLES in ${database.title}`, | ||
|
@@ -225,6 +239,7 @@ | |
query: { | ||
id: dataSource?.id, | ||
}, | ||
signal: abortController.signal, | ||
}); | ||
|
||
database.meta = setMeta(database, response); | ||
|
This file was deleted.
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 dont think this is correct. This should only show if there is a local cluster. The default cluster will be returned as a part of the datasources API
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 that makes sense i was worried making too big of a change in the case of no local cluster.
should we create an issue for this?
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.
Yes, the expected behaviour is that this option only shows up when you have a local cluster. If MDS is off the index list should be shown directly.