From 07b1d48bd3e884b1d50271a460a83717089d76e9 Mon Sep 17 00:00:00 2001 From: Larry Gregory Date: Thu, 3 Jan 2019 19:36:54 -0500 Subject: [PATCH] Provides context to spaces grid action buttons (#27911) (#28009) Fixes #27744 cc @elastic/eui-design -- It appears that the [`DefaultItemAction`](https://elastic.github.io/eui/#/display/tables) can only accept hard-coded `name`/`description` values. While this isn't necessarily a bad thing, I'm wondering if the linked issue (#27744) will be a common enough occurrence within Kibana to make the DefaultItemAction less useful. What do you think about allowing functions for the `name` and `description` fields, so that they can get access to the row's record, and provide context as necessary? --- .../spaces_grid_pages.test.tsx.snap | 14 ++------ .../spaces_grid/spaces_grid_page.tsx | 33 ++++++++++++------- 2 files changed, 23 insertions(+), 24 deletions(-) diff --git a/x-pack/plugins/spaces/public/views/management/spaces_grid/__snapshots__/spaces_grid_pages.test.tsx.snap b/x-pack/plugins/spaces/public/views/management/spaces_grid/__snapshots__/spaces_grid_pages.test.tsx.snap index 1e5370f1ca7e24..20174537be8ea3 100644 --- a/x-pack/plugins/spaces/public/views/management/spaces_grid/__snapshots__/spaces_grid_pages.test.tsx.snap +++ b/x-pack/plugins/spaces/public/views/management/spaces_grid/__snapshots__/spaces_grid_pages.test.tsx.snap @@ -81,21 +81,11 @@ exports[`SpacesGridPage renders as expected 1`] = ` Object { "actions": Array [ Object { - "color": "primary", - "description": "Edit this space.", - "icon": "pencil", - "name": "Edit", - "onClick": [Function], - "type": "icon", + "render": [Function], }, Object { "available": [Function], - "color": "danger", - "description": "Delete this space.", - "icon": "trash", - "name": "Delete", - "onClick": [Function], - "type": "icon", + "render": [Function], }, ], "name": "Actions", diff --git a/x-pack/plugins/spaces/public/views/management/spaces_grid/spaces_grid_page.tsx b/x-pack/plugins/spaces/public/views/management/spaces_grid/spaces_grid_page.tsx index d61c4113366cbf..d2ba3c54f64097 100644 --- a/x-pack/plugins/spaces/public/views/management/spaces_grid/spaces_grid_page.tsx +++ b/x-pack/plugins/spaces/public/views/management/spaces_grid/spaces_grid_page.tsx @@ -8,6 +8,7 @@ import React, { Component, Fragment } from 'react'; import { EuiButton, + EuiButtonIcon, EuiFlexGroup, EuiFlexItem, // @ts-ignore @@ -251,21 +252,29 @@ export class SpacesGridPage extends Component { name: 'Actions', actions: [ { - name: 'Edit', - description: 'Edit this space.', - onClick: this.onEditSpaceClick, - type: 'icon', - icon: 'pencil', - color: 'primary', + render: (record: Space) => { + return ( + this.onEditSpaceClick(record)} + /> + ); + }, }, { available: (record: Space) => !isReservedSpace(record), - name: 'Delete', - description: 'Delete this space.', - onClick: this.onDeleteSpaceClick, - type: 'icon', - icon: 'trash', - color: 'danger', + render: (record: Space) => { + return ( + this.onDeleteSpaceClick(record)} + /> + ); + }, }, ], },