-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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
Conversation
…o 157109-remove-server-routes
…o 157109-remove-server-routes
@@ -5,7 +5,7 @@ | |||
"description": "Contains functionality for the field list which can be integrated into apps", | |||
"plugin": { | |||
"id": "unifiedFieldList", | |||
"server": true, | |||
"server": false, |
There was a problem hiding this comment.
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!
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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']; |
There was a problem hiding this comment.
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"> |
There was a problem hiding this comment.
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"> |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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[] { |
There was a problem hiding this comment.
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.
Pinging @elastic/kibana-data-discovery (Team:DataDiscovery) |
There was a problem hiding this 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!
There was a problem hiding this 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.
There was a problem hiding this 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
There was a problem hiding this 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
There was a problem hiding this 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
💚 Build Succeeded
Metrics [docs]Public APIs missing comments
Async chunks
Page load bundle
Unknown metric groupsAPI count
ESLint disabled line counts
References to deprecated APIs
Total ESLint disabled count
History
To update your PR or re-run it, just comment with: cc @jughosta |
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:
unifiedFieldList
page object which is used now in functional tests (methods are extracted from existingdiscover
page object).For testing:
Steps:
yarn start --run-examples
Checklist