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

[Stack Monitoring] Add setup mode to react app #110670

Merged
merged 10 commits into from
Sep 3, 2021

Conversation

estermv
Copy link
Contributor

@estermv estermv commented Aug 31, 2021

Summary

This PR adds the setup mode to the react app.
I just tested it in the overview page. To verify that is working I enabled the legacy monitoring, so this badge appears when you enter the setup mode:
Screenshot 2021-09-02 at 17 48 50

Notes for the reviewer

  • Set monitoring.ui.render_react_app: true in kibana.dev.yml to render the react app.
  • SetupModeRenderer and setup_mode.tsx are almost copies from the original files, just adapting them to work in react. When angular is removed, we will need to move setup_mode.tsx to the original location so all imports from existing react child components keep working.

@estermv estermv added v8.0.0 Team:Infra Monitoring UI - DEPRECATED DEPRECATED - Label for the Infra Monitoring UI team. Use Team:obs-ux-infra_services release_note:skip Skip the PR/issue when compiling release notes Feature:Stack Monitoring auto-backport Deprecated - use backport:version if exact versions are needed v7.16.0 Epic: Stack Monitoring de-angularization labels Aug 31, 2021
* 2.0.
*/

import React, { Fragment } from 'react';
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, it's forked from that file. I couldn't use the legacy shims because there is no scope mock in the Legacy class and because the global state context doesn't exist in the Angular work and it's needed here.

But good point with forking the tests, I'll take a look now to see if it's easy to adapt them to the changes made 🤞

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I didn't fork tests yet. There are some snapshot tests that I think it would be interesting to run against (I could also copy that, but I think is too much copy).

Copy link
Contributor

@matschaffer matschaffer left a comment

Choose a reason for hiding this comment

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

I did some exploring to try to figure out why the alerts from the angular side weren't showing in the new setup mode. But looks like they get wired up as part of the base_controller.js, so that explains it.

Otherwise looks workable. Curious about that forked code, but not curious enough to block merge.

@estermv estermv marked this pull request as ready for review September 2, 2021 15:50
@estermv estermv requested a review from a team as a code owner September 2, 2021 15:50
@estermv estermv requested review from a team September 2, 2021 15:50
@elasticmachine
Copy link
Contributor

Pinging @elastic/logs-metrics-ui (Team:logs-metrics-ui)

@@ -209,6 +211,7 @@ export const initSetupModeState = async ($scope: any, $injector: any, callback?:
};

export const isInSetupMode = (context?: ISetupModeContext) => {
if (isReactMigrationEnabled()) return setupModeReact.isInSetupMode(context);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This method is used in many places in react child components rendered also in angular. This is a hack to make it work with the new file without modifying several components.

@@ -222,6 +225,7 @@ export const isInSetupMode = (context?: ISetupModeContext) => {
};

export const isSetupModeFeatureEnabled = (feature: SetupModeFeature) => {
if (isReactMigrationEnabled()) return setupModeReact.isSetupModeFeatureEnabled(feature);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This method is used in many places in react child components rendered also in angular. This is a hack to make it work with the new file without modifying several components.

@estermv
Copy link
Contributor Author

estermv commented Sep 2, 2021

@matschaffer I added some changes since you reviewed, so I requested another review.

@estermv
Copy link
Contributor Author

estermv commented Sep 2, 2021

@elasticmachine merge upstream

Copy link
Contributor

@matschaffer matschaffer left a comment

Choose a reason for hiding this comment

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

I love the isInSetupMode refactoring update. But I noticed we have duplicate buttons.

We could merge this and sort that out in a later PR but maybe good to fix up now.

<SetupModeEnterButton enabled={enabled} toggleSetupMode={toggleSetupMode} />
</I18nContext>
</KibanaContextProvider>,
document.getElementById('setupModeNav')
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we renter into the div here rather than put a conditional component into the PageTemplate?

Also I noticed we now have two "setup" things, so guessing we should maybe move the setupModeNav into MonitoringToolbar?

Screen Shot 2021-09-03 at 13 38 23

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is how it was done before and I don't know exactly why they did it that way.

When I added it, it just worked so I thought that changing it will take more time and it could introduce some bugs. I also think that everything related to setup mode needs to be refactored, both from a UX perspective (I'm not sure how intuitive it is for users...) and technically so we could improve everything together.

@estermv
Copy link
Contributor Author

estermv commented Sep 3, 2021

@elasticmachine merge upstream

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
monitoring 580 583 +3

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
monitoring 762.6KB 775.4KB +12.8KB

Page load bundle

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

id before after diff
monitoring 47.9KB 48.3KB +439.0B

History

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

@estermv estermv merged commit 75486ec into elastic:master Sep 3, 2021
@kibanamachine
Copy link
Contributor

💔 Backport failed

Status Branch Result
7.x Commit could not be cherrypicked due to conflicts

To backport manually run:
node scripts/backport --pr 110670

@kibanamachine kibanamachine added the backport missing Added to PRs automatically when the are determined to be missing a backport. label Sep 7, 2021
@kibanamachine
Copy link
Contributor

Friendly reminder: Looks like this PR hasn’t been backported yet.
To create backports run node scripts/backport --pr 110670 or prevent reminders by adding the backport:skip label.

estermv added a commit to estermv/kibana that referenced this pull request Sep 7, 2021
* Show setup mode button and setup bottom bar

* Adapt setup mode in react components to work without angular

* Add setup mode data update to react app

* Add missing functions from setup mode

* Revert setup mode changes from react components

* remove some empty lines

* Add setup button to  monitoring toolbar

* Fix types

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
@kibanamachine kibanamachine removed the backport missing Added to PRs automatically when the are determined to be missing a backport. label Sep 7, 2021
estermv added a commit that referenced this pull request Sep 7, 2021
* Show setup mode button and setup bottom bar

* Adapt setup mode in react components to work without angular

* Add setup mode data update to react app

* Add missing functions from setup mode

* Revert setup mode changes from react components

* remove some empty lines

* Add setup button to  monitoring toolbar

* Fix types

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto-backport Deprecated - use backport:version if exact versions are needed Epic: Stack Monitoring de-angularization Feature:Stack Monitoring release_note:skip Skip the PR/issue when compiling release notes Team:Infra Monitoring UI - DEPRECATED DEPRECATED - Label for the Infra Monitoring UI team. Use Team:obs-ux-infra_services v7.16.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants