Skip to content

[Dashboard][Embeddable] Add placeholder title to visualize embeddable#74960

Closed
majagrubic wants to merge 14 commits intoelastic:masterfrom
majagrubic:add-title-to-vis-emebeddable
Closed

[Dashboard][Embeddable] Add placeholder title to visualize embeddable#74960
majagrubic wants to merge 14 commits intoelastic:masterfrom
majagrubic:add-title-to-vis-emebeddable

Conversation

@majagrubic
Copy link
Copy Markdown
Contributor

@majagrubic majagrubic commented Aug 13, 2020

Summary

This is something I've been meaning to implement for a while - a placeholder title for when visualization is "by-value" mode.
This is how it looks like:
Screenshot 2020-08-13 at 16 10 24

When adding title as usual, title will be shown.
add_panel_title

Things get a bit more complicated when saving/unsaving from library. Could you have a look and see if this is as you expect it to be @ryankeairns ?

NOTE: Visualizations by value are not enabled by default. To test this PR, you'll need to manually change the config setting to true here: https://github.com/elastic/kibana/blob/master/src/plugins/dashboard/config.ts#L23

Checklist

Delete any items that are not applicable to this PR.

For maintainers

@majagrubic majagrubic requested a review from ryankeairns August 13, 2020 15:23
@ryankeairns
Copy link
Copy Markdown
Contributor

ryankeairns commented Aug 13, 2020

This is looking good!

One potential issue I noticed is that the title gets erased when toggling the 'Show panel title' switch off

Steps to reproduce:

  • Add a viz panel with no title
  • Edit the panel title, type in a new title, click Save in modal (title displays as expected), then Save the Dashboard
  • Switch back to dashboard Edit mode, Edit the panel title, switch 'Show panel title' to off, click Save in modal

Expected result
The title is visually hidden
Opening the 'Edit panel title' modal shows the swtich off, and the title is still present (disabled)

Actual result
[No title] is displayed
Opening the 'Edit panel title' modal shows the swtich is off, but the title is now empty

@majagrubic
Copy link
Copy Markdown
Contributor Author

ok, this is a bit more convoluted than I thought. will work on it in the next couple of days

@majagrubic majagrubic marked this pull request as ready for review September 15, 2020 12:35
@majagrubic majagrubic requested a review from a team September 15, 2020 12:35
@majagrubic majagrubic requested review from a team as code owners September 15, 2020 12:35
@majagrubic majagrubic added release_note:roadmap Team:Visualizations Team label for Lens, elastic-charts, Graph, legacy editors (TSVB, Visualize, Timelion) t// labels Sep 15, 2020
@elasticmachine
Copy link
Copy Markdown
Contributor

Pinging @elastic/kibana-app (Team:KibanaApp)

@ryankeairns
Copy link
Copy Markdown
Contributor

@majagrubic I might be confusing myself, but when I create a new viz from Dashboard, shouldn't this PR allow me to save without adding a title? I just tried this again and it seems the title is now required.

@majagrubic
Copy link
Copy Markdown
Contributor Author

@ryankeairns by default we don't allow saving embeddables by value just yet. you'll need to manually change the config value to true when testing this PR here: https://github.com/elastic/kibana/blob/master/src/plugins/dashboard/config.ts#L23

@ryankeairns
Copy link
Copy Markdown
Contributor

This is looking good!

One potential issue I noticed is that the title gets erased when toggling the 'Show panel title' switch off

Steps to reproduce:

* Add a viz panel with no title

* Edit the panel title, type in a new title, click Save in modal (title displays as expected), then Save the Dashboard

* Switch back to dashboard Edit mode, Edit the panel title, switch 'Show panel title' to _off_, click Save in modal

Expected result
The title is visually hidden
Opening the 'Edit panel title' modal shows the swtich off, and the title is still present (disabled)

Actual result
[No title] is displayed
Opening the 'Edit panel title' modal shows the swtich is off, but the title is now empty

Thanks for looking into this further. The title is now visually hidden as opposed to showing [No title], which is good, however the value is still being erased. It's not a huge deal, but when I choose to show/hide the title, I expect the value to remain.

When I initially toggle it off, the value is still present, just disabled

Screen Shot 2020-09-16 at 9 33 24 AM

When I return to toggle it back on, the value is gone

Screen Shot 2020-09-16 at 9 33 56 AM

Screen Shot 2020-09-16 at 9 44 08 AM

@ryankeairns
Copy link
Copy Markdown
Contributor

ryankeairns commented Sep 16, 2020

I've been thinking about this more and agree that it is convoluted. Here is what I'm expecting to happen, but perhaps it can be simplified:

Panel title field is empty Panel title field has a value
Show panel title is on Display [No title] Display actual title
Show panel title is off Display nothing Display nothing*

*The bottom right box is where I see the issue. I had previously entered a title, then decided to toggle Show panel title off. It doesn't mean I wanted to delete/reset the Panel title field, I just wanted to hide it from displaying.

@majagrubic
Copy link
Copy Markdown
Contributor Author

@ryankeairns thanx for the detailed description of the flow. I had a look at this today and supporting this last use-case is quite tricky, due to the architecture of embeddables (I understand it sounds super simple). Can we leave it for now as-is and leave it as an improvement at a later stage?

@ryankeairns
Copy link
Copy Markdown
Contributor

@majagrubic sure, please just create an issue to track the follow up work. Thank you.

@majagrubic
Copy link
Copy Markdown
Contributor Author

@elasticmachine merge upstream

@botelastic botelastic bot added the Feature:Embedding Embedding content via iFrame label Sep 18, 2020
@majagrubic
Copy link
Copy Markdown
Contributor Author

Created a follow-up issue: #77862

ThomThomson
ThomThomson previously approved these changes Sep 18, 2020
Copy link
Copy Markdown
Contributor

@ThomThomson ThomThomson left a comment

Choose a reason for hiding this comment

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

Tested locally on chrome,

I really like how by value mode makes the 'show panel title' switch default to false. The addition of the placeholder title also makes a lot of sense and contributes nicely to rounding out our 'by value' features!

@ThomThomson ThomThomson self-requested a review September 18, 2020 20:40
@ThomThomson ThomThomson dismissed their stale review September 18, 2020 20:44

Second look at code

Copy link
Copy Markdown
Contributor

@ThomThomson ThomThomson left a comment

Choose a reason for hiding this comment

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

Upon looking at the code again, I am realizing that there are a few ways to simplify this greatly and minimize the impact on other embeddables / places around the code base. It should be possible to implement this entirely in panel_header.tsx.

/**
* Returns the placeholder title of this embeddable, if it exists.
*/
getPlaceholderTitle?(): string | undefined;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Seems to me that the placeholder title shouldn't go in a public API like this. Why should each embeddable know about the placeholder title?

// propagate the placeholder title to the output embeddable
// but only when the visualization is in edit/Visualize mode
if (!this.parent && this.placeholderTitle !== this.output.placeholderTitle) {
this.updateOutput({ placeholderTitle: this.placeholderTitle });
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Would this mean that every embeddable is required to propagate the placeholder title in order for it to work?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Not sure what you mean by "every embeddable", but if you mean "every visualize embeddable that had its placeholder title changed", then the answer is yes 😄

Copy link
Copy Markdown
Contributor

@ThomThomson ThomThomson Sep 21, 2020

Choose a reason for hiding this comment

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

Oh I see, I thought that this was required to propagate the dashboard placeholder title to the embeddable output so that the panel header could pick it up. The lens embeddable for instance, doesn't show the placeholder title.

It sounds like this is to support custom overrides to the placeholder title by embeddables?

// @ts-expect-error
delete input.id;
const placeholderTitle = i18n.translate('dashboard.embeddable.placeholderTitle', {
defaultMessage: '[No Title]',
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is there a use case for defining this in the dashboard controller? Maybe there's something I'm missing, but couldn't this be defined in the panel header so it wouldn't have to passed around so much?

Copy link
Copy Markdown
Contributor Author

@majagrubic majagrubic Sep 21, 2020

Choose a reason for hiding this comment

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

Dashboard "decides" what the placeholder title for embeddables on the dashboard will be. Moving this inside panel header would mean that placeholder title for every embeddable would need to be the same. Additionally, we're polluting that component by giving it more responsibility than it should have. That component should render the title regardless of where it came from.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I see what you mean, but I am still more of the opinion that a placeholder title is exactly the kind of responsibility that the header should have.

It also seems like giving each panel header the same placeholder title would result in greater consistency, and that an addition to i_embeddable is a much more polluting change than adding functionality to panel_header

@majagrubic
Copy link
Copy Markdown
Contributor Author

majagrubic commented Sep 21, 2020

@elasticmachine merge upstream

@kibanamachine
Copy link
Copy Markdown
Contributor

💚 Build Succeeded

Build metrics

async chunks size

id value diff baseline
visualize 414.8KB +28.0B 414.7KB

page load bundle size

id value diff baseline
dashboard 708.4KB +26.0B 708.3KB
embeddable 432.5KB +2.3KB 430.2KB
total +2.3KB

History

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

@majagrubic
Copy link
Copy Markdown
Contributor Author

@elasticmachine merge upstream

@elasticmachine
Copy link
Copy Markdown
Contributor

merge conflict between base and head

@AlonaNadler
Copy link
Copy Markdown

I can't pull the pr ATM but a few points I notice from the conversation :

  • title for visualizations is important. In case someone didn't add a title I think you should show no title when on edit mode. On reading mode does it also show no title? if users didn't add title on reading mode can it appear empty? it won't be friendly if all panels will show add title
  • Ideally we had an easier way proximate to the title itself to change the title @majagrubic

@majagrubic majagrubic closed this Oct 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Feature:Embedding Embedding content via iFrame Team:Visualizations Team label for Lens, elastic-charts, Graph, legacy editors (TSVB, Visualize, Timelion) t// v7.10.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants