Skip to content

Comments

has_variants=false: disable Generate Variants button and fix the selection attributes in variant's edit/crete #6298

Merged
mirekm merged 5 commits intomainfrom
fix/vargen-no-variants
Jan 29, 2026
Merged

has_variants=false: disable Generate Variants button and fix the selection attributes in variant's edit/crete #6298
mirekm merged 5 commits intomainfrom
fix/vargen-no-variants

Conversation

@mirekm
Copy link
Member

@mirekm mirekm commented Jan 29, 2026

No description provided.

`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.
Copilot AI review requested due to automatic review settings January 29, 2026 13:56
@mirekm mirekm requested a review from a team as a code owner January 29, 2026 13:56
@mirekm mirekm added the skip changeset Use if your changes doesn't need entry in changelog label Jan 29, 2026
@changeset-bot
Copy link

changeset-bot bot commented Jan 29, 2026

⚠️ No Changeset found

Latest commit: c7afef6

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

lkostrowski
lkostrowski previously approved these changes Jan 29, 2026
@codecov
Copy link

codecov bot commented Jan 29, 2026

Codecov Report

❌ Patch coverage is 6.89655% with 27 lines in your changes missing coverage. Please review.
✅ Project coverage is 42.48%. Comparing base (1245dab) to head (c7afef6).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...oductVariants/components/ProductVariantsHeader.tsx 0.00% 13 Missing ⚠️
...ductVariantCreatePage/ProductVariantCreatePage.tsx 0.00% 8 Missing ⚠️
src/components/Datagrid/components/Header.tsx 0.00% 2 Missing ⚠️
...components/ProductUpdatePage/ProductUpdatePage.tsx 0.00% 2 Missing ⚠️
...cts/components/ProductVariants/ProductVariants.tsx 0.00% 1 Missing ⚠️
...c/products/views/ProductVariant/ProductVariant.tsx 0.00% 1 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates product/variant UI behavior for product types with hasVariants=false, preventing variant generation and clarifying configuration requirements.

Changes:

  • Plumbs hasVariants (and productTypeId where 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 (and name where 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 references gDvd3v for the same tooltip message. As a result, 4YtpqB appears unused and gDvd3v is 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",
Copy link

Copilot AI Jan 29, 2026

Choose a reason for hiding this comment

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

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

Suggested change
id: "gDvd3v",
id: "4YtpqB",

Copilot uses AI. Check for mistakes.
.join(" ");
};

const attributesList = unsupportedRequiredAttributes
Copy link

Copilot AI Jan 29, 2026

Choose a reason for hiding this comment

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

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.

Suggested change
const attributesList = unsupportedRequiredAttributes
const attributesList = unsupportedRequiredAttributes
.filter(a => a.name)

Copilot uses AI. Check for mistakes.
Comment on lines 491 to 494
<ProductVariants
productId={productId}
productTypeId={product?.productType.id ?? ""}
productName={product?.name}
Copy link

Copilot AI Jan 29, 2026

Choose a reason for hiding this comment

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

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

Copilot uses AI. Check for mistakes.
Comment on lines +314 to 316
{hasVariants && selectionAttributes.length > 0 && (
<>
<CardSpacer />
Copy link

Copilot AI Jan 29, 2026

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
@mirekm mirekm merged commit 6f61b4f into main Jan 29, 2026
11 of 14 checks passed
@mirekm mirekm deleted the fix/vargen-no-variants branch January 29, 2026 14:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip changeset Use if your changes doesn't need entry in changelog

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants