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

[Drilldowns] import dashboard url generator from plugin contract #64628

Merged

Conversation

Dosant
Copy link
Contributor

@Dosant Dosant commented Apr 28, 2020

Summary

Following up on #63108 (comment)
Following recommendation from: #62815

Instead of importing url generator using ID and registry, import it via plugin contract.

@stacey-gammon, should I create a ticket to clean url generator registry and to use the same approach in ML?

Checklist

Delete any items that are not applicable to this PR.

For maintainers

@Dosant Dosant added Feature:Dashboard Dashboard related features Feature:Embedding Embedding content via iFrame v8.0.0 Team:AppArch release_note:skip Skip the PR/issue when compiling release notes v7.8.0 labels Apr 28, 2020
@Dosant Dosant requested review from streamich, stacey-gammon and a team April 28, 2020 09:29
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-app-arch (Team:AppArch)

@@ -153,7 +150,7 @@ export class DashboardToDashboardDrilldown
}
}

return getUrlGenerator(DASHBOARD_APP_URL_GENERATOR).createUrl({
return this.params.getDashboardUrlGenerator().createUrl!({
Copy link
Contributor

Choose a reason for hiding this comment

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

huh, having a hard time following this without pulling down the code... why would this possibly be undefined?

Copy link
Contributor Author

@Dosant Dosant Apr 29, 2020

Choose a reason for hiding this comment

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

I just realised a difference...
When I started exporting directly and using directly it is UrlGeneratorsDefinition
But when we access from share plugin registry it is UrlGeneratorContract.
So url generator registry wrap the definition and adds additional logic. Which means this "refactor" is not 1 to 1 functionality match.

Not sure how to proceed from here in this case, but this pr is incorrect then right now...

Copy link
Contributor

Choose a reason for hiding this comment

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

ahhhh. Yea this is the problem discussed in that issue #62815. However, this PR has a solution for it: #62998 that may work. You'd have to change it to registerUrlGenerator returns the getter that will return the contract in the start life cycle.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks!

share plugin is optional in dashboard. So I guess this also means that dashboardUrlGenerator will be optional on dashboard plugin contract?

Copy link
Contributor

@stacey-gammon stacey-gammon Apr 29, 2020

Choose a reason for hiding this comment

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

somewhat of a bummer, but that share plugin contains the code for handling migrations automatically, which is why the Definition becomes a Contract. This may change when Persistable state registries becomes a formal, generic service. I would take the path of least resistance for now (require share plugin for this functionality), and we can revisit when we know more about how the persistable state registries will work.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@stacey-gammon please take a look 🙏
hope I followed the proposed solution correctly.

This needs further clean up: like removing global mappings and fixing how ML uses it, but I don't want to do this in this pr, because it points to drilldowns branch

@Dosant Dosant marked this pull request as draft April 29, 2020 09:35
const actionFlyoutCreateDrilldown = new FlyoutCreateDrilldownAction({ start });
uiActions.addTriggerAction(CONTEXT_MENU_TRIGGER, actionFlyoutCreateDrilldown);

const actionFlyoutEditDrilldown = new FlyoutEditDrilldownAction({ start });
uiActions.addTriggerAction(CONTEXT_MENU_TRIGGER, actionFlyoutEditDrilldown);

const dashboardToDashboardDrilldown = new DashboardToDashboardDrilldown({
getSavedObjectsClient,
start,
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is a move in the wrong direction. While it's very easy to just pass down start it encourages tight coupling to core. See https://www.notion.so/Tight-Coupling-in-Kibana-fcee0454319140d39aa5e83052bba901

Copy link
Contributor

Choose a reason for hiding this comment

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

Had a similar comment in a PR from Vadim, we can move this discussion outside this PR. Don't let it block you.

Copy link
Contributor

@stacey-gammon stacey-gammon left a comment

Choose a reason for hiding this comment

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

code review only

@Dosant Dosant force-pushed the dev/import-dashboard-url-generator-directly branch from a26e409 to 18935b8 Compare May 4, 2020 15:34
@Dosant Dosant changed the base branch from drilldowns to master May 4, 2020 15:35
@Dosant Dosant marked this pull request as ready for review May 4, 2020 15:35
@Dosant Dosant requested a review from a team as a code owner May 4, 2020 15:35
@Dosant
Copy link
Contributor Author

Dosant commented May 6, 2020

@elasticmachine merge upstream

@botelastic botelastic bot added the Feature:Drilldowns Embeddable panel Drilldowns label May 6, 2020
const getDashboardUrlGenerator = () => {
const urlGenerator = start().plugins.dashboard.dashboardUrlGenerator;
if (!urlGenerator)
throw new Error('dashboardUrlGenerator is required for dashboard to dashboard drilldown');
Copy link
Contributor

Choose a reason for hiding this comment

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

This message contains error message specific for drilldowns.

... required for dashboard to dashboard drilldown

When somebody else in this plugin will start using the dashboard URL generator, this error message will not make sense for them.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

But it is inside /dashboard_drilldowns_services.ts 🤔

@Dosant Dosant requested review from majagrubic and ThomThomson May 7, 2020 09:09
@Dosant Dosant added v7.9.0 and removed v7.8.0 labels May 7, 2020
@Dosant
Copy link
Contributor Author

Dosant commented May 7, 2020

@elasticmachine merge upstream

@Dosant
Copy link
Contributor Author

Dosant commented May 7, 2020

@majagrubic or @ThomThomson might taking a code owner look please? 🙏

Copy link
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 and safari. Everything dashboard / Kibana App related still works as expected. I also took the opportunity to understand the broader context of this change, and that makes sense as well.

LGTM!

const { plugins } = this.params.start();

return plugins.share.urlGenerators.getUrlGenerator(DASHBOARD_APP_URL_GENERATOR).createUrl({
return this.params.getDashboardUrlGenerator().createUrl({
Copy link
Contributor

Choose a reason for hiding this comment

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

This looks much cleaner!

@Dosant
Copy link
Contributor Author

Dosant commented May 8, 2020

@elasticmachine merge upstream

@Dosant
Copy link
Contributor Author

Dosant commented May 11, 2020

@elasticmachine merge upstream

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

History

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

@Dosant Dosant merged commit 387e28a into elastic:master May 11, 2020
@Dosant Dosant deleted the dev/import-dashboard-url-generator-directly branch May 11, 2020 08:13
Dosant added a commit to Dosant/kibana that referenced this pull request May 11, 2020
gmmorris added a commit to gmmorris/kibana that referenced this pull request May 11, 2020
* master: (58 commits)
  [Drilldowns][chore] import dashboard url generator from plugin contract (elastic#64628)
  fix double flyouts in add panel flow (elastic#65861)
  Point 7.x to 7.9.0 in .backportrc.json
  Mount ui/new_platform applications in same div structure as Core (elastic#63930)
  [Uptime] Settings threshold validation (elastic#65454)
  Fix edit alert flyout to update initialAlert after edit (elastic#65359)
  Fix anomalies display on focused APM service map (elastic#65882)
  [SIEM][Detection Engine] Increases the template limit for ECS mappings
  [SIEM][CASE] Moves functional tests from "legacyEs" to "Es" (elastic#65851)
  [Metrics UI] Fix p95/p99 charts and alerting error (elastic#65579)
  [ML] Add job timing stats to anomaly jobs (elastic#65696)
  restore index pattern management data-test-subj's (elastic#64697)
  [Discover] Prevent whitespace wrapping of doc table header (elastic#52861)
  [SIEM] Fixes a CSS issue with Timeline field truncation (elastic#65789)
  Skipping failing tests. elastic#65867 elastic#65866 elastic#65865
  [Discover] Deangularize the hits counter and create a react component (elastic#65631)
  Tsvb less update (elastic#65467)
  [TSVB] Remove remaining lodash.set usage (elastic#65846)
  [Uptime] Add `a11y` tests (elastic#65514)
  [Uptime] Enable loading on monitor list (elastic#65670)
  ...
Dosant added a commit that referenced this pull request May 12, 2020
…ct (#64628) (#65972)

Co-authored-by: Elastic Machine <[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
Feature:Dashboard Dashboard related features Feature:Drilldowns Embeddable panel Drilldowns Feature:Embedding Embedding content via iFrame release_note:skip Skip the PR/issue when compiling release notes v7.9.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants