-
Notifications
You must be signed in to change notification settings - Fork 861
[EuiDataGrid] Feature: toolbar reorganization and row height control #5415
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
Merged
cee-chen
merged 19 commits into
main
from
feat/datagrid/toolbar-reorg-and-row-height-switcher
Dec 7, 2021
Merged
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
7ca1bc8
[EuiDataGrid] Toolbar UI layout reorganization (#5334)
constancecchen 4a73ad3
Merge branch 'main' into feat/datagrid/toolbar-reorg-and-row-height-s…
cee-chen 513e7c9
Merge branch 'main' into feat/datagrid/toolbar-reorg-and-row-height-s…
cee-chen b19d0a6
Merge branch 'main' into feat/datagrid/toolbar-reorg-and-row-height-s…
cee-chen 72fdf3f
[EuiDataGrid] Add extra left prepend position to the `additionalContr…
constancecchen c8d82e7
Merge branch 'main' into feat/datagrid/toolbar-reorg-and-row-height-s…
cee-chen ff742c6
[EuiDataGrid] Add rowHeightSwitcher logic + API change (#5372)
constancecchen 1620d93
Merge branch 'main' into feat/datagrid/toolbar-reorg-and-row-height-s…
cee-chen cbcff1f
[PR feedback] Toggle full screen button to use exit icon
cee-chen 6584e58
[PR feedback] Fix incorrect documentation links
cee-chen 2848d56
Merge branch 'main' into feat/datagrid/toolbar-reorg-and-row-height-s…
cee-chen 4559a9e
[EuiDataGrid] Add `onChange` callbacks for display selector changes (…
constancecchen 7969f14
Merge branch 'main' into feat/datagrid/toolbar-reorg-and-row-height-s…
cee-chen cedee33
[EuiDataGrid] Row height switcher should override `rowHeights` + add …
constancecchen 9d816bf
[EuiDataGrid] improve height calculation (#5447)
chandlerprall 94315d6
Merge branch 'main' into feat/datagrid/toolbar-reorg-and-row-height-s…
constancecchen f358f7c
[PR feedback] Export new hook services
constancecchen 56f215b
Fix datagrid spec to use new cy.mount
constancecchen 26c9513
PRETTIERRRRRR
cee-chen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,209 @@ | ||
| import React, { useState, useCallback, Fragment } from 'react'; | ||
|
|
||
| // @ts-ignore Importing from JS | ||
| import { fake } from 'faker'; | ||
|
|
||
| import { | ||
| EuiDataGrid, | ||
| EuiButtonEmpty, | ||
| EuiButtonIcon, | ||
| EuiLink, | ||
| EuiToolTip, | ||
| useGeneratedHtmlId, | ||
| EuiFlyout, | ||
| EuiFlyoutBody, | ||
| EuiFlyoutHeader, | ||
| EuiText, | ||
| EuiTitle, | ||
| EuiContextMenuItem, | ||
| EuiContextMenuPanel, | ||
| EuiPopover, | ||
| } from '../../../../src'; | ||
|
|
||
| const columns = [ | ||
| { | ||
| id: 'name', | ||
| }, | ||
| { | ||
| id: 'email', | ||
| }, | ||
| { | ||
| id: 'city', | ||
| }, | ||
| { | ||
| id: 'country', | ||
| }, | ||
| { | ||
| id: 'account', | ||
| }, | ||
| ]; | ||
|
|
||
| const data: any[] = []; | ||
|
|
||
| for (let i = 1; i < 20; i++) { | ||
| data.push({ | ||
| name: fake('{{name.lastName}}, {{name.firstName}} {{name.suffix}}'), | ||
| email: fake('{{internet.email}}'), | ||
| city: ( | ||
| <EuiLink href="http://google.com">{fake('{{address.city}}')}</EuiLink> | ||
| ), | ||
| country: fake('{{address.country}}'), | ||
| account: fake('{{finance.account}}'), | ||
| }); | ||
| } | ||
|
|
||
| export default () => { | ||
| const [pagination, setPagination] = useState({ pageIndex: 0, pageSize: 10 }); | ||
| const [isFlyoutVisible, setIsFlyoutVisible] = useState(false); | ||
| const flyoutTitleId = useGeneratedHtmlId({ | ||
| prefix: 'dataGridAdditionalControlsFlyout', | ||
| }); | ||
|
|
||
| let flyout; | ||
| if (isFlyoutVisible) { | ||
| flyout = ( | ||
| <EuiFlyout | ||
| onClose={() => setIsFlyoutVisible(false)} | ||
| aria-labelledby={flyoutTitleId} | ||
| > | ||
| <EuiFlyoutHeader hasBorder> | ||
| <EuiTitle size="m"> | ||
| <h2 id={flyoutTitleId}>Inspect</h2> | ||
| </EuiTitle> | ||
| </EuiFlyoutHeader> | ||
| <EuiFlyoutBody> | ||
| <EuiText> | ||
| <p> | ||
| This is not a real control, just an example of how to trigger a | ||
| flyout from a custom data grid control. | ||
| </p> | ||
| </EuiText> | ||
| </EuiFlyoutBody> | ||
| </EuiFlyout> | ||
| ); | ||
| } | ||
|
|
||
| const [isPopoverOpen, setPopover] = useState(false); | ||
| const popoverId = useGeneratedHtmlId({ | ||
| prefix: 'dataGridAdditionalControlsPopover', | ||
| }); | ||
| const alertAndClosePopover = (position?: string) => { | ||
| setPopover(false); | ||
| window.alert( | ||
| `This is not a real control. It was passed into the \`${position}\` position.` | ||
| ); | ||
| }; | ||
|
|
||
| const [visibleColumns, setVisibleColumns] = useState(() => | ||
| columns.map(({ id }) => id) | ||
| ); | ||
|
|
||
| const setPageIndex = useCallback( | ||
| (pageIndex) => setPagination({ ...pagination, pageIndex }), | ||
| [pagination, setPagination] | ||
| ); | ||
| const setPageSize = useCallback( | ||
| (pageSize) => setPagination({ ...pagination, pageSize, pageIndex: 0 }), | ||
| [pagination, setPagination] | ||
| ); | ||
|
|
||
| return ( | ||
| <> | ||
| <EuiDataGrid | ||
| aria-label="Data grid demo with additional controls" | ||
| columns={columns} | ||
| columnVisibility={{ | ||
| visibleColumns: visibleColumns, | ||
| setVisibleColumns: setVisibleColumns, | ||
| }} | ||
| rowCount={data.length} | ||
| gridStyle={{ | ||
| border: 'horizontal', | ||
| header: 'underline', | ||
| }} | ||
| renderCellValue={({ rowIndex, columnId }) => data[rowIndex][columnId]} | ||
| pagination={{ | ||
| ...pagination, | ||
| pageSizeOptions: [5, 10, 25], | ||
| onChangeItemsPerPage: setPageSize, | ||
| onChangePage: setPageIndex, | ||
| }} | ||
| toolbarVisibility={{ | ||
| additionalControls: { | ||
| left: { | ||
| prepend: ( | ||
| <EuiButtonEmpty | ||
| size="xs" | ||
| iconType="document" | ||
| color="text" | ||
| onClick={() => alertAndClosePopover('left.prepend')} | ||
| > | ||
| {data.length} results | ||
| </EuiButtonEmpty> | ||
| ), | ||
| append: ( | ||
| <EuiPopover | ||
| id={popoverId} | ||
| button={ | ||
| <EuiButtonEmpty | ||
| size="xs" | ||
| iconType="download" | ||
| onClick={() => setPopover((open) => !open)} | ||
| > | ||
| Download | ||
| </EuiButtonEmpty> | ||
| } | ||
| isOpen={isPopoverOpen} | ||
| closePopover={() => setPopover(false)} | ||
| panelPaddingSize="none" | ||
| > | ||
| <EuiContextMenuPanel | ||
| size="s" | ||
| items={[ | ||
| <EuiContextMenuItem | ||
| key="csv" | ||
| onClick={() => alertAndClosePopover('left.append')} | ||
| > | ||
| CSV | ||
| </EuiContextMenuItem>, | ||
| <EuiContextMenuItem | ||
| key="jsonedit" | ||
| onClick={() => alertAndClosePopover('left.append')} | ||
| > | ||
| JSON | ||
| </EuiContextMenuItem>, | ||
| ]} | ||
| /> | ||
| </EuiPopover> | ||
| ), | ||
| }, | ||
| right: ( | ||
| <Fragment> | ||
| <EuiToolTip | ||
| title="Updated 3 min ago" | ||
| content="Click to refresh" | ||
| > | ||
| <EuiButtonIcon | ||
| aria-label="Refresh grid data" | ||
| size="xs" | ||
| iconType="refresh" | ||
| onClick={() => alertAndClosePopover('right')} | ||
| /> | ||
| </EuiToolTip> | ||
| <EuiToolTip content="Inspect grid data"> | ||
| <EuiButtonIcon | ||
| aria-label="Inspect grid data" | ||
| size="xs" | ||
| iconType="inspect" | ||
| onClick={() => setIsFlyoutVisible(true)} | ||
| /> | ||
| </EuiToolTip> | ||
| </Fragment> | ||
| ), | ||
| }, | ||
| }} | ||
| /> | ||
| {flyout} | ||
| </> | ||
| ); | ||
| }; | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.