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

Implement ScopedHistory.block #91099

Merged
merged 9 commits into from
Feb 22, 2021

Conversation

pgayvallet
Copy link
Contributor

@pgayvallet pgayvallet commented Feb 11, 2021

Summary

Fix #88896

Checklist

@pgayvallet pgayvallet added release_note:skip Skip the PR/issue when compiling release notes Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc v7.13.0 labels Feb 11, 2021
@pgayvallet pgayvallet changed the title Implements ScopedHistory.block Implement ScopedHistory.block Feb 11, 2021
@pgayvallet pgayvallet marked this pull request as ready for review February 11, 2021 14:36
@pgayvallet pgayvallet requested a review from a team as a code owner February 11, 2021 14:36
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-core (Team:Core)

@pgayvallet
Copy link
Contributor Author

@joshdover Now that we have this, do we want to deprecates AppMountParameters.onAppLeave? I looked at the usages, and adapting all the current usages is not going to be trivial, so I'm wondering if I should deprecates this API and open a follow-up to ping the teams to migrate to History.block?

@Bamieh Bamieh self-requested a review February 15, 2021 08:03
Copy link
Member

@Bamieh Bamieh left a comment

Choose a reason for hiding this comment

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

LGTM

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.

Thank you for doing this. I just added a couple of NITs 😇

src/core/public/application/scoped_history.ts Show resolved Hide resolved
await testSubjects.existOrFail('navigationBlockConfirmModAl');
await PageObjects.common.clickConfirmOnModal();
expect(await browser.getCurrentUrl()).to.contain('/app/core_history_block/foo');
});
Copy link
Member

Choose a reason for hiding this comment

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

NIT: What happens if we navigate back to core_history_block, do we get the confirmation again? Can we add a test to ensure we don't leave hanging Prompts? How about re-entering the app? Will it re-register the Prompt a 2nd time?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What happens if we navigate back to core_history_block, do we get the confirmation again?

In this specific test plugin's implementation, we don't, as we are using the Prompt component on the / page only, so the block handler will be disposed when leaving this specific page. I can add a test asserting this behavior, even if it's more the plugin's implementation detail we would be testing here.

Can we add a test to ensure we don't leave hanging Prompts? How about re-entering the app? Will it re-register the Prompt a 2nd time?

When re-entering the app, a new ScopedHistory instance will be created, and the Prompt will be reattach from this new instance to the global history. The block handlers removal when the history changes from active to inactive is more heavily tested in the ScopedHistory's unit tests (which is way easier than from FTR).

@joshdover
Copy link
Contributor

Now that we have this, do we want to deprecates AppMountParameters.onAppLeave? I looked at the usages, and adapting all the current usages is not going to be trivial, so I'm wondering if I should deprecates this API and open a follow-up to ping the teams to migrate to History.block?

Yes, let's mark it deprecated and open a new issue for migrating existing usages.

Copy link
Contributor

@yakhinvadim yakhinvadim left a comment

Choose a reason for hiding this comment

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

Just tested the branch. Works perfectly in Enterprise Search!

image

Thanks for doing it so quickly!

Copy link
Member

@cee-chen cee-chen left a comment

Choose a reason for hiding this comment

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

+1-ing Vadim's approval - I assumed we were tagged in mostly for QA vs. code review, but you want a secondary reviewer as well feel free to shout (not sure how useful I'd be though :)

"server": false,
"ui": true,
"requiredBundles": ["kibanaReact"]
}
Copy link
Member

Choose a reason for hiding this comment

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

Just to confirm my understanding of this - if we want to use <Prompt>, do we need to include this plugin in Enterprise Search as a required dependency? Or no/is it already baked in?

Copy link
Contributor

@yakhinvadim yakhinvadim Feb 16, 2021

Choose a reason for hiding this comment

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

I imported it from react-router-dom and it worked, so I guess it's baked in.

Feel free to correct me, if I'm wrong!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Na, everything is provided from core. I just used kibanaReact in the test plugin for some utility functions

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
core 446 447 +1

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
core 478.6KB 479.8KB +1.2KB

History

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

@pgayvallet pgayvallet merged commit eed5f72 into elastic:master Feb 22, 2021
pgayvallet added a commit to pgayvallet/kibana that referenced this pull request Feb 22, 2021
* implements ScopedHistory.block

* add FTR tests

* fix test plugin id

* update generated doc

* deprecates AppMountParameters.onAppLeave

* typo fix

* add new FTR test

* fix added test
gmmorris added a commit to gmmorris/kibana that referenced this pull request Feb 22, 2021
* master: (36 commits)
  [Uptime] Thumbnail full screen view steps navigation fix (elastic#91895)
  Implement ScopedHistory.block (elastic#91099)
  [Lens] Fix overlowing content on a chart for charts and table (elastic#92006)
  handle source column differences in embeddable as well (elastic#91987)
  [Vega] [Map] disable map rotation using right right click /  touch rotation gesture (elastic#91996)
  [Lens] Load indexpatterns list from indexPattern Service (elastic#91984)
  [coverage] ingest data in parallel (elastic#92074)
  [Lens] Drag and drop performance improvements (elastic#91641)
  A few more environment uiFilters fixes (elastic#92044)
  Enabling Uptime and Dashboard a11y test (elastic#91017)
  [Security Solution][Detections] Adds more granular validation for nested fields (elastic#92041)
  [Security Solution] [Detections] add overflow-wrap for description (elastic#91945)
  [Security Solution] [Detections] do not truncate filename in value list table in modal (elastic#91952)
  Skip flaky apm test elastic#91673 (elastic#92065)
  [docker] Default server.name to hostname (elastic#90799)
  Use documentation link service for snapshot restore (elastic#91596)
  [Security Solution] Clearing up all jest errors and warnings (elastic#91740)
  Add `@kbn/analytics` to UI Shared Deps (elastic#91810)
  [7.12][Telemetry] Add missing fields for security telemetry (elastic#91920)
  [Security Solution] Adds cypress-pipe (elastic#91550)
  ...
pgayvallet added a commit that referenced this pull request Feb 22, 2021
* implements ScopedHistory.block

* add FTR tests

* fix test plugin id

* update generated doc

* deprecates AppMountParameters.onAppLeave

* typo fix

* add new FTR test

* fix added test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release_note:skip Skip the PR/issue when compiling release notes Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc v7.13.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Request] In-app Prompt/onLeave confirmation
8 participants