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

[UnifiedFieldList] Migrate field list components from Lens to UnifiedFieldList #142758

Merged
merged 79 commits into from
Nov 2, 2022

Conversation

jughosta
Copy link
Contributor

@jughosta jughosta commented Oct 5, 2022

Addresses #135678

Summary

This PR migrates components/logic from Lens to UnifiedFieldList. There should be no visual changes at this point.

  • Extract Lens components to UnifiedFieldList plugin
  • Create a new hook useExistingFieldsFetcher for fetching fields existence data. A separate hook useExistingFieldsReader will be used for reading the fetched data in children components (instead of reading from Lens redux state).
  • Create useGroupedFields hook for grouping a fields list into sections
  • Integrate these components back into Lens page
  • Adjust after [Lens] Rename datasources #142553
  • Adjust after [Lens]Adds selected field accordion to the fields list #143175
  • Refactor text-based languages sidebar view to use the same common components
  • Add more tests and update docs

As our next step we integrate them into Discover page.

Notes for testing:
Please test field list on Lens page. It should behave as before for regular/ad-hoc data views and for text-based queries. Fields existence data was removed from Lens redux store and the layers panel now uses useExistingFieldsReader hook to get the existence data - please check that ui controls work as before. Please also check that the performance of the sidebar with a lot of fields was not affected.

Checklist

@jughosta jughosta added release_note:skip Skip the PR/issue when compiling release notes backport:skip This commit does not require backporting Team:DataDiscovery Discover, search (e.g. data plugin and KQL), data views, saved searches. For ES|QL, use Team:ES|QL. v8.6.0 labels Oct 5, 2022
@jughosta jughosta self-assigned this Oct 5, 2022
kibanamachine and others added 23 commits October 5, 2022 15:28
…d-list-sections

# Conflicts:
#	x-pack/plugins/lens/public/indexpattern_datasource/datapanel.tsx
…d-list-sections

# Conflicts:
#	src/plugins/unified_field_list/public/components/field_list/field_list_grouped.scss
#	src/plugins/unified_field_list/public/components/field_list/fields_accordion.tsx
#	src/plugins/unified_field_list/public/components/field_list/no_fields_callout.test.tsx
#	src/plugins/unified_field_list/public/components/field_list/no_fields_callout.tsx
#	x-pack/plugins/lens/public/data_views_service/loader.test.ts
#	x-pack/plugins/lens/public/data_views_service/loader.ts
#	x-pack/plugins/lens/public/datasources/form_based/datapanel.test.tsx
#	x-pack/plugins/lens/public/datasources/form_based/datapanel.tsx
#	x-pack/plugins/lens/public/datasources/form_based/dimension_panel/dimension_panel.test.tsx
#	x-pack/plugins/lens/public/datasources/form_based/dimension_panel/field_input.test.tsx
#	x-pack/plugins/lens/public/datasources/form_based/dimension_panel/field_select.tsx
#	x-pack/plugins/lens/public/datasources/form_based/dimension_panel/reference_editor.tsx
#	x-pack/plugins/lens/public/datasources/form_based/field_list.scss
#	x-pack/plugins/lens/public/datasources/form_based/field_list.tsx
#	x-pack/plugins/lens/public/datasources/form_based/fields_accordion.test.tsx
#	x-pack/plugins/lens/public/datasources/form_based/fields_accordion.tsx
#	x-pack/plugins/lens/public/datasources/form_based/no_fields_callout.test.tsx
#	x-pack/plugins/lens/public/datasources/form_based/no_fields_callout.tsx
#	x-pack/plugins/lens/public/datasources/form_based/operations/definitions/index.ts
#	x-pack/plugins/lens/public/datasources/form_based/operations/definitions/terms/field_inputs.tsx
#	x-pack/plugins/lens/public/indexpattern_datasource/field_list.scss
#	x-pack/plugins/lens/public/indexpattern_datasource/fields_accordion.tsx
#	x-pack/plugins/lens/public/indexpattern_datasource/no_fields_callout.test.tsx
#	x-pack/plugins/lens/public/indexpattern_datasource/no_fields_callout.tsx
@jughosta
Copy link
Contributor Author

@dej611 Updated. Thanks for reviewing the PR!

@kertal kertal added the Feature:UnifiedFieldList The unified field list component used by Lens & Discover label Oct 25, 2022
Copy link
Contributor

@davismcphee davismcphee left a comment

Choose a reason for hiding this comment

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

Finished my code review and it looks great 👍 The documentation is nice to have and lots of test coverage is always good. I left a few questions and comments, and I still have to do some more local testing to do, but it LGTM so far.

src/plugins/unified_field_list/README.md Show resolved Hide resolved
isAffectedByGlobalFilter: false,
isAffectedByTimeFilter: true,
// Show details on timeout but not failure
// hideDetails: fieldsExistenceInfoUnavailable && !existenceFetchTimeout, // TODO: is this check still necessary?
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we know if this is necessary now or do we possibly need input from the Lens team?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The question is how to catch timeouts of loadFieldExisting after it was moved from Lens server API to public of unifiedFieldList plugin in #139453. It might be not relevant anymore.

cc @dimaanj

Copy link
Member

Choose a reason for hiding this comment

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

I also think that this is no longer necessary since dataViewsService getFieldsForIndexPattern doesn't support a dedicated timeout error state, right @mattkime ?

Copy link
Contributor

@davismcphee davismcphee left a comment

Choose a reason for hiding this comment

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

I got a chance to finish my local testing today and if there are issues, I can't find them at least 👍 Everything worked great and I didn't encounter anything that seemed like a bug to me.

The only thing I noticed that seemed a little strange was that once I added a field to my vis, the plus button in its popover became disabled and the tooltip description didn't seem correct:
incorrect_tooltip

This isn't a blocker to me though (and it might have already worked that way in Lens), but I wonder if doing something like switching the plus button to a minus when the field is selected would be more helpful to a user instead:
with_minus

Other than that, this LGTM as soon as we get the lastFetchRequestedAtTimestamp concerns sorted out.

…d-list-sections

# Conflicts:
#	x-pack/plugins/lens/public/datasources/text_based/fields_accordion.tsx
@jughosta
Copy link
Contributor Author

@elasticmachine merge upstream

@jughosta
Copy link
Contributor Author

@davismcphee I think the behaviour of "+" button becoming disabled in the popover for a selected field is correct. It's the same on the main branch and the tooltip is the same.

@jughosta jughosta requested a review from dej611 October 28, 2022 13:56
Copy link
Contributor

@davismcphee davismcphee left a comment

Choose a reason for hiding this comment

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

Thanks for the updates! I did a final round of testing and code review, and it LGTM 🎉 It seems like there might still be a couple outstanding questions in the comments before we hit the button, but on my end this seems ready to merge. I'm excited to see this implemented in Discover too 🙂

I think the behaviour of "+" button becoming disabled in the popover for a selected field is correct. It's the same on the main branch and the tooltip is the same.

Thanks for checking that for me, and it's good to know the behaviour is the same as before. I probably should have written "I think disabling the button and keeping the tooltip isn't a great UX" instead, but that's not something for this PR to address anyway.

@jughosta
Copy link
Contributor Author

jughosta commented Nov 1, 2022

Hi @elastic/kibana-vis-editors,
Can I ask for another review for this refactoring?

Copy link
Contributor

@stratoula stratoula left a comment

Choose a reason for hiding this comment

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

This works fine Julia! I can't find any regression on functionality or performance. Thanx for working on that :) LGTM

@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
lens 895 885 -10
unifiedFieldList 32 49 +17
total +7

Public APIs missing comments

Total count of every public API that lacks a comment. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats comments for more detailed information.

id before after diff
lens 583 580 -3
unifiedFieldList 117 187 +70
total +67

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
lens 1.3MB 1.3MB -13.5KB
unifiedFieldList 20.4KB 33.3KB +12.9KB
total -608.0B

Public APIs missing exports

Total count of every type that is part of your API that should be exported but is not. This will cause broken links in the API documentation system. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats exports for more detailed information.

id before after diff
unifiedFieldList 2 4 +2

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
unifiedFieldList 15.8KB 21.0KB +5.1KB
Unknown metric groups

API count

id before after diff
lens 676 673 -3
unifiedFieldList 122 192 +70
total +67

async chunk count

id before after diff
unifiedFieldList 2 4 +2

ESLint disabled in files

id before after diff
osquery 1 2 +1

ESLint disabled line counts

id before after diff
enterpriseSearch 19 21 +2
fleet 57 63 +6
lens 20 19 -1
osquery 103 108 +5
securitySolution 439 445 +6
unifiedFieldList 9 13 +4
total +22

References to deprecated APIs

id before after diff
lens 31 16 -15
unifiedFieldList 30 40 +10
total -5

Total ESLint disabled count

id before after diff
enterpriseSearch 20 22 +2
fleet 65 71 +6
lens 23 22 -1
osquery 104 110 +6
securitySolution 516 522 +6
unifiedFieldList 9 13 +4
total +23

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

cc @jughosta

Copy link
Contributor

@dej611 dej611 left a comment

Choose a reason for hiding this comment

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

Tested again in Safari and found no new bugs from main 👍

@jughosta jughosta merged commit ca1c58d into elastic:main Nov 2, 2022
jughosta added a commit that referenced this pull request Dec 1, 2022
…to Discover (#144412)

Closes #135678

## Summary

This PR continues the work started in
#142758 to bring field list
grouping from Lens into Discover.

- [x] Integrate new components and hooks into Discover page
- [x] Refactor fields grouping logic
- [x] Render Popular fields under a new separate section
- [x] Remove "Hide empty fields" switch
- [x] Adjust filtering logic
- [x] Refactor fields existence logic in Discover
- [x] Add "Unmapped fields" section
- [x] Highlight the matching term when searching for a field 
- [x] Show field icons when in SQL mode
- [x] Add tooltips to field list section headings
- [x] Add tests, clean up

<img width="340" alt="Screenshot 2022-11-15 at 15 39 27"
src="https://user-images.githubusercontent.com/1415710/201947349-726ffc3a-a17f-411b-be92-81d97879765a.png">

For testing on Discover page:
Please check different use cases and toggling Advanced Settings:
- regular vs ad-hoc data views
- data views with and without a time field
- data views with unmapped and empty fields
- data views with a lot of fields
- data views with some fields being filtered out via data view
configuration
- updating query, filters, and time range
- regular and SQL mode
- searching by a field name in the sidebar
- applying a field filter in the sidebar
- adding, editing, and removing a field
- Field Statistics table when some columns are selected or no columns
are selected
- multifields in the field popover should work as before (icon should
change from "+" to "x" when subfield is selected as a column)
- `discover:searchOnPageLoad` should not show fields if turned off
- `discover:searchFieldsFromSource` should show multifields right in the
fields list if enabled
- `discover:enableSql` should show Selected and Available fields only
when enabled
- `discover:showLegacyFieldTopValues` should show old (green) field
stats in its popover
- `doc_table:legacy`

On Lens page:
- scroll position should reset when data view is switched or when
searching by a field name
- regular and SQL mode

### Checklist

- [x] Any text added follows [EUI's writing
guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses
sentence case text and includes [i18n
support](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)
- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
- [x] This renders correctly on smaller devices using a responsive
layout. (You can test this [in your
browser](https://www.browserstack.com/guide/responsive-testing-on-local-server))
- [x] This was checked for [cross-browser
compatibility](https://www.elastic.co/support/matrix#matrix_browsers)

Co-authored-by: Michael Marcialis <[email protected]>
Co-authored-by: Kibana Machine <[email protected]>
Co-authored-by: Stratoula Kalafateli <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:skip This commit does not require backporting Feature:UnifiedFieldList The unified field list component used by Lens & Discover release_note:skip Skip the PR/issue when compiling release notes Team:DataDiscovery Discover, search (e.g. data plugin and KQL), data views, saved searches. For ES|QL, use Team:ES|QL. v8.6.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.