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

[Management] Scripted fields table in React #16604

Merged
merged 6 commits into from
Feb 12, 2018

Conversation

chrisronline
Copy link
Contributor

@chrisronline chrisronline commented Feb 8, 2018

Fixes #16539
Relates to #15721

This PR converts the scripted field tables to using React/EUI.

screen shot 2018-02-08 at 9 26 34 am

cc @cjcenizal

@@ -1,7 +1,7 @@
import _ from 'lodash';
import './index_header';
import './indexed_fields_table';
import './scripted_fields_table';
// import './scripted_fields_table';
Copy link
Contributor

Choose a reason for hiding this comment

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

commented out code begone

@@ -140,4 +143,43 @@ uiModules.get('apps/management')
$scope.indexPattern.timeFieldName = field.name;
return $scope.indexPattern.save();
};

$scope.tryToRenderScriptedFieldsTable = function () {
if ($state.tab === 'scriptedFields') {
Copy link
Contributor

Choose a reason for hiding this comment

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

This file and a couple of others are just so bound up in Angular. Since we are supposed to be running away from Angular anyway, I wonder if it makes sense to take this Reactification work farther ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yea I agree, but I think the focus should be on the tables for now to ensure those can go out sooner rather than later. Once the tables are in, I want to take a pass on the shell part (edit_index_pattern)

Copy link
Contributor

Choose a reason for hiding this comment

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

I guess I just worry about people looking at these squashed merged changes and taking them as patterns.

Copy link
Contributor

Choose a reason for hiding this comment

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

And maybe there are bugs in all this glue code. Just seems better to get out of this to me.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yea I don't want that to happen, but converting this to React is probably more work than it seems because this is a shell that renders angular directives and getting those to work within a React shell seems complicated too.

What if I renamed the variables/functions in here to names that directly state to not use this and it's just a stopgap?

@elasticmachine
Copy link
Contributor

💔 Build Failed

@elasticmachine
Copy link
Contributor

💔 Build Failed

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Copy link
Contributor

@cjcenizal cjcenizal left a comment

Choose a reason for hiding this comment

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

Rad! This looks sweet. I had a few minor suggestions. Can we delete scripted_fields_table_angular.js? Looks like it's not in use.

@@ -140,4 +142,45 @@ uiModules.get('apps/management')
$scope.indexPattern.timeFieldName = field.name;
return $scope.indexPattern.save();
};

$scope.tryToRenderScriptedFieldsTable = function () {
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this need to be a scope method? Can we just make it a local function?

Copy link
Contributor

Choose a reason for hiding this comment

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

And a minor nit: can we rename it to updateScriptedFieldsTab? I wasn't sure how to intuit its role from the word "try" in the name.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, I'll change it

}
};

$scope.renderScriptedFieldsTable = function () {
Copy link
Contributor

@cjcenizal cjcenizal Feb 8, 2018

Choose a reason for hiding this comment

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

I think it makes sense to redefine this as a local function instead of a scope method (unless it needs to be on scope, but I don't think it does), and to move the logic from scripted_fields_table/index.js into here instead.

This makes sense to me since it mirrors how this will be structured once we migrate to React. The owner of the <ScriptedFieldsTable /> instance will be responsible for providing the props it needs. I think it also simplifies the code a bit.

So it would be:

function renderScriptedFieldsTable() {
  const node = document.getElementById(DOM_ELEMENT_ID);
  if (!node) {
    return;
  }

  render(
    <ScriptedFieldsTable
      indexPattern={$scope.indexPattern}
      fieldFilter={$scope.fieldFilter}
      scriptedFieldLanguageFilter={$scope.scriptedFieldLanguageFilter}
      helpers={{
        redirectToRoute: (obj, route) => {
          $scope.kbnUrl.redirectToRoute(obj, route);
          $scope.$apply();
        },
        getRouteHref: (obj, route) => $scope.kbnUrl.getRouteHref(obj, route),
      }}
    />,
    node,
  );
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds good!

return (
<div>
<EuiCallOut
title="Deprecation Warning"
Copy link
Contributor

Choose a reason for hiding this comment

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

According to our writing guidelines, this should be sentence case, "Deprecation warning." @gchaps Could you look over the copy below and provide feedback?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure!

);
}

renderNoFieldsFound() {
Copy link
Contributor

Choose a reason for hiding this comment

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

The empty table looks a little weird:

image

At a later point the Design team will come up with a nice solution for empty table states which we can use here. For now can we just not render anything, including the table, when there are no fields?

Copy link
Contributor

@gchaps gchaps Feb 8, 2018

Choose a reason for hiding this comment

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

My comments for the screen above:

  1. Tab names should have init caps:

Fields
Scripted fields
Source filters

  1. I feel that this paragraph is overwritten

These scripted fields are computed on the fly from your data. They can be used in visualizations and displayed in your documents. However, they cannot be searched. You can manage them here and add new ones as you see fit, but be careful, scripts can be tricky!

My recommendation:

You can use scripted fields in visualizations and display them in your documents. However, you cannot search scripted fields.

  1. Button names use sentence case:

Add Scripted Field -> Add scripted field

  1. No scripted fields found. -> No scripted fields found (no ending punctuation)

For the screen below:

1)The delete button in the upper right is in red and the Delete button in the confirmation modal is blue. The color should be consistent. Red is typically used for Delete.

  1. Rewrite for the sentence starting with "This page.." as follows:

This page lists every field in the log* index and the field's associated core type as recorded by Elasticsearch. To change a field type, use the Elasticsearch Mapping API.

  1. For the Add button on the on the Source filter page, our guidelines say to follow Add by a noun, so

Add source filter

  1. I recommend cutting down on the text under Source filter and making it easier to scan, The text feels like a help topic

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks!

1)The delete button in the upper right is in red and the Delete button in the confirmation modal is blue. The color should be consistent. Red is typically used for Delete.

@cjcenizal Is this supported in EUI now? I don't see a prop that looks like it will do it. Want me to add something?

Copy link
Contributor

Choose a reason for hiding this comment

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

@chrisronline Yes please! Thanks!

Copy link
Contributor

@jen-huang jen-huang left a comment

Choose a reason for hiding this comment

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

This pattern is super similar to what I've done so far for the indexed fields table so that's awesome 😄I'll adjust what I have to match more closely with this (just small changes).

I second CJ's comments about removing scripted_fields_table_angular.js. I removed the old angular version for indexed fields table. Also +1 on hiding table when there aren't any fields to display.

Also saw a small bug where if you delete a field, the count on the tab doesn't update:
feb-08-2018 14-41-26

We&apos;ve detected that the following deprecated languages are in use: {deprecatedLangsInUse.join(', ')}.
Support for these languages will be removed in the next major version of Kibana and Elasticsearch.
We recommend converting your scripted fields to <EuiLink href={painlessDocLink}>Painless</EuiLink>.
</p>
Copy link
Contributor

Choose a reason for hiding this comment

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

Here's my suggested rewrite. I'd prefer to see a more descriptive title than Deprecation Warning

Deprecated languages in use

The following deprecated languages are in use: {deprecatedLangsInUse.join(', ')}. Support for these languages will be removed in the next major version of Kibana and Elasticsearch. Convert you scripted fields to Painless to avoid any problems.

@chrisronline
Copy link
Contributor Author

@jen-huang Great catch!

@chrisronline
Copy link
Contributor Author

Thanks for the feedback everyone! PR is updated and ready for another pass!

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@jen-huang
Copy link
Contributor

jen-huang commented Feb 9, 2018

@chrisronline Another minor thing - long field names overlap the next column a bit too soon:
screen shot 2018-02-09 at 1 39 48 pm

I dealt with the same issue on indexed fields table. My fix includes setting width: '50%' on the field name column, '50px' on the actions column, and '120px' on the boolean value columns. YMMV since the columns here have different data.

@chrisronline
Copy link
Contributor Author

Thanks @jen-huang! @cjcenizal does it make sense to fix something like that in EUI directly?

@cjcenizal
Copy link
Contributor

@chrisronline Yes it absolutely does. We just need to remove the max-width: 20px style from the .euiTableCell class. And make sure it doesn't break anything in the table examples on the docs site.

@chrisronline
Copy link
Contributor Author

Great, I made a ticket to address that

Copy link
Contributor

@jen-huang jen-huang left a comment

Choose a reason for hiding this comment

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

LGTM!

Copy link
Contributor

@cjcenizal cjcenizal left a comment

Choose a reason for hiding this comment

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

💎 LGTM! I noticed that when a scripted field uses the default formatting the "Default" column is blank. Maybe it's worth showing the default value there?

@chrisronline chrisronline merged commit b932467 into elastic:master Feb 12, 2018
@chrisronline chrisronline deleted the eui/scripted_fields_table branch February 12, 2018 18:48
@chrisronline
Copy link
Contributor Author

Backport

6.x: 0060fd1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants