[Discover] [Unified Data Table] Add document comparison mode#166577
[Discover] [Unified Data Table] Add document comparison mode#166577davismcphee merged 73 commits intoelastic:mainfrom
Conversation
3bbbc44 to
5fad331
Compare
|
@davismcphee this is looking amazing! I'm sending you a first round of design-related comments and ideas I would like us to consider:
|
175d1f6 to
6304bab
Compare
|
/ci |
|
/ci |
davismcphee
left a comment
There was a problem hiding this comment.
Thanks for the feedback! I've made some changes based on the suggestions and updated mockups.
What should we do with smart fields?
I think we should treat this as a known bug and address it when we integrate smart fields as a native Discover feature, similar to what we're planning for the field statistics tab. But I can definitely create a separate issue to track it so we don't forget.
From what I understand we pick documents by their id when rendering columns for comparison, right? The thing is that documents can have same ids but come from different indices. We had such bug in DocViewer in the past.
The comparison mode is based on our existing selected documents logic, which depends on the generated ID in DataTableRecord to guarantee uniqueness. The only place we use the raw document ID is for displaying in the comparison table headers (so we could technically see a duplicate ID in the headers, although I think the chances of that happening are quite low, and the functionality will still work as expected):
kibana/packages/kbn-discover-utils/src/utils/get_doc_id.ts
Lines 10 to 17 in 001f24c
...ges/kbn-unified-data-table/src/components/compare_documents/hooks/use_comparison_columns.tsx
Outdated
Show resolved
Hide resolved
...ges/kbn-unified-data-table/src/components/compare_documents/hooks/use_comparison_columns.tsx
Show resolved
Hide resolved
packages/kbn-unified-data-table/src/components/data_table_document_selection.tsx
Outdated
Show resolved
Hide resolved
packages/kbn-unified-data-table/src/components/compare_documents/comparison_controls.tsx
Outdated
Show resolved
Hide resolved
amyjtechwriter
left a comment
There was a problem hiding this comment.
LGTM, labels and docs side. Hopefully I have answered all the comments tagged in but if I've missed anything please let me know!
jughosta
left a comment
There was a problem hiding this comment.
Looking great!
I like the separate "Compare" button! The new highlight on both buttons seem a bit distracting though.
I also tested a case when user selects documents for comparison, then changes the time range and those documents are gone. We could probably improve UI by showing a message that documents are not available anymore or something like it.
| setSelectedDocs, | ||
| setIsCompareActive, | ||
| }: CompareDocumentsProps) => { | ||
| const [showDiff, setShowDiff] = useLocalStorage(getStorageKey(consumer, 'ShowDiff'), true); |
There was a problem hiding this comment.
If user toggles "Show diff" off, exits the comparison mode, then next time they press "Compare" button, should not it get enabled again? Otherwise why to go to comparison mode if it's off.
There was a problem hiding this comment.
I think we should keep this in local storage to be consistent with the other settings. In most cases users probably won't have a reason to disable diffing, but there are some legitimate use cases such as just wanting to view multiple documents in a vertical format similar to the doc viewer, or wanting to retain the original colours when viewing documents that use the colour field formatter instead of having them overwritten by the diff colours. This way they can exist comparison mode, select more documents, and return to comparison mode without having to keep disabling "Show diff".
@davismcphee I agree with Julia. I think with the new dedicated |
andreadelrio
left a comment
There was a problem hiding this comment.
@davismcphee Thanks for implementing the changes to this menu. Adding some comments below.
I think leaving the Basic/Advanced options enabled when Show diff is set to off looks a bit odd. We could consider disabling them when Show diff is set to off and adding a tooltip explaining why such as "You need to enable Show diff".
Same goes for the Show diff decorations toggle. If Show diff is set to off, this toggle should be disabled.
…loses access to them
davismcphee
left a comment
There was a problem hiding this comment.
@jughosta @andreadelrio thanks both for the feedback!
I updated both of the button badges back to the original colour now:

I also updated the settings menu to disable the diff mode entries and decorations switch, and added a tooltip, when "Show diff" is off:

I also tested a case when user selects documents for comparison, then changes the time range and those documents are gone. We could probably improve UI by showing a message that documents are not available anymore or something like it.
@jughosta good catch! Rather than showing a message when the documents are no longer available, I instead made it so the columns remain visible in the comparison table until the user exists comparison mode: 8c5bcaa. I feel like this is a bit more friendly to users so they don't accidentally lose the documents they're comparing if they trigger a refetch or have auto refresh enabled. WDYT?
...ges/kbn-unified-data-table/src/components/compare_documents/hooks/use_comparison_columns.tsx
Show resolved
Hide resolved
...ges/kbn-unified-data-table/src/components/compare_documents/hooks/use_comparison_columns.tsx
Show resolved
Hide resolved
| setSelectedDocs, | ||
| setIsCompareActive, | ||
| }: CompareDocumentsProps) => { | ||
| const [showDiff, setShowDiff] = useLocalStorage(getStorageKey(consumer, 'ShowDiff'), true); |
There was a problem hiding this comment.
I think we should keep this in local storage to be consistent with the other settings. In most cases users probably won't have a reason to disable diffing, but there are some legitimate use cases such as just wanting to view multiple documents in a vertical format similar to the doc viewer, or wanting to retain the original colours when viewing documents that use the colour field formatter instead of having them overwritten by the diff colours. This way they can exist comparison mode, select more documents, and return to comparison mode without having to keep disabling "Show diff".
andreadelrio
left a comment
There was a problem hiding this comment.
Superb job on this Davis! I'm approving now but I would like to confirm with @amyjtechwriter whether the text in the new tooltip looks good to her.
|
Hey hey, we can keep "You need to enable Show Diff" or if you think it's just as clear we could just use "Enable Show diff". I don't have a super strong preference here, so I think go with the one you like best :) |
kertal
left a comment
There was a problem hiding this comment.
Such a great feature, so much great fine tuning! Really great work 🥳 Let's 🚢 !
Great work, Davis! My favourite feature now! 👍 🎉
And thanks, @kertal, for proposing it!
Thx to @andreadelrio for the mockups in 2021 built by just a very basic description in the issue we resolve. Something like this is so important showing a potential useful concept in action. One can write a lot of good description how something should work, but an animated mock is always better 👍
💛 Build succeeded, but was flaky
Failed CI StepsTest Failures
Metrics [docs]Module Count
Public APIs missing comments
Async chunks
Page load bundle
Unknown metric groupsAPI count
async chunk count
ESLint disabled line counts
Total ESLint disabled count
History
To update your PR or re-run it, just comment with: |
|
Thanks all for helping bring this over the finish line! It seems like we're good with the current tooltip text, so I'm going to merge this now 🙂 |








Summary
This PR adds a new document comparison mode to Discover and Unified Data Table:

Flaky test runner x50: https://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/5590.
Resolves #93567.
Checklist
For maintainers