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

Added isSortable to Datagrid columns #2952

Merged
merged 9 commits into from
Mar 1, 2020

Conversation

ashikmeerankutty
Copy link
Contributor

@ashikmeerankutty ashikmeerankutty commented Feb 29, 2020

Summary

Fixes #2950

Checklist

  • Check against all themes for compatibility in both light and dark modes
  • Checked in mobile
  • Checked in IE11 and Firefox
  • Props have proper autodocs
  • Added documentation examples
  • Added or updated jest tests
  • Checked for breaking changes and labeled appropriately
  • Checked for accessibility including keyboard-only and screenreader modes
  • A changelog entry exists and is marked appropriately

@kibanamachine
Copy link

Since this is a community submitted pull request, a Jenkins build has not been kicked off automatically. Can an Elastic organization member please verify the contents of this patch and then kick off a build manually?

@chandlerprall
Copy link
Contributor

chandlerprall commented Feb 29, 2020

Thanks for this! Two things:

  • needs to have an entry added to the top of CHANGELOG.md describing the additional feature and linking to this PR
  • please add the same optional isSortable flag to EuiDataGridSchemaDetector and also check for its presence in column_sorting - if either is set to false then the column should not be sortable. Similar logic to
    iconType={
    schema.hasOwnProperty(id) &&
    schema[id].columnType != null
    ? getDetailsForSchema(
    schemaDetectors,
    schema[id].columnType
    ).icon
    : 'tokenString'
    }

Currently, most of these settings come from the schema detector definition, but that can be cumbersome to work with and we are going to move to columns overriding individual settings like isSortable.

@ashikmeerankutty
Copy link
Contributor Author

@chandlerprall I have updated the changes you have suggested. Can you please review the changes.

Copy link
Contributor

@chandlerprall chandlerprall left a comment

Choose a reason for hiding this comment

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

Changes look good, just one thing to clean up

{inactiveColumns.length > 0 && (

needs to be updated to consider the length of sortable columns, otherwise the Pick fields to sort by UI can end up as an empty drop down instead of removed from the window.

empty selection ui

To help consolidate the new logic, it's probably best to create a new array (e.g. inactiveSortableColumns or similar) based on the isSortable props, and use that array when rendering choices and showing/hiding selection popover.

CHANGELOG.md Outdated Show resolved Hide resolved
@ashikmeerankutty
Copy link
Contributor Author

@chandlerprall Changes updated. Can you please review?

@chandlerprall
Copy link
Contributor

jenkins test this

Copy link
Contributor

@chandlerprall chandlerprall left a comment

Choose a reason for hiding this comment

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

Schema detector test at

schemaDetectors={[
{
type: 'ipaddress',
detector(value: string) {
return value.match(/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/)
? 1
: 0;
},
icon: 'alert',
color: 'primary',
sortTextAsc: 'a-z',
sortTextDesc: 'z-a',
},
]}
needs isSortable: true

src/components/datagrid/column_sorting.tsx Show resolved Hide resolved
@chandlerprall
Copy link
Contributor

Sorry for the back-and-forth - should be the last 2 items, then I'll merge this in.

@ashikmeerankutty
Copy link
Contributor Author

@chandlerprall No problem. Can you please review it?

@chandlerprall
Copy link
Contributor

jenkins test this

@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_2952/

Copy link
Contributor

@chandlerprall chandlerprall left a comment

Choose a reason for hiding this comment

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

LGTM! Pulled & tested locally.

@chandlerprall chandlerprall merged commit 7fdac45 into elastic:master Mar 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DataGrid columns should be able to be marked as un-sortable
3 participants