Skip to content

WIP ACM-30854 Remove PlacementRule from UI#5965

Open
oksanabaza wants to merge 2 commits intostolostron:mainfrom
oksanabaza:ACM-30854
Open

WIP ACM-30854 Remove PlacementRule from UI#5965
oksanabaza wants to merge 2 commits intostolostron:mainfrom
oksanabaza:ACM-30854

Conversation

@oksanabaza
Copy link
Copy Markdown
Contributor

@oksanabaza oksanabaza commented Apr 10, 2026

📝 Summary

Ticket Summary (Title):

ACM-30854 Remove PlacementRule from UI

Ticket Link:

https://redhat.atlassian.net/browse/ACM-30854

Type of Change:

  • 🐞 Bug Fix
  • ✨ Feature
  • 🔧 Refactor
  • 💸 Tech Debt
  • 🧪 Test-related
  • 📄 Docs

✅ Checklist

General

  • PR title follows the convention (e.g. ACM-12340 Fix bug with...)
  • Code builds and runs locally without errors
  • No console logs, commented-out code, or unnecessary files
  • All commits are meaningful and well-labeled
  • All new display strings are externalized for localization (English only)
  • (Nice to have) JSDoc comments added for new functions and interfaces

If Feature

  • UI/UX reviewed (if applicable)
  • All acceptance criteria met
  • Unit test coverage added or updated
  • Relevant documentation or comments included

If Bugfix

  • Root cause and fix summary are documented in the ticket (for future reference / errata)
  • Fix tested thoroughly and resolves the issue
  • Test(s) added to prevent regression

🗒️ Notes for Reviewers

Summary by CodeRabbit

Release Notes

  • Refactor
    • Removed "Placement rules" toggle option from the Applications view.
    • Consolidated placement selection interface—subscription applications now select placements directly without intermediate placement rule selection.
    • Updated terminology throughout to reference "Placements" exclusively.
    • Simplified modal warning messages to reference only "Placements" in policy deletion flows.

Signed-off-by: Oksana Bazylieva <obazylie@redhat.com>
Signed-off-by: Oksana Bazylieva <obazylie@redhat.com>
@openshift-ci
Copy link
Copy Markdown

openshift-ci bot commented Apr 10, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: oksanabaza

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 10, 2026

📝 Walkthrough

Walkthrough

This PR consolidates "Placement Rules" to "Placements" by renaming control identifiers, state atoms, function exports, and type references across the codebase. Deprecated PlacementRule kind handling is removed from template logic, and the PlacementRule items list/table is removed from AdvancedConfiguration. Support for placementrules toggle option is eliminated.

Changes

Cohort / File(s) Summary
Test Fixture Updates
frontend/src/components/TemplateEditor/TemplateEditor.test.js, frontend/src/components/TemplateEditor/controls/ControlPanelComboBox.test.js, frontend/src/components/TemplateEditor/utils/initialize-control-data.test.tsx, frontend/src/routes/Applications/CreateSubscriptionApplication/transformers/transform-resources-to-controls.test.js
Updated control IDs consistently: existingrule-checkboxexisting-placement-checkbox, placementrulecomboplacementcombo, selectedRuleNameselectedPlacementName. Loading text updated from "Loading placement rules..." to "Loading placements..."
Feature Tests
frontend/src/routes/Applications/AdvancedConfiguration.test.tsx, frontend/src/routes/Applications/CreateSubscriptionApplication/SubscriptionApplication.test.tsx, frontend/src/routes/Governance/policies/Policies.test.tsx
Updated to use placementsState and PlacementKind instead of placementRulesState and PlacementRuleKind. Removed placement rule selection steps and related network mocks. Updated modal warning text from "These Placements/PlacementRules are in use elsewhere" to "These Placements are in use elsewhere"
Feature Removal
frontend/src/routes/Applications/AdvancedConfiguration.tsx, frontend/src/routes/Governance/policies/Policies.tsx
Removed PlacementRule RBAC check, deleted PlacementRule items list/table configuration and row action handling. Updated warning alert kind parameter from 'Placements/PlacementRules' to 'Placements'
Control Data Refactoring
frontend/src/routes/Applications/CreateSubscriptionApplication/controlData/ControlDataPlacement.js
Renamed exported functions: loadExistingPlacementRules()loadExistingPlacements(), updateNewRuleControls()updateSelectedPlacementControls(), reverseExistingRule()reverseExistingPlacement(). Removed placement rule data fetching and deprecated rule kind handling. Updated availability logic to populate from placements only
Control Data Utilities
frontend/src/routes/Applications/CreateSubscriptionApplication/controlData/ControlData.js, frontend/src/routes/Applications/CreateSubscriptionApplication/controlData/utils.js
Updated control ID references in placement-related state clearing logic. Changed from existingrule-checkbox / selectedRuleName to existing-placement-checkbox / selectedPlacementName
Template Updates
frontend/src/routes/Applications/CreateSubscriptionApplication/templates/template.hbs, frontend/src/routes/Applications/CreateSubscriptionApplication/templates/templatePlacement.hbs
Updated template context parameters from selectedRuleName / existingrule-checkbox to selectedPlacementName / existing-placement-checkbox. Removed isDeprecatedPR conditional logic and deprecated rule YAML block. Changed selfLink reference from selfLinks.PlacementRule to selfLinks.Placement
Component Type Changes
frontend/src/routes/Applications/components/ToggleSelector.tsx
Removed 'placementrules' from ApplicationToggleOptions union type and from options array. Only 'subscriptions', 'channels', and 'placements' remain valid

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ❓ Inconclusive The description includes ticket reference, type selection, and a checklist, but most checklist items remain unchecked and no implementation details or reviewer notes are provided. Check at least the completed items (code builds, no console logs, meaningful commits, test coverage, localization) to indicate PR readiness; add any reviewer context needed.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title directly reflects the primary change: removing PlacementRule from the UI across multiple application and policy flows.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ast-grep (0.42.1)
frontend/src/routes/Applications/CreateSubscriptionApplication/transformers/transform-resources-to-controls.test.js

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@openshift-ci
Copy link
Copy Markdown

openshift-ci bot commented Apr 10, 2026

@oksanabaza: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/check 30d58db link true /test check

Full PR test history. Your PR dashboard.

Details

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.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a 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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
frontend/src/routes/Applications/CreateSubscriptionApplication/templates/templatePlacement.hbs (1)

7-19: ⚠️ Potential issue | 🟠 Major

Legacy PlacementRule edits are now serialized as Placement.

This template no longer branches on the deprecated controls, but the edit pipeline still populates isDeprecatedPR / deprecated-rule for existing subscriptions that reference PlacementRule. Saving one of those apps will now emit placementRef.kind: Placement and selfLinks.Placement, which changes the referenced resource instead of preserving the legacy object.

Also applies to: 36-47

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@frontend/src/routes/Applications/CreateSubscriptionApplication/templates/templatePlacement.hbs`
around lines 7 - 19, The template currently always emits placementRef.kind:
Placement causing legacy PlacementRule references to be converted; update
templatePlacement.hbs to detect the legacy flags (isDeprecatedPR and/or
deprecated-rule) and, when present, emit placementRef.kind as PlacementRule and
preserve the original name/selfLink instead of forcing Placement: adjust the
branching around selectedPlacementName and existing-placement-checkbox (and
where `@root.name` / uniqueGroupID are used) so that legacy subscriptions keep
kind: PlacementRule and their selfLinks.Placement handling rather than being
rewritten to kind: Placement.
🧹 Nitpick comments (1)
frontend/src/routes/Applications/CreateSubscriptionApplication/SubscriptionApplication.test.tsx (1)

636-679: Keep one regression test for legacy PlacementRule edit/save.

These updates remove the only changed-path coverage around deprecated PlacementRule subscriptions, but transform-resources-to-controls.js still has explicit handling for spec.placement.placementRef.kind === PlacementRule. A round-trip break there would now go uncaught. Please keep one edit/save test for a legacy subscription until that compatibility path is removed end-to-end.

As per coding guidelines, "Verify test coverage is meaningful, not just for metrics".

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@frontend/src/routes/Applications/CreateSubscriptionApplication/SubscriptionApplication.test.tsx`
around lines 636 - 679, Restore a regression test that covers editing and saving
a legacy PlacementRule subscription: add or keep one test (e.g., alongside or as
a variant of the existing "edit a git subscription application" test in
SubscriptionApplication.test.tsx) that mounts a subscription whose
spec.placement.placementRef.kind is "PlacementRule", exercises the edit/save
flow (clicking the git card, modifying fields, saving), and asserts round-trip
behavior so transform-resources-to-controls.js handling for
spec.placement.placementRef.kind === PlacementRule remains covered; reference
the existing test harness (RecoilRoot state setup, MemoryRouter route to
NavigationPath.editApplicationSubscription, and waitForNocks helpers) to
implement this single preserved regression test.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In
`@frontend/src/routes/Applications/CreateSubscriptionApplication/controlData/ControlDataPlacement.js`:
- Around line 29-40: loadExistingPlacements currently only returns Placement
objects which drops support for legacy PlacementRule refs; change the query
returned by loadExistingPlacements to fetch and merge both Placements and
PlacementRules (or fetch PlacementRules as a fallback) using nsControl.active so
setAvailableRules receives a combined list and legacy PlacementRule names remain
in available; keep variables() assigning nsControl as-is and ensure
reverseExistingPlacement still reads
Subscription.spec.placement.placementRef.name (and/or
transform-resources-to-controls.js continues seeding PlacementRule state) so
legacy rule names are preserved or explicitly migrated during initialization.

In `@frontend/src/routes/Governance/policies/Policies.tsx`:
- Line 1113: The title prop is interpolating a raw literal 'Placements' into
t('policy.modal.message.reused', { kind: 'Placements' }) — replace the
hard-coded label with a localized string before interpolation (e.g., create/use
a translation key like t('policy.kind.placements') or
t('policy.kind.placementLabel') and pass that value as the kind parameter) so
the call becomes t('policy.modal.message.reused', { kind:
t('policy.kind.placements') }); update Policies.tsx where title is set to use
the localized kind.

---

Outside diff comments:
In
`@frontend/src/routes/Applications/CreateSubscriptionApplication/templates/templatePlacement.hbs`:
- Around line 7-19: The template currently always emits placementRef.kind:
Placement causing legacy PlacementRule references to be converted; update
templatePlacement.hbs to detect the legacy flags (isDeprecatedPR and/or
deprecated-rule) and, when present, emit placementRef.kind as PlacementRule and
preserve the original name/selfLink instead of forcing Placement: adjust the
branching around selectedPlacementName and existing-placement-checkbox (and
where `@root.name` / uniqueGroupID are used) so that legacy subscriptions keep
kind: PlacementRule and their selfLinks.Placement handling rather than being
rewritten to kind: Placement.

---

Nitpick comments:
In
`@frontend/src/routes/Applications/CreateSubscriptionApplication/SubscriptionApplication.test.tsx`:
- Around line 636-679: Restore a regression test that covers editing and saving
a legacy PlacementRule subscription: add or keep one test (e.g., alongside or as
a variant of the existing "edit a git subscription application" test in
SubscriptionApplication.test.tsx) that mounts a subscription whose
spec.placement.placementRef.kind is "PlacementRule", exercises the edit/save
flow (clicking the git card, modifying fields, saving), and asserts round-trip
behavior so transform-resources-to-controls.js handling for
spec.placement.placementRef.kind === PlacementRule remains covered; reference
the existing test harness (RecoilRoot state setup, MemoryRouter route to
NavigationPath.editApplicationSubscription, and waitForNocks helpers) to
implement this single preserved regression test.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 2ac1871a-7791-403a-b77a-108388216bb6

📥 Commits

Reviewing files that changed from the base of the PR and between 0b8ecfa and 30d58db.

⛔ Files ignored due to path filters (1)
  • frontend/public/locales/en/translation.json is excluded by !frontend/public/locales/**
📒 Files selected for processing (15)
  • frontend/src/components/TemplateEditor/TemplateEditor.test.js
  • frontend/src/components/TemplateEditor/controls/ControlPanelComboBox.test.js
  • frontend/src/components/TemplateEditor/utils/initialize-control-data.test.tsx
  • frontend/src/routes/Applications/AdvancedConfiguration.test.tsx
  • frontend/src/routes/Applications/AdvancedConfiguration.tsx
  • frontend/src/routes/Applications/CreateSubscriptionApplication/SubscriptionApplication.test.tsx
  • frontend/src/routes/Applications/CreateSubscriptionApplication/controlData/ControlData.js
  • frontend/src/routes/Applications/CreateSubscriptionApplication/controlData/ControlDataPlacement.js
  • frontend/src/routes/Applications/CreateSubscriptionApplication/controlData/utils.js
  • frontend/src/routes/Applications/CreateSubscriptionApplication/templates/template.hbs
  • frontend/src/routes/Applications/CreateSubscriptionApplication/templates/templatePlacement.hbs
  • frontend/src/routes/Applications/CreateSubscriptionApplication/transformers/transform-resources-to-controls.test.js
  • frontend/src/routes/Applications/components/ToggleSelector.tsx
  • frontend/src/routes/Governance/policies/Policies.test.tsx
  • frontend/src/routes/Governance/policies/Policies.tsx

Comment on lines +29 to 40
export const loadExistingPlacements = (t) => {
let nsControl = undefined

return {
query: () => {
return Promise.all([listPlacementRules(nsControl.active).promise, listPlacements(nsControl.active).promise])
return listPlacements(nsControl.active).promise
},
variables: (control, globalControl) => {
nsControl = globalControl.find(({ id: idCtrl }) => idCtrl === 'namespace')
},
loadingDesc: t('creation.app.loading.rules'),
loadingDesc: t('Loading placements...'),
setAvailable: setAvailableRules.bind(null),
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

This drops round-trip support for existing PlacementRule subscriptions.

transform-resources-to-controls.js still seeds deprecated PlacementRule state for edit flows, and reverseExistingPlacement() still loads the old ref name from Subscription.spec.placement.placementRef.name. After this change, the combo can only load Placement objects, so a legacy rule name can never exist in available and gets cleared during initialization instead of being preserved or explicitly migrated.

Also applies to: 66-133

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@frontend/src/routes/Applications/CreateSubscriptionApplication/controlData/ControlDataPlacement.js`
around lines 29 - 40, loadExistingPlacements currently only returns Placement
objects which drops support for legacy PlacementRule refs; change the query
returned by loadExistingPlacements to fetch and merge both Placements and
PlacementRules (or fetch PlacementRules as a fallback) using nsControl.active so
setAvailableRules receives a combined list and legacy PlacementRule names remain
in available; keep variables() assigning nsControl as-is and ensure
reverseExistingPlacement still reads
Subscription.spec.placement.placementRef.name (and/or
transform-resources-to-controls.js continues seeding PlacementRule state) so
legacy rule names are preserved or explicitly migrated during initialization.

<AcmAlert
variant="warning"
title={t('policy.modal.message.reused', { kind: 'Placements/PlacementRules' })}
title={t('policy.modal.message.reused', { kind: 'Placements' })}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Localize interpolated kind label in warning title

'Placements' is user-facing text passed as a raw literal. Please localize it before interpolation.

Suggested fix
-              title={t('policy.modal.message.reused', { kind: 'Placements' })}
+              title={t('policy.modal.message.reused', { kind: t('Placements') })}

As per coding guidelines, "Ensure all user-facing strings use useTranslation() or from src/lib/acm-i18next."

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
title={t('policy.modal.message.reused', { kind: 'Placements' })}
title={t('policy.modal.message.reused', { kind: t('Placements') })}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@frontend/src/routes/Governance/policies/Policies.tsx` at line 1113, The title
prop is interpolating a raw literal 'Placements' into
t('policy.modal.message.reused', { kind: 'Placements' }) — replace the
hard-coded label with a localized string before interpolation (e.g., create/use
a translation key like t('policy.kind.placements') or
t('policy.kind.placementLabel') and pass that value as the kind parameter) so
the call becomes t('policy.modal.message.reused', { kind:
t('policy.kind.placements') }); update Policies.tsx where title is set to use
the localized kind.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant