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

[Navigation embeddable] Add content management #160896

Merged
merged 25 commits into from
Aug 10, 2023

Conversation

nickpeihl
Copy link
Member

@nickpeihl nickpeihl commented Jun 29, 2023

Fixes #154362

Summary

Adds content management to navigation embeddable feature branch.

Allows Links panels to be by-value or by-reference on a Dashboard. The UX for users to choose to save by-value or by-reference remains to be finalized and is out of scope for this PR.

Copy link
Contributor

@Heenawter Heenawter left a comment

Choose a reason for hiding this comment

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

Initial review - left a few questions + comments, and I caught a couple bugs that you may already know about. This is coming along great! 🎉

This makes it easier to use the Elasticsearch `_update` API for saved
objects. With arrays we are always replacing the entire selection. Using
`_update` with an object mapping applies only partial updates. So it was
not possible to delete a link.
The `createNewEmbeddable` function will catch the rejected promise and return to the dashboard.
embeddable.inputIsRefType(embeddable.getInput())
) {
embeddable.reload();
}
Copy link
Member Author

Choose a reason for hiding this comment

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

We can make this better by making changes to the Container.replaceEmbeddable method to be functionally similar to the replacePanel function in dashboard/public/dashboard_container/embeddable/api/panel_management.ts.

Copy link
Contributor

@Heenawter Heenawter Aug 7, 2023

Choose a reason for hiding this comment

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

PR to address this: nickpeihl#2 @nickpeihl @ThomThomson

Figured it was easiest to make a PR against this PR, so that we can test the saved object stuff in its entirety - let me know if something else works better, though 👍


export type NavigationEmbeddableContentType = 'navigation_embeddable';

// TODO does this type need to be versioned?
Copy link
Member Author

@nickpeihl nickpeihl Aug 7, 2023

Choose a reason for hiding this comment

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

👀

</EuiFlexItem>
) : null}
</EuiFlexGroup>
</EuiFlexItem>
Copy link
Member Author

Choose a reason for hiding this comment

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

We could make this EuiFlyoutFooter into separate components. But I think it is out-of-scope for this PR until we have user testing to answer the question "Is it better to use two buttons in the footer for by-value / by-value creation, or do we want to use the originally proposed EuiSwitch"?

const { metaInfo, attributes } = await this.attributeService.unwrapAttributes(input);
if (this.isDestroyed) return;

// TODO handle metaInfo
Copy link
Member Author

Choose a reason for hiding this comment

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

👀

).catch(() => {
// swallow the promise rejection that happens when the flyout is closed
return {};
});
Copy link
Member Author

Choose a reason for hiding this comment

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

No need to catch here as the Embeddable panel will handle the catch and return without creating an embeddable.

Copy link
Contributor

@Heenawter Heenawter Aug 7, 2023

Choose a reason for hiding this comment

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

@nickpeihl I think we still need this catch because we're getting an Unhandled promise rejection error thrown to the console on cancel when editing an existing embeddable:

Screen.Recording.2023-08-07.at.3.38.46.PM.mov

Copy link
Member Author

@nickpeihl nickpeihl Aug 10, 2023

Choose a reason for hiding this comment

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

Oops, I still need to look into this. I was under the impression that we should not have to return anything since the createNewEmbeddable method has a catch.

EDIT: Oh, you said "when editing an existing embeddable". 😅

@nickpeihl nickpeihl marked this pull request as ready for review August 7, 2023 18:03
@nickpeihl nickpeihl requested a review from a team as a code owner August 7, 2023 18:03
@nickpeihl nickpeihl requested a review from a team as a code owner August 7, 2023 18:03
@nickpeihl
Copy link
Member Author

Marking this as "Ready for review". I added some 👀 comments that I'm still looking over to see if they are in scope for this PR.

@nickpeihl nickpeihl requested a review from Heenawter August 7, 2023 18:04
@botelastic botelastic bot added the Feature:Embedding Embedding content via iFrame label Aug 7, 2023
Copy link
Contributor

@Heenawter Heenawter left a comment

Choose a reason for hiding this comment

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

Making good progress! 🎉

These equality of these constants are compared in the replaceEmbeddable function which errors because they were different.

It seems this happens in other plugins, too, but we don't see errors since the constants are identical. See `MAP_SAVED_OBJECT_TYPE` and `CONTENT_ID` in the maps plugin. 🙈
@kibana-ci
Copy link
Collaborator

kibana-ci commented Aug 10, 2023

💔 Build Failed

Failed CI Steps

Test Failures

  • [job] [logs] FTR Configs #65 / Console App CCS Perform CCS Search in Console it should be able to access remote data
  • [job] [logs] FTR Configs #65 / Console App CCS Perform CCS Search in Console it should be able to access remote data
  • [job] [logs] FTR Configs #28 / Controls Range Slider Control create and edit edits title and size of an existing control and retains existing range selection
  • [job] [logs] FTR Configs #28 / Controls Range Slider Control create and edit edits title and size of an existing control and retains existing range selection
  • [job] [logs] FTR Configs #13 / dashboard app - group 5 embed mode default URL params renders as expected
  • [job] [logs] FTR Configs #13 / dashboard app - group 5 embed mode default URL params renders as expected
  • [job] [logs] FTR Configs #6 / Fleet Endpoints fleet policy secrets Should correctly create the policy with secrets
  • [job] [logs] FTR Configs #6 / Fleet Endpoints fleet policy secrets Should correctly create the policy with secrets
  • [job] [logs] FTR Configs #3 / 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 #3 / 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 / MetricsUI Endpoints log highlight apis /log_entries/highlights with the default source highlights built-in message column
  • [job] [logs] FTR Configs #59 / MetricsUI Endpoints log highlight apis /log_entries/highlights with the default source highlights built-in message column
  • [job] [logs] FTR Configs #14 / 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 #14 / 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 #8 / 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 #20 / 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 #8 / 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 #20 / 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 #2 / SO type registrations does not remove types from registrations without updating excludeOnUpgradeQuery
  • [job] [logs] FTR Configs #22 / Synthetics API Tests PrivateLocationAddMonitor added an integration for previously added monitor
  • [job] [logs] FTR Configs #22 / Synthetics API Tests PrivateLocationAddMonitor added an integration for previously added monitor
  • [job] [logs] FTR Configs #61 / visualize app visual builder tsdb check should show an error when using an unsupported tsdb field type
  • [job] [logs] FTR Configs #61 / 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 [c7485e6]

History

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

Copy link
Contributor

@Heenawter Heenawter left a comment

Choose a reason for hiding this comment

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

This is working flawlessly now - wow! 🎉 Left one tiny nit, and it looks like the promise rejection is still being thrown when cancelling out of the edit action as shown here. But once that's resolved, I think it's ready to be approved 🤩

@@ -94,6 +94,7 @@ export class EditPanelAction implements Action<ActionContext> {
const oldExplicitInput = embeddable.getExplicitInput();
const newExplicitInput = await factory.getExplicitInput(oldExplicitInput, embeddable.parent);
embeddable.parent?.replaceEmbeddable(embeddable.id, newExplicitInput);

Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Oops - this extra line here is probably from my PR 😅 Probably best to remove it hehe

@nickpeihl
Copy link
Member Author

This is working flawlessly now - wow! 🎉 Left one tiny nit, and it looks like the promise rejection is still being thrown when cancelling out of the edit action as shown here. But once that's resolved, I think it's ready to be approved 🤩

Fixed in ce38804

Regarding the CI failures, I think we can merge without fixing most of those since this is a feature branch. We will need to fix failures before merging the feature branch into main. WDYT @Heenawter?

@Heenawter
Copy link
Contributor

I think we can merge without fixing most of those since this is a feature branch. We will need to fix failures before merging the feature branch into main.

@nickpeihl Agreed 👍

@nickpeihl nickpeihl merged commit 577134c into elastic:navigation-embeddable Aug 10, 2023
Heenawter added a commit that referenced this pull request Aug 16, 2023
… error handling (#162285)

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:
    

https://github.com/elastic/kibana/assets/8698078/37d27683-a6c4-4e7a-9589-0eb0fb899e98
    
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](#162182).
 
### 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:


https://github.com/elastic/kibana/assets/8698078/33a3e573-36a2-47ca-b367-3e04f9541ca3

> **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:


https://github.com/elastic/kibana/assets/8698078/41d68ac7-557c-4586-a59b-7268086991dd

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

- [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)
- [ ] ~[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~ Will be
addressed in #161287
- [x] Any UI touched in this PR is usable by keyboard only (learn more
about [keyboard accessibility](https://webaim.org/techniques/keyboard/))
- [x] Any UI touched in this PR does not create any new axe failures
(run axe in browser:
[FF](https://addons.mozilla.org/en-US/firefox/addon/axe-devtools/),
[Chrome](https://chrome.google.com/webstore/detail/axe-web-accessibility-tes/lhdoppojpmngadmnindnejefpokejbdd?hl=en-US))
- [x] This renders correctly on smaller devices using a responsive
layout. (You can test this [in your
browser](https://www.browserstack.com/guide/responsive-testing-on-local-server))
- [x] This was checked for [cross-browser
compatibility](https://www.elastic.co/support/matrix#matrix_browsers)

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

---------

Co-authored-by: Andrea Del Rio <[email protected]>
Co-authored-by: kibanamachine <[email protected]>
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants