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

[Dashboard Navigation] Add horizontal/vertical embeddable rendering + error handling #162285

Merged
merged 42 commits into from
Aug 16, 2023

Conversation

Heenawter
Copy link
Contributor

@Heenawter Heenawter commented Jul 19, 2023

Closes #154357
Closes #161563

Summary

Warning
I will be waiting to merge this PR until after #160896 is merged - I am simply opening it early so that we can start the design review process 👍

Layout

This PR improves the rendering of the navigation embeddable to include both a horizontal and vertical layout option, as well as changing the style of how the links are rendered:

Screen.Recording.2023-07-25.at.11.23.49.AM.mov

A known issue with the horizontal layout is that, as demonstrated in the above video, a "compact" horizontal navigation panel does not render as nicely in edit mode versus view mode - this is an overall panel problem and not specifically a problem with the navigation embeddable (although the navigation embeddable definitely makes it more obvious). This will be resolved for all panels by removing the panel header altogether.

Error handling

This PR adds proper error handling to the navigation embeddable so that, if a dashboard link is "broken" (i.e. the destination dashboard has been deleted or cannot be fetched), an appropriate error message shows up in both the component and the editor flyout:

Screen.Recording.2023-07-25.at.12.14.28.PM.mov

Note
When possible, we want to provide the user with as much context as possible for broken dashboard links - that is why, if a dashboard link was given a custom label, we still show this custom label even when the destination dashboard has been deleted/is unreachable.

However, once a dashboard has been deleted, we no longer know what the title of that dashboard was because the saved object no longer exists - so, if a dashboard link is not given a custom label and the destination dashboard is deleted, we default to the "Error fetching dashboard" error message instead. In order to create a distinction between these two scenarios (a broken dashboard link with a custom label versus without), we italicize the generic "Error fetching dashboard" error text.

Improved efficiency

Previously, the navigation embeddable was handling its own dashboard cache, which meant that (a) every single embeddable had its own cache and (b) the navigation embeddable code had to be mindful when choosing to use the memoized/cached version of the dashboard versus fetching it fresh.

After discussing with @ThomThomson about how to better handle this, we opted to move this logic to the dashboard content management service - not only does this clean up the navigation embeddable code, it also improves all the loading of dashboards in general. For example, consider the following video where I was testing re-loading a previously loaded dashboard on a throttled Slow 3G network:

Screen.Recording.2023-07-20.at.3.10.49.PM.mov

Notice in the above video how much faster the secondary load of the dashboard is in comparison to the first initial load - this is because, in the second load, we can hit the cache instead of re-fetching the dashboard from the content management client, which allows us to skip an entire loading state.

Checklist

For maintainers

@Heenawter Heenawter added Team:Presentation Presentation Team for Dashboard, Input Controls, and Canvas loe:medium Medium Level of Effort impact:high Addressing this issue will have a high level of impact on the quality/strength of our product. labels Jul 19, 2023
@Heenawter Heenawter self-assigned this Jul 19, 2023
@Heenawter Heenawter force-pushed the embeddable-rendering-ui_2023-07-18 branch from d58c6c1 to 86ac78f Compare July 24, 2023 22:17
@Heenawter Heenawter force-pushed the embeddable-rendering-ui_2023-07-18 branch from 86ac78f to 09091ea Compare July 24, 2023 22:28
@Heenawter Heenawter force-pushed the embeddable-rendering-ui_2023-07-18 branch from 8b4e240 to 1011d65 Compare August 14, 2023 17:46
@Heenawter
Copy link
Contributor Author

@nickpeihl @andreadelrio I have updated this PR to replace the dual save buttons with the "Save to library" EUISwitch, as we discussed offline 🎉

Screen.Recording.2023-08-15.at.12.35.02.PM.mov

Copy link
Member

@nickpeihl nickpeihl left a comment

Choose a reason for hiding this comment

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

I have updated this PR to replace the dual save buttons with the "Save to library" EUISwitch, as we discussed offline 🎉

Awesome! Changes lgtm!

code review and tested by-value and by-reference panels

@andreadelrio
Copy link
Contributor

andreadelrio commented Aug 15, 2023

This is looking great! At this point, I would like to get @amyjtechwriter to help us with the copy. Should we capitalize links or not? do we add the word panel or not? Whatever we agree on we should use consistently in all flyouts, modals, menus where we mention this feature.

image

@nickpeihl @Heenawter I think this modal works, but I think adding "to library" at the end of the heading will add clarity as to why this modal shows up when users have the "save to library" toggle set to true and hit Save in the flyout. What do you think?

Some more context: When we show the menu for a Lens visualization we have an item that read "Edit Lens" because Lens is a proper noun. Should we give links panels the same treatment even though Links is not really a separate app?

image image

@Heenawter
Copy link
Contributor Author

