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

Prevent flicker on Getting Started page #11826

Merged

Conversation

ycombinator
Copy link
Contributor

@ycombinator ycombinator commented May 16, 2017

Fixes #11808.

What's in the box

This PR:

  • Prevents flicker of the chrome by starting out the chrome as invisible. Then, depending on the scenario being handled in the add_setup_work.js module's gettingStartedGateCheck function, makes the chrome visible again.

  • Consolidates the code that toggles the chrome visibility into a single module, add_setup_work.js, making it easier to reason about chrome visibility under various scenarios.

  • Extracts the three scenarios handled by the gettingStartedGateCheck function into their own functions for better readability.

Before this PR

gs_before

After this PR

gs_after

@ycombinator ycombinator requested review from epixa and spalger May 16, 2017 19:43
@ycombinator ycombinator added :Management review v5.5.0 v6.0.0 bug Fixes for quality problems that affect the customer experience labels May 16, 2017
Copy link
Contributor

@spalger spalger left a comment

Choose a reason for hiding this comment

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

Can you please add some tests for gettingStartedGateCheck()? Happy to help bootstrap them if you're not sure where to start.

@ycombinator
Copy link
Contributor Author

@spalger I created #11850 for functional tests that will exercise the paths through gettingStartedGateCheck(). I made it a separate PR hoping it's a bit easier to review.

@epixa
Copy link
Contributor

epixa commented May 17, 2017

We really should write more unit tests for this stuff rather than jumping directly to functional tests. Sometimes that's not really doable with the legacy code though.

@@ -11,6 +11,67 @@ import {
CREATE_INDEX_PATTERN_ROUTE
} from './constants';

function handleExistingIndexPatternsScenario(indexPatterns, currentRoute, config) {
// If index patterns exist, we're not going to show the user the Getting Starte page.
Copy link
Contributor

Choose a reason for hiding this comment

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

Starte should be Started

}

// Otherwise, check if we have a default index pattern
let defaultIndexPattern = config.get('defaultIndex');
Copy link
Contributor

Choose a reason for hiding this comment

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

This defaultIndex logic doesn't seem appropriate in the getting started guide, as it doesn't seem to be related at all. If someone were to disable the getting_started plugin entirely, it would break the default index behavior.

Copy link
Contributor

Choose a reason for hiding this comment

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

I see now that this already existed in the getting started guide from the previous PR. Where was it moved from? Can it be moved back?

Copy link
Contributor

Choose a reason for hiding this comment

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

The same sentiment applies further down in this file with the "please create a new index pattern" logic.

Copy link
Contributor

Choose a reason for hiding this comment

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

This doesn't need to be dealt with in this PR since you're fixing a bug here and just moving stuff around, but we really should sort it out in a follow up.

Copy link
Contributor Author

@ycombinator ycombinator May 17, 2017

Choose a reason for hiding this comment

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

So the reason the two pieces of logic (getting started and default index patterns) have been combined is that both use RouteSetupManager.addSetupWork(fn) to do their job.

In an early implementation I had the two independent of each other but I would see the "No default index pattern" notifier on the Getting Started page. This was happening because, AFAICT, there's no way of specifying the order of execution of the two fns registered with RouteSetupManager.addSetupWork(fn). So my solution to control the order was to combine the two pieces of logic into one fn.

@ycombinator
Copy link
Contributor Author

@epixa @spalger I've added unit tests to this PR. Ready for review again.

* gettingStartedGateCheck, which does the actual work.
*/
function _gettingStartedGateCheck(Private, $injector) {
Copy link
Contributor

Choose a reason for hiding this comment

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

How about gettingStartedGateCheckProvider? Or just putting this inline with uiRoutes.addSetupWork()?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I'll take the latter option. Gracias.

@@ -230,7 +230,7 @@ Notifier.config = {
errorLifetime: 300000,
warningLifetime: 10000,
infoLifetime: 5000,
setInterval: window.setInterval,
setInterval: window.setInterval.bind(window),
Copy link
Contributor

Choose a reason for hiding this comment

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

Why does setInterval need to be bound to window but clearInterval doesn't?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

clearInterval probably does too. The code path I was testing with the Getting Started page ended up exercising setInterval, so I fixed that one. I will fix clearInterval as well. Thanks for pointing it out.

@ycombinator ycombinator force-pushed the getting-started/prevent-flicker branch from 3f61821 to f39599d Compare May 19, 2017 11:48
@ycombinator
Copy link
Contributor Author

@spalger I've rebased on master and incorporated the changes from #11881. Mind taking a (hopefully quick) look again at this PR to make sure its working as you expect with those changes?

@epixa
Copy link
Contributor

epixa commented May 23, 2017

LGTM

Copy link
Contributor

@spalger spalger left a comment

Choose a reason for hiding this comment

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

LGTM

@ycombinator ycombinator merged commit c4b3ade into elastic:master May 23, 2017
ycombinator added a commit that referenced this pull request May 23, 2017
* Consolide chrome visibility toggle code into single module

* Extracting code into helper functions for better readability

* Removing redundant setting

* Extracting functions to higher level in scope so they are not defined multiple times

* Fixing typo in comment

* Starting to add unit tests

* Actually adding the tests this time

* Adding unit tests for handleGettingStartedOptedOutScenario function

* Binding this to window to prevent Uncaught TypeError: Illegal invocation

* Adding unit tests for handleExistingIndexPatternsScenario function

* Add helper function to aid unit testing

* Refactor unit tests

* Inlining function to prevent naming awkwardness

* Binding this to window to remove ambiguity

* Adding missing import

* Fixing import

* Catching expected error
@ycombinator
Copy link
Contributor Author

Backported to:

  • 5.x / 5.5: 0a88700

@ycombinator ycombinator deleted the getting-started/prevent-flicker branch May 23, 2017 18:54
snide pushed a commit to snide/kibana that referenced this pull request May 30, 2017
* Consolide chrome visibility toggle code into single module

* Extracting code into helper functions for better readability

* Removing redundant setting

* Extracting functions to higher level in scope so they are not defined multiple times

* Fixing typo in comment

* Starting to add unit tests

* Actually adding the tests this time

* Adding unit tests for handleGettingStartedOptedOutScenario function

* Binding this to window to prevent Uncaught TypeError: Illegal invocation

* Adding unit tests for handleExistingIndexPatternsScenario function

* Add helper function to aid unit testing

* Refactor unit tests

* Inlining function to prevent naming awkwardness

* Binding this to window to remove ambiguity

* Adding missing import

* Fixing import

* Catching expected error
ycombinator added a commit to ycombinator/kibana that referenced this pull request Jun 2, 2017
ycombinator added a commit to ycombinator/kibana that referenced this pull request Jun 3, 2017
ycombinator added a commit that referenced this pull request Jun 5, 2017
* Revert "When on an embedded page, bypass Getting Started gate check (#12040)"

This reverts commit 05293f1.

* Revert "Making tweaks. (#12003)"

This reverts commit aa3fa06.

* Revert "Functional tests for the Getting Started page (#11850)"

This reverts commit 099178a.

* Revert "Prevent flicker on Getting Started page (#11826)"

This reverts commit c4b3ade.

* Revert "Getting Started page (#11805)"

This reverts commit 32eff37.

* Remove check for Getting Started page from navigateToApp
ycombinator added a commit that referenced this pull request Jun 5, 2017
* Revert "When on an embedded page, bypass Getting Started gate check (#12040)"

This reverts commit 05293f1.

* Revert "Making tweaks. (#12003)"

This reverts commit aa3fa06.

* Revert "Functional tests for the Getting Started page (#11850)"

This reverts commit 099178a.

* Revert "Prevent flicker on Getting Started page (#11826)"

This reverts commit c4b3ade.

* Revert "Getting Started page (#11805)"

This reverts commit 32eff37.

* Remove check for Getting Started page from navigateToApp
PopradiArpad pushed a commit to PopradiArpad/kibana that referenced this pull request Jun 6, 2017
* Revert "When on an embedded page, bypass Getting Started gate check (elastic#12040)"

This reverts commit 05293f1.

* Revert "Making tweaks. (elastic#12003)"

This reverts commit aa3fa06.

* Revert "Functional tests for the Getting Started page (elastic#11850)"

This reverts commit 099178a.

* Revert "Prevent flicker on Getting Started page (elastic#11826)"

This reverts commit c4b3ade.

* Revert "Getting Started page (elastic#11805)"

This reverts commit 32eff37.

* Remove check for Getting Started page from navigateToApp
chrisronline pushed a commit to chrisronline/kibana that referenced this pull request Jun 14, 2017
* Revert "When on an embedded page, bypass Getting Started gate check (elastic#12040)"

This reverts commit 05293f1.

* Revert "Making tweaks. (elastic#12003)"

This reverts commit aa3fa06.

* Revert "Functional tests for the Getting Started page (elastic#11850)"

This reverts commit 099178a.

* Revert "Prevent flicker on Getting Started page (elastic#11826)"

This reverts commit c4b3ade.

* Revert "Getting Started page (elastic#11805)"

This reverts commit 32eff37.

* Remove check for Getting Started page from navigateToApp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Fixes for quality problems that affect the customer experience review v5.5.0 v6.0.0-alpha2 v6.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants