Skip to content

Commit 86af956

Browse files
committed
[docs] Add examples of callback props
+ update actions example to include props table
1 parent cdc1c39 commit 86af956

2 files changed

Lines changed: 16 additions & 8 deletions

File tree

src-docs/src/views/tables/actions/actions.tsx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -183,13 +183,14 @@ export default () => {
183183
} else {
184184
let actions: Array<DefaultItemAction<User>> = [
185185
{
186-
name: 'Elastic.co',
187-
description: 'Go to elastic.co',
186+
name: 'User profile',
187+
description: ({ firstName, lastName }) =>
188+
`Visit ${firstName} ${lastName}'s profile`,
188189
icon: 'editorLink',
189190
color: 'primary',
190191
type: 'icon',
191-
href: 'https://elastic.co',
192-
target: '_blank',
192+
href: ({ id }) => `${window.location.href}?id=${id}`,
193+
target: '_self',
193194
'data-test-subj': 'action-outboundlink',
194195
},
195196
];
@@ -205,13 +206,14 @@ export default () => {
205206
},
206207
{
207208
name: (user: User) => (user.id ? 'Delete' : 'Remove'),
208-
description: 'Delete this user',
209+
description: ({ firstName, lastName }) =>
210+
`Delete ${firstName} ${lastName}`,
209211
icon: 'trash',
210212
color: 'danger',
211213
type: 'icon',
212214
onClick: deleteUser,
213215
isPrimary: true,
214-
'data-test-subj': 'action-delete',
216+
'data-test-subj': ({ id }) => `action-delete-${id}`,
215217
},
216218
{
217219
name: 'Edit',

src-docs/src/views/tables/actions/actions_section.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
import React from 'react';
2-
import { EuiBasicTable } from '../../../../../src/components';
2+
3+
import { EuiBasicTable, EuiCode } from '../../../../../src/components';
4+
35
import { GuideSectionTypes } from '../../../components';
46

7+
import { EuiTableActionsColumnType } from '!!prop-loader!../../../../../src/components/basic_table/table_types';
8+
import { CustomItemAction } from '!!prop-loader!../../../../../src/components/basic_table/action_types';
9+
import { DefaultItemActionProps as DefaultItemAction } from '../props/props';
10+
511
import Table from './actions';
6-
import { EuiCode } from '../../../../../src/components/code';
712
const source = require('!!raw-loader!./actions');
813

914
export const section = {
@@ -40,5 +45,6 @@ export const section = {
4045
</>
4146
),
4247
components: { EuiBasicTable },
48+
props: { EuiTableActionsColumnType, DefaultItemAction, CustomItemAction },
4349
demo: <Table />,
4450
};

0 commit comments

Comments
 (0)