-
Notifications
You must be signed in to change notification settings - Fork 892
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
fix: Dev tools console autocomplete issue #5567 #5568
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #5568 +/- ##
==========================================
+ Coverage 66.98% 67.02% +0.03%
==========================================
Files 3293 3294 +1
Lines 63294 63296 +2
Branches 10067 10066 -1
==========================================
+ Hits 42396 42422 +26
+ Misses 18458 18431 -27
- Partials 2440 2443 +3
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
f6a4bdd
to
b3c82b4
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.
@kishor82 Thanks for the fix! Just a couple minor questions and suggestions.
interface SettingKeyToPathMap { | ||
fields: '_mapping'; | ||
indices: '_aliases'; | ||
templates: '_template'; | ||
} |
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.
Why do we need to define this as an interface? It seems like it would be simpler to just define the const here, instead of within the retrieveSettings
scope:
interface SettingKeyToPathMap { | |
fields: '_mapping'; | |
indices: '_aliases'; | |
templates: '_template'; | |
} | |
const SETTING_KEY_TO_PATH_MAP = { | |
fields: '_mapping'; | |
indices: '_aliases'; | |
templates: '_template'; | |
} as const; |
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, it would be simpler to define it as a constant. I initially set it up for potential usage in tests and other functions, but it turned out to be unnecessary.
Promise.allSettled([ | ||
retrieveMappings(http, settingsToRetrieve, dataSourceId), | ||
retrieveAliases(http, settingsToRetrieve, dataSourceId), | ||
retrieveTemplates(http, settingsToRetrieve, dataSourceId), | ||
]).then(() => { | ||
]).then((res) => { |
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 need this? If so, I think our style would generally be
]).then((res) => { | |
]).then((_res) => { |
to hint that it's unused.
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 no longer require this. I added a console while testing and forgot to remove it.
@@ -330,13 +336,8 @@ function retrieveSettings( | |||
if (settingsToRetrieve[settingsKey] === true) { | |||
return opensearch.send(http, 'GET', settingKeyToPathMap[settingsKey], null, dataSourceId); | |||
} else { | |||
if (settingsToRetrieve[settingsKey] === false) { | |||
// If the user doesn't want autocomplete suggestions, then clear any that exist | |||
return Promise.resolve({}); |
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.
Why did we want to change this response shape?
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.
The check settingsToRetrieve[settingsKey] === false
is unnecessary, so I have removed it. Additionally, in the else condition, the response body doesn't matter, whether it's undefined
or {}
, as long as it's not an instance of HttpResponse
.
headers: Array<[string, string]> | ||
): Response => { | ||
return { | ||
// headers: {} as Headers, |
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.
remove
// headers: {} as Headers, |
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.
@kishor82 Thanks for all the fixes! I pulled it down locally and reproduced your demo - LGTM!
62afa55
to
8a244f4
Compare
Signed-off-by: Kishor Rathva <kishorrathva8298@gmail.com>
Signed-off-by: Kishor Rathva <kishorrathva8298@gmail.com>
Signed-off-by: Kishor Rathva <kishorrathva8298@gmail.com>
Signed-off-by: Kishor Rathva <kishorrathva8298@gmail.com>
Signed-off-by: Kishor Rathva <kishorrathva8298@gmail.com>
Also verified on 1.3. |
* fix: Dev tools console autocomplete issue #5567 * Added CHANGELOG * Added test for retrieveAutoCompleteInfo * Refactored tests * Added suggested changes. --------- Signed-off-by: Kishor Rathva <kishorrathva8298@gmail.com> (cherry picked from commit a5c45a3) Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
* fix: Dev tools console autocomplete issue #5567 * Added CHANGELOG * Added test for retrieveAutoCompleteInfo * Refactored tests * Added suggested changes. --------- (cherry picked from commit a5c45a3) Signed-off-by: Kishor Rathva <kishorrathva8298@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
Resolves a bug in the Console Plugin Dev Tool where the retrieveSettings function was incorrectly called with 'fields' instead of 'indices'. for
retrieveAliases
function.Issues Resolved
closes #5567
Screenshot
Check List
yarn test:jest
yarn test:jest_integration