fix(webui): replace nested create routes with parent-view modals#2081
Conversation
andrewazores
left a comment
There was a problem hiding this comment.
Functionality looks and feels great!
When embedded is true
Are there cases where we still use these components with embedded={false}?
Good catch. Now that the standalone create routes are removed, |
|
All looking good. I just had a thought though - we have some issues with passing state around using the React router when cryostat-web is running as part of the OpenShift Console plugin: cryostatio/cryostat-openshift-console-plugin#143 I guess this also means that with this change, the user will be able to navigate ex. from a Dashboard card or the Topology view to Recordings when they want to start a recording, but the modal will not automatically appear (and will continue to not be pre-populated if they manually open it)? |
Hmm.. how about using a URL search param for the modal trigger and keep |
|
I don't know how well URL search params work in the context of a console plugin, but it's worth giving it a shot. |
|
Check out cryostatio/cryostat-openshift-console-plugin#143 (comment) , I wrote down my thoughts on what the problem is. I could be wrong though, this was just my brain dump from what I understand is going on. If you're going to test out this PR in an OpenShift context anyway I encourage you to also test out my hypothesis about the router state being intercepted. If that is the case then it may not be so hard for us to solve on the Console Plugin side, and may not need to worry about the URL search params "fix" on this side. |
Okay so I tested this PR inside the OpenShift Console plugin and it lines up with the router-state interception issue from |
d5e858d to
8302bb8
Compare
8302bb8 to
b85f029
Compare
…e-modals # Conflicts: # src/app/CreateRecording/CreateRecording.tsx # src/app/routes.tsx
|
@jtolentino1 rebase, please. I think this is ready for review now, right? |
no, not yet. I was testing this commit: b85f029 with cryostat-openshift-plugin and wasn't working just yet. actively working on a fix |
|
Minor bug:
Similarly, creating a JFR Metrics dashboard card and going through its recording creation flow does not dismiss the modal either. And the same with Target Analysis, from the Recordings view. Directly creating a recording from the Recording view does dismiss the modal upon recording creation. |
Welcome to Cryostat! 👋
Before contributing, make sure you have:
mainbranch[chore, ci, docs, feat, fix, test]To recreate commits with GPG signature
git fetch upstream && git rebase --force --gpg-sign upstream/mainFixes: #1284
Description of the change:
Remove the nested create sub-routes (
/recordings/create,/rules/create,/topology/create-custom-target) fromroutes.tsx. These child route definitions are replaced by PatternFlyModalcomponents rendered directly within their parent views (Recordings.tsx,Rules.tsx,Topology.tsx). Each parent view manages a boolean state that is set totruewhenlocation.state.openCreateModalis present, and clears the state on modal close to prevent re-opening on re-render.Add
embeddedandonCloseprops to the three create components (CreateRecording,CreateRule,CreateTarget). Whenembeddedistrue, the component skips its page-level wrapper (TargetVieworBreadcrumbPage) and returns just the form content, making it suitable for rendering inside a modal. TheonCloseprop is passed down to the inner form components (CustomRecordingForm,SnapshotRecordingForm,CreateRuleForm) asonExit, which they call instead ofnavigate('..')when provided.Add a
modalPrefillRedux store slice (ModalPrefillSlice.ts) withmodalPrefillSetIntentandmodalPrefillClearIntentactions. TheuseModalFromLocationStatehook checkslocation.statefirst, then falls back to the ReduxmodalPrefillstore, so the modal opens and receives prefill data even when the OpenShift Console Router dropslocation.stateduring cross-page navigation. Cross-page call-sites (Dashboard, Events, Topology actions,CryostatLink) dispatchmodalPrefillSetIntentto Redux before callingnavigate(). Same-page call-sites (Create button on Recordings, Edit/Copy on Rules) uselocation.stateonly since it works reliably for same-page navigation.Update tests to remove references to the deleted sub-routes, render create components at the parent path instead, and assert navigation to the parent route. A
globalThis.Requestpolyfill is added totest-setup.js, and the Mirage recording creation handler now includesjvmIdin the notification message to support the modal's async table refresh.Motivation for the change:
Navigating directly to the create sub-routes (e.g. by pasting
/recordings/createinto the browser) renders a blank page with a console error because the nested routes cannot properly initialize outside of their parent context. Replacing them with modals avoids this issue entirely, since the parent view is always the entry point.How to manually test: