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

[Data Explorer][Discover 2.0] Implement data fetch, index pattern, saved search for table vis #4564

Conversation

ananzh
Copy link
Member

@ananzh ananzh commented Jul 13, 2023

Description

  • Fetch data and feed to table vis by deangularizing controller methods
  • Transfer legacy table to data grid Table
  • Remove doc view links for now

Issues Resolved

#4224

Screenshot

Screenshot 2023-07-17 at 07 40 38 Screenshot 2023-07-17 at 07 46 52

Testing the changes

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

@codecov
Copy link

codecov bot commented Jul 13, 2023

Codecov Report

Merging #4564 (84bb885) into feature/data-explorer (6e87e28) will increase coverage by 0.02%.
The diff coverage is 78.94%.

❗ Current head 84bb885 differs from pull request most recent head 859432b. Consider uploading reports for the commit 859432b to get more accurate results

@@                    Coverage Diff                    @@
##           feature/data-explorer    #4564      +/-   ##
=========================================================
+ Coverage                  66.58%   66.60%   +0.02%     
=========================================================
  Files                       3278     3282       +4     
  Lines                      62645    62732      +87     
  Branches                    9759     9780      +21     
=========================================================
+ Hits                       41710    41782      +72     
- Misses                     18569    18574       +5     
- Partials                    2366     2376      +10     
Flag Coverage Δ
Linux 66.54% <78.94%> (+0.02%) ⬆️
Windows 66.54% <78.94%> (+0.02%) ⬆️

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

Files Changed Coverage Δ
...omponents/data_grid/data_grid_table_cell_value.tsx 70.83% <70.83%> (ø)
...ins/discover/public/__mock__/index_pattern_mock.ts 75.00% <75.00%> (ø)
...blic/application/view_components/utils/get_sort.ts 88.88% <88.88%> (ø)
...lic/application/components/utils/use_pagination.ts 90.00% <90.00%> (ø)

... and 2 files with indirect coverage changes

Copy link
Member

@ashwin-pc ashwin-pc left a comment

Choose a reason for hiding this comment

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

The PR looks good to me, just one blocking change to add the doc_viewer_links service back. Unit tests would be really appreciated since we will need them before merge to main anyways.

* SPDX-License-Identifier: Apache-2.0
*/

export const toolbarVisibility = {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
export const toolbarVisibility = {
export const TOOLBAR_VISIBILITY = {

nit:

Copy link
Member Author

Choose a reason for hiding this comment

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

will change

Copy link
Member

Choose a reason for hiding this comment

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

do we need all this custom css?

Copy link
Member

Choose a reason for hiding this comment

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

As we discussed earlier, lets add this back to the app. Its an api we expose that is not used in our project but is used by the community

Copy link
Member Author

Choose a reason for hiding this comment

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

will add it back

Copy link
Member

Choose a reason for hiding this comment

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

Can you add a unit test for this file? it looks like it wont change in future.

Copy link
Member Author

Choose a reason for hiding this comment

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

Will add an initial unit test for now. This data_grid_table_cell_value.tsx will need further polish to include nested fields and others.

Copy link
Member

Choose a reason for hiding this comment

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

The same goes for this. Unit tests will be useful here

Copy link
Member Author

Choose a reason for hiding this comment

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

will add a unit test

const { core, chrome, data, uiSettings: config, toastNotifications } = services;
const [savedSearch, setSavedSearch] = useState<SavedSearch>();
const [indexPattern, setIndexPattern] = useState<IndexPattern | undefined>(undefined);
// ToDo: get id from data explorer since it is handling the routing logic
Copy link
Member

Choose a reason for hiding this comment

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

nit: I usually have my case sensitivity turned on so i dont want to accidentally miss this

Suggested change
// ToDo: get id from data explorer since it is handling the routing logic
// TODO: get id from data explorer since it is handling the routing logic

Copy link
Member Author

Choose a reason for hiding this comment

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

will replace all ToDo to TODO

};
}, [data$, fetchState]);

// ToDo: implement columns, onAddColumn, onRemoveColumn, onMoveColumn, onSetColumns using config, indexPattern, appState
Copy link
Member

Choose a reason for hiding this comment

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

most of these are already done in my side panel PR so i'd hold off implementing this until then :)

Comment on lines 39 to 40
<EuiPage className="dscCanvasAppPage">
<EuiPageBody className="dscCanvasAppPageBody">
Copy link
Member

Choose a reason for hiding this comment

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

Do we need EuiPage and EuiPageBody? We already have them at the app root level

Copy link
Member Author

Choose a reason for hiding this comment

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

will remove

indexPattern: IndexPattern;
}

export const DiscoverTableService = ({
Copy link
Member

Choose a reason for hiding this comment

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

Do we need this? Right now the React tree looks like:

Canvas -> DiscoverTable -> DiscoverTableService -> DiscoverTableApplication -> DataGrid

Cant we instead simplify this to just be

Canvas -> DiscoverTable -> DataGrid?

Copy link
Member Author

Choose a reason for hiding this comment

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

This DiscoverTableApplication actually need to rename. It will include DiscoverChart (HitsCount, TimeChartHeader and Histogram) and DiscoverTable.
This discover_table_service is used to have any updates on services, like data & saved search for both DiscoverChart and DiscoverTable.

We could re-evaluate and simply after canvas parts all implemented.

Copy link
Member

Choose a reason for hiding this comment

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

All files inside utils need to have unit tests. I wont hold back the PR if they arent there, but before we merge to main, we definitely need to add them

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes and will do. Currently, use_discover_canvas_service is not done. We will add tests for every utility functions after canvas is done.

Issue Resolve
opensearch-project#4442

Signed-off-by: ananzh <ananzh@amazon.com>
Issue Resolve:
opensearch-project#4397

Signed-off-by: ananzh <ananzh@amazon.com>
@ashwin-pc ashwin-pc added discover for discover reinvent de-angular de-angularize work data explorer Issues related to the Data Explorer project labels Jul 25, 2023
@ananzh ananzh force-pushed the feature/data-explorer-fetch branch from f3d17ed to 84bb885 Compare July 25, 2023 17:24
Signed-off-by: ananzh <ananzh@amazon.com>
@ananzh ananzh force-pushed the feature/data-explorer-fetch branch from 84bb885 to 859432b Compare July 25, 2023 17:28
@ananzh
Copy link
Member Author

ananzh commented Jul 25, 2023

@ashwin-pc fixed all your comments. Some major changes are 1) add some initial tests. I put index pattern mock into a common mock folder bc it will be used by many other comps. Currently dataRowsMock is in each test file, but if there is more duplication, we will also move it to common folder. 2) add doc_views_link back. will see how to use it better and verify these links work in later work.

Copy link
Member

@ashwin-pc ashwin-pc left a comment

Choose a reason for hiding this comment

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

Wont block on the new index pattern mock, but in a followup PR can you replace the custom mock with an existing one so that we dont have many ways to mock the same thing. Index patterns may change soon and custom mocks like this will make it annoying to update tests that rely on them.

Copy link
Member

Choose a reason for hiding this comment

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

Do we need this? Cant we use import { getStubIndexPattern } from '../../../../../../data/public/test_utils'; like the one found in src/plugins/discover/public/application/components/sidebar/lib/field_calculator.test.ts?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes we could. This is a great finding. I think we just need to add a new data in fixture. Let me do it in a follow up PR.

@ananzh ananzh merged commit 146cc36 into opensearch-project:feature/data-explorer Jul 26, 2023
20 of 37 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
data explorer Issues related to the Data Explorer project de-angular de-angularize work discover for discover reinvent distinguished-contributor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants