fix(promocode): clarify Apply-to-all scope (Audience: All only)#928
fix(promocode): clarify Apply-to-all scope (Audience: All only)#928caseylocker wants to merge 2 commits into
Conversation
Backend tightens canBeAppliedTo() so the implicit "apply to all" branch only covers Audience = All ticket types (see companion API SDS). This change updates the admin copy so the checkbox label and a new helper-text row name the restriction explicitly. WithInvitation, WithoutInvitation, and WithPromoCode ticket types must be opted in via the picker after saving. No JS logic change — the apply_to_all_tix flag is and remains UI-only. Refs: ClickUp 86b9vrpxp; companion summit-api branch feat/promo-code-apply-to-all-audience-restriction
The `edit_promocode.apply_to_all_tix` i18n key is also rendered by speakers-promo-code-spec-form.js under the AUTO_GENERATED_SPEAKERS_DISCOUNT_CODE branch (a discount-code path). The label update from the prior commit lands there too, so the same helper row belongs beneath that checkbox to keep the admin clarity consistent across both forms. Spec line citations updated to reflect the actual en.json position. Refs: ClickUp 86b9vrpxp; Codex review of a694ada.
📝 WalkthroughWalkthroughThis PR adds specification-driven updates to the promo code form's "Apply to all Ticket Types" checkbox, including clarified copy, helper text explaining audience coverage behavior, and integration test assertions across the discount form, speakers discount form, and i18n keys. ChangesPromo Code Apply-to-All UI Clarity Update
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (2)
src/components/forms/speakers-promo-code-spec-form.js (1)
17-20: 💤 Low valueStyle consistency improvement.
Adding semicolons to import statements improves code style consistency across the file.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/components/forms/speakers-promo-code-spec-form.js` around lines 17 - 20, The import statements for Dropdown, Input, PromocodeInput, and TagInput are missing semicolons; update each import line (the ones importing "openstack-uicore-foundation/lib/components/inputs/dropdown", "openstack-uicore-foundation/lib/components/inputs/text-input", "openstack-uicore-foundation/lib/components/inputs/promocode-input", and "openstack-uicore-foundation/lib/components/inputs/tag-input") to end with a semicolon to match the file's style and maintain consistency.src/components/forms/promocode-form/forms/discount-base-pc-form.js (1)
3-4: 💤 Low valueMinor: Import order adjustment.
The reordering of imports (Input before BasePCForm) appears to be alphabetical sorting. This is a minor style improvement bundled with the feature change.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/components/forms/promocode-form/forms/discount-base-pc-form.js` around lines 3 - 4, The import order was changed so Input is imported before BasePCForm; revert to the original logical ordering by placing BasePCForm before Input to match project style (i.e., import BasePCForm from "./base-pc-form" then import Input from "openstack-uicore-foundation/lib/components/inputs/text-input"); update the import sequence around the symbols BasePCForm and Input so only order changes are made.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@src/components/forms/promocode-form/forms/discount-base-pc-form.js`:
- Around line 3-4: The import order was changed so Input is imported before
BasePCForm; revert to the original logical ordering by placing BasePCForm before
Input to match project style (i.e., import BasePCForm from "./base-pc-form" then
import Input from
"openstack-uicore-foundation/lib/components/inputs/text-input"); update the
import sequence around the symbols BasePCForm and Input so only order changes
are made.
In `@src/components/forms/speakers-promo-code-spec-form.js`:
- Around line 17-20: The import statements for Dropdown, Input, PromocodeInput,
and TagInput are missing semicolons; update each import line (the ones importing
"openstack-uicore-foundation/lib/components/inputs/dropdown",
"openstack-uicore-foundation/lib/components/inputs/text-input",
"openstack-uicore-foundation/lib/components/inputs/promocode-input", and
"openstack-uicore-foundation/lib/components/inputs/tag-input") to end with a
semicolon to match the file's style and maintain consistency.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: c0c365b5-6b5f-41be-800e-ae2f409a4317
📒 Files selected for processing (5)
doc/promo-code-apply-to-all-audience-restriction.mdsrc/components/forms/promocode-form/__tests__/promocode-form.integration.test.jssrc/components/forms/promocode-form/forms/discount-base-pc-form.jssrc/components/forms/speakers-promo-code-spec-form.jssrc/i18n/en.json
ref: https://app.clickup.com/t/86b9vrpxp
Summary
The backend tightens
canBeAppliedTo()so the implicit "apply to all" branch only coversAudience = Allticket types (see companion summit-api PR). This change updates the admin copy so the checkbox label and a new helper-text row name the restriction explicitly. WithInvitation, WithoutInvitation, and WithPromoCode ticket types must be opted in via the picker after saving.No JS logic change — the
apply_to_all_tixflag is and remains UI-only (deleted before send atsrc/actions/promocode-actions.js:160and re-derived fromticket_types_rules.length === 0atsrc/reducers/promocodes/promocode-reducer.js:179).doc/promo-code-apply-to-all-audience-restriction.mdfeat/→feature/to satisfycheck-branch-nameCI)What changed
src/i18n/en.json—apply_to_all_tixrewritten to "Apply to all ticket types (Audience: All)"; newapply_to_all_tix_helperkey.src/components/forms/promocode-form/forms/discount-base-pc-form.js— added<small className="form-text text-muted">helper row beneath the checkbox.src/components/forms/speakers-promo-code-spec-form.js— same i18n key is rendered under theAUTO_GENERATED_SPEAKERS_DISCOUNT_CODEbranch; added the matching helper row there.src/components/forms/promocode-form/__tests__/promocode-form.integration.test.js— new test cases (6 discount-code classes × label/helper assertions + helper-renders-when-unchecked).doc/promo-code-apply-to-all-audience-restriction.md— dedicated spec.AC5 wording note
The ClickUp acceptance criterion #5 says "submitting
apply_to_all_ticket_types = trueresolves to Audience = All only, regardless of frontend." No such payload field is sent —apply_to_all_tixis a UI-only flag and is stripped before the API call. The actual enforcement is on the backend at the entity level (canBeAppliedTo). See the companion summit-api PR. A hostile client cannot bypass — there's no field to forge.Test plan
yarn test --watchAll=false src/components/forms/promocode-form/__tests__/promocode-form.integration.test.js— 38/38 passyarn test --watchAll=false --testPathPatterns="promocode|promo-code|methods"— 97/97 passapi.dev.fnopen.com, YOCO summit), opened theSUMMIT_DISCOUNT_CODEeditor for promo100OFF(1773). Label rendered as "Apply to all ticket types (Audience: All)"; helper-text row visible directly below the checkbox. A fresh navigation rendered the box checked (derived from emptyticket_types_rules) with Amount/Rate visible and no picker — confirming the UI-only flag round-trips. Unchecked →DiscountTicketTablepicker appeared with all summit ticket types exposed (added a throwawayAudience=WithPromoCodetype on YOCO and confirmed it appeared in the picker dropdown after a hard refresh).AUTO_GENERATED_SPEAKERS_DISCOUNT_CODE. Same label + helper rendered inside the modal'sSpeakerPromoCodeSpecForm. Closes the coverage gap that no Jest test covers this form.Notes
actions.test.js,dropbox-sync-actions.test.js,edit-sponsor-page.test.js) — same failures present onorigin/masterbaseline.Summary by CodeRabbit