-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Conversation
* 2.0. | ||
*/ | ||
|
||
import React, { Fragment } from 'react'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems like it's forked from https://github.com/elastic/kibana/blob/master/x-pack/plugins/monitoring/public/components/renderers/setup_mode.js
Do you think we could use the legacy shims to avoid the fork? Or if not should we maybe also fork https://github.com/elastic/kibana/blob/master/x-pack/plugins/monitoring/public/components/renderers/setup_mode.test.js ?
There was a problem hiding this comment.
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 🤞
There was a problem hiding this comment.
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).
There was a problem hiding this 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.
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); |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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.
@matschaffer I added some changes since you reviewed, so I requested another review. |
@elasticmachine merge upstream |
There was a problem hiding this 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') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
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.
@elasticmachine merge upstream |
💚 Build Succeeded
Metrics [docs]Module Count
Async chunks
Page load bundle
History
To update your PR or re-run it, just comment with: |
💔 Backport failed
To backport manually run: |
Friendly reminder: Looks like this PR hasn’t been backported yet. |
* 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>
* 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>
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:
Notes for the reviewer
SetupModeRenderer
andsetup_mode.tsx
are almost copies from the original files, just adapting them to work in react. When angular is removed, we will need to movesetup_mode.tsx
to the original location so all imports from existing react child components keep working.