Heenawter commented Aug 15, 2023

@andreadelrio

Should we capitalize links or not? do we add the word panel or not? Whatever we agree on we should use consistently in all flyouts, modals, menus where we mention this feature.

For reference, here are some other save modals for different embeddable types:

Embeddable Modal
Lens image

Note: Looks like this should probably be fixed to the proper noun "Lens" 👀
Maps image
Visualization image

Based on the above, I would agree that changing it to "Save links" (lowercase) would be ideal!

Some more context: When we show the menu for a Lens visualization we have an item that read "Edit Lens" because Lens is a proper noun. Should we give links panels the same treatment even though Links is not really a separate app?

I think the capitalization of the "Edit <Lens/map/visualization/links>" option in the config menu should ideally match whatever capitalization we use in the "Save to library" modal - right now, there seems to be a lot of inconsistency between all the different panel types.

We can ensure that it matches for the links embeddable in this feature branch (in this case, I think that lowercase "links" makes the most sense), but I would argue that fixing the labels for the other panel types + addressing the overall consistency problem should probably be addressed outside of the links embeddable work - probably as part of dashboard usabilty?

If we agree, I can definitely file a separate issue 👍

I think this modal works, but I think adding "to library" at the end of the heading will add clarity as to why this modal shows up when users have the "save to library" toggle set to true and hit Save in the flyout.

For consistency, we would probably want to add "to library" to the end of the above modals as well, if we decide to go that route (from what I can tell, this is all a shared component - so, that should be super quick and easy 😄). Definitely defaulting to @amyjtechwriter's opinion on this, because I'm good either way 👍

Similar to above, I think it might be worth fixing this inconstancy in main as part of the dashboard usability initiative so that both (1) we don't muddy up the link embeddable feature branch with non-critical / tangentially related work and (2) we don't have to wait for the links embeddable to be available on main in order for these UX improvements to be available.

cc @cqliu1 for the dashboard usability mentions 👀

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 🎉. This is coming along very nicely, great job @Heenawter and @nickpeihl! Agreed that we can take care of copy consistency issues on main rather than on this branch 👍.

@Heenawter Heenawter requested a review from afharo August 16, 2023 14:49
@amyjtechwriter
Copy link
Contributor

Hello hello @Heenawter and @andreadelrio, this might be an unnecessary opinion here if the copy issues are going to be addressed on a different branch, but I really like your combined solutions of Save links to library. I think it's great and very clear.

Copy link
Member

@afharo afharo left a comment

Choose a reason for hiding this comment

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

SO changes LGTM! Thanks for iterating on it 🧡

@Heenawter Heenawter merged commit f0ebcb2 into navigation-embeddable Aug 16, 2023
1 check passed
@Heenawter Heenawter deleted the embeddable-rendering-ui_2023-07-18 branch August 16, 2023 17:19
@kibana-ci
Copy link
Collaborator

kibana-ci commented Aug 16, 2023

💔 Build Failed

Failed CI Steps

Test Failures

  • [job] [logs] Jest Integration Tests #3 / checking migration metadata changes on all registered SO types detecting migration related changes in registered types
  • [job] [logs] FTR Configs #62 / Console App CCS Perform CCS Search in Console it should be able to access remote data
  • [job] [logs] FTR Configs #62 / Console App CCS Perform CCS Search in Console it should be able to access remote data
  • [job] [logs] FTR Configs #11 / Controls Range Slider Control create and edit edits title and size of an existing control and retains existing range selection
  • [job] [logs] FTR Configs #11 / Controls Range Slider Control create and edit edits title and size of an existing control and retains existing range selection
  • [job] [logs] FTR Configs #7 / dashboard app - group 5 embed mode default URL params renders as expected
  • [job] [logs] FTR Configs #7 / dashboard app - group 5 embed mode default URL params renders as expected
  • [job] [logs] FTR Configs #12 / Fleet Endpoints fleet policy secrets Should correctly create the policy with secrets
  • [job] [logs] FTR Configs #12 / Fleet Endpoints fleet policy secrets Should correctly create the policy with secrets
  • [job] [logs] FTR Configs #37 / lens app - group 4 lens tsdb downsampling for rolled up metric shows warnings in editor when using median
  • [job] [logs] FTR Configs #37 / lens app - group 4 lens tsdb downsampling for rolled up metric shows warnings in editor when using median
  • [job] [logs] FTR Configs #59 / machine learning - data frame analytics outlier detection creation iowa house prices runs the analytics job and displays it correctly in the job list
  • [job] [logs] FTR Configs #59 / machine learning - data frame analytics outlier detection creation iowa house prices runs the analytics job and displays it correctly in the job list
  • [job] [logs] FTR Configs #45 / MetricsUI Endpoints log highlight apis /log_entries/highlights with the default source highlights built-in message column
  • [job] [logs] FTR Configs #45 / MetricsUI Endpoints log highlight apis /log_entries/highlights with the default source highlights built-in message column
  • [job] [logs] FTR Configs #17 / Options list control Dashboard options list creation and editing Options List Control creation and editing experience renames an existing control and retains selection
  • [job] [logs] FTR Configs #17 / Options list control Dashboard options list creation and editing Options List Control creation and editing experience renames an existing control and retains selection
  • [job] [logs] FTR Configs #11 / security APIs - Kerberos Kerberos authentication API access with missing access token document or expired refresh token. "before each" hook for "non-AJAX call should initiate SPNEGO and clear existing cookie"
  • [job] [logs] FTR Configs #13 / security APIs - Kerberos Kerberos authentication API access with missing access token document or expired refresh token. "before each" hook for "non-AJAX call should initiate SPNEGO and clear existing cookie"
  • [job] [logs] FTR Configs #11 / security APIs - Kerberos Kerberos authentication API access with missing access token document or expired refresh token. "before each" hook for "non-AJAX call should initiate SPNEGO and clear existing cookie"
  • [job] [logs] FTR Configs #13 / security APIs - Kerberos Kerberos authentication API access with missing access token document or expired refresh token. "before each" hook for "non-AJAX call should initiate SPNEGO and clear existing cookie"
  • [job] [logs] FTR Configs #51 / security APIs - SAML SAML authentication API access with missing access token document. "before each" hook for "should properly set cookie and redirect user to IdP"
  • [job] [logs] FTR Configs #51 / security APIs - SAML SAML authentication API access with missing access token document. "before each" hook for "should properly set cookie and redirect user to IdP"
  • [job] [logs] Jest Integration Tests #4 / SO type registrations does not remove types from registrations without updating excludeOnUpgradeQuery
  • [job] [logs] FTR Configs #37 / Synthetics API Tests PrivateLocationAddMonitor added an integration for previously added monitor
  • [job] [logs] FTR Configs #37 / Synthetics API Tests PrivateLocationAddMonitor added an integration for previously added monitor
  • [job] [logs] FTR Configs #56 / visualize app visual builder tsdb check should show an error when using an unsupported tsdb field type
  • [job] [logs] FTR Configs #56 / visualize app visual builder tsdb check should show an error when using an unsupported tsdb field type

Metrics [docs]

‼️ ERROR: no builds found for mergeBase sha [577134c]

History

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

cc @Heenawter

Heenawter added a commit that referenced this pull request Aug 16, 2023
## Summary

As part of a [larger navigation embeddable
discussion](#162285 (comment)),
it was noted that there were inconsistencies between how we display the
panel type between the saved object modal and the context menu action.
Turns out, this is because we were using the embeddable `type` in the
`"Save to library"` modal title while the context menu action uses the
factory's `displayName` - while this coincidentally worked **in most
cases** (`maps` and `visualization`), it **does not** work for Lens
panels, since we want to use the proper noun `"Lens"` in this case
rather than the saved object type `"lens"`:

<p align="center"><img width="500"
src="https://github.com/elastic/kibana/assets/8698078/d56659bf-ff13-4974-80bb-f267fdcb1cff"/></p>

This was even **more** obvious with the navigation embeddable, since the
saved object type is currently `"navigation_embeddable"` (this may
change in the future):

<p align="center"><img width="500"
src="https://github.com/elastic/kibana/assets/8698078/868daebb-fa51-4f97-bd23-3cf47472fadf"/></p>



Therefore, by switching to use the factory's `displayName` (if
available), the saved object modal will now stay consistent with the
`"Edit <x>"` option in the context menu for each panel.

| Before | After |
|--------|--------|
|
![image](https://github.com/elastic/kibana/assets/8698078/d56659bf-ff13-4974-80bb-f267fdcb1cff)
|
![image](https://github.com/elastic/kibana/assets/8698078/eb651928-3e9d-4c7c-bc3a-d6e3e98854f6)
|
|
![image](https://github.com/elastic/kibana/assets/8698078/868daebb-fa51-4f97-bd23-3cf47472fadf)
|
![image](https://github.com/elastic/kibana/assets/8698078/d1f9ca7e-1711-4041-b025-efb2b36f0684)|
|
![image](https://github.com/elastic/kibana/assets/8698078/633f8d6b-185f-4b47-b9ca-4bda24344c44)
|
![image](https://github.com/elastic/kibana/assets/8698078/8537bf39-a04e-4492-9d20-3162396fc4e2)<br><p
align="center">**No change**, as expected.</p> |
|
![image](https://github.com/elastic/kibana/assets/8698078/75a19c15-efec-4c32-b980-6200d7c17e8e)
|
![image](https://github.com/elastic/kibana/assets/8698078/bd7cb2e9-ae4f-4b52-a7ef-04d74949fd28)<br><p
align="center">**No change**, as expected.</p> |

Note that, in the above "After" screenshots, `Links` is still
capitalized unnecessarily - this is because, if we change the factory's
`displayName` to be the lowercase `"links"`, this fixes the modal but it
**also** impacts the item in the add panel context menu and the panel
actions context menu, like so:

| Add panel context menu | Panel actions context menu |
|--------|--------|
|
![image1](https://github.com/elastic/kibana/assets/8698078/57e16f0b-1f5c-4291-afd3-a69e57540967)
| ![Screenshot 2023-08-16 at 1 36 14
PM](https://github.com/elastic/kibana/assets/8698078/34d41119-4c84-460d-923c-1d2570dadfd9)|

This is because the link embeddable is not currently registered as a
"visualization" and so the `"Add panel"` context menu logic is handled
as part of `getEmbeddableFactoryMenuItem` in
`./src/plugins/dashboard/public/dashboard_app/top_nav/editor_menu.tsx`
rather than `getVisTypeMenuItem` (this **could** potentially be fixed by
#162840 since we have custom
logic for displaying aliases). While the lowercase `"links"` in the
panel actions context menu is **desired**, it is **not** desirable to
have the lowercase `"links"` in the add panel context menu - however, it
is not currently possible to change one without changing the other.

Note that this is **also** true for the `"Image"` embeddable - by
changing the `displayName` of the image factory from `"Image"` to
`"image"`, the `"Edit"` panel actions context menu item would be
displayed correctly as `"Edit image"` (currently, it is `"Edit Image"`)
but the lowercase `"image"` would also be displayed in the add panel
context menu, which is undesirable.

It will require a larger refactor to fix these inconsistencies, so it
should be addressed separately.

### Checklist

- [x] 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)

### 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)
Heenawter added a commit that referenced this pull request Jan 26, 2024
## Summary

This PR fixes the alias redirect problem that was noted in the attached
SDH.

For context, as part of the [Links panel
work](#166896), I added [dashboard
caching](#162285) to make
navigation more efficient - however, when implementing this, I did not
consider the redirect behaviour.

Specifically, we were **always** adding dashboards to the cache, even if
the load outcome meant a redirect was necessary - so, because the meta
info for the dashboard fetch result was cached, this meant that the
`'aliasMatch'` outcome was **also** cached. Because of this, after a
redirect happened, the second attempt to load the dashboard would return
the result from the **cache** rather than fetching the dashboard from
the CM client - but, as described previously, the cached dashboard would
still appear as though it required a redirect because the cached outcome
was `'aliasMatch'`.

Therefore, because of hitting this early return on **both** fetch
attempts (before the redirect, after the redirect)...


https://github.com/elastic/kibana/blob/4565b1bfba91cd24f73f8ce37fa7be73283a4453/src/plugins/dashboard/public/dashboard_container/embeddable/create/create_dashboard.ts#L165-L171

... the dashboard information would not get updated. _(Oof!)_ 

Despite the lengthy description of the problem, the solution is quite
simple - just don't add dashboards to the cache if they require a
redirect. And then everything works! 🎉

### Videos
**Before**


https://github.com/elastic/kibana/assets/8698078/983b81a6-acf3-4e71-804a-6ed75c36896f


**After**


https://github.com/elastic/kibana/assets/8698078/028369ff-f73f-43e6-9abb-b35f0d2f33e1


### Testing
To test, I followed the directions from [this PR
description](#163658) to get a
dashboard that requires a redirect - then, I created a markdown panel
with the **old** (from the Default space) dashboard ID in the new space
to see the same redirect behaviour that the customer in the SDH was
seeing.

### Checklist
- [x] This was checked for [cross-browser
compatibility](https://www.elastic.co/support/matrix#matrix_browsers)
- [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

### 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)
kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Jan 26, 2024
## Summary

This PR fixes the alias redirect problem that was noted in the attached
SDH.

For context, as part of the [Links panel
work](elastic#166896), I added [dashboard
caching](elastic#162285) to make
navigation more efficient - however, when implementing this, I did not
consider the redirect behaviour.

Specifically, we were **always** adding dashboards to the cache, even if
the load outcome meant a redirect was necessary - so, because the meta
info for the dashboard fetch result was cached, this meant that the
`'aliasMatch'` outcome was **also** cached. Because of this, after a
redirect happened, the second attempt to load the dashboard would return
the result from the **cache** rather than fetching the dashboard from
the CM client - but, as described previously, the cached dashboard would
still appear as though it required a redirect because the cached outcome
was `'aliasMatch'`.

Therefore, because of hitting this early return on **both** fetch
attempts (before the redirect, after the redirect)...

https://github.com/elastic/kibana/blob/4565b1bfba91cd24f73f8ce37fa7be73283a4453/src/plugins/dashboard/public/dashboard_container/embeddable/create/create_dashboard.ts#L165-L171

... the dashboard information would not get updated. _(Oof!)_

Despite the lengthy description of the problem, the solution is quite
simple - just don't add dashboards to the cache if they require a
redirect. And then everything works! 🎉

### Videos
**Before**

https://github.com/elastic/kibana/assets/8698078/983b81a6-acf3-4e71-804a-6ed75c36896f

**After**

https://github.com/elastic/kibana/assets/8698078/028369ff-f73f-43e6-9abb-b35f0d2f33e1

### Testing
To test, I followed the directions from [this PR
description](elastic#163658) to get a
dashboard that requires a redirect - then, I created a markdown panel
with the **old** (from the Default space) dashboard ID in the new space
to see the same redirect behaviour that the customer in the SDH was
seeing.

### Checklist
- [x] This was checked for [cross-browser
compatibility](https://www.elastic.co/support/matrix#matrix_browsers)
- [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

### 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)

(cherry picked from commit 27b34d5)
kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Jan 26, 2024
## Summary

This PR fixes the alias redirect problem that was noted in the attached
SDH.

For context, as part of the [Links panel
work](elastic#166896), I added [dashboard
caching](elastic#162285) to make
navigation more efficient - however, when implementing this, I did not
consider the redirect behaviour.

Specifically, we were **always** adding dashboards to the cache, even if
the load outcome meant a redirect was necessary - so, because the meta
info for the dashboard fetch result was cached, this meant that the
`'aliasMatch'` outcome was **also** cached. Because of this, after a
redirect happened, the second attempt to load the dashboard would return
the result from the **cache** rather than fetching the dashboard from
the CM client - but, as described previously, the cached dashboard would
still appear as though it required a redirect because the cached outcome
was `'aliasMatch'`.

Therefore, because of hitting this early return on **both** fetch
attempts (before the redirect, after the redirect)...

https://github.com/elastic/kibana/blob/4565b1bfba91cd24f73f8ce37fa7be73283a4453/src/plugins/dashboard/public/dashboard_container/embeddable/create/create_dashboard.ts#L165-L171

... the dashboard information would not get updated. _(Oof!)_

Despite the lengthy description of the problem, the solution is quite
simple - just don't add dashboards to the cache if they require a
redirect. And then everything works! 🎉

### Videos
**Before**

https://github.com/elastic/kibana/assets/8698078/983b81a6-acf3-4e71-804a-6ed75c36896f

**After**

https://github.com/elastic/kibana/assets/8698078/028369ff-f73f-43e6-9abb-b35f0d2f33e1

### Testing
To test, I followed the directions from [this PR
description](elastic#163658) to get a
dashboard that requires a redirect - then, I created a markdown panel
with the **old** (from the Default space) dashboard ID in the new space
to see the same redirect behaviour that the customer in the SDH was
seeing.

### Checklist
- [x] This was checked for [cross-browser
compatibility](https://www.elastic.co/support/matrix#matrix_browsers)
- [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

### 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)

(cherry picked from commit 27b34d5)
kibanamachine added a commit that referenced this pull request Jan 26, 2024
# Backport

This will backport the following commits from `main` to `8.12`:
- [[Dashboard] Only cache non-alias dashboards
(#175635)](#175635)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Hannah
Mudge","email":"Heenawter@users.noreply.github.com"},"sourceCommit":{"committedDate":"2024-01-26T16:09:28Z","message":"[Dashboard]
Only cache non-alias dashboards (#175635)\n\n## Summary\r\n\r\nThis PR
fixes the alias redirect problem that was noted in the
attached\r\nSDH.\r\n\r\nFor context, as part of the [Links
panel\r\nwork](#166896), I added
[dashboard\r\ncaching](#162285) to
make\r\nnavigation more efficient - however, when implementing this, I
did not\r\nconsider the redirect behaviour.\r\n\r\nSpecifically, we were
**always** adding dashboards to the cache, even if\r\nthe load outcome
meant a redirect was necessary - so, because the meta\r\ninfo for the
dashboard fetch result was cached, this meant that the\r\n`'aliasMatch'`
outcome was **also** cached. Because of this, after a\r\nredirect
happened, the second attempt to load the dashboard would return\r\nthe
result from the **cache** rather than fetching the dashboard from\r\nthe
CM client - but, as described previously, the cached dashboard
would\r\nstill appear as though it required a redirect because the
cached outcome\r\nwas `'aliasMatch'`.\r\n\r\nTherefore, because of
hitting this early return on **both** fetch\r\nattempts (before the
redirect, after the
redirect)...\r\n\r\n\r\nhttps://github.com/elastic/kibana/blob/4565b1bfba91cd24f73f8ce37fa7be73283a4453/src/plugins/dashboard/public/dashboard_container/embeddable/create/create_dashboard.ts#L165-L171\r\n\r\n...
the dashboard information would not get updated. _(Oof!)_
\r\n\r\nDespite the lengthy description of the problem, the solution is
quite\r\nsimple - just don't add dashboards to the cache if they require
a\r\nredirect. And then everything works! 🎉\r\n\r\n###
Videos\r\n**Before**\r\n\r\n\r\nhttps://github.com/elastic/kibana/assets/8698078/983b81a6-acf3-4e71-804a-6ed75c36896f\r\n\r\n\r\n**After**\r\n\r\n\r\nhttps://github.com/elastic/kibana/assets/8698078/028369ff-f73f-43e6-9abb-b35f0d2f33e1\r\n\r\n\r\n###
Testing\r\nTo test, I followed the directions from [this
PR\r\ndescription](#163658) to get
a\r\ndashboard that requires a redirect - then, I created a markdown
panel\r\nwith the **old** (from the Default space) dashboard ID in the
new space\r\nto see the same redirect behaviour that the customer in the
SDH was\r\nseeing.\r\n\r\n### Checklist\r\n- [x] This was checked for
[cross-browser\r\ncompatibility](https://www.elastic.co/support/matrix#matrix_browsers)\r\n-
[x] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common scenarios\r\n\r\n### For
maintainers\r\n\r\n- [ ] This was checked for breaking API changes and
was
[labeled\r\nappropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)","sha":"27b34d591111a878001eaac7b0f3ef0173bc8f02","branchLabelMapping":{"^v8.13.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["bug","Feature:Dashboard","release_note:fix","Team:Presentation","loe:small","impact:high","backport:prev-minor","v8.12.1","v8.13.0"],"title":"[Dashboard]
Only cache non-alias
dashboards","number":175635,"url":"https://github.com/elastic/kibana/pull/175635","mergeCommit":{"message":"[Dashboard]
Only cache non-alias dashboards (#175635)\n\n## Summary\r\n\r\nThis PR
fixes the alias redirect problem that was noted in the
attached\r\nSDH.\r\n\r\nFor context, as part of the [Links
panel\r\nwork](#166896), I added
[dashboard\r\ncaching](#162285) to
make\r\nnavigation more efficient - however, when implementing this, I
did not\r\nconsider the redirect behaviour.\r\n\r\nSpecifically, we were
**always** adding dashboards to the cache, even if\r\nthe load outcome
meant a redirect was necessary - so, because the meta\r\ninfo for the
dashboard fetch result was cached, this meant that the\r\n`'aliasMatch'`
outcome was **also** cached. Because of this, after a\r\nredirect
happened, the second attempt to load the dashboard would return\r\nthe
result from the **cache** rather than fetching the dashboard from\r\nthe
CM client - but, as described previously, the cached dashboard
would\r\nstill appear as though it required a redirect because the
cached outcome\r\nwas `'aliasMatch'`.\r\n\r\nTherefore, because of
hitting this early return on **both** fetch\r\nattempts (before the
redirect, after the
redirect)...\r\n\r\n\r\nhttps://github.com/elastic/kibana/blob/4565b1bfba91cd24f73f8ce37fa7be73283a4453/src/plugins/dashboard/public/dashboard_container/embeddable/create/create_dashboard.ts#L165-L171\r\n\r\n...
the dashboard information would not get updated. _(Oof!)_
\r\n\r\nDespite the lengthy description of the problem, the solution is
quite\r\nsimple - just don't add dashboards to the cache if they require
a\r\nredirect. And then everything works! 🎉\r\n\r\n###
Videos\r\n**Before**\r\n\r\n\r\nhttps://github.com/elastic/kibana/assets/8698078/983b81a6-acf3-4e71-804a-6ed75c36896f\r\n\r\n\r\n**After**\r\n\r\n\r\nhttps://github.com/elastic/kibana/assets/8698078/028369ff-f73f-43e6-9abb-b35f0d2f33e1\r\n\r\n\r\n###
Testing\r\nTo test, I followed the directions from [this
PR\r\ndescription](#163658) to get
a\r\ndashboard that requires a redirect - then, I created a markdown
panel\r\nwith the **old** (from the Default space) dashboard ID in the
new space\r\nto see the same redirect behaviour that the customer in the
SDH was\r\nseeing.\r\n\r\n### Checklist\r\n- [x] This was checked for
[cross-browser\r\ncompatibility](https://www.elastic.co/support/matrix#matrix_browsers)\r\n-
[x] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common scenarios\r\n\r\n### For
maintainers\r\n\r\n- [ ] This was checked for breaking API changes and
was
[labeled\r\nappropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)","sha":"27b34d591111a878001eaac7b0f3ef0173bc8f02"}},"sourceBranch":"main","suggestedTargetBranches":["8.12"],"targetPullRequestStates":[{"branch":"8.12","label":"v8.12.1","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.13.0","branchLabelMappingKey":"^v8.13.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/175635","number":175635,"mergeCommit":{"message":"[Dashboard]
Only cache non-alias dashboards (#175635)\n\n## Summary\r\n\r\nThis PR
fixes the alias redirect problem that was noted in the
attached\r\nSDH.\r\n\r\nFor context, as part of the [Links
panel\r\nwork](#166896), I added
[dashboard\r\ncaching](#162285) to
make\r\nnavigation more efficient - however, when implementing this, I
did not\r\nconsider the redirect behaviour.\r\n\r\nSpecifically, we were
**always** adding dashboards to the cache, even if\r\nthe load outcome
meant a redirect was necessary - so, because the meta\r\ninfo for the
dashboard fetch result was cached, this meant that the\r\n`'aliasMatch'`
outcome was **also** cached. Because of this, after a\r\nredirect
happened, the second attempt to load the dashboard would return\r\nthe
result from the **cache** rather than fetching the dashboard from\r\nthe
CM client - but, as described previously, the cached dashboard
would\r\nstill appear as though it required a redirect because the
cached outcome\r\nwas `'aliasMatch'`.\r\n\r\nTherefore, because of
hitting this early return on **both** fetch\r\nattempts (before the
redirect, after the
redirect)...\r\n\r\n\r\nhttps://github.com/elastic/kibana/blob/4565b1bfba91cd24f73f8ce37fa7be73283a4453/src/plugins/dashboard/public/dashboard_container/embeddable/create/create_dashboard.ts#L165-L171\r\n\r\n...
the dashboard information would not get updated. _(Oof!)_
\r\n\r\nDespite the lengthy description of the problem, the solution is
quite\r\nsimple - just don't add dashboards to the cache if they require
a\r\nredirect. And then everything works! 🎉\r\n\r\n###
Videos\r\n**Before**\r\n\r\n\r\nhttps://github.com/elastic/kibana/assets/8698078/983b81a6-acf3-4e71-804a-6ed75c36896f\r\n\r\n\r\n**After**\r\n\r\n\r\nhttps://github.com/elastic/kibana/assets/8698078/028369ff-f73f-43e6-9abb-b35f0d2f33e1\r\n\r\n\r\n###
Testing\r\nTo test, I followed the directions from [this
PR\r\ndescription](#163658) to get
a\r\ndashboard that requires a redirect - then, I created a markdown
panel\r\nwith the **old** (from the Default space) dashboard ID in the
new space\r\nto see the same redirect behaviour that the customer in the
SDH was\r\nseeing.\r\n\r\n### Checklist\r\n- [x] This was checked for
[cross-browser\r\ncompatibility](https://www.elastic.co/support/matrix#matrix_browsers)\r\n-
[x] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common scenarios\r\n\r\n### For
maintainers\r\n\r\n- [ ] This was checked for breaking API changes and
was
[labeled\r\nappropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)","sha":"27b34d591111a878001eaac7b0f3ef0173bc8f02"}}]}]
BACKPORT-->

Co-authored-by: Hannah Mudge <Heenawter@users.noreply.github.com>
lcawl pushed a commit to lcawl/kibana that referenced this pull request Jan 26, 2024
## Summary

This PR fixes the alias redirect problem that was noted in the attached
SDH.

For context, as part of the [Links panel
work](elastic#166896), I added [dashboard
caching](elastic#162285) to make
navigation more efficient - however, when implementing this, I did not
consider the redirect behaviour.

Specifically, we were **always** adding dashboards to the cache, even if
the load outcome meant a redirect was necessary - so, because the meta
info for the dashboard fetch result was cached, this meant that the
`'aliasMatch'` outcome was **also** cached. Because of this, after a
redirect happened, the second attempt to load the dashboard would return
the result from the **cache** rather than fetching the dashboard from
the CM client - but, as described previously, the cached dashboard would
still appear as though it required a redirect because the cached outcome
was `'aliasMatch'`.

Therefore, because of hitting this early return on **both** fetch
attempts (before the redirect, after the redirect)...


https://github.com/elastic/kibana/blob/4565b1bfba91cd24f73f8ce37fa7be73283a4453/src/plugins/dashboard/public/dashboard_container/embeddable/create/create_dashboard.ts#L165-L171

... the dashboard information would not get updated. _(Oof!)_ 

Despite the lengthy description of the problem, the solution is quite
simple - just don't add dashboards to the cache if they require a
redirect. And then everything works! 🎉

### Videos
**Before**


https://github.com/elastic/kibana/assets/8698078/983b81a6-acf3-4e71-804a-6ed75c36896f


**After**


https://github.com/elastic/kibana/assets/8698078/028369ff-f73f-43e6-9abb-b35f0d2f33e1


### Testing
To test, I followed the directions from [this PR
description](elastic#163658) to get a
dashboard that requires a redirect - then, I created a markdown panel
with the **old** (from the Default space) dashboard ID in the new space
to see the same redirect behaviour that the customer in the SDH was
seeing.

### Checklist
- [x] This was checked for [cross-browser
compatibility](https://www.elastic.co/support/matrix#matrix_browsers)
- [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

### 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)
CoenWarmer pushed a commit to CoenWarmer/kibana that referenced this pull request Feb 15, 2024
## Summary

This PR fixes the alias redirect problem that was noted in the attached
SDH.

For context, as part of the [Links panel
work](elastic#166896), I added [dashboard
caching](elastic#162285) to make
navigation more efficient - however, when implementing this, I did not
consider the redirect behaviour.

Specifically, we were **always** adding dashboards to the cache, even if
the load outcome meant a redirect was necessary - so, because the meta
info for the dashboard fetch result was cached, this meant that the
`'aliasMatch'` outcome was **also** cached. Because of this, after a
redirect happened, the second attempt to load the dashboard would return
the result from the **cache** rather than fetching the dashboard from
the CM client - but, as described previously, the cached dashboard would
still appear as though it required a redirect because the cached outcome
was `'aliasMatch'`.

Therefore, because of hitting this early return on **both** fetch
attempts (before the redirect, after the redirect)...


https://github.com/elastic/kibana/blob/4565b1bfba91cd24f73f8ce37fa7be73283a4453/src/plugins/dashboard/public/dashboard_container/embeddable/create/create_dashboard.ts#L165-L171

... the dashboard information would not get updated. _(Oof!)_ 

Despite the lengthy description of the problem, the solution is quite
simple - just don't add dashboards to the cache if they require a
redirect. And then everything works! 🎉

### Videos
**Before**


https://github.com/elastic/kibana/assets/8698078/983b81a6-acf3-4e71-804a-6ed75c36896f


**After**


https://github.com/elastic/kibana/assets/8698078/028369ff-f73f-43e6-9abb-b35f0d2f33e1


### Testing
To test, I followed the directions from [this PR
description](elastic#163658) to get a
dashboard that requires a redirect - then, I created a markdown panel
with the **old** (from the Default space) dashboard ID in the new space
to see the same redirect behaviour that the customer in the SDH was
seeing.

### Checklist
- [x] This was checked for [cross-browser
compatibility](https://www.elastic.co/support/matrix#matrix_browsers)
- [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

### 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)
CoenWarmer pushed a commit to CoenWarmer/kibana that referenced this pull request Feb 15, 2024
## Summary

This PR fixes the alias redirect problem that was noted in the attached
SDH.

For context, as part of the [Links panel
work](elastic#166896), I added [dashboard
caching](elastic#162285) to make
navigation more efficient - however, when implementing this, I did not
consider the redirect behaviour.

Specifically, we were **always** adding dashboards to the cache, even if
the load outcome meant a redirect was necessary - so, because the meta
info for the dashboard fetch result was cached, this meant that the
`'aliasMatch'` outcome was **also** cached. Because of this, after a
redirect happened, the second attempt to load the dashboard would return
the result from the **cache** rather than fetching the dashboard from
the CM client - but, as described previously, the cached dashboard would
still appear as though it required a redirect because the cached outcome
was `'aliasMatch'`.

Therefore, because of hitting this early return on **both** fetch
attempts (before the redirect, after the redirect)...


https://github.com/elastic/kibana/blob/4565b1bfba91cd24f73f8ce37fa7be73283a4453/src/plugins/dashboard/public/dashboard_container/embeddable/create/create_dashboard.ts#L165-L171

... the dashboard information would not get updated. _(Oof!)_ 

Despite the lengthy description of the problem, the solution is quite
simple - just don't add dashboards to the cache if they require a
redirect. And then everything works! 🎉

### Videos
**Before**


https://github.com/elastic/kibana/assets/8698078/983b81a6-acf3-4e71-804a-6ed75c36896f


**After**


https://github.com/elastic/kibana/assets/8698078/028369ff-f73f-43e6-9abb-b35f0d2f33e1


### Testing
To test, I followed the directions from [this PR
description](elastic#163658) to get a
dashboard that requires a redirect - then, I created a markdown panel
with the **old** (from the Default space) dashboard ID in the new space
to see the same redirect behaviour that the customer in the SDH was
seeing.

### Checklist
- [x] This was checked for [cross-browser
compatibility](https://www.elastic.co/support/matrix#matrix_browsers)
- [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

### 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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
impact:high Addressing this issue will have a high level of impact on the quality/strength of our product. loe:medium Medium Level of Effort Team:Presentation Presentation Team for Dashboard, Input Controls, and Canvas
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants