[Dashboard][Embeddable] Add placeholder title to visualize embeddable#74960
[Dashboard][Embeddable] Add placeholder title to visualize embeddable#74960majagrubic wants to merge 14 commits intoelastic:masterfrom
Conversation
|
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:
Expected result Actual result |
|
ok, this is a bit more convoluted than I thought. will work on it in the next couple of days |
|
Pinging @elastic/kibana-app (Team:KibanaApp) |
|
@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. |
|
@ryankeairns by default we don't allow saving embeddables by value just yet. you'll need to manually change the config value to |
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 disabledWhen I return to toggle it back on, the value is gone |
|
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:
*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. |
|
@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? |
|
@majagrubic sure, please just create an issue to track the follow up work. Thank you. |
|
@elasticmachine merge upstream |
|
Created a follow-up issue: #77862 |
ThomThomson
left a comment
There was a problem hiding this comment.
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
left a comment
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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?
src/plugins/embeddable/public/lib/panel/panel_header/panel_header.tsx
Outdated
Show resolved
Hide resolved
| // 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 }); |
There was a problem hiding this comment.
Would this mean that every embeddable is required to propagate the placeholder title in order for it to work?
There was a problem hiding this comment.
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 😄
There was a problem hiding this comment.
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]', |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
|
@elasticmachine merge upstream |
💚 Build SucceededBuild metricsasync chunks size
page load bundle size
History
To update your PR or re-run it, just comment with: |
|
@elasticmachine merge upstream |
|
merge conflict between base and head |
|
I can't pull the pr ATM but a few points I notice from the conversation :
|



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:
When adding title as usual, title will be shown.

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
truehere: https://github.com/elastic/kibana/blob/master/src/plugins/dashboard/config.ts#L23Checklist
Delete any items that are not applicable to this PR.
For maintainers