Skip to content

fix(opportunities): prefill Create Purchase Plan modal from multiple homogeneous commitments (closes #898) - #899

Merged
cristim merged 1 commit into
feat/multicloud-web-frontendfrom
fix/qa-6.7-multi-commitment-prefill
Jun 1, 2026
Merged

cristim merged 1 commit into
feat/multicloud-web-frontendfrom
fix/qa-6.7-multi-commitment-prefill

Conversation

@cristim

@cristim cristim commented Jun 1, 2026 •

Copy link
Copy Markdown
Member

Summary

Fixes QA finding 6.7: in Opportunities -> Plan commitments, selecting 2+ commitments that share the same Provider/Service/Term/Payment and clicking "Plan from N selected" opened the Create Purchase Plan modal showing defaults (AWS, EC2, 1 Year, No Upfront) instead of prefilling from the selection.

#770/#778 already prefilled the modal for a single selected commitment (the prefill ran only when the snapshot length was exactly 1). This PR extends that to the homogeneous multi-selection case.

Changes

  • frontend/src/plans.ts — openCreatePlanModal now prefills the Purchase Configuration (provider/service/term/payment) whenever the snapshot is non-empty, using the first commitment as the representative. The "Plan from N selected" button only enables on a homogeneous selection (enforced by isHomogeneousSelection in recommendations.ts), so any element shares those four values.
  • The account chip is prefilled only when every selected commitment carries the same cloud_account_id; a multi-account selection leaves it empty for the user to fill, since provider/service/term/payment homogeneity does not imply a single account.

Tests

  • New regression tests in frontend/src/__tests__/plans.test.ts:
    • prefills provider/service/term/payment from a homogeneous multi-commitment selection
    • prefills the account chip when all commitments share one account
    • leaves the account chip empty when commitments span accounts
  • Full plans (110) and recommendations (319) suites pass; tsc --noEmit clean.

Closes #898. Relates to #770/#778.

Summary by CodeRabbit

  • New Features

    • Plan modal now supports prefilling configuration fields when creating a plan from multiple commitments, using shared values for provider, service, term, and payment.
    • Account chip automatically prefills when all selected commitments belong to the same account; remains empty for mixed accounts.
  • Tests

    • Expanded test coverage for multi-commitment plan creation scenarios.

…homogeneous commitments (closes #898)

When 2+ commitments sharing the same provider/service/term/payment are
selected and the user clicks "Plan from N selected", the Create Purchase
Plan modal now prefills the Purchase Configuration from the shared values
instead of showing defaults. The "Plan from N selected" button only
enables on a homogeneous selection, so the first commitment is a valid
representative.

The account chip is prefilled only when every selected commitment carries
the same cloud_account_id; a multi-account selection leaves it empty for
the user to fill, since provider/service/term/payment homogeneity does not
imply a single account.

Extends the single-selection prefill from #770/#778 (QA finding 6.7).
@cristim cristim added triaged Item has been triaged priority/p2 Backlog-worthy severity/medium Moderate harm urgency/this-sprint Within the current sprint impact/many Affects most users effort/s Hours type/bug Defect labels Jun 1, 2026
@cristim

cristim commented Jun 1, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jun 1, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 14aaa157-5b17-4f93-88ad-8cf79b88f04c

📥 Commits

Reviewing files that changed from the base of the PR and between 1b99460 and 5bf1c8d.

📒 Files selected for processing (2)
  • frontend/src/__tests__/plans.test.ts
  • frontend/src/plans.ts

📝 Walkthrough

Walkthrough

This PR extends modal prefill behavior to support multiple selected commitments. The Create Plan modal now prefills provider, service, term, and payment from any non-empty selection of homogeneous commitments, and preloads the account chip only when all commitments share the same cloud account.

Changes

Multi-commitment plan prefill

Layer / File(s) Summary
Multi-commitment prefill condition and account-chip logic
frontend/src/plans.ts, frontend/src/__tests__/plans.test.ts
Prefill Purchase Configuration now triggers for one or more commitments (using the first as representative), account-chip preselection checks whether all commitments share the same cloud_account_id, and tests validate homogeneous prefill, conditional account-chip population, and empty account-chip behavior across different accounts.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

  • LeanerCloud/CUDly#778: Both PRs update modal prefill logic in plans.ts and corresponding tests to handle selected commitments, extending behavior around openCreatePlanModal prefill and account-chip population.
  • LeanerCloud/CUDly#777: Both PRs extend the "Plan from X selected" flow to support multi-item homogeneous selection, adding logic to validate and handle multiple commitments with shared provider/service/term/payment values.
  • LeanerCloud/CUDly#711: Both PRs modify account-chip behavior in the Plans modal around setupPlanAccountsSection, adjusting how chips are preloaded and filtered based on provider and account selection criteria.

Poem

🐰 A modal that's clever and wise,
Now handles selections of any size—
Two, three, or ten commitments aligned,
Prefill the fields that share the same mind,
Account chips dance when clouds coincide!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly references the main change: prefilling the Create Purchase Plan modal for homogeneous multi-commitments, and directly links to the resolved issue (#898).
Linked Issues check ✅ Passed The PR successfully implements all coding objectives from #898: prefilling Purchase Configuration fields from multiple homogeneous commitments, account chip prefilling only when all commitments share the same cloud_account_id, and extended test coverage.
Out of Scope Changes check ✅ Passed All changes are directly scoped to resolving #898: modifications to plans.ts for prefill logic and plans.test.ts for regression tests are all relevant to the homogeneous multi-commitment prefill feature.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/qa-6.7-multi-commitment-prefill

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

@coderabbitai

coderabbitai Bot commented Jun 1, 2026

Copy link
Copy Markdown
Contributor
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@cristim
cristim merged commit 9476456 into feat/multicloud-web-frontend Jun 1, 2026
5 checks passed
@cristim
cristim deleted the fix/qa-6.7-multi-commitment-prefill branch June 3, 2026 21:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

effort/s Hours impact/many Affects most users priority/p2 Backlog-worthy severity/medium Moderate harm triaged Item has been triaged type/bug Defect urgency/this-sprint Within the current sprint

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant