-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
React/EUI-ify indexed fields table #16695
Conversation
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.
Awesome! This looks great! The code pattern is probably the best I've ever seen ;)
I did find a few things:
Tooltip positioning
I'm not sure if this is fixable outside of EUI but this is definitely misaligned.
Yes indicators
I'm not sure I love this choice of icon to indicate yes
. Did this come down from design?
Refresh fields
This doesn't seem to work for me. If I click the button, the fields are fetched, but the table isn't updated. You probably just need to re render the table once this happens in the angular code
@chrisronline Thanks for the review!
|
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.
Looks great overall! Just had a couple of minor suggestions.
I have to say that I am not really feeling the dots in the table. 😐 My brain just doesn't pick up their meaning as quickly as with checkmarks. I also find myself feeling a bit unsure about what I can do with the table when the actions are hidden until you hover. I didn't realize I could edit the rows until I accidentally stumbled upon that functionality.
} else if($state.tab === 'scriptedFields') { | ||
updateScriptedFieldsTable($scope, $state); | ||
} | ||
} |
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.
Minor suggestion: how about early exiting here to avoid nesting, and a slightly terser switch instead of else if?
if ($scope.fieldFilter === undefined) {
return;
}
switch ($state.tab) {
case 'indexedFields':
updateIndexedFieldsTable($scope, $state);
case 'scriptedFields':
updateScriptedFieldsTable($scope, $state);
}
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.
Updated 👍
} | ||
|
||
|
||
// import React, { Component } from 'react'; |
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.
Can we delete this commented out code?
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.
Wow how did that get in there... 🙈
@cjcenizal Thanks for reviewing! Might the hidden actions be something that can be added to TableOfRecords? Some property like @snide Any thoughts on CJ's comments above about dots vs checkmarks? |
💔 Build Failed |
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.
💰LGTM!
💔 Build Failed |
💔 Build Failed |
💔 Build Failed |
💚 Build Succeeded |
@jen-huang I don't think it's a requirement, but feel free to check out the new table implementation in EUI and how @cjcenizal updated the scripted fields table to use it #16901. It might be cool to start using that in this PR |
c3d462c
to
8caf7e2
Compare
💔 Build Failed |
8caf7e2
to
979acef
Compare
💚 Build Succeeded |
@chrisronline PR ready for another pass with EuiTableInMemory. Pulled in |
import { ScriptedFieldsTable } from './scripted_fields_table'; | ||
|
||
const REACT_INDEXED_FIELDS_DOM_ELEMENT_ID = 'reactIndexedFieldsTable'; |
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.
I'm still seeing an issue where the fields aren't refreshing once I click Refresh Fields
. I think it's because this change is never propagating to the React component.
I'm wondering if we just let this parent container control the fields and pass it in so we can easily tie a change in the fields to the React lifecycle. Or maybe find another way.
But if you like the first idea, here is a some code I whipped up that might work:
diff --git a/src/core_plugins/kibana/public/management/sections/indices/edit_index_pattern/edit_index_pattern.js b/src/core_plugins/kibana/public/management/sections/indices/edit_index_pattern/edit_index_pattern.js
index f1187c3fed..02ab1c6540 100644
--- a/src/core_plugins/kibana/public/management/sections/indices/edit_index_pattern/edit_index_pattern.js
+++ b/src/core_plugins/kibana/public/management/sections/indices/edit_index_pattern/edit_index_pattern.js
@@ -67,6 +67,7 @@ function updateIndexedFieldsTable($scope, $state) {
render(
<IndexedFieldsTable
indexPattern={$scope.indexPattern}
+ fields={$scope.fields}
fieldFilter={$scope.fieldFilter}
fieldWildcardMatcher={$scope.fieldWildcardMatcher}
indexedFieldTypeFilter={$scope.indexedFieldTypeFilter}
@@ -138,6 +139,7 @@ uiModules.get('apps/management')
$scope.$watch('indexPattern.fields', function () {
$scope.editSections = $scope.editSectionsProvider($scope.indexPattern);
$scope.refreshFilters();
+ $scope.fields = $scope.indexPattern.getNonScriptedFields();
updateIndexedFieldsTable($scope, $state);
updateScriptedFieldsTable($scope, $state);
});
@@ -180,7 +182,11 @@ uiModules.get('apps/management')
$scope.refreshFields = function () {
const confirmModalOptions = {
confirmButtonText: 'Refresh',
- onConfirm: () => { $scope.indexPattern.refreshFields(); },
+ onConfirm: async () => {
+ await $scope.indexPattern.refreshFields();
+ $scope.fields = $scope.indexPattern.getNonScriptedFields();
+ updateIndexedFieldsTable($scope, $state);
+ },
title: 'Refresh field list?'
};
confirmModal(
diff --git a/src/core_plugins/kibana/public/management/sections/indices/edit_index_pattern/indexed_fields_table/indexed_fields_table.js b/src/core_plugins/kibana/public/management/sections/indices/edit_index_pattern/indexed_fields_table/indexed_fields_table.js
index 995f4bbb37..acea91db5d 100644
--- a/src/core_plugins/kibana/public/management/sections/indices/edit_index_pattern/indexed_fields_table/indexed_fields_table.js
+++ b/src/core_plugins/kibana/public/management/sections/indices/edit_index_pattern/indexed_fields_table/indexed_fields_table.js
@@ -10,6 +10,7 @@ import {
export class IndexedFieldsTable extends Component {
static propTypes = {
indexPattern: PropTypes.object.isRequired,
+ fields: PropTypes.array.isRequired,
fieldFilter: PropTypes.string,
indexedFieldTypeFilter: PropTypes.string,
helpers: PropTypes.shape({
@@ -22,12 +23,14 @@ export class IndexedFieldsTable extends Component {
super(props);
this.state = {
- fields: []
+ fields: this.mapFields(this.props.fields),
};
}
- componentWillMount() {
- this.fetchFields();
+ componentWillReceiveProps(nextProps) {
+ if (nextProps.fields !== this.props.fields) {
+ this.setState({ fields: this.mapFields(nextProps.fields) });
+ }
}
mapFields(fields) {
@@ -47,13 +50,6 @@ export class IndexedFieldsTable extends Component {
});
}
- fetchFields = async () => {
- const fields = this.mapFields(await this.props.indexPattern.getNonScriptedFields());
- this.setState({
- fields
- });
- }
-
getFilteredFields = createSelector(
(state) => state.fields,
(state, props) => props.fieldFilter,
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.
thanks, implemented similar changes
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.
a couple of minor things, but looking good.
|
||
mapFields(fields) { | ||
const { indexPattern, fieldWildcardMatcher } = this.props; | ||
const fieldWildcardMatch = fieldWildcardMatcher((indexPattern.sourceFilters && indexPattern.sourceFilters.map(f => f.value) || [])); |
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.
this line is really long
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.
broke it up
...field, | ||
displayName: field.displayName, | ||
routes: field.routes, | ||
indexPattern: field.indexPattern, |
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.
lines 41-43 are covered by line 40.
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.
displayName, routes, and indexPattern
aren't enumerable properties :(
Object.keys(field)
(7) ["name", "type", "count", "scripted", "searchable", "aggregatable", "readFromDocValues"]
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.
ahh, nm then :-)
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.
Can we leave a comment here explaining that? I'm pretty sure I would come along and make the same assumption Bill did. :)
@chrisronline Ready for another pass, refresh fields should work now. |
💚 Build Succeeded |
|
||
// Allow the componentWillMount code to execute | ||
// https://github.com/airbnb/enzyme/issues/450 | ||
await component.update(); // Fire `componentWillMount()` |
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.
We can simplify all of this from #16968
// Ensure all promises resolve
await new Promise(resolve => process.nextTick(resolve));
// Ensure the state changes are reflected
component.update();
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.
so much better!!
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.
This is looking GREAT! I just have one minor request for the tests that should hopefully make them more clear.
@chrisronline Updated! |
💚 Build Succeeded |
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.
LGTM!!!
* React/EUI-ifying indexed fields table
Fixes #16694
Relates to #15721
Converts the indexed fields table to React/EUI.