-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Use push flyout for Discover document flyout #166406
Changes from all commits
cadd8d8
23dc630
58cc26e
b164831
cea1288
deaa9ee
70d7127
083921c
54d24b6
a9072e4
b583a9d
ab29999
8e70fb3
0b97736
3b4cb11
28483cd
5e9b816
e8028d9
2d2eb32
ddf3694
dfebc40
9942d54
6ca57ec
a83c461
46d4424
8c1bdec
865fed9
785c75f
a5d409a
8b3d9f8
1de9a94
da63a18
f488e70
816fafc
0156206
8ab3fd7
b268e75
88c7b05
ec72196
e1f6667
8e362f3
42d6612
4e995f7
8cfa359
40be3e2
8866baf
f86a39d
9abcf27
8d69a43
6f462be
f48a840
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,20 +14,25 @@ import type { DataView } from '@kbn/data-views-plugin/public'; | |
import { | ||
EuiFlexGroup, | ||
EuiFlexItem, | ||
EuiFlyout, | ||
EuiFlyoutResizable, | ||
EuiFlyoutBody, | ||
EuiFlyoutFooter, | ||
EuiFlyoutHeader, | ||
EuiTitle, | ||
EuiSpacer, | ||
EuiPortal, | ||
EuiPagination, | ||
keys, | ||
EuiButtonEmpty, | ||
useEuiTheme, | ||
useIsWithinMinBreakpoint, | ||
} from '@elastic/eui'; | ||
import type { Filter, Query, AggregateQuery } from '@kbn/es-query'; | ||
import type { DataTableRecord } from '@kbn/discover-utils/types'; | ||
import type { DocViewFilterFn } from '@kbn/unified-doc-viewer/types'; | ||
import type { DataTableColumnsMeta } from '@kbn/unified-data-table'; | ||
import { UnifiedDocViewer } from '@kbn/unified-doc-viewer-plugin/public'; | ||
import useLocalStorage from 'react-use/lib/useLocalStorage'; | ||
import { useDiscoverServices } from '../../hooks/use_discover_services'; | ||
import { isTextBasedQuery } from '../../application/main/utils/is_text_based_query'; | ||
import { useFlyoutActions } from './use_flyout_actions'; | ||
|
@@ -55,6 +60,8 @@ function getIndexByDocId(hits: DataTableRecord[], id: string) { | |
return h.id === id; | ||
}); | ||
} | ||
|
||
export const FLYOUT_WIDTH_KEY = 'discover:flyoutWidth'; | ||
/** | ||
* Flyout displaying an expanded Elasticsearch document | ||
*/ | ||
|
@@ -75,6 +82,13 @@ export function DiscoverGridFlyout({ | |
}: DiscoverGridFlyoutProps) { | ||
const services = useDiscoverServices(); | ||
const flyoutCustomization = useDiscoverCustomization('flyout'); | ||
const { euiTheme } = useEuiTheme(); | ||
const isXlScreen = useIsWithinMinBreakpoint('xl'); | ||
const DEFAULT_WIDTH = euiTheme.base * 34; | ||
const defaultWidth = flyoutCustomization?.size ?? DEFAULT_WIDTH; // Give enough room to search bar to not wrap | ||
const [flyoutWidth, setFlyoutWidth] = useLocalStorage(FLYOUT_WIDTH_KEY, defaultWidth); | ||
const minWidth = euiTheme.base * 24; | ||
const maxWidth = euiTheme.breakpoint.xl; | ||
|
||
const isPlainRecord = isTextBasedQuery(query); | ||
// Get actual hit with updated highlighted searches | ||
|
@@ -204,16 +218,24 @@ export function DiscoverGridFlyout({ | |
defaultMessage: 'Document', | ||
}); | ||
const flyoutTitle = flyoutCustomization?.title ?? defaultFlyoutTitle; | ||
const flyoutSize = flyoutCustomization?.size ?? 'm'; | ||
|
||
return ( | ||
<EuiPortal> | ||
<EuiFlyout | ||
<EuiFlyoutResizable | ||
onClose={onClose} | ||
size={flyoutSize} | ||
type="push" | ||
size={flyoutWidth} | ||
pushMinBreakpoint="xl" | ||
data-test-subj="docTableDetailsFlyout" | ||
onKeyDown={onKeyDown} | ||
ownFocus={false} | ||
ownFocus={true} | ||
minWidth={minWidth} | ||
maxWidth={maxWidth} | ||
onResize={setFlyoutWidth} | ||
css={{ | ||
maxWidth: `${isXlScreen ? `calc(100vw - ${DEFAULT_WIDTH}px)` : '90vw'} !important`, | ||
}} | ||
paddingSize="m" | ||
> | ||
<EuiFlyoutHeader hasBorder> | ||
<EuiFlexGroup | ||
|
@@ -225,7 +247,7 @@ export function DiscoverGridFlyout({ | |
> | ||
<EuiFlexItem grow={false}> | ||
<EuiTitle | ||
size="s" | ||
size="xs" | ||
data-test-subj="docTableRowDetailsTitle" | ||
css={css` | ||
white-space: nowrap; | ||
|
@@ -257,7 +279,14 @@ export function DiscoverGridFlyout({ | |
)} | ||
</EuiFlyoutHeader> | ||
<EuiFlyoutBody>{bodyContent}</EuiFlyoutBody> | ||
</EuiFlyout> | ||
<EuiFlyoutFooter> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. From the EUI docs (https://elastic.github.io/eui/#/layout/flyout#push-versus-overlay):
|
||
<EuiButtonEmpty iconType="cross" onClick={onClose} flush="left"> | ||
{i18n.translate('discover.grid.flyout.close', { | ||
defaultMessage: 'Close', | ||
})} | ||
</EuiButtonEmpty> | ||
</EuiFlyoutFooter> | ||
</EuiFlyoutResizable> | ||
</EuiPortal> | ||
); | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -78,17 +78,19 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { | |
it('should display a log level badge when available', async () => { | ||
await dataGrid.clickRowToggle({ columnIndex: 4 }); | ||
await testSubjects.existOrFail('logsExplorerFlyoutLogLevel'); | ||
await dataGrid.closeFlyout(); | ||
}); | ||
|
||
it('should not display a log level badge when not available', async () => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For some reason this test (and the others below) were failing because the web elements had become "stale", and were throwing errors. I'm not sure how the changes in this PR would affect this, but breaking these into separate There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This PR will actually remove most of these tests after moving the doc view implementation, I'll take care of the conflicts but this LGTM. |
||
await dataGrid.clickRowToggle({ rowIndex: 1, columnIndex: 4 }); | ||
await testSubjects.missingOrFail('logsExplorerFlyoutLogLevel'); | ||
}); | ||
|
||
it('should display a message code block when available', async () => { | ||
await dataGrid.clickRowToggle({ columnIndex: 4 }); | ||
await testSubjects.existOrFail('logsExplorerFlyoutLogMessage'); | ||
await dataGrid.closeFlyout(); | ||
}); | ||
|
||
it('should not display a message code block when not available', async () => { | ||
await dataGrid.clickRowToggle({ rowIndex: 1, columnIndex: 4 }); | ||
await testSubjects.missingOrFail('logsExplorerFlyoutLogMessage'); | ||
}); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -80,17 +80,19 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { | |
it('should display a log level badge when available', async () => { | ||
await dataGrid.clickRowToggle({ columnIndex: 4 }); | ||
await testSubjects.existOrFail('logsExplorerFlyoutLogLevel'); | ||
await dataGrid.closeFlyout(); | ||
}); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: I think the flyouts no longer need to be closed in those tests, since we navigate to Discover before each test |
||
|
||
it('should not display a log level badge when not available', async () => { | ||
await dataGrid.clickRowToggle({ rowIndex: 1, columnIndex: 4 }); | ||
await testSubjects.missingOrFail('logsExplorerFlyoutLogLevel'); | ||
}); | ||
|
||
it('should display a message code block when available', async () => { | ||
await dataGrid.clickRowToggle({ columnIndex: 4 }); | ||
await testSubjects.existOrFail('logsExplorerFlyoutLogMessage'); | ||
await dataGrid.closeFlyout(); | ||
}); | ||
|
||
it('should not display a message code block when not available', async () => { | ||
await dataGrid.clickRowToggle({ rowIndex: 1, columnIndex: 4 }); | ||
await testSubjects.missingOrFail('logsExplorerFlyoutLogMessage'); | ||
}); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lukasolson this comment is referring to the element being rendered in the
EuiFlyoutBody
let's bring this over the finishing line by adjusting the responsiveness of the action column of the
DocViewerTable
. Something like this should work with a change at the beginning of theDocViewerTable
component.kibana/src/plugins/unified_doc_viewer/public/components/doc_viewer_table/table.tsx
Lines 111 to 125 in f734170
With
setRef
being used at theEuiFlexGroup
wrapperThen the action column would no longer be responsive to the window width, but to the flyout width, which is a better pattern anyway. Should we use
euiTheme.breakpoint.m
oreuiTheme.breakpoint.l
? Both look good to me.Thx for the feedback @andreadelrio and
useResizeObserver
hint @davismcpheeThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One other note: we should also make the single document and surrounding documents buttons responsive based on the flyout width since they currently use the window width too. We should be able to use the same resize observer approach for both the buttons and table actions.
We could use a preset breakpoint, but it might even be better to just use
euiTheme.base * X
and get a value close to when the UI elements start to "break".