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

[Discover] Redesign for the grid, panels and sidebar v1 #165866

Merged
merged 76 commits into from
Sep 12, 2023
Merged
Show file tree
Hide file tree
Changes from 69 commits
Commits
Show all changes
76 commits
Select commit Hold shift + click to select a range
6be6936
[Discover] Update grid styles
jughosta Aug 17, 2023
7c27938
[Discover] Update tests
jughosta Aug 17, 2023
72bc5b2
[Discover] Update tests
jughosta Aug 17, 2023
0ac8342
[Discover] Add a comment
jughosta Aug 17, 2023
69ed036
[Discover] Update tests
jughosta Aug 17, 2023
680641b
[Discover] Update tests
jughosta Aug 17, 2023
de53757
[Discover] Address review comments
jughosta Sep 4, 2023
aca35f3
[Discover] Enable row stripes
jughosta Sep 4, 2023
2c65d30
Merge remote-tracking branch 'upstream/main' into redesign-checkboxes
jughosta Sep 4, 2023
bdcbf1d
[Discover] Update header background
jughosta Sep 4, 2023
1c71502
[Discover] Update document view
jughosta Sep 4, 2023
159dcbb
Merge branch 'main' into redesign-checkboxes
jughosta Sep 4, 2023
fa58fa3
[Discover] Update jest snapshots
jughosta Sep 4, 2023
e575c01
Merge branch 'main' into redesign-checkboxes
jughosta Sep 5, 2023
f56a108
[Discover] Remove background from panels
jughosta Sep 5, 2023
dbe7a7f
[Discover] Update field list styles
jughosta Sep 5, 2023
f5d1996
[Discover] Update Add Field button
jughosta Sep 5, 2023
9a139e3
[Discover] Remove tabs background
jughosta Sep 5, 2023
2eddea6
[Discover] Apply item shadow changes only for discover
jughosta Sep 5, 2023
15693c9
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine Sep 5, 2023
604d722
[Discover] Swap checkbox and arrow back
jughosta Sep 5, 2023
7e59c76
[Discover] Update context app layout to remove extra horizontal margin
jughosta Sep 5, 2023
46d813c
[Discover] Add top border to grid controls
jughosta Sep 5, 2023
1820c3a
[Discover] Change how shadow is overriden
jughosta Sep 5, 2023
3ffc0ff
Merge remote-tracking branch 'origin/164661-discover-panels-redesign'…
jughosta Sep 5, 2023
2e783c3
[Discover] Fix tests
jughosta Sep 5, 2023
1f86e50
[Discover] Remove comment
jughosta Sep 5, 2023
cd4c90c
Merge branch 'main' into 164661-discover-panels-redesign
jughosta Sep 5, 2023
22637f5
Merge branch 'main' into redesign-checkboxes
jughosta Sep 6, 2023
5cd57a0
Merge branch 'main' into 164661-discover-panels-redesign
jughosta Sep 6, 2023
e691ccb
Merge branch '164661-discover-panels-redesign' into discover-redesign-v1
jughosta Sep 6, 2023
4c20cd7
[Discover] Show a drag handle on hover
jughosta Sep 6, 2023
ba5267a
[Discover] Reduce space between items
jughosta Sep 6, 2023
fcc7a24
[Discover] Update bottom button
jughosta Sep 6, 2023
c15f2e4
[Discover] Add collapse/expand buttons
jughosta Sep 6, 2023
296613f
[Discover] Update tests
jughosta Sep 6, 2023
4c5b6e4
[Discover] Rearrange sidebar toggle button
jughosta Sep 6, 2023
25de160
Merge branch 'main' into discover-redesign-v1
jughosta Sep 6, 2023
68bac23
[Discover] Cleanup translations
jughosta Sep 6, 2023
84e11a4
[Discover] Update tests
jughosta Sep 6, 2023
a94212a
[Discover] Update tests
jughosta Sep 6, 2023
cf1f1bc
[Discover] Fix drag handle theme
jughosta Sep 6, 2023
68c3208
[Discover] Fix sidebar toggle theme
jughosta Sep 6, 2023
c8cf870
Merge branch 'main' into discover-redesign-v1
jughosta Sep 6, 2023
d8a0666
[Discover] Update tests
jughosta Sep 6, 2023
eb0f3d2
Merge remote-tracking branch 'origin/discover-redesign-v1' into disco…
jughosta Sep 6, 2023
20064d6
Merge branch 'main' into discover-redesign-v1
jughosta Sep 7, 2023
ab2c54e
[Discover] Update sidebar toggle icons to old ones
jughosta Sep 7, 2023
1d8ae3b
[Discover] Remove sidebar item drag icon
jughosta Sep 7, 2023
47b4595
[Discover] Update padding on Single Document page
jughosta Sep 7, 2023
eeb633f
Update src/plugins/discover/public/application/context/context_app.tsx
jughosta Sep 7, 2023
ac89e52
[Discover] Remove the border above tabs
jughosta Sep 7, 2023
12f56be
[Discover] Move sidebar toggle logic from discover plugin to unified …
jughosta Sep 7, 2023
84ef775
[Discover] Make bottom button style customizable and fix it for the f…
jughosta Sep 7, 2023
f8ff9c5
[Discover] Enable sidebar toggle for example page
jughosta Sep 7, 2023
f2171cc
[Discover] Clean up tests
jughosta Sep 7, 2023
6aafce3
Merge branch 'main' into discover-redesign-v1
jughosta Sep 7, 2023
f631110
[Discover] Update histogram test
jughosta Sep 7, 2023
44bf5de
Merge branch 'main' into discover-redesign-v1
jughosta Sep 7, 2023
5357b53
Remove some whitespace around the Unified Histogram resize button
davismcphee Sep 7, 2023
ddb0795
[Discover] Fix flyout button action
jughosta Sep 8, 2023
4325927
[Discover] Add top level configuration for the compressed view
jughosta Sep 8, 2023
b34d3bc
[Discover] Add bottom border for Field Statistics tab
jughosta Sep 8, 2023
1ec4869
Merge pull request #5 from davismcphee/discover-redesign-resize-button
jughosta Sep 8, 2023
ee354cd
[Discover] Overwrite item background and cleanup
jughosta Sep 8, 2023
0aaf693
Merge branch 'main' into discover-redesign-v1
jughosta Sep 8, 2023
951fe65
Fix Unified Field List drag styles
davismcphee Sep 9, 2023
a93943c
[Discover] Fine tune row controls positioning
jughosta Sep 9, 2023
55daac1
Merge pull request #6 from davismcphee/discover-redesign-drag-fix
jughosta Sep 11, 2023
920ba5b
Merge branch 'main' into discover-redesign-v1
jughosta Sep 11, 2023
c824954
Merge branch 'main' into discover-redesign-v1
jughosta Sep 11, 2023
dec3d35
[Discover] Make time field column a little wider
jughosta Sep 11, 2023
a1173fa
[Discover] Fix row controls on Surrounding Documents page
jughosta Sep 11, 2023
b54538e
[Discover] Update test snapshots
jughosta Sep 11, 2023
d55d577
Merge branch 'main' into discover-redesign-v1
jughosta Sep 11, 2023
ee7807a
Merge branch 'main' into discover-redesign-v1
jughosta Sep 11, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ const getCreationOptions: UnifiedFieldListSidebarContainerProps['getCreationOpti
originatingApp: PLUGIN_ID,
localStorageKeyPrefix: 'examples',
timeRangeUpdatesType: 'timefilter',
compressed: true,
showSidebarToggleButton: true,
disablePopularFields: true,
};
};
Expand Down
22 changes: 22 additions & 0 deletions packages/kbn-dom-drag-drop/src/drag_drop.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,28 @@ describe('DragDrop', () => {
});
});

test('dragstart sets dragClassName as expected', async () => {
const dndDispatch = jest.fn();
const component = mount(
<ChildDragDropProvider value={[{ ...defaultContextState, dragging: undefined }, dndDispatch]}>
<DragDrop value={value} draggable={true} order={[2, 0, 1, 0]} dragClassName="dragTest">
<button>Hi!</button>
</DragDrop>
</ChildDragDropProvider>
);
const dragDrop = component.find('[data-test-subj="testDragDrop"]').at(0);

expect(dragDrop.getDOMNode().querySelector('.dragTest')).toBeNull();
dragDrop.simulate('dragstart', { dataTransfer });
expect(dragDrop.getDOMNode().querySelector('.dragTest')).toBeDefined();

act(() => {
jest.runAllTimers();
});

expect(dragDrop.getDOMNode().querySelector('.dragTest')).toBeNull();
});

test('drop resets all the things', async () => {
const preventDefault = jest.fn();
const stopPropagation = jest.fn();
Expand Down
17 changes: 17 additions & 0 deletions packages/kbn-dom-drag-drop/src/drag_drop.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ interface BaseProps {
* The CSS class(es) for the root element.
*/
className?: string;
/**
* CSS class to apply when the item is being dragged
*/
dragClassName?: string;

/**
* The event handler that fires when an item
Expand Down Expand Up @@ -212,6 +216,7 @@ const removeSelection = () => {
const DragInner = memo(function DragInner({
dataTestSubj,
className,
dragClassName,
value,
children,
dndDispatch,
Expand Down Expand Up @@ -305,6 +310,18 @@ const DragInner = memo(function DragInner({
// so we know we have DraggableProps if we reach this code.
if (e && 'dataTransfer' in e) {
e.dataTransfer.setData('text', value.humanData.label);

// Apply an optional class to the element being dragged so the ghost
// can be styled. We must add it to the actual element for a single
// frame before removing it so the ghost picks up the styling.
const current = e.currentTarget;

if (dragClassName && !current.classList.contains(dragClassName)) {
current.classList.add(dragClassName);
requestAnimationFrame(() => {
current.classList.remove(dragClassName);
});
}
Comment on lines +313 to +324
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@davismcphee helped here to improve the view of a dragging item on Discover jughosta#6

}

// Chrome causes issues if you try to render from within a
Expand Down
85 changes: 51 additions & 34 deletions packages/kbn-unified-data-table/src/components/data_table.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,6 @@
max-width: 100%;
height: 100%;
overflow: hidden;
border-radius: $euiBorderRadius;

.euiDataGrid__controls {
border: none;
border-bottom: $euiBorderThin;
}

.euiDataGridRowCell.euiDataGridRowCell--firstColumn {
border-left: none;
padding: 0;
}

.euiDataGridRowCell.euiDataGridRowCell--lastColumn {
border-right: none;
}

.unifiedDataTable__table .euiDataGridRowCell:first-of-type,
.unifiedDataTable__table .euiDataGrid--headerShade.euiDataGrid--bordersAll .euiDataGridHeaderCell:first-of-type {
border-left: none;
border-right: none;
}

.euiDataGridRowCell:last-of-type,
.euiDataGridHeaderCell:last-of-type {
border-right: none;
}
}

.unifiedDataTable__cellValue {
Expand Down Expand Up @@ -57,6 +31,29 @@
flex-direction: column;
flex-wrap: nowrap;
height: 100%;

.euiDataGrid__content {
background: transparent;
}

.euiDataGrid__controls {
border-top: $euiBorderThin;
}

.euiDataGrid--headerUnderline .euiDataGridHeaderCell {
border-bottom: $euiBorderThin;
}

.euiDataGridRowCell.euiDataGridRowCell--controlColumn[data-gridcell-column-id='openDetails'],
.euiDataGridRowCell.euiDataGridRowCell--controlColumn[data-gridcell-column-id='select'] {
padding-left: 0;
padding-right: 0;
}

.euiDataGrid--rowHoverHighlight .euiDataGridRow:hover,
.euiDataGrid--rowHoverHighlight .euiDataGridRow:hover .euiDataGridRowCell__contentByHeight + .euiDataGridRowCell__expandActions {
background-color: tintOrShade($euiColorLightShade, 50%, 0);
}
}

.unifiedDataTable__table {
Expand All @@ -65,14 +62,6 @@
min-height: 0;
}

.unifiedDataTable__footer {
flex-shrink: 0;
background-color: $euiColorLightShade;
padding: $euiSize / 2 $euiSize;
margin-top: $euiSize / 4;
text-align: center;
}

.unifiedDataTable__flyoutHeader {
white-space: nowrap;
}
Expand Down Expand Up @@ -118,7 +107,35 @@
@include euiTextTruncate;
}

.unifiedDataTable__rowControl {
// fine-tuning the vertical alignment with the text for any row height setting
margin-top: -3px;
.euiDataGridRowCell__truncate & { // "Single line" row height setting
margin-top: 0;
}
}

.unifiedDataTable__descriptionList {
// force the content truncation when "Single line" row height setting is active
.euiDataGridRowCell__truncate & {
-webkit-line-clamp: 1;
display: -webkit-box;
-webkit-box-orient: vertical;
height: 100%;
overflow: hidden;
}
}

.unifiedDataTable__descriptionListTitle {
margin-inline: 0 0;
padding-inline: 0;
background: transparent;
font-weight: $euiFontWeightBold;
}

.unifiedDataTable__descriptionListDescription {
margin-inline: $euiSizeS $euiSizeS;
padding-inline: 0;
Comment on lines +129 to +138
Copy link
Member

Choose a reason for hiding this comment

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

worth to note that these changes will also resolve #146339 🥳

word-break: break-all;
white-space: normal;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import { buildEditFieldButton } from './build_edit_field_button';

const openDetails = {
id: 'openDetails',
width: 24,
width: 26,
headerCellRender: () => (
<EuiScreenReaderOnly>
<span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,19 @@ import {
EuiCopy,
EuiDataGridCellValueElementProps,
EuiPopover,
EuiFlexGroup,
EuiFlexItem,
useEuiTheme,
} from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n-react';
import { euiDarkVars as themeDark, euiLightVars as themeLight } from '@kbn/ui-theme';
import { i18n } from '@kbn/i18n';
import { css } from '@emotion/react';
import type { DataTableRecord } from '@kbn/discover-utils/types';
import { UnifiedDataTableContext } from '../table_context';

export const SelectButton = ({ rowIndex, setCellProps }: EuiDataGridCellValueElementProps) => {
const { euiTheme } = useEuiTheme();
const { selectedDocs, expanded, rows, isDarkMode, setSelectedDocs } =
useContext(UnifiedDataTableContext);
const doc = useMemo(() => rows[rowIndex], [rows, rowIndex]);
Expand All @@ -46,20 +51,33 @@ export const SelectButton = ({ rowIndex, setCellProps }: EuiDataGridCellValueEle
}, [expanded, doc, setCellProps, isDarkMode]);

return (
<EuiCheckbox
id={doc.id}
aria-label={toggleDocumentSelectionLabel}
checked={checked}
data-test-subj={`dscGridSelectDoc-${doc.id}`}
onChange={() => {
if (checked) {
const newSelection = selectedDocs.filter((docId) => docId !== doc.id);
setSelectedDocs(newSelection);
} else {
setSelectedDocs([...selectedDocs, doc.id]);
}
}}
/>
<EuiFlexGroup
responsive={false}
direction="column"
justifyContent="center"
className="unifiedDataTable__rowControl"
css={css`
padding-block: ${euiTheme.size.xs}; // to have the same height as "openDetails" control
padding-left: ${euiTheme.size.xs}; // space between controls
`}
>
<EuiFlexItem grow={false}>
<EuiCheckbox
id={doc.id}
aria-label={toggleDocumentSelectionLabel}
checked={checked}
data-test-subj={`dscGridSelectDoc-${doc.id}`}
onChange={() => {
if (checked) {
const newSelection = selectedDocs.filter((docId) => docId !== doc.id);
setSelectedDocs(newSelection);
} else {
setSelectedDocs([...selectedDocs, doc.id]);
}
}}
/>
</EuiFlexItem>
</EuiFlexGroup>
);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,23 +62,25 @@ export const ExpandButton = ({ rowIndex, setCellProps }: EuiDataGridCellValueEle
}

return (
<EuiToolTip content={buttonLabel} delay="long" ref={toolTipRef}>
<EuiButtonIcon
id={rowIndex === 0 ? tourStep : undefined}
size="xs"
iconSize="s"
aria-label={buttonLabel}
data-test-subj={testSubj}
onClick={() => {
const nextHit = isCurrentRowExpanded ? undefined : current;
toolTipRef.current?.hideToolTip();
setPressed(Boolean(nextHit));
setExpanded?.(nextHit);
}}
color={isCurrentRowExpanded ? 'primary' : 'text'}
iconType={isCurrentRowExpanded ? 'minimize' : 'expand'}
isSelected={isCurrentRowExpanded}
/>
</EuiToolTip>
<div className="unifiedDataTable__rowControl">
<EuiToolTip content={buttonLabel} delay="long" ref={toolTipRef}>
<EuiButtonIcon
id={rowIndex === 0 ? tourStep : undefined}
size="xs"
iconSize="s"
aria-label={buttonLabel}
data-test-subj={testSubj}
onClick={() => {
const nextHit = isCurrentRowExpanded ? undefined : current;
toolTipRef.current?.hideToolTip();
setPressed(Boolean(nextHit));
setExpanded?.(nextHit);
}}
color={isCurrentRowExpanded ? 'primary' : 'text'}
iconType={isCurrentRowExpanded ? 'minimize' : 'expand'}
isSelected={isCurrentRowExpanded}
/>
</EuiToolTip>
</div>
);
};
12 changes: 7 additions & 5 deletions packages/kbn-unified-data-table/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@ export const defaultMonacoEditorWidth = 370;
export const defaultTimeColumnWidth = 210;
export const kibanaJSON = 'kibana-json';

export const GRID_STYLE = {
border: 'all',
export const GRID_STYLE: EuiDataGridStyle = {
border: 'horizontal',
fontSize: 's',
cellPadding: 's',
rowHover: 'none',
} as EuiDataGridStyle;
cellPadding: 'l',
rowHover: 'highlight',
header: 'underline',
stripes: true,
};

export const toolbarVisibility = {
showColumnSelector: {
Expand Down
Loading