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] Remove redundant server routes. Create new example plugin for unified field list components and migrate tests. #158377

Merged
merged 31 commits into from
May 31, 2023

Conversation

jughosta
Copy link
Contributor

@jughosta jughosta commented May 24, 2023

Summary

Before:

Unified Field List plugin has internal routes (wrappers for client code) which exist only to run api functional tests against them:

  • /api/unified_field_list/existing_fields/{dataViewId}
  • /api/unified_field_list/field_stats

Client code does not call these routes directly. So there is no reason in keeping and versioning them.

After:

  • Internal routes are removed
  • A new "Unified Field List Examples" page was created http://localhost:5601/app/unifiedFieldListExamples
  • API functional tests (which used the routes) were converted to functional tests against this new example page
  • Created a new unifiedFieldList page object which is used now in functional tests (methods are extracted from existing discover page object).

For testing:

Steps:

  1. Run Kibana with examples: yarn start --run-examples
  2. Install sample data
  3. And navigate to Developer Examples > Unified Field List Examples page.

May-26-2023 13-24-03

Checklist

jughosta and others added 22 commits May 24, 2023 15:20
@jughosta jughosta changed the title [UnifiedFieldList] Create new example plugin for unified field list components [UnifiedFieldList] Remove redundant server routes. Create new example plugin for unified field list components and migrate tests. May 26, 2023
@jughosta jughosta self-assigned this May 26, 2023
@jughosta jughosta added release_note:deprecation 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. Feature:UnifiedFieldList The unified field list component used by Lens & Discover release_note:skip Skip the PR/issue when compiling release notes and removed release_note:deprecation labels May 26, 2023
@@ -5,7 +5,7 @@
"description": "Contains functionality for the field list which can be integrated into apps",
"plugin": {
"id": "unifiedFieldList",
"server": true,
"server": false,
Copy link
Contributor Author

@jughosta jughosta May 26, 2023

Choose a reason for hiding this comment

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

Removed the server code. Now we can convert unifiedFieldList from a plugin to a package!

Copy link
Member

Choose a reason for hiding this comment

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

Great PR removing legacy and providing documentation that can be tested! Just a question, it migrating to packages would have been possible before, but it would need 2 different packages for public and server code, much more effort right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@kertal Yes, and a server package would consist of only routes for tests (if it's even possible to test package routes with functional API tests)

@@ -39,30 +39,25 @@ function getCommonFieldItemButtonProps({
}: GetCommonFieldItemButtonPropsParams): {
field: FieldItemButtonProps<DataViewField>['field'];
isSelected: FieldItemButtonProps<DataViewField>['isSelected'];
dataTestSubj: FieldItemButtonProps<DataViewField>['dataTestSubj'];
Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's a part of unifiedFieldList page now.

@@ -480,86 +482,91 @@ const FieldStatsComponent: React.FC<FieldStatsProps> = ({

if (field.type === 'date') {
return combineWithTitleAndFooter(
<div data-test-subj={`${dataTestSubject}-histogram`}>
<Chart size={{ height: 200, width: 300 - 32 }}>
<div data-test-subj="unifiedFieldStats-timeDistribution">
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Only wrapped with an additional div with a stable data-test-subj.


if (showingHistogram || !topValues || !topValues.buckets.length) {
return combineWithTitleAndFooter(
<div data-test-subj="unifiedFieldStats-histogram">
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Same

{buckets.map((bucket, index) => {
const fieldValue = bucket.key;
const formatted = formatter.convert(fieldValue);
<div
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Same. Also only added a div wrapper.

/**
* Exported only for unit tests.
*/
export function legacyExistingFields(docs: estypes.SearchHit[], fields: Field[]): string[] {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Found some unreachable code. Removed.

@jughosta jughosta marked this pull request as ready for review May 26, 2023 13:41
@jughosta jughosta requested review from a team as code owners May 26, 2023 13:41
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-data-discovery (Team:DataDiscovery)

Copy link
Contributor

@ThomThomson ThomThomson left a comment

Choose a reason for hiding this comment

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

Code only review, functional test changes LGTM!

Copy link
Contributor

@peteharverson peteharverson left a comment

Choose a reason for hiding this comment

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

Edit to the transform plugin test LGTM for ML.

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.

Code review only, Visualizations team changes LGTM

Copy link
Contributor

@nreese nreese left a comment

Choose a reason for hiding this comment

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

kibana-gis changes LGTM
code review only

Copy link
Member

@kertal kertal left a comment

Choose a reason for hiding this comment

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

Code LGTM 👍 Great to have a nice example plugin, this is very helpful. And by removing / migrating those server side we don't need to migrate these APIs for server less. Win-win . Tested locally and works as expected

@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

Metrics [docs]

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
unifiedFieldList 267 270 +3

Async chunks

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

id before after diff
discover 421.6KB 421.5KB -107.0B
unifiedFieldList 47.9KB 48.4KB +431.0B
total +324.0B

Page load bundle

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

id before after diff
unifiedFieldList 52.8KB 53.1KB +269.0B
Unknown metric groups

API count

id before after diff
unifiedFieldList 293 296 +3

ESLint disabled line counts

id before after diff
enterpriseSearch 19 21 +2
securitySolution 416 420 +4
unifiedFieldList 21 18 -3
total +3

References to deprecated APIs

id before after diff
unifiedFieldList 30 20 -10

Total ESLint disabled count

id before after diff
enterpriseSearch 20 22 +2
securitySolution 500 504 +4
unifiedFieldList 21 18 -3
total +3

History

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

cc @jughosta

@jughosta jughosta merged commit 8d399fe into elastic:main May 31, 2023
@jughosta jughosta deleted the 157109-remove-server-routes branch May 31, 2023 11:25
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.9.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Unified Field List] Routes must satisfy bwca [UnifiedFieldList] Add examples of field list
10 participants