Skip to content

Fix: use different query for add-on ddl - #303

Open
santipalenque wants to merge 3 commits into
mainfrom
fix/add-on-dropdown-fix
Open

Fix: use different query for add-on ddl#303
santipalenque wants to merge 3 commits into
mainfrom
fix/add-on-dropdown-fix

Conversation

@santipalenque

@santipalenque santipalenque commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

as part of https://app.clickup.com/t/9014802374/86bat8h0n

Summary by CodeRabbit

  • New Features

    • Added generalized add-on type selectors for standard and Formik-integrated forms.
    • Add-on options now display clear, readable names.
    • Selectors now retrieve available add-on types from the consolidated source.
  • Breaking Changes

    • Replaced summit-specific selector names with generalized add-on type selector names.
    • Integrations using the previous selector names or summit-specific properties must be updated.

@coderabbitai

coderabbitai Bot commented Jul 31, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The pull request renames summit-specific addon selectors to addon type selectors, updates option mapping to use addon names, changes the query endpoint, and updates Formik integration, exports, Webpack entries, package version, and tests.

Changes

Addon type selector

Layer / File(s) Summary
Addon type selector core
src/utils/query-actions.js, src/components/mui/addon-type-select.js
The selector now queries the all-summits add-on-types endpoint. It uses each add-on name as the option value and label.
Formik and package wiring
src/components/mui/formik-inputs/mui-formik-addon-type-select.js, src/components/index.js, webpack.common.js, package.json
The Formik wrapper, public exports, Webpack entries, and package version now use the addon type selector names and paths.
Selector test updates
src/components/mui/__tests__/addon-type-select.test.js, src/components/mui/__tests__/mui-formik-addon-type-select.test.js
Tests now use addon objects and the renamed MUI and Formik components. Formik placeholder and error behavior coverage remains in place.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested reviewers: smarcet

🚥 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 identifies the main change: using a different query for the add-on dropdown.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ 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/add-on-dropdown-fix

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
src/components/mui/__tests__/addon-type-select.test.js (1)

52-60: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Assert the option mapping in this test.

The test named "renders options returned by querySummitAddons" only checks that the query was called. It would pass if r.name were ignored or mapped to the wrong value. Open the select and assert that Addon Alpha and Addon Beta render as the option labels and values.

🤖 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/mui/__tests__/addon-type-select.test.js` around lines 52 - 60,
Update the test “renders options returned by querySummitAddons” to open the
rendered Select after the query resolves, then assert that options labeled and
valued “Addon Alpha” and “Addon Beta” are present. Keep the existing
querySummitAddons invocation assertion while verifying the returned addon name
mapping.
🤖 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/mui/__tests__/addon-type-select.test.js`:
- Around line 52-60: Update the test “renders options returned by
querySummitAddons” to open the rendered Select after the query resolves, then
assert that options labeled and valued “Addon Alpha” and “Addon Beta” are
present. Keep the existing querySummitAddons invocation assertion while
verifying the returned addon name mapping.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 0c1ceee9-2896-428b-a4be-7cf66312bcb6

📥 Commits

Reviewing files that changed from the base of the PR and between 43f0d8c and e52c822.

📒 Files selected for processing (7)
  • src/components/index.js
  • src/components/mui/__tests__/addon-type-select.test.js
  • src/components/mui/__tests__/mui-formik-addon-type-select.test.js
  • src/components/mui/addon-type-select.js
  • src/components/mui/formik-inputs/mui-formik-addon-type-select.js
  • src/utils/query-actions.js
  • webpack.common.js

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the add-on dropdown to use the add-on types endpoint and renames the MUI selector entry points accordingly, including Formik integration and updated exports/versioning.

Changes:

  • Switched add-on data retrieval from summit metadata to the global add-on types endpoint.
  • Renamed/replaced the summit add-on select components with generalized add-on type select components (including Formik wrapper) and updated exports/webpack entries.
  • Updated/addjusted unit tests and bumped the package version.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
webpack.common.js Updates published bundle entry points to the new add-on type select modules.
src/utils/query-actions.js Changes the query endpoint used for fetching add-on options (now add-on types).
src/components/mui/formik-inputs/mui-formik-addon-type-select.js Renames and rewires the Formik wrapper to use the new add-on type selector.
src/components/mui/addon-type-select.js Updates the selector component to normalize and display add-on type names.
src/components/mui/tests/mui-formik-addon-type-select.test.js Updates Formik wrapper tests to mock and assert against the renamed selector.
src/components/mui/tests/addon-type-select.test.js Updates selector tests to reflect the new API response shape and component name.
src/components/index.js Updates public exports to expose the new selector components.
package.json Bumps the package version for the release containing these changes.
Suppressed comments (4)

src/components/mui/tests/addon-type-select.test.js:24

  • This test file uses fireEvent-style interaction in other MUI Select tests in the repo, but fireEvent isn't imported here. Importing it will allow the options-rendering test to actually open the Select and assert on the menu items.

This issue also appears on line 52 of the same file.
src/components/mui/tests/addon-type-select.test.js:56

  • The "renders options" test currently only asserts that the query function was called, but it doesn't verify that the option labels are actually rendered. This can miss regressions in the normalization logic (e.g., using the wrong field for labels).
    src/components/mui/addon-type-select.js:33
  • The add-on types endpoint returns objects (tests mock {id, name}), but the component currently uses name as the option value/key. Using id as the option value is more stable (avoids collisions if names repeat) and matches the pattern used by SponsorAddonSelect.
    src/components/mui/addon-type-select.js:72
  • If the Select option values are numeric IDs, the value prop type should be number to match and avoid type mismatches in consumers.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/utils/query-actions.js
Comment thread src/components/index.js Outdated
Comment thread src/utils/query-actions.js
Comment thread src/utils/query-actions.js
Comment thread src/components/mui/addon-type-select.js Outdated
Comment thread src/components/mui/__tests__/addon-type-select.test.js Outdated

@smarcet smarcet left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@santipalenque please review

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated no new comments.

Suppressed comments (5)

src/components/mui/addon-type-select.js:36

  • The effect fetches options using summitId but the dependency array is empty, so the list will not refresh if summitId changes (and this also trips react-hooks/exhaustive-deps). Include summitId in the dependency array or explicitly justify why it must only run once.

This issue also appears on line 67 of the same file.
src/components/mui/addon-type-select.js:70

  • AddonTypeSelect still requires summitId, but the underlying query now hits the /summits/all/add-on-types endpoint where summitId no longer affects results. Making this prop optional avoids forcing callers to pass a dummy value for a generalized selector.
    src/components/mui/tests/addon-type-select.test.js:56
  • The test "renders options returned by querySummitAddons" doesn’t actually assert that the option labels render, so it won’t catch regressions in the new {id,name} mapping. Open the select and assert the expected option text is present.
    src/components/mui/formik-inputs/mui-formik-addon-type-select.js:46
  • MuiFormikAddonTypeSelect still requires summitId, but the underlying selector now queries the global add-on types endpoint. Making summitId optional here avoids forcing Formik forms to provide a summit id that no longer affects the results.
    src/utils/query-actions.js:636
  • summitId is now unused in querySummitAddons since the endpoint is /summits/all/add-on-types. Renaming the parameter to _summitId makes the intent clear and avoids confusion for future maintainers.
export const querySummitAddons = async (
    summitId,
    callback
) => {

@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 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.

Inline comments:
In `@src/components/mui/addon-type-select.js`:
- Around line 29-31: Update the Formik contract used by MuiFormikAddonTypeSelect
so addon values are consistently represented by names across initial values,
persisted data, and submit payloads, or normalize legacy addon objects at the
Formik boundary before selection. Ensure existing object-shaped values still
resolve to the matching MenuItem, and add a regression test covering the legacy
value shape.
🪄 Autofix

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: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 95968de1-4f20-4b54-8ad2-387876f9f9cf

📥 Commits

Reviewing files that changed from the base of the PR and between 43f0d8c and eba7583.

📒 Files selected for processing (8)
  • package.json
  • src/components/index.js
  • src/components/mui/__tests__/addon-type-select.test.js
  • src/components/mui/__tests__/mui-formik-addon-type-select.test.js
  • src/components/mui/addon-type-select.js
  • src/components/mui/formik-inputs/mui-formik-addon-type-select.js
  • src/utils/query-actions.js
  • webpack.common.js
🚧 Files skipped from review as they are similar to previous changes (5)
  • webpack.common.js
  • src/components/mui/formik-inputs/mui-formik-addon-type-select.js
  • src/components/mui/tests/addon-type-select.test.js
  • src/utils/query-actions.js
  • src/components/mui/tests/mui-formik-addon-type-select.test.js

Comment on lines 29 to +31
const normalized = results.map((r) => ({
value: r,
label: r
value: r.name,
label: r.name

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

rg -n -C 5 \
  '\b(MuiFormikAddonTypeSelect|MuiSummitAddonSelect|MuiFormikSummitAddonSelect|AddonTypeSelect)\b' \
  --glob '*.{js,jsx,mjs,cjs}' . || true

rg -n -C 5 \
  '\b(initialValues|setFieldValue|setValue|addon)\b' \
  --glob '*.{js,jsx,mjs,cjs}' . || true

Repository: OpenStackweb/openstack-uicore-foundation

Length of output: 50397


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== files =="
find . -path './node_modules' -prune -o -path './dist' -prune -o -path './build' -prune -o \( -type f \( -name '*.js' -o -name '*.jsx' -o -name '*.mjs' -o -name '*.cjs' \) \) -print | sed 's#^\./##' | sort

echo "== component slices =="
sed -n '1,120p' src/components/mui/addon-type-select.js
echo "--- formik wrapper ---"
sed -n '1,80p' src/components/mui/formik-inputs/mui-formik-addon-type-select.js
echo "--- mui index slice ---"
sed -n '60,105p' src/components/index.js
echo "--- direct imports/usages (focused) =="
rg -n --glob '*.{js,jsx,mjs,cjs}' 'from ["'\''].*addon-type-select["'\'']|<MuiFormikAddonTypeSelect|<MuiAddonTypeSelect' . || true

echo "== addon field occurrences (focused) =="
rg -n --glob '*.{js,jsx,mjs,cjs}' '\badd[on]s?\b' . | head -n 220

Repository: OpenStackweb/openstack-uicore-foundation

Length of output: 25887


Migrate the Formik value contract before using addon names.

value: r.name changes the selector value from the full addon object to a string. MuiFormikAddonTypeSelect forwards field.value unchanged and stores the selected value directly. If an existing form still initializes addon with the previous object shape, no MenuItem matches it.

Use addon names for existing Formik initial values, persisted values, and submit payloads, or normalize legacy values at the Formik boundary. Add a regression test for the old value shape.

🤖 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/mui/addon-type-select.js` around lines 29 - 31, Update the
Formik contract used by MuiFormikAddonTypeSelect so addon values are
consistently represented by names across initial values, persisted data, and
submit payloads, or normalize legacy addon objects at the Formik boundary before
selection. Ensure existing object-shaped values still resolve to the matching
MenuItem, and add a regression test covering the legacy value shape.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants