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

Clean console indexPatterns api error #418

Merged
merged 1 commit into from
May 26, 2023

Conversation

junqiu-lei
Copy link
Member

@junqiu-lei junqiu-lei commented May 26, 2023

Description

Use indexPatterns api from services.data.indexPatterns to clean browser console error

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

Signed-off-by: Junqiu Lei <junqiu@amazon.com>
@junqiu-lei junqiu-lei changed the title Clean console ReferenceError Clean console indexPatterns api error May 26, 2023
@codecov
Copy link

codecov bot commented May 26, 2023

Codecov Report

Merging #418 (aae6f92) into main (ddb27ed) will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff           @@
##             main     #418   +/-   ##
=======================================
  Coverage   41.36%   41.36%           
=======================================
  Files          53       53           
  Lines        1777     1777           
  Branches      329      329           
=======================================
  Hits          735      735           
  Misses       1014     1014           
  Partials       28       28           

see 1 file with indirect coverage changes

// @ts-ignore
const newIndexPattern = await indexPatterns.get(selectedLayerConfig.source.indexPatternId);
const newIndexPattern = await services.data.indexPatterns.get(
// @ts-ignore
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this by mistake or intentional? having comment inside method parameter seems weird.

Copy link
Member Author

Choose a reason for hiding this comment

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

Intentional for the below line

@@ -241,8 +241,10 @@ export const MapContainer = ({
(indexPattern) => indexPattern.id === selectedLayerConfig.source.indexPatternId
);
if (!findIndexPattern) {
// @ts-ignore
const newIndexPattern = await indexPatterns.get(selectedLayerConfig.source.indexPatternId);
const newIndexPattern = await services.data.indexPatterns.get(
Copy link
Collaborator

Choose a reason for hiding this comment

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

I just couldn't match commit message and this code change.
Correct indexPatterns api from services.data.indexPatterns to clean browser console error.
but the code is changing indexPatterns to services.data.indexPatterns

Copy link
Member Author

Choose a reason for hiding this comment

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

The method is used to update layersIndexPatterns which is only used in top nav comment as a requirement prop, but no use there currently(it's mainly used for global filter, we don't support yet).

It used to be passed in by:

    const {
      data: { indexPatterns },
    } = services;

so it's the reason we change from indexPatterns to services.data.indexPatterns

https://github.com/opensearch-project/dashboards-maps/blob/2.8/public/components/map_top_nav/top_nav_menu.tsx#L141

Copy link
Collaborator

Choose a reason for hiding this comment

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

Got it. So it is Use indexPatterns api from services.data.indexPatterns to clean browser console error.

@junqiu-lei junqiu-lei merged commit 485ef36 into opensearch-project:main May 26, 2023
24 checks passed
@junqiu-lei junqiu-lei deleted the console_error branch May 26, 2023 18:25
opensearch-trigger-bot bot pushed a commit that referenced this pull request May 26, 2023
Signed-off-by: Junqiu Lei <junqiu@amazon.com>
(cherry picked from commit 485ef36)
opensearch-trigger-bot bot pushed a commit that referenced this pull request May 26, 2023
Signed-off-by: Junqiu Lei <junqiu@amazon.com>
(cherry picked from commit 485ef36)
junqiu-lei pushed a commit that referenced this pull request May 26, 2023
junqiu-lei pushed a commit that referenced this pull request May 26, 2023
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.

None yet

3 participants