Skip to content

Commit

Permalink
[Onboarding] Search detail document list tweaks (#194804)
Browse files Browse the repository at this point in the history
## Summary

- Implemented priority ordering of fields. Semantic_text, dense_vector,
sparse_vector comes first + special field names.
- give extra information + copy action for dense_vector fields
- updated the design for the non compact view


![Screenshot 2024-10-10 at 16 12
58](https://github.com/user-attachments/assets/34b89455-6184-4a41-b9e3-8d67a1926f95)

  

### Checklist

Delete any items that are not applicable to this PR.

- [ ] Any text added follows [EUI's writing
guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses
sentence case text and includes [i18n
support](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)
- [ ]
[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)
was added for features that require explanation or tutorials
- [ ] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
- [ ] [Flaky Test
Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was
used on any tests changed
- [ ] Any UI touched in this PR is usable by keyboard only (learn more
about [keyboard accessibility](https://webaim.org/techniques/keyboard/))
- [ ] Any UI touched in this PR does not create any new axe failures
(run axe in browser:
[FF](https://addons.mozilla.org/en-US/firefox/addon/axe-devtools/),
[Chrome](https://chrome.google.com/webstore/detail/axe-web-accessibility-tes/lhdoppojpmngadmnindnejefpokejbdd?hl=en-US))
- [ ] If a plugin configuration key changed, check if it needs to be
allowlisted in the cloud and added to the [docker
list](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)
- [ ] This renders correctly on smaller devices using a responsive
layout. (You can test this [in your
browser](https://www.browserstack.com/guide/responsive-testing-on-local-server))
- [ ] This was checked for [cross-browser
compatibility](https://www.elastic.co/support/matrix#matrix_browsers)


### Risk Matrix

Delete this section if it is not applicable to this PR.

Before closing this PR, invite QA, stakeholders, and other developers to
identify risks that should be tested prior to the change/feature
release.

When forming the risk matrix, consider some of the following examples
and how they may potentially impact the change:

| Risk | Probability | Severity | Mitigation/Notes |

|---------------------------|-------------|----------|-------------------------|
| Multiple Spaces—unexpected behavior in non-default Kibana Space.
| Low | High | Integration tests will verify that all features are still
supported in non-default Kibana Space and when user switches between
spaces. |
| Multiple nodes—Elasticsearch polling might have race conditions
when multiple Kibana nodes are polling for the same tasks. | High | Low
| Tasks are idempotent, so executing them multiple times will not result
in logical error, but will degrade performance. To test for this case we
add plenty of unit tests around this logic and document manual testing
procedure. |
| Code should gracefully handle cases when feature X or plugin Y are
disabled. | Medium | High | Unit tests will verify that any feature flag
or plugin combination still results in our service operational. |
| [See more potential risk
examples](https://github.com/elastic/kibana/blob/main/RISK_MATRIX.mdx) |


### For maintainers

- [ ] This was checked for breaking API changes and was [labeled
appropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)

---------

Co-authored-by: Julian Rosado <[email protected]>
  • Loading branch information
joemcelroy and julianrosado authored Oct 11, 2024
1 parent ab248df commit 2f54dc8
Show file tree
Hide file tree
Showing 12 changed files with 309 additions and 155 deletions.
10 changes: 10 additions & 0 deletions packages/kbn-search-index-documents/components/result/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the "Elastic License
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/

export const PERMANENTLY_TRUNCATED_FIELDS = ['dense_vector', 'sparse_vector'];
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ export {
resultMetaData,
resultToFieldFromMappingResponse,
resultToFieldFromMappings as resultToField,
reorderFieldsInImportance,
} from './result_metadata';
34 changes: 25 additions & 9 deletions packages/kbn-search-index-documents/components/result/result.scss
Original file line number Diff line number Diff line change
@@ -1,20 +1,36 @@
.resultField:nth-child(odd) {
background-color: $euiColorLightestShade;
}

.resultField {
padding: $euiSizeXS $euiSizeS;
padding: 0;
border-bottom: 1px solid $euiColorLightShade;
position: relative;

&:last-child {
border-bottom: none;
}

> .euiTableRowCell {
>.euiTableRow:hover {
background-color: $euiColorEmptyShade;
}

>.euiTableRowCell {
border-top: none;
border-bottom: none;

> .euiTableCellContent {
padding: $euiSizeXS;
>.euiTableCellContent {
padding: $euiSizeS;
font-family: $euiCodeFontFamily;
color: $euiColorMediumShade;
}
}
}

.denseVectorFieldValue {
position: absolute;
right: 0;
top: $euiSizeS;
background-color: $euiColorEmptyShade;
padding: 0 $euiSizeS;
}

.resultExpandColumn {
border-left: $euiBorderThin;
align-items: flex-start;
Expand All @@ -31,4 +47,4 @@
display: flex;
align-items: center;
justify-content: flex-start;
}
}
152 changes: 59 additions & 93 deletions packages/kbn-search-index-documents/components/result/result.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import {
EuiButtonIcon,
EuiFlexGroup,
EuiFlexItem,
EuiPanel,
EuiSpacer,
EuiHorizontalRule,
EuiSplitPanel,
EuiToolTip,
} from '@elastic/eui';

Expand Down Expand Up @@ -66,99 +66,65 @@ export const Result: React.FC<ResultProps> = ({
const toolTipContent = <>{tooltipText}</>;

return (
<EuiPanel
hasBorder
data-test-subj="search-index-documents-result"
paddingSize={compactCard ? 's' : 'l'}
>
<EuiFlexGroup gutterSize="none">
<EuiFlexItem>
<EuiFlexGroup
direction="column"
gutterSize="none"
responsive={false}
justifyContent="spaceAround"
>
<EuiFlexItem grow={false}>
{compactCard && (
<ResultHeader
title={
metaData.title ??
i18n.translate('searchIndexDocuments.result.title.id', {
defaultMessage: 'Document id: {id}',
values: { id: metaData.id },
})
}
metaData={{
...metaData,
onDocumentDelete,
}}
/>
)}
{!compactCard && (
<RichResultHeader
showScore={showScore}
title={
metaData.title ??
i18n.translate('searchIndexDocuments.result.title.id', {
defaultMessage: 'Document id: {id}',
values: { id: metaData.id },
})
}
onTitleClick={onDocumentClick}
metaData={{
...metaData,
onDocumentDelete,
}}
rightSideActions={
<EuiFlexItem grow={false}>
<EuiToolTip position="left" content={toolTipContent}>
<EuiButtonIcon
iconType={isExpanded ? 'fold' : 'unfold'}
color={isExpanded ? 'danger' : 'primary'}
onClick={(e: React.MouseEvent<HTMLElement>) => {
e.stopPropagation();
setIsExpanded(!isExpanded);
}}
aria-label={tooltipText}
/>
</EuiToolTip>
</EuiFlexItem>
}
/>
)}
</EuiFlexItem>
<EuiFlexItem>
{!compactCard &&
((isExpanded && fields.length > 0) ||
(!isExpanded && fields.slice(0, defaultVisibleFields).length > 0)) && (
<EuiSpacer size="l" />
)}
<ResultFields
isExpanded={isExpanded}
fields={isExpanded ? fields : fields.slice(0, defaultVisibleFields)}
<EuiSplitPanel.Outer hasBorder={true} data-test-subj="search-index-documents-result">
<EuiSplitPanel.Inner paddingSize="m" color="plain" className="resultHeaderContainer">
<EuiFlexGroup gutterSize="none" alignItems="center">
<EuiFlexItem>
{compactCard && (
<ResultHeader
title={
metaData.title ??
i18n.translate('searchIndexDocuments.result.title.id', {
defaultMessage: 'Document id: {id}',
values: { id: metaData.id },
})
}
metaData={metaData}
/>
</EuiFlexItem>
</EuiFlexGroup>
</EuiFlexItem>
{compactCard && (
)}

{!compactCard && (
<RichResultHeader
showScore={showScore}
title={
metaData.title ??
i18n.translate('searchIndexDocuments.result.title.id', {
defaultMessage: 'Document id: {id}',
values: { id: metaData.id },
})
}
onTitleClick={onDocumentClick}
metaData={{
...metaData,
onDocumentDelete,
}}
/>
)}
</EuiFlexItem>
<EuiFlexItem grow={false}>
<div className="resultExpandColumn">
<EuiToolTip position="left" content={toolTipContent}>
<EuiButtonIcon
iconType={isExpanded ? 'fold' : 'unfold'}
color="text"
onClick={(e: React.MouseEvent<HTMLElement>) => {
e.stopPropagation();
setIsExpanded(!isExpanded);
}}
aria-label={tooltipText}
/>
</EuiToolTip>
</div>
<EuiToolTip position="left" content={toolTipContent}>
<EuiButtonIcon
size="xs"
iconType={isExpanded ? 'fold' : 'unfold'}
color={isExpanded ? 'danger' : 'primary'}
data-test-subj={isExpanded ? 'documentShowLessFields' : 'documentShowMoreFields'}
onClick={(e: React.MouseEvent<HTMLElement>) => {
e.stopPropagation();
setIsExpanded(!isExpanded);
}}
aria-label={tooltipText}
/>
</EuiToolTip>
</EuiFlexItem>
)}
</EuiFlexGroup>
</EuiPanel>
</EuiFlexGroup>
</EuiSplitPanel.Inner>
<EuiHorizontalRule margin="none" />
<EuiSplitPanel.Inner paddingSize="m">
<ResultFields
isExpanded={isExpanded}
fields={isExpanded ? fields : fields.slice(0, defaultVisibleFields)}
/>
</EuiSplitPanel.Inner>
</EuiSplitPanel.Outer>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,12 @@

import React from 'react';

import {
EuiCodeBlock,
EuiIcon,
EuiTableRow,
EuiTableRowCell,
EuiText,
EuiToken,
} from '@elastic/eui';
import { EuiTableRow, EuiTableRowCell, EuiText, EuiToken } from '@elastic/eui';

import { euiThemeVars } from '@kbn/ui-theme';
import { ResultFieldProps } from './result_types';
import { PERMANENTLY_TRUNCATED_FIELDS } from './constants';
import { ResultFieldValue } from './result_field_value';

const iconMap: Record<string, string> = {
boolean: 'tokenBoolean',
Expand Down Expand Up @@ -64,9 +59,11 @@ export const ResultField: React.FC<ResultFieldProps> = ({
iconType,
fieldName,
fieldValue,
fieldType,
fieldType = 'object',
isExpanded,
}) => {
const shouldTruncate = !isExpanded || PERMANENTLY_TRUNCATED_FIELDS.includes(fieldType);

return (
<EuiTableRow className="resultField">
<EuiTableRowCell className="resultFieldRowCell" width={euiThemeVars.euiSizeL} valign="middle">
Expand All @@ -79,31 +76,16 @@ export const ResultField: React.FC<ResultFieldProps> = ({
</EuiTableRowCell>
<EuiTableRowCell
className="resultFieldRowCell"
width="25%"
width="20%"
truncateText={!isExpanded}
valign="middle"
>
<EuiText size="xs">{fieldName}</EuiText>
</EuiTableRowCell>
<EuiTableRowCell
className="resultFieldRowCell"
width={euiThemeVars.euiSizeXXL}
valign="middle"
>
<EuiIcon type="sortRight" color="subdued" />
<EuiText size="s" color="default">
{fieldName}
</EuiText>
</EuiTableRowCell>
<EuiTableRowCell className="resultFieldRowCell" truncateText={!isExpanded} valign="middle">
{(fieldType === 'object' ||
fieldType === 'array' ||
fieldType === 'nested' ||
Array.isArray(fieldValue)) &&
isExpanded ? (
<EuiCodeBlock language="json" overflowHeight="250" transparentBackground>
{fieldValue}
</EuiCodeBlock>
) : (
<EuiText size="xs">{fieldValue}</EuiText>
)}
<EuiTableRowCell className="resultFieldRowCell" truncateText={shouldTruncate} valign="middle">
<ResultFieldValue fieldValue={fieldValue} fieldType={fieldType} isExpanded={isExpanded} />
</EuiTableRowCell>
</EuiTableRow>
);
Expand Down
Loading

0 comments on commit 2f54dc8

Please sign in to comment.