-
Notifications
You must be signed in to change notification settings - Fork 670
CONSOLE-5012: Migrate delete modals and PVC modals to overlay pattern #15932
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
base: main
Are you sure you want to change the base?
Conversation
|
@rhamilto: This pull request references CONSOLE-5012 which is a valid jira issue. Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.22.0" version, but no target version was set. DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
|
@rhamilto: This pull request references CONSOLE-5012 which is a valid jira issue. Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.22.0" version, but no target version was set. DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
📝 WalkthroughWalkthroughModals were migrated from createModalLauncher-based launchers to OverlayComponent providers wrapped by ModalWrapper and wired to closeOverlay. Lazy (React.lazy) provider variants were added and callers now use useOverlay/launchModal to open modals. Several action factories were refactored into hook-based actions (useMemo returning Action) that invoke lazy providers. Modal.setAppElement is initialized in App on mount, and OverlayProvider rendering now uses Suspense for dynamic overlays. 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
Comment |
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.
Actionable comments posted: 2
🤖 Fix all issues with AI agents
In `@frontend/public/components/modals/delete-pvc-modal.tsx`:
- Around line 9-16: Restore a default export so existing callers importing the
default don't break: export the modal component previously exposed as the
default (the DeletePVCModal component used with createModalLauncher) as the
file's default export in addition to any named exports; locate the
DeletePVCModal symbol (and the modal wrapper/props usage such as
ModalComponentProps) and add a default export for it so index
re-exports/back-compat continue to work.
In `@frontend/public/components/modals/index.ts`:
- Line 3: OverlayProvider is rendering lazy components from componentsMap
without a Suspense boundary causing runtime throws; import Suspense from 'react'
and wrap each mapped provider render (the map that returns <c.Component
{...c.props} closeOverlay={() => closeOverlay(id)} />) in <Suspense
fallback={null}> so each lazy modal provider is suspended safely; apply the same
change to the LazyClonePVCModalProvider and LazyRestorePVCModalProvider render
blocks so their lazy components are also wrapped with Suspense.
🧹 Nitpick comments (2)
frontend/packages/console-app/src/components/modals/clone/clone-pvc-modal.tsx (1)
279-285: Provider implementation looks solid; consider explicit prop destructuring for clarity.The pattern is correct:
blockingprevents accidental dismissal during form entry, and mapping bothcancelandclosetocloseOverlayaligns with howClonePVCModaluses them (success path at line 132, cancel button at line 269).One minor refinement: spreading
...propspassescloseOverlayto the inner modal which doesn't consume it. While harmless, destructuring makes the prop threading more explicit:✨ Optional: explicit prop destructuring
-export const ClonePVCModalProvider: OverlayComponent<ClonePVCModalProps> = (props) => { +export const ClonePVCModalProvider: OverlayComponent<ClonePVCModalProps> = ({ + closeOverlay, + ...modalProps +}) => { return ( - <ModalWrapper blocking onClose={props.closeOverlay}> - <ClonePVCModal cancel={props.closeOverlay} close={props.closeOverlay} {...props} /> + <ModalWrapper blocking onClose={closeOverlay}> + <ClonePVCModal cancel={closeOverlay} close={closeOverlay} {...modalProps} /> </ModalWrapper> ); };frontend/public/components/modals/expand-pvc-modal.tsx (1)
4-11: Keepclosenon‑optional to prevent runtimeundefinedcalls.Line 97 now inherits
close?: () => voidfromModalComponentProps, but Line 47 callsclose()unguarded. Consider keepingcloserequired inExpandPVCModalProps(even if you still reuse the shared type) to avoid accidental misuse in tests or future direct renders.♻️ Suggested type tightening
export type ExpandPVCModalProps = { kind: K8sKind; resource: K8sResourceKind; -} & ModalComponentProps; +} & Required<Pick<ModalComponentProps, 'close'>> & + Pick<ModalComponentProps, 'cancel'>;Also applies to: 97-108
|
@rhamilto: This pull request references CONSOLE-5012 which is a valid jira issue. Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.22.0" version, but no target version was set. DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
1 similar comment
|
@rhamilto: This pull request references CONSOLE-5012 which is a valid jira issue. Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.22.0" version, but no target version was set. DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
7354328 to
3dc1895
Compare
3dc1895 to
b6487b4
Compare
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.
Actionable comments posted: 3
🤖 Fix all issues with AI agents
In `@frontend/packages/dev-console/src/actions/context-menu.ts`:
- Around line 42-45: The code calls asAccessReview using kind casted unsafely in
useDeleteResourceAction; add a guard for kind === undefined at the start of
useDeleteResourceAction to avoid the unsafe cast — return an Action that is
disabled (with a clear disabledReason) or early-return null/undefined per the
surrounding API, and only call asAccessReview and perform RBAC checks when kind
is defined; update references to useDeleteResourceAction and any downstream
consumers to handle the disabled/early-return case accordingly.
In `@frontend/packages/knative-plugin/src/actions/creators.ts`:
- Around line 120-152: The hook useDeleteKnativeServiceResource currently
assumes kind is defined and dereferences it; update the function to guard for
undefined kind by returning an Action object that is disabled/no-op (e.g., id
`delete-resource`, label same as before, cta as a noop and accessReview omitted
or set to a safe falsy value) when kind is undefined, and only build the full
action (including using LazyDeleteModalProvider, cleanUpWorkload in
deleteAllResources, and asAccessReview) once kind is present; ensure the
returned disabled action still matches the Action shape so render won't throw
and keep dependencies ([kind, obj, serviceTypeValue, serviceCreatedFromWebFlag,
launchModal]) intact.
In `@frontend/public/components/factory/modal.tsx`:
- Around line 37-40: Guard the Modal's appElement prop against a missing DOM
root: when obtaining appElement via document.getElementById('app-content')
ensure you convert a null result to undefined (matching the App component
pattern) before passing it into the Modal component (i.e., normalize the result
of document.getElementById('app-content') to undefined and pass that variable
named appElement into <Modal .../>). This keeps behavior explicit and consistent
with Modal.setAppElement usage.
|
/retest |
|
/assign @yapei Tech debt, so assigning labels |
|
@rhamilto: This pull request references CONSOLE-5012 which is a valid jira issue. Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.22.0" version, but no target version was set. DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
This commit migrates all instances of confirmModal to use the modern overlay pattern with useWarningModal, completing the modal migration effort started in previous PRs. Changes: - Removed deprecated confirmModal launcher and confirm-modal.tsx file - Migrated topology moveNodeToGroup to use useWarningModal with proper cancel handling via global handler pattern - Updated StopNodeMaintenanceModal to remove deprecated imperative API and keep only the useStopNodeMaintenanceModal hook - Fixed useWarningModal to properly call closeOverlay() and filter it from props spread to prevent React DOM warnings - Added try-catch in topology drag-drop to prevent optimistic update when user cancels the move operation - Updated all metal3-plugin maintenance components to use the hook-based approach This PR builds upon and depends on: - openshift#15932 (ResourceLimitsModal migration) - openshift#15939 (DeletePDBModal migration) - openshift#15940 (ConfigureUnschedulableModal migration) - openshift#15946 (Global error modal utility) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
|
performed some regression tests about PVC actions, Expand, Clone, Restore...some delete modal |
|
@yapei: This PR has been marked as verified by DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
frontend/packages/console-app/src/actions/hooks/usePVCActions.ts
Outdated
Show resolved
Hide resolved
62bc535 to
23cb295
Compare
|
@rhamilto: This pull request references CONSOLE-5012 which is a valid jira issue. Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.22.0" version, but no target version was set. DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
This commit migrates all instances of confirmModal to use the modern overlay pattern with useWarningModal, completing the modal migration effort started in previous PRs. Changes: - Removed deprecated confirmModal launcher and confirm-modal.tsx file - Migrated topology moveNodeToGroup to use useWarningModal with proper cancel handling via global handler pattern - Updated StopNodeMaintenanceModal to remove deprecated imperative API and keep only the useStopNodeMaintenanceModal hook - Fixed useWarningModal to properly call closeOverlay() and filter it from props spread to prevent React DOM warnings - Added try-catch in topology drag-drop to prevent optimistic update when user cancels the move operation - Updated all metal3-plugin maintenance components to use the hook-based approach This PR builds upon and depends on: - openshift#15932 (ResourceLimitsModal migration) - openshift#15939 (DeletePDBModal migration) - openshift#15940 (ConfigureUnschedulableModal migration) - openshift#15946 (Global error modal utility) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
|
/retest |
1 similar comment
|
/retest |
|
@rhamilto: The following test failed, say
Full PR test history. Your PR dashboard. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here. |
|
/retest |
logonoff
left a comment
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.
/lgtm
I think in theory some of these new action hooks should be applied and used via a console extension, but we can do that in a follow up.
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: logonoff, rhamilto The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
IMO, that just adds extra code. I get the dog fooding argument, but... |
It's just the pattern we were doing before.. I guess as long as people can still add their own kebab actions via an extension it's okay |
Summary
Migrates delete modals and PVC-related modals from the deprecated
createModalLauncherpattern to the modernOverlayComponentpattern. This is part of CONSOLE-5012 to modernize modal handling across the console.Changes
Modals Migrated (5 total)
All modals now follow the
OverlayComponentpattern with consistent implementation:DeleteModal (
public/components/modals/delete-modal.tsx)DeleteModalOverlay: OverlayComponentcreateModalLauncherusageDeletePVCModal (
public/components/modals/delete-pvc-modal.tsx)DeletePVCModalOverlay: OverlayComponenthistory.pushwithuseNavigatefrom react-router-dom-v5-compatExpandPVCModal (
public/components/modals/expand-pvc-modal.tsx)ExpandPVCModalOverlay: OverlayComponenthistory.pushwithuseNavigatefrom react-router-dom-v5-compatLazyExpandPVCModalOverlayClonePVCModal (
packages/console-app/src/components/modals/clone/clone-pvc-modal.tsx)ClonePVCModalOverlay: OverlayComponenthistory.pushwithuseNavigatefrom react-router-dom-v5-compatLazyClonePVCModalOverlayRestorePVCModal (
packages/console-app/src/components/modals/restore-pvc/restore-pvc-modal.tsx)RestorePVCModalOverlay: OverlayComponenthistory.pushwithuseNavigatefrom react-router-dom-v5-compatLazyRestorePVCModalOverlayAction Creators Converted to Hooks (2 total)
To integrate with the React hooks system and
useOverlay()pattern:useDeleteResourceAction(packages/dev-console/src/actions/context-menu.ts)DeleteResourceActionfunction to hookuseOverlay()andLazyDeleteModalOverlaydeployment-provider.ts,deploymentconfig-provider.tsuseDeleteKnativeServiceResource(packages/knative-plugin/src/actions/creators.ts)deleteKnativeServiceResourcefunction to hookcleanUpWorkloadbased onserviceCreatedFromWebFlagknative-plugin/src/actions/providers.tsUpdated to Use New Overlay Modals
Replaced direct modal function calls with
useOverlay()+ lazy modal overlays:useCommonActions.ts: Changed fromdeleteModaltolaunchModal(LazyDeleteModalOverlay, ...)usePVCActions.ts:expandPVCModaltolaunchModal(LazyExpandPVCModalOverlay, ...)clonePVCModaltolaunchModal(LazyClonePVCModalOverlay, ...)deletePVCModaltolaunchModal(LazyDeletePVCModalOverlay, ...)useVolumeSnapshotActions.ts: Changed fromrestorePVCModaltolaunchModal(LazyRestorePVCModalOverlay, ...)React Hooks Dependency Array Updates
Added
launchModalto dependency arrays where it's used:useCommonActions.ts: AddedlaunchModalto dependency array with explanatory comment about excluded stable modal launcher functionsusePVCActions.ts: UseslaunchModalfromuseOverlay()hookuseVolumeSnapshotActions.ts: AddedlaunchModalto dependency arrayuseDeleteResourceAction: AddedlaunchModalto dependency arrayuseDeleteKnativeServiceResource: AddedlaunchModalto dependency arrayNote: While
launchModalfromuseOverlay()is referentially stable, it's included in dependency arrays for correctness and to satisfy exhaustive-deps linting rules.Navigation Updates
Replaced deprecated
history.pushwith modernuseNavigatehook:useNavigatefromreact-router-dom-v5-compatsetTimeoutwrappers that were previously needed withhistory.pushnavigate()calls are safe with the modern hook (no setState during render warnings)Naming Convention
All modal overlay components and exports follow the
*ModalOverlaynaming pattern:DeleteModalOverlay,DeletePVCModalOverlay,ExpandPVCModalOverlay,ClonePVCModalOverlay,RestorePVCModalOverlayLazyDeleteModalOverlay,LazyDeletePVCModalOverlay,LazyExpandPVCModalOverlay,LazyClonePVCModalOverlay,LazyRestorePVCModalOverlayThis naming convention clearly distinguishes these from the deprecated
ModalProviderpattern and aligns with theOverlayComponenttype.Infrastructure Updates
OverlayProvider.tsx: Added<Suspense>wrapper for lazy-loaded overlay componentsapp.tsx: Added globalModal.setAppElementinitialization inuseLayoutEffectfor accessibilitymodal.tsx:Modal.setAppElementcalls (now set globally)appElementselector inModalWrapper(now usesdocument.getElementByIdinstead of fallback chain)appElementprop toModalWrapperfor proper accessibilitymodals/index.ts: Updated exports to use consistentReact.lazy()pattern with all new modal overlaysPattern Example
Benefits
useOverlay()Modal.setAppElementsetupuseNavigatehook (no setTimeout wrappers needed)*ModalOverlaypatternTesting
useNavigatenavigation works without setState warningsRelated
Summary by CodeRabbit
Refactor
*ModalOverlaynaming convention for delete/expand/clone/restore operations.Bug Fixes / Accessibility
✏️ Tip: You can customize this high-level summary in your review settings.