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][DocViewer] Limit the height of long field values by default #183736

Merged
merged 28 commits into from
Aug 10, 2024

Conversation

jughosta
Copy link
Contributor

@jughosta jughosta commented May 17, 2024

Summary

This PR adds a default height limit for values in DocViewer. If the value is too long, we visually truncate it and add "View more" button which allows to expand to view the entire value. This way all fields in the flyout are easily accessible (less scrolling required) even if they contain long values. The height can be configured via the existing truncate:maxHeight Advanced Setting. If user expands a value, closes the flyout and opens it again, the value will be shown as expanded again for that field.

Aug-02-2024 10-24-58

Related: #164236

Testing

Some cases to check while testing:

  • varios value formats
  • legacy table vs data grid
  • doc viewer flyout vs Single Document page

Sample long value:

POST test_this/_doc/
{
  "message": """javax.servlet.ServletException: Something bad happened
    at com.example.myproject.OpenSessionInViewFilter.doFilter(OpenSessionInViewFilter.java:60)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    at com.example.myproject.ExceptionHandlerFilter.doFilter(ExceptionHandlerFilter.java:28)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    at com.example.myproject.OutputBufferFilter.doFilter(OutputBufferFilter.java:33)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388)
    at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
    at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
    at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
    at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418)
    at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
    at org.mortbay.jetty.Server.handle(Server.java:326)
    at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
    at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:943)
    at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:756)
    at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:218)
    at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
    at org.mortbay.jetty.bio.SocketConnector$Connection.run(SocketConnector.java:228)
    at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)
Caused by: com.example.myproject.MyProjectServletException
    at com.example.myproject.MyServlet.doPost(MyServlet.java:169)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
    at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1166)
    at com.example.myproject.OpenSessionInViewFilter.doFilter(OpenSessionInViewFilter.java:30)
    ... 27 more
Caused by: org.hibernate.exception.ConstraintViolationException: could not insert: [com.example.myproject.MyEntity]
    at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:96)
    at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
    at org.hibernate.id.insert.AbstractSelectingDelegate.performInsert(AbstractSelectingDelegate.java:64)
    at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2329)
    at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2822)
    at org.hibernate.action.EntityIdentityInsertAction.execute(EntityIdentityInsertAction.java:71)
    at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:268)
    at org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:321)
    at org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:204)
    at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:130)
    at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:210)
    at org.hibernate.event.def.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:56)
    at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:195)
    at org.hibernate.event.def.DefaultSaveEventListener.performSaveOrUpdate(DefaultSaveEventListener.java:50)
    at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:93)
    at org.hibernate.impl.SessionImpl.fireSave(SessionImpl.java:705)
    at org.hibernate.impl.SessionImpl.save(SessionImpl.java:693)
    at org.hibernate.impl.SessionImpl.save(SessionImpl.java:689)
    at sun.reflect.GeneratedMethodAccessor5.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.hibernate.context.ThreadLocalSessionContext$TransactionProtectionWrapper.invoke(ThreadLocalSessionContext.java:344)
    at $Proxy19.save(Unknown Source)
    at com.example.myproject.MyEntityService.save(MyEntityService.java:59) <-- relevant call (see notes below)
    at com.example.myproject.MyServlet.doPost(MyServlet.java:164)
    ... 32 more
Caused by: java.sql.SQLException: Violation of unique constraint MY_ENTITY_UK_1: duplicate value(s) for column(s) MY_COLUMN in statement [...]
    at org.hsqldb.jdbc.Util.throwError(Unknown Source)
    at org.hsqldb.jdbc.jdbcPreparedStatement.executeUpdate(Unknown Source)
    at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeUpdate(NewProxyPreparedStatement.java:105)
    at org.hibernate.id.insert.AbstractSelectingDelegate.performInsert(AbstractSelectingDelegate.java:57)
    ... 54 more"""
}

Checklist

@jughosta jughosta added release_note:enhancement backport:skip This commit does not require backporting Team:DataDiscovery Discover, search (e.g. data plugin and KQL), data views, saved searches. For ES|QL, use Team:ES|QL. Feature:UnifiedDocViewer Issues relating to the unified doc viewer component labels May 17, 2024
@jughosta jughosta self-assigned this May 17, 2024
@jughosta
Copy link
Contributor Author

/ci

@jughosta jughosta marked this pull request as ready for review May 17, 2024 18:25
@jughosta jughosta requested review from a team as code owners May 17, 2024 18:25
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-data-discovery (Team:DataDiscovery)

Copy link
Contributor

@davismcphee davismcphee left a comment

Choose a reason for hiding this comment

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

I haven't tested yet, and I think we definitely need something like this back in the doc viewer for long values, but two thoughts:

  • If we intend to migrate doc viewer to EUI data grid, will this be as useful since users will be able to customize the row height anyway?
  • With the design in this PR, if a user clicks "view more" and the value turns out to be really long, they have to scroll all the way to the end to get to the "view less" button, which seems like it could be a frustrating UX. Something we might want to consider from the design side.

@jughosta
Copy link
Contributor Author

Hi @davismcphee,

If we intend to migrate doc viewer to EUI data grid, will this be as useful since users will be able to customize the row height anyway?

I think it would be still useful. EuiDataGrid allows to truncate all cell values or to auto-show all cell values but there is no option "in between" to show one value while truncating the others for example.

With the design in this PR, if a user clicks "view more" and the value turns out to be really long, they have to scroll all the way to the end to get to the "view less" button, which seems like it could be a frustrating UX. Something we might want to consider from the design side.

Good point. We could also return the arrow button which would be shown above the value.

@kertal
Copy link
Member

kertal commented May 21, 2024

Hi @davismcphee,

If we intend to migrate doc viewer to EUI data grid, will this be as useful since users will be able to customize the row height anyway?

I think it would be still useful. EuiDataGrid allows to truncate all cell values or to auto-show all cell values but there is no option "in between" to show one value while truncating the others for example.

I do agree at the current state I think it is useful at this state and also initially when introducing EuiDataGrid.

With the design in this PR, if a user clicks "view more" and the value turns out to be really long, they have to scroll all the way to the end to get to the "view less" button, which seems like it could be a frustrating UX. Something we might want to consider from the design side.

Good point. We could also return the arrow button which would be shown above the value.

Definitely good point! Visually I like the text buttons more than the expand error, but functional-wise, yes it could lead to lots of scrolling. Wdyt @andreadelrio @isaclfreire , back in the days, be fore we removed it it looked like this:

@jughosta
Copy link
Contributor Author

jughosta commented Jun 3, 2024

@kertal @andreadelrio @davismcphee How should we proceed here? By returning the arrow button?

@davismcphee
Copy link
Contributor

@jughosta It looks like @andreadelrio is on PTO this week, and it would be great to get her input if we can wait until she's back. Otherwise we could reach out to someone else from design instead.

@andreadelrio
Copy link
Contributor

  • to migrate doc viewer to EUI data grid, will this be as useful since users will be able to customize the row height anyway?

Hi team, what if we do something like this? It's borrowing from the proposal I shared when we were going to do #179189. If we choose this direction, I'm happy to add the new icons (plus and minus in square) to EUI.

Frame 1321315041

@davismcphee
Copy link
Contributor

@andreadelrio that works for me!

@kertal
Copy link
Member

kertal commented Jun 11, 2024

@andreadelrio yes, much better than the old expand arrow

jughosta added 2 commits July 3, 2024 14:43
…-values

# Conflicts:
#	src/plugins/unified_doc_viewer/public/components/doc_viewer_table/table.scss
@kertal
Copy link
Member

kertal commented Jul 4, 2024

In the latest iteration @jughosta suggested an existing plus icon, since the new one in not yet available. For consistency of expanding I'd suggest to go with the arrow like back in the days, because it's also used in the field list. We can easily change to the new icons @andreadelrio suggested. I think with placing the arrow on the left side of the text if screen space allows it, it's already looking better. When testing I've noticed that Chrome / Firefox might need a bit less height, at least in my used example it looked like this

Discover_-Elastic_und_Discover-Elastic_und_Discover-_Elastic

@jughosta
Copy link
Contributor Author

jughosta commented Aug 2, 2024

/ci

@jughosta
Copy link
Contributor Author

jughosta commented Aug 2, 2024

/ci

@jughosta
Copy link
Contributor Author

jughosta commented Aug 2, 2024

Ready for review 💫

@jughosta jughosta marked this pull request as ready for review August 2, 2024 13:57
@jughosta jughosta requested a review from a team August 2, 2024 13:58
Copy link
Contributor

@andreadelrio andreadelrio left a comment

Choose a reason for hiding this comment

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

Design changes LGTM. Nice job @jughosta !

Copy link
Contributor

@davismcphee davismcphee left a comment

Choose a reason for hiding this comment

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

The code changes look good and it works well! Just left a couple of minor questions.

const { uiSettings } = getUnifiedDocViewerServices();
let truncateMaxHeight = uiSettings.get(TRUNCATE_MAX_HEIGHT);

if (truncateMaxHeight === TRUNCATE_MAX_HEIGHT_DEFAULT_VALUE) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Rather than piggybacking off the existing legacy doc table max height, I wonder if we shouldn't just introduce a dedicated setting for the doc viewer flyout to avoid this hidden adjustment which seems a bit magical? Adding a new advanced setting isn't great, but ideally we'll be able to get rid of the legacy grid ones soon anyway.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay, agree with your concern. How about making it a fixed configuration in code without introducing another setting and mark the existing one as deprecated?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes let's do that 👍 advanced settings suck anyway so not introducing another is good. I thought about it a bit more too and I think it makes more sense to have this as a user/browser level setting instead if needed, like the ES|QL "hide null values" toggle, so we could discuss it with a designer as a potential followup.

const isCollapsible =
!isDetails &&
truncateMaxHeight > 0 &&
String(rawValue).length > COLLAPSE_LINE_LENGTH &&
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need COLLAPSE_LINE_LENGTH if we're using the div height anyway? Couldn't we base it off only div height instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right, I updated the implementation.

Copy link
Contributor

@davismcphee davismcphee left a comment

Choose a reason for hiding this comment

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

Another quick test and it's still working great 🙌 much cleaner looking than the old version too, thanks!

@jughosta jughosta enabled auto-merge (squash) August 10, 2024 07:45
@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
unifiedDocViewer 278 279 +1

Public APIs missing comments

Total count of every public API that lacks a comment. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats comments for more detailed information.

id before after diff
@kbn/discover-utils 104 105 +1

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
unifiedDocViewer 202.8KB 204.2KB +1.4KB

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
unifiedDocViewer 12.0KB 12.0KB +57.0B
Unknown metric groups

API count

id before after diff
@kbn/discover-utils 130 131 +1

ESLint disabled line counts

id before after diff
unifiedDocViewer 10 9 -1

Total ESLint disabled count

id before after diff
unifiedDocViewer 10 9 -1

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

cc @jughosta

@jughosta jughosta merged commit 625e89e into elastic:main Aug 10, 2024
19 checks passed
jughosta added a commit that referenced this pull request Dec 3, 2024
- Closes #167582

## Summary

This PR removes the code related to the legacy doc table and 2 Advanced
Settings: `doc_table:legacy` and `truncate:maxHeight`.

The legacy table in Discover was replaced by the new data grid in v8.3.
The `doc_table:legacy` Advanced Setting was added to let users switch
back to the legacy table if necessary. The removal of the setting and
the legacy table entirely would allow us to reduce bundle size,
maintenance burden, and code complexity.

Also the legacy table does not support many new features which were
added to the grid only (e.g. comparing selected documents, context-aware
UI based on current solution project, column resizing, bulk row
selection, copy actions, new doc viewer flyout, and more).

Since v8.15 `doc_table:legacy` is marked as deprecated on Advanced
Settings page via #179899

Since v8.16 `truncate:maxHeight` is marked as deprecated too via
#183736

The removal of these 2 settings and the associated code is planned for
v9.

### Checklist

- [x]
[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)
was added for features that require explanation or tutorials
- [x] [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
- [x] This was checked for breaking HTTP API changes, and any breaking
changes have been approved by the breaking-change committee. The
`release_note:breaking` label should be applied in these situations.

---------

Co-authored-by: kibanamachine <[email protected]>
Co-authored-by: Elastic Machine <[email protected]>
hop-dev pushed a commit to hop-dev/kibana that referenced this pull request Dec 5, 2024
- Closes elastic#167582

## Summary

This PR removes the code related to the legacy doc table and 2 Advanced
Settings: `doc_table:legacy` and `truncate:maxHeight`.

The legacy table in Discover was replaced by the new data grid in v8.3.
The `doc_table:legacy` Advanced Setting was added to let users switch
back to the legacy table if necessary. The removal of the setting and
the legacy table entirely would allow us to reduce bundle size,
maintenance burden, and code complexity.

Also the legacy table does not support many new features which were
added to the grid only (e.g. comparing selected documents, context-aware
UI based on current solution project, column resizing, bulk row
selection, copy actions, new doc viewer flyout, and more).

Since v8.15 `doc_table:legacy` is marked as deprecated on Advanced
Settings page via elastic#179899

Since v8.16 `truncate:maxHeight` is marked as deprecated too via
elastic#183736

The removal of these 2 settings and the associated code is planned for
v9.

### Checklist

- [x]
[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)
was added for features that require explanation or tutorials
- [x] [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
- [x] This was checked for breaking HTTP API changes, and any breaking
changes have been approved by the breaking-change committee. The
`release_note:breaking` label should be applied in these situations.

---------

Co-authored-by: kibanamachine <[email protected]>
Co-authored-by: Elastic Machine <[email protected]>
CAWilson94 pushed a commit to CAWilson94/kibana that referenced this pull request Dec 9, 2024
- Closes elastic#167582

## Summary

This PR removes the code related to the legacy doc table and 2 Advanced
Settings: `doc_table:legacy` and `truncate:maxHeight`.

The legacy table in Discover was replaced by the new data grid in v8.3.
The `doc_table:legacy` Advanced Setting was added to let users switch
back to the legacy table if necessary. The removal of the setting and
the legacy table entirely would allow us to reduce bundle size,
maintenance burden, and code complexity.

Also the legacy table does not support many new features which were
added to the grid only (e.g. comparing selected documents, context-aware
UI based on current solution project, column resizing, bulk row
selection, copy actions, new doc viewer flyout, and more).

Since v8.15 `doc_table:legacy` is marked as deprecated on Advanced
Settings page via elastic#179899

Since v8.16 `truncate:maxHeight` is marked as deprecated too via
elastic#183736

The removal of these 2 settings and the associated code is planned for
v9.

### Checklist

- [x]
[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)
was added for features that require explanation or tutorials
- [x] [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
- [x] This was checked for breaking HTTP API changes, and any breaking
changes have been approved by the breaking-change committee. The
`release_note:breaking` label should be applied in these situations.

---------

Co-authored-by: kibanamachine <[email protected]>
Co-authored-by: Elastic Machine <[email protected]>
CAWilson94 pushed a commit to CAWilson94/kibana that referenced this pull request Dec 12, 2024
- Closes elastic#167582

## Summary

This PR removes the code related to the legacy doc table and 2 Advanced
Settings: `doc_table:legacy` and `truncate:maxHeight`.

The legacy table in Discover was replaced by the new data grid in v8.3.
The `doc_table:legacy` Advanced Setting was added to let users switch
back to the legacy table if necessary. The removal of the setting and
the legacy table entirely would allow us to reduce bundle size,
maintenance burden, and code complexity.

Also the legacy table does not support many new features which were
added to the grid only (e.g. comparing selected documents, context-aware
UI based on current solution project, column resizing, bulk row
selection, copy actions, new doc viewer flyout, and more).

Since v8.15 `doc_table:legacy` is marked as deprecated on Advanced
Settings page via elastic#179899

Since v8.16 `truncate:maxHeight` is marked as deprecated too via
elastic#183736

The removal of these 2 settings and the associated code is planned for
v9.

### Checklist

- [x]
[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)
was added for features that require explanation or tutorials
- [x] [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
- [x] This was checked for breaking HTTP API changes, and any breaking
changes have been approved by the breaking-change committee. The
`release_note:breaking` label should be applied in these situations.

---------

Co-authored-by: kibanamachine <[email protected]>
Co-authored-by: Elastic Machine <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:skip This commit does not require backporting Feature:UnifiedDocViewer Issues relating to the unified doc viewer component release_note:enhancement Team:DataDiscovery Discover, search (e.g. data plugin and KQL), data views, saved searches. For ES|QL, use Team:ES|QL. v8.16.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bring back "toggle field details" in discover document view
7 participants