-
Notifications
You must be signed in to change notification settings - Fork 665
CONSOLE-4709: Remove kebab factory uses from default-resouce list and details pages #15732
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
CONSOLE-4709: Remove kebab factory uses from default-resouce list and details pages #15732
Conversation
|
@vikram-raj: This pull request references CONSOLE-4709 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.21.0" version, but no target version was set. In 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. |
396ce87 to
00f0fd2
Compare
WalkthroughAdded an Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes
✨ Finishing touches
🧪 Generate unit tests (beta)
Comment |
|
/cc @yapei For QE review |
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: 1
🧹 Nitpick comments (2)
frontend/packages/console-shared/src/components/actions/menu/ActionMenu.tsx (1)
17-18: Guard PopperappendToagainstnulland consider impact of new defaultThe new
appendToprop is useful, but this expression:appendTo={appendTo || containerRef.current}can pass
nulltoPopperon initial render (beforecontainerRefis set), even though the union type doesn’t includenull, and it also changes the default behavior from Popper’s internal default to always using the local container.To keep behavior safer and closer to the previous default, consider:
- <Popper - triggerRef={toggleRef} - popper={menu} - placement="bottom-end" - isVisible={isOpen} - appendTo={appendTo || containerRef.current} - /> + <Popper + triggerRef={toggleRef} + popper={menu} + placement="bottom-end" + isVisible={isOpen} + appendTo={appendTo ?? containerRef.current ?? undefined} + />This avoids ever passing
nulland only overrides Popper’s default when a container actually exists. Please verify this matches the expectations forPopper’sappendTosemantics in the PatternFly version you’re using.Also applies to: 27-28, 103-109
frontend/public/components/default-resource.tsx (1)
392-408: Avoid double-fetching the same resource inDefaultDetailsPage
DefaultDetailsPagenow callsuseK8sGetto fetchresourceforResourceActionsMenu, whileDetailsPageitself is already responsible for loading the object passed to its child pages. This means the same resource is fetched twice on details pages, which is unnecessary overhead and adds complexity.A more scalable design would be to let
customActionMenube a render function that receives the loadedobjfromDetailsPage, e.g.,customActionMenu={(obj) => <ResourceActionsMenu resource={obj} ... />}, avoiding the extra hook and API call entirely.Not a blocker for this PR, but worth considering for a follow-up to keep the data flow and network usage lean.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Cache: Disabled due to data retention organization setting
Knowledge base: Disabled due to Reviews -> Disable Knowledge Base setting
📒 Files selected for processing (3)
frontend/packages/console-shared/src/components/actions/menu/ActionMenu.tsx(3 hunks)frontend/packages/metal3-plugin/src/components/modals/PowerOffHostModal.tsx(0 hunks)frontend/public/components/default-resource.tsx(4 hunks)
💤 Files with no reviewable changes (1)
- frontend/packages/metal3-plugin/src/components/modals/PowerOffHostModal.tsx
🧰 Additional context used
📓 Path-based instructions (1)
**
⚙️ CodeRabbit configuration file
-Focus on major issues impacting performance, readability, maintainability and security. Avoid nitpicks and avoid verbosity.
Files:
frontend/packages/console-shared/src/components/actions/menu/ActionMenu.tsxfrontend/public/components/default-resource.tsx
🔇 Additional comments (1)
frontend/public/components/default-resource.tsx (1)
53-56: ResourceActionsMenu abstraction looks goodThe
ResourceActionsMenuwrapper arounduseCommonResourceActionsandActionMenucleanly centralizes default actions for a resource and keeps the call sites simple. No issues from a readability or maintainability standpoint here.Also applies to: 81-89
00f0fd2 to
eecfd0a
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: 0
🧹 Nitpick comments (2)
frontend/public/components/default-resource.tsx (2)
53-56: Avoid duplicatingActionMenuprop types inResourceActionsMenuThe implementation looks good, but
variant/appendTotypes are re-declared here and can drift fromActionMenuover time. You can tighten coupling and drop the extra spread by deriving props fromActionMenudirectly:-const ResourceActionsMenu: React.FC<{ - resource: K8sResourceKind; - variant: ActionMenuVariant; - appendTo?: HTMLElement | (() => HTMLElement) | 'inline'; -}> = ({ resource, variant, appendTo }) => { - const common = useCommonResourceActions(kindObj(referenceFor(resource)), resource); - const menuActions = [...common]; - return <ActionMenu actions={menuActions} variant={variant} appendTo={appendTo} />; -}; +type ResourceActionsMenuProps = { + resource: K8sResourceKind; +} & Pick<React.ComponentProps<typeof ActionMenu>, 'variant' | 'appendTo'>; + +const ResourceActionsMenu: React.FC<ResourceActionsMenuProps> = ({ + resource, + variant, + appendTo, +}) => { + const common = useCommonResourceActions(kindObj(referenceFor(resource)), resource); + return <ActionMenu actions={common} variant={variant} appendTo={appendTo} />; +};This keeps
ResourceActionsMenuin sync ifActionMenu’s public API evolves and avoids an unnecessary array copy.Also applies to: 81-89
392-408: Consider avoiding a second fetch/watch of the same resource inDefaultDetailsPageWiring
customActionMenuvia:const [resource, resourceLoaded, resourceError] = useK8sGet(...); customActionMenu={ resourceLoaded && !resourceError ? ( <ResourceActionsMenu resource={resource} variant={ActionMenuVariant.DROPDOWN} /> ) : null }is straightforward, but if
DetailsPagealready loads/watches this resource internally, this introduces a second fetch/watch for the same object on the details view.If that’s the case, consider a follow-up refactor where
DetailsPageexposes the loaded resource (e.g., via a render prop or by passing it intocustomActionMenu) so the action menu can reuse the existing data source instead of callinguseK8sGetagain.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Cache: Disabled due to data retention organization setting
Knowledge base: Disabled due to Reviews -> Disable Knowledge Base setting
📒 Files selected for processing (3)
frontend/packages/console-shared/src/components/actions/menu/ActionMenu.tsx(3 hunks)frontend/packages/metal3-plugin/src/components/modals/PowerOffHostModal.tsx(0 hunks)frontend/public/components/default-resource.tsx(4 hunks)
💤 Files with no reviewable changes (1)
- frontend/packages/metal3-plugin/src/components/modals/PowerOffHostModal.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
- frontend/packages/console-shared/src/components/actions/menu/ActionMenu.tsx
🧰 Additional context used
📓 Path-based instructions (1)
**
⚙️ CodeRabbit configuration file
-Focus on major issues impacting performance, readability, maintainability and security. Avoid nitpicks and avoid verbosity.
Files:
frontend/public/components/default-resource.tsx
🔇 Additional comments (1)
frontend/public/components/default-resource.tsx (1)
227-231: KebabappendTohandling is now safe and robustUsing
document.getElementById('popper-container') ?? document.bodyensuresappendTois nevernull, so Popper always has a valid container even if the dedicated popper node is missing. This resolves the earlier nullability issue while preserving the desired placement behavior.
eecfd0a to
0d86377
Compare
vikram-raj
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.
/label px-approved
/label docs-approved
|
/retest |
0d86377 to
293bad0
Compare
|
@yapei Good catch. Resolved the Prometheus issue action issue on the details page. |
The prometheus mismatch issue have been fixed with latest code |
|
@yapei: This PR has been marked as verified by In 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-shared/src/components/actions/menu/ActionMenu.tsx
Outdated
Show resolved
Hide resolved
293bad0 to
e3d453a
Compare
|
I've updated the props type according to the review comment. No change in feature. /verified by @yapei |
|
@vikram-raj: This PR has been marked as verified by In 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. |
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: 0
🧹 Nitpick comments (1)
frontend/public/components/default-resource.tsx (1)
393-421: Consider aligningLazyActionMenucontext key with the extension guard
resourceProviderGuardfilters extensions byprops.kind, butLazyActionMenureceivescontext={{ [referenceFor(obj)]: obj }}. IfreferenceFor(obj)ever differs fromprops.kind, extensions that passed the guard may not find their object in context. You might want to key the context offprops.kind(or at least fall back to it) for consistency with the guard and with the list view pattern.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Cache: Disabled due to data retention organization setting
Knowledge base: Disabled due to Reviews -> Disable Knowledge Base setting
📒 Files selected for processing (3)
frontend/packages/console-shared/src/components/actions/menu/ActionMenu.tsx(3 hunks)frontend/packages/metal3-plugin/src/components/modals/PowerOffHostModal.tsx(0 hunks)frontend/public/components/default-resource.tsx(4 hunks)
💤 Files with no reviewable changes (1)
- frontend/packages/metal3-plugin/src/components/modals/PowerOffHostModal.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
- frontend/packages/console-shared/src/components/actions/menu/ActionMenu.tsx
🧰 Additional context used
📓 Path-based instructions (1)
**
⚙️ CodeRabbit configuration file
-Focus on major issues impacting performance, readability, maintainability and security. Avoid nitpicks and avoid verbosity.
Files:
frontend/public/components/default-resource.tsx
🔇 Additional comments (2)
frontend/public/components/default-resource.tsx (2)
53-56:ResourceActionsMenuabstraction looks sound and type-safeUsing
useCommonResourceActionsplus a thinResourceActionsMenuwrapper, typed viaPick<React.ComponentProps<typeof ActionMenu>, 'variant' | 'appendTo'>, keeps the public API small and aligns with the existingActionMenucontract. This centralizes default resource actions cleanly without leaking implementation details.Also applies to: 80-92
225-239: Kebab actions migration withappendTofallback looks correctThe switch to
<ResourceActionsMenu>for the row actions, combined withappendTo={document.getElementById('popper-container') ?? document.body}, avoids the earliernullissue and ensures Popper always has a valid container while keeping extension-based actions (LazyActionMenu) intact.
|
/lgtm |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: logonoff, vikram-raj The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
@vikram-raj: all tests passed! Full PR test history. Your PR dashboard. 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 kubernetes-sigs/prow repository. I understand the commands that are listed here. |






Remove the use of the kebab factory from the default-resource list and the details page
Changes from the big PR #15520