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
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions public/components/map_container/map_container.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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.

// @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

selectedLayerConfig.source.indexPatternId
);
const cloneLayersIndexPatterns = [...layersIndexPatterns, newIndexPattern];
setLayersIndexPatterns(cloneLayersIndexPatterns);
}
Expand Down