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

[EuiDataGrid] Feature: toolbar reorganization and row height control #5415

Merged
merged 19 commits into from
Dec 7, 2021
Merged
Show file tree
Hide file tree
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 Nov 10, 2021
4a73ad3
Merge branch 'main' into feat/datagrid/toolbar-reorg-and-row-height-s…
cee-chen Nov 10, 2021
513e7c9
Merge branch 'main' into feat/datagrid/toolbar-reorg-and-row-height-s…
cee-chen Nov 17, 2021
b19d0a6
Merge branch 'main' into feat/datagrid/toolbar-reorg-and-row-height-s…
cee-chen Nov 19, 2021
72fdf3f
[EuiDataGrid] Add extra left prepend position to the `additionalContr…
constancecchen Nov 23, 2021
c8d82e7
Merge branch 'main' into feat/datagrid/toolbar-reorg-and-row-height-s…
cee-chen Nov 23, 2021
ff742c6
[EuiDataGrid] Add rowHeightSwitcher logic + API change (#5372)
constancecchen Nov 24, 2021
1620d93
Merge branch 'main' into feat/datagrid/toolbar-reorg-and-row-height-s…
cee-chen Nov 24, 2021
cbcff1f
[PR feedback] Toggle full screen button to use exit icon
cee-chen Nov 30, 2021
6584e58
[PR feedback] Fix incorrect documentation links
cee-chen Nov 30, 2021
2848d56
Merge branch 'main' into feat/datagrid/toolbar-reorg-and-row-height-s…
cee-chen Nov 30, 2021
4559a9e
[EuiDataGrid] Add `onChange` callbacks for display selector changes (…
constancecchen Dec 2, 2021
7969f14
Merge branch 'main' into feat/datagrid/toolbar-reorg-and-row-height-s…
cee-chen Dec 2, 2021
cedee33
[EuiDataGrid] Row height switcher should override `rowHeights` + add …
constancecchen Dec 3, 2021
9d816bf
[EuiDataGrid] improve height calculation (#5447)
chandlerprall Dec 7, 2021
94315d6
Merge branch 'main' into feat/datagrid/toolbar-reorg-and-row-height-s…
constancecchen Dec 7, 2021
f358f7c
[PR feedback] Export new hook services
constancecchen Dec 7, 2021
56f215b
Fix datagrid spec to use new cy.mount
constancecchen Dec 7, 2021
26c9513
PRETTIERRRRRR
cee-chen Dec 7, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
## [`main`](https://github.com/elastic/eui/tree/main)

- Updated the organization of `EuiDataGrid`'s toolbar/grid controls ([#5334](https://github.com/elastic/eui/pull/5334))
- Updated `EuiDataGrid`'s full screen mode to use the `fullScreenExit` icon ([#5415](https://github.com/elastic/eui/pull/5415))
- Added `left.append` and `left.prepend` to `EuiDataGrid`'s `toolbarVisibility.additionalControls` prop [#5394](https://github.com/elastic/eui/pull/5394))
- Added a row height control to `EuiDataGrid`'s toolbar ([#5372](https://github.com/elastic/eui/pull/5372))
- Added `onChange` callbacks to `EuiDataGrid`'s `gridStyle` and `rowHeightOptions` settings ([#5424](https://github.com/elastic/eui/pull/5424))
- Added a reset button to `EuiDataGrid`'s display controls ([#5428](https://github.com/elastic/eui/pull/5428))
- Added `timeRefresh` icon ([#5383](https://github.com/elastic/eui/pull/5383))
- Added `responsive` and `iconOnly` props to `EuiSuperUpdateButton` ([#5383](https://github.com/elastic/eui/pull/5383))
- Added better auto refresh indicator to `EuiSuperDatePicker` ([#5383](https://github.com/elastic/eui/pull/5383))
Expand All @@ -14,13 +20,15 @@

**Bug fixes**

- Fixed persistent `EuiDataGrid` full screen `<body>` class ([#5354](https://github.com/elastic/eui/pull/5354))
- Fixed dark mode background color of `EuiFormControlLayout` `prepend` and `append` ([#5383](https://github.com/elastic/eui/pull/5383))
- Fixed background color of `EuiFormControlLayout` when `readOnly` ([#5383](https://github.com/elastic/eui/pull/5383))
- Fixed the name of `data-test-subj` prop of `EuiFormControlLayout` ([#5383](https://github.com/elastic/eui/pull/5383))
- Fixed global reset styles for plain `<button>`s ([#5452](https://github.com/elastic/eui/pull/5452))

**Breaking changes**

- Removed `toolbarVisibility`'s `showStyleSelector` prop of `EuiDataGrid` in favor of `showDisplaySelector`, which allows configuration of both grid density and row height ([#5372](https://github.com/elastic/eui/pull/5372))
- Changed prop name `applyRefreshInterval` to `onRefreshChange` in `EuiRefreshInterval` ([#5383](https://github.com/elastic/eui/pull/5383))
- Increased the size of `s`-sized `EuiLoadingSpinner`s to match `s`-sized `EuiIcon`s ([#5440](https://github.com/elastic/eui/pull/5440))

Expand Down
7 changes: 7 additions & 0 deletions cypress/support/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,10 @@
import '@cypress/code-coverage/support';
import './commands.js';
require(THEME_IMPORT); // defined by DefinePlugin in the cypress webpack config

// @see https://github.com/quasarframework/quasar/issues/2233#issuecomment-492975745
Cypress.on('uncaught:exception', (err) => {
if (err.message.includes('> ResizeObserver loop limit exceeded')) {
return false;
}
});
104 changes: 0 additions & 104 deletions src-docs/src/views/datagrid/additional_controls.js

This file was deleted.

209 changes: 209 additions & 0 deletions src-docs/src/views/datagrid/additional_controls.tsx
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)}
>
cee-chen marked this conversation as resolved.
Show resolved Hide resolved
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}
</>
);
};
Loading