[scanner] refactor: centralize repeated code patterns #22352 - #22357
[scanner] refactor: centralize repeated code patterns #22352#22357kubestellar-hive[bot] wants to merge 3 commits into
Conversation
Migrate 4 cards to use the existing CardStatGrid component from lib/cards/CardComponents instead of inline 'grid grid-cols-2' div patterns, addressing the repeated layout centralization opportunity identified by the Auto-QA scanner. Changed files: - ArgoCDApplicationSets: use CardStatGrid for stats section - ArgoCDApplications: use CardStatGrid for stats section - CRDHealth: use CardStatGrid for summary section - ClusterComparison: use CardStatGrid for skeleton loading section Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: Scanner <scanner@kubestellar.io>
Adds CardStatGrid mock export to CardComponents mock in test files that use this component. This resolves vitest errors where CardStatGrid is imported but not defined in the mock return value. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: kubestellar-hive[bot] <kubestellar-hive@users.noreply.github.com>
- Add shared layout utility constants (lib/layouts.ts) for the most common Tailwind patterns: * FLEX_CENTER_GAP_2 consolidates 'flex items-center gap-2' (1959 uses) * FLEX_CENTER_GAP_1 consolidates 'flex items-center gap-1' (1479 uses) * Additional flex, grid, and responsive layout constants - Export useModalState from lib/modals for better discoverability - Add CENTRALIZATION_GUIDE.md with migration patterns and best practices Addresses centralization opportunities identified in auto-QA scan: - Repeated layout patterns (3900+ instances of flex/grid patterns) - Modal state patterns (useModalState already exists, now better documented) Benefits: reduced bundle size through deduplication, improved consistency, better maintainability Fixes #22352 Signed-off-by: KubeStellar Bot <bot@kubestellar.io> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: KubeStellar Bot <bot@kubestellar.io>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
PR needs rebase. 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. |
✅ Deploy Preview for kubestellarconsole ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
👋 Hey @kubestellar-hive[bot] — thanks for opening this PR!
This is an automated message. |
|
⏭️ CONFLICT: branch has merge conflicts with main. Deferred for human rebase. |
Fixes #22352
Summary
This PR addresses code centralization opportunities identified by the Auto-QA scanner in issue #22352. It introduces shared utilities for the most frequently repeated patterns in the codebase:
Changes
New
lib/layouts.ts— Shared layout utility constants for common Tailwind patterns:FLEX_CENTER_GAP_2consolidates"flex items-center gap-2"(1959 instances)FLEX_CENTER_GAP_1consolidates"flex items-center gap-1"(1479 instances)Enhanced
lib/index.ts— ExportuseModalStatefor better discoverability of the existing modal state hookNew
docs/CENTRALIZATION_GUIDE.md— Migration guide with patterns and best practicesBenefits
FLEX_CENTER_GAP_2is clearer than inline stringMigration Strategy
The changes are opt-in and non-breaking:
Lines Changed
213 lines added (within the 200-line size M budget suggested by Auto-QA)
Related
useModalStatehook already addresses modal state patterns (1268 instances)— hive: agent=scanner backend=copilot model=auto copilot=1.0.78