Conversation
`has_attributes` will be depracated shortly but for now we the API enforces the has_attributes flag to be true in order to set variant attribute values
…butes=false Provide additinal information that has_variants needs to be on to change create variant with selection attributes.
|
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #6298 +/- ##
==========================================
- Coverage 42.49% 42.48% -0.02%
==========================================
Files 2492 2492
Lines 43220 43235 +15
Branches 10203 10176 -27
==========================================
+ Hits 18368 18369 +1
- Misses 23531 24830 +1299
+ Partials 1321 36 -1285 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
Updates product/variant UI behavior for product types with hasVariants=false, preventing variant generation and clarifying configuration requirements.
Changes:
- Plumbs
hasVariants(andproductTypeIdwhere needed) through product variant edit/create and variants list views to gate generator/attribute UI. - Disables “Generate variants” when the product type is not configured (no variants or no selection attributes) and adds a tooltip linking to product type settings.
- Extends GraphQL queries/fragments/types plus fixtures/messages to include
ProductType.hasVariants(andnamewhere required).
Reviewed changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/products/views/ProductVariant/ProductVariant.tsx | Passes hasVariants into the variant edit page. |
| src/products/queries.ts | Fetches productType.name and productType.hasVariants for variant create data. |
| src/products/fixtures.ts | Updates product type fixture to include hasVariants. |
| src/products/components/ProductVariants/components/ProductVariantsHeader.tsx | Disables generator based on product type config and adds richer tooltip content + product type link. |
| src/products/components/ProductVariants/ProductVariants.tsx | Threads hasVariants/productTypeId into header and gates generator rendering. |
| src/products/components/ProductVariantPage/VariantAttributesSection.tsx | Shows an informational card when attributes exist but variants are disabled. |
| src/products/components/ProductVariantPage/ProductVariantPage.tsx | Gates selection attributes UI behind hasVariants and passes total attribute count. |
| src/products/components/ProductVariantPage/ProductVariantPage.test.tsx | Adjusts test setup for new hasVariants requirement. |
| src/products/components/ProductVariantCreatePage/ProductVariantCreatePage.tsx | Hides variant attribute sections when hasVariants=false and shows an info message with link. |
| src/products/components/ProductUpdatePage/ProductUpdatePage.tsx | Passes productTypeId and hasVariants into variants list. |
| src/graphql/types.generated.ts | Regenerates types to include hasVariants on product type in relevant selections. |
| src/graphql/hooks.generated.ts | Regenerates hooks/documents to query hasVariants/name. |
| src/fragments/products.ts | Adds hasVariants to the variant fragment’s product type selection. |
| src/components/Datagrid/components/Header.tsx | Adds optional disabled prop to the “add row” header button. |
| locale/defaultMessages.json | Adds/removes/updates message entries for new tooltip/info text. |
Comments suppressed due to low confidence (1)
locale/defaultMessages.json:1106
- This locale entry updates the string for id
4YtpqB, but the code now referencesgDvd3vfor the same tooltip message. As a result,4YtpqBappears unused andgDvd3vis missing from the default messages. Update the key to match the code (or revert the code id change) to keep translations consistent.
"4YyeCx": {
"context": "label for order total amount",
"string": "Order total"
},
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| }, | ||
| unsupportedRequiredAttributes: { | ||
| id: "4YtpqB", | ||
| id: "gDvd3v", |
There was a problem hiding this comment.
The message id for unsupportedRequiredAttributes was changed to gDvd3v, but locale/defaultMessages.json still contains the old 4YtpqB entry and has no gDvd3v key. This will result in missing/incorrect localization (and leaves an unused message id). Align the id between the code and the locale file (either keep 4YtpqB or update the locale entry to gDvd3v).
| id: "gDvd3v", | |
| id: "4YtpqB", |
| .join(" "); | ||
| }; | ||
|
|
||
| const attributesList = unsupportedRequiredAttributes |
There was a problem hiding this comment.
VariantAttributeFragment.name is nullable; using it in a template literal will render the string "null" when missing. Consider falling back to an empty string / placeholder (e.g. a.name ?? "") or filtering out nameless attributes before building attributesList.
| const attributesList = unsupportedRequiredAttributes | |
| const attributesList = unsupportedRequiredAttributes | |
| .filter(a => a.name) |
| <ProductVariants | ||
| productId={productId} | ||
| productTypeId={product?.productType.id ?? ""} | ||
| productName={product?.name} |
There was a problem hiding this comment.
productTypeId is being passed as product?.productType.id ?? "". An empty string will make productTypeUrl(productTypeId) resolve to /product-types/ (list) instead of a specific product type, which is especially confusing now that the disabled Generator tooltip links to product type settings. Prefer not passing a sentinel "" (e.g. render ProductVariants only when the id is available, or make the prop optional and hide the link when missing).
| {hasVariants && selectionAttributes.length > 0 && ( | ||
| <> | ||
| <CardSpacer /> |
There was a problem hiding this comment.
New UI behavior is introduced here for hasVariants (hiding selection attributes and showing an informational card when variant attributes exist but the product type has variants disabled), but the existing ProductVariantPage.test.tsx only exercises hasVariants: true. Add coverage for the hasVariants: false cases to prevent regressions.
No description provided.