Skip to content
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 tool console autocomplete not loading issue #3775

Merged

Conversation

zhongnansu
Copy link
Member

@zhongnansu zhongnansu commented Apr 4, 2023

Description

Dev tool console dynamic autocomplete is not working, this PR is to fix it . Solution is just pass along the http all the way to the opensearch.send()

Issues Resolved

#3515

Check List

  • All tests pass
    • yarn test:jest
    • yarn test:jest_integration
    • yarn test:ftr
  • New functionality includes testing.
  • New functionality has been documented.
  • Update CHANGELOG.md
  • Commits are signed per the DCO using --signoff

@zhongnansu zhongnansu requested a review from a team as a code owner April 4, 2023 00:42
@zhongnansu zhongnansu added v2.7.0 backport 2.x Skip-Changelog PRs that are too trivial to warrant a changelog or release notes entry labels Apr 4, 2023
@codecov-commenter
Copy link

codecov-commenter commented Apr 4, 2023

Codecov Report

Merging #3775 (aa34740) into main (6b42669) will decrease coverage by 0.01%.
The diff coverage is 60.00%.

📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more

@@            Coverage Diff             @@
##             main    #3775      +/-   ##
==========================================
- Coverage   66.43%   66.43%   -0.01%     
==========================================
  Files        3210     3210              
  Lines       61677    61681       +4     
  Branches     9522     9522              
==========================================
+ Hits        40977    40978       +1     
- Misses      18419    18421       +2     
- Partials     2281     2282       +1     
Flag Coverage Δ
Linux 66.38% <60.00%> (-0.01%) ⬇️
Windows 66.38% <60.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...ensearch/use_send_current_request_to_opensearch.ts 68.00% <0.00%> (ø)
...rc/plugins/console/public/lib/mappings/mappings.js 72.78% <60.34%> (+1.46%) ⬆️
...containers/editor/legacy/console_editor/editor.tsx 55.00% <100.00%> (ø)

... and 2 files with indirect coverage changes

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

Copy link
Member

@joshuarrrr joshuarrrr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@zhongnansu A couple minor questions, but this looks good. Thanks for the jquery updates, too!

src/plugins/console/public/lib/mappings/mappings.js Outdated Show resolved Hide resolved
Comment on lines 61 to +68
let ret = [].concat.apply([], indicesOrAliases);
ret.sort();
let last;
ret = $.map(ret, function (v) {
const r = last === v ? null : v;
last = v;
return r;
});
ret = ret.reduce((result, value, index, array) => {
const last = array[index - 1];
if (last !== value) {
result.push(value);
}
return result;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit - this is fine, but all we're really trying to do is get an array with the unique values, right? Something like

const ret = [...new Set(indicesOrAliases)]]

src/plugins/console/public/lib/mappings/mappings.js Outdated Show resolved Hide resolved
@joshuarrrr
Copy link
Member

@Nicksqain If you have a chance, please review and compare to your changes in mapping.js from #3733

After this is merged, we can rebase your PR on top.

@zhongnansu zhongnansu requested a review from joshuarrrr April 4, 2023 20:54
@joshuarrrr
Copy link
Member

@zhongnansu The other thing I forgot to mention in the review - what ideas do you have about the best way to add a regression test for this? It's actually a fairly significant impact to lose this data-based autocompletion, so we'd like to make sure our tests catch it if it breaks in the future. My initial thought is that it makes the most sense as a functional test, because we can make sure it's actually correctly using the data to correctly populate the fields.

Signed-off-by: Su <szhongna@amazon.com>
@zhongnansu zhongnansu force-pushed the dev-tool-fix-autocomplete branch from 2a4b2e2 to d5f0812 Compare April 4, 2023 23:39
@ashwin-pc
Copy link
Member

@zhongnansu why are we skipping the changelog here?

@Nicksqain
Copy link
Contributor

Nicksqain commented Apr 5, 2023

@Nicksqain If you have a chance, please review and compare to your changes in mapping.js from #3733

After this is merged, we can rebase your PR on top.

@joshuarrrr Then maybe I should just copy the modified mapping.js from @zhongnansu into my mapping.js?
Or delete mapping.js in my PR

@zhongnansu zhongnansu changed the title Fix dev tool console autocomplete issue Fix dev tool console autocomplete not loading issue Apr 5, 2023
@zhongnansu
Copy link
Member Author

@zhongnansu why are we skipping the changelog here?

@ashwin-pc my bad, I though it was an unreleased bug. Added change log

@zhongnansu zhongnansu requested a review from ashwin-pc April 5, 2023 17:35
@zhongnansu zhongnansu removed the Skip-Changelog PRs that are too trivial to warrant a changelog or release notes entry label Apr 5, 2023
@zhongnansu
Copy link
Member Author

@zhongnansu The other thing I forgot to mention in the review - what ideas do you have about the best way to add a regression test for this? It's actually a fairly significant impact to lose this data-based autocompletion, so we'd like to make sure our tests catch it if it breaks in the future. My initial thought is that it makes the most sense as a functional test, because we can make sure it's actually correctly using the data to correctly populate the fields.

good point, I am having similar thoughts. Maybe create an issue in functional test repo to track

Comment on lines 51 to 53
if (typeof indicesOrAliases === 'string') {
indicesOrAliases = [indicesOrAliases];
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How would you feel about changing this chunk and the above condition to:

Suggested change
if (typeof indicesOrAliases === 'string') {
indicesOrAliases = [indicesOrAliases];
}
if (typeof indicesOrAliases === 'string') {
indicesOrAliases = [indicesOrAliases];
} else if (!Array.isArray(indicesOrAliases)) {
return;
}

note that unlike the previous code, this is return nothing.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since it's a new condition comparing to previous code, can you elaborate on the use case of returning noting, when indicesOrAliases is not a string and not an Array?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This kind of change seems more suitable as part of migrating this mappings file from js to ts. @zhongnansu Do you mind opening a stub issue for that?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@joshuarrrr
Copy link
Member

good point, I am having similar thoughts. Maybe create an issue in functional test repo to track

OK, cool - please create that issue and link it here.

@zhongnansu
Copy link
Member Author

good point, I am having similar thoughts. Maybe create an issue in functional test repo to track

OK, cool - please create that issue and link it here.

@joshuarrrr issue created opensearch-project/opensearch-dashboards-functional-test#605

Comment on lines 51 to 53
if (typeof indicesOrAliases === 'string') {
indicesOrAliases = [indicesOrAliases];
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This kind of change seems more suitable as part of migrating this mappings file from js to ts. @zhongnansu Do you mind opening a stub issue for that?

@joshuarrrr joshuarrrr merged commit 29008fa into opensearch-project:main Apr 6, 2023
opensearch-trigger-bot bot pushed a commit that referenced this pull request Apr 6, 2023
* Fix dev tool console autocomplete issue
* add changelog

Signed-off-by: Su <szhongna@amazon.com>

---------

Signed-off-by: Su <szhongna@amazon.com>
(cherry picked from commit 29008fa)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>

# Conflicts:
#	CHANGELOG.md
zhongnansu added a commit that referenced this pull request Apr 6, 2023
* Fix dev tool console autocomplete issue
* add changelog

Signed-off-by: Su <szhongna@amazon.com>

---------

Signed-off-by: Su <szhongna@amazon.com>
(cherry picked from commit 29008fa)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>

# Conflicts:
#	CHANGELOG.md

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Zhongnan Su <szhongna@amazon.com>
sikhote pushed a commit to sikhote/OpenSearch-Dashboards that referenced this pull request Apr 24, 2023
…ct#3775)

* Fix dev tool console autocomplete issue
* add changelog

Signed-off-by: Su <szhongna@amazon.com>

---------

Signed-off-by: Su <szhongna@amazon.com>
Signed-off-by: David Sinclair <david@sinclair.tech>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] Dev tool console autocomplete suggestion doesn't suggest index name
7 participants