betodealmeida opened a new pull request, #40280:
URL: https://github.com/apache/superset/pull/40280

   <!---
   Please write the PR title following the conventions at 
https://www.conventionalcommits.org/en/v1.0.0/
   Example:
   fix(dashboard): load charts correctly
   -->
   
   ### SUMMARY
   <!--- Describe the change below, including rationale and design decisions -->
   
   Adds two pieces of UX plumbing so semantic-layer extensions can ship a 
runtime form that fully describes a single view (think MetricFlow cubes), and 
so any runtime form that exposes a "pick several from a fixed list" field 
renders the right control.
   
   #### Changes
   
   ##### `superset-frontend/src/features/semanticLayers/jsonFormsHelpers.tsx`
   
   New JSON Forms renderer `MultiEnumControl` for schemas of the shape:
   
   ```json
   { "type": "array", "items": { "enum": [...], "x-enumNames": [...] } }
   ```
   
   - Rendered as a single Antd `<Select mode="multiple">` (tag-style 
multi-pick).
   - Uses `items.x-enumNames` for display labels, falling back to the raw enum 
value.
   - Honors the host form's `config.refreshingSchema` flag: the control shows a 
loading indicator while the schema is being re-fetched (e.g. dependent options 
narrowing as the user picks), without becoming disabled.
   - Registered at rank `35` so it beats upstream `PrimitiveArrayControl` (rank 
`30`), which previously rendered a misleading "Add …" repeater of single 
selects that couldn't surface `x-enumNames`.
   - The existing `enumNamesEntry` (scalar `x-enumNames` renderer) is narrowed 
to only fire when `schema.type !== 'array'`, so the new array entry owns the 
multi-select case.
   
   ##### `superset-frontend/src/features/semanticViews/AddSemanticViewModal.tsx`
   
   Adds support for a top-level `x-singleView: true` flag on a layer's runtime 
schema. When set, the layer is treated as describing exactly one semantic view:
   
   - The "Semantic Views" multi-select picker is hidden.
   - Once `get_semantic_views` returns, the first not-yet-added view is 
auto-selected so the **Add** button can fire without an extra click.
   - The selection effect is idempotent (compares previous and next arrays 
before calling `setSelectedViewNames`), so it doesn't re-render the modal in a 
loop.
   
   Also fixes a small bug in the "no runtime config" path of the 
layer-selection effect: previously, when a layer's runtime schema had no 
`properties` we skipped `applyRuntimeSchema(schema)` and went straight to 
`fetchViews`, which threw away top-level metadata like `x-singleView`. We now 
call `applyRuntimeSchema(schema)` first, then fetch views.
   
   #### Why this matters
   
   Extensions like MetricFlow expose layers that *are* a single cube — there is 
no list of views to pick from. Before this branch, the modal forced the user 
through an empty-but-required picker. With `x-singleView`, the runtime form 
fully drives the Add flow.
   
   `MultiEnumControl` is a generic prerequisite: those same single-view runtime 
schemas commonly include "select N tags / N dimensions" array-of-enum fields, 
and the upstream PrimitiveArray renderer wasn't usable for them.
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   <!--- Skip this if not applicable -->
   
   ### TESTING INSTRUCTIONS
   <!--- Required! What steps can be taken to manually verify the changes? -->
   
   - Open *Add Semantic View* against a layer **without** `x-singleView`: 
behavior unchanged — picker is shown, manual selection required.
   - Open *Add Semantic View* against a layer **with** `x-singleView: true` and 
a non-empty runtime form: picker is hidden; once `get_semantic_views` resolves, 
the first available view is preselected and **Add** is enabled.
   - Same as above but the runtime form has *no* `properties`: `x-singleView` 
is still honored (picker hidden, view auto-selected).
   - A runtime form with an `array`/`items.enum` field renders an Antd 
tag-style multi-select using `x-enumNames` for labels; the control shows a 
loading spinner during schema refresh without disabling editing.
   
   ### ADDITIONAL INFORMATION
   <!--- Check any relevant boxes with "x" -->
   <!--- HINT: Include "Fixes #nnn" if you are fixing an existing issue -->
   - [ ] Has associated issue:
   - [ ] Required feature flags:
   - [ ] Changes UI
   - [ ] Includes DB Migration (follow approval process in 
[SIP-59](https://github.com/apache/superset/issues/13351))
     - [ ] Migration is atomic, supports rollback & is backwards-compatible
     - [ ] Confirm DB migration upgrade and downgrade tested
     - [ ] Runtime estimates and downtime expectations provided
   - [ ] Introduces new feature or API
   - [ ] Removes existing feature or API
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to