Allow changing useLegacyShippingZoneStockAvailability shop settings#6536
Allow changing useLegacyShippingZoneStockAvailability shop settings#6536lkostrowski merged 6 commits intomainfrom
useLegacyShippingZoneStockAvailability shop settings#6536Conversation
🦋 Changeset detectedLatest commit: b59dff0 The changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #6536 +/- ##
==========================================
- Coverage 48.17% 48.16% -0.01%
==========================================
Files 2589 2589
Lines 46043 46049 +6
Branches 10868 10586 -282
==========================================
Hits 22181 22181
- Misses 22617 23489 +872
+ Partials 1245 379 -866
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
Adds UI + GraphQL wiring to allow changing the shop.useLegacyShippingZoneStockAvailability setting from the Site Settings area.
Changes:
- Extends shop GraphQL fragment/codegen to include
useLegacyShippingZoneStockAvailability. - Adds a new “Stock availability” section with a checkbox to toggle the setting.
- Includes the setting in the shop settings update input mapping and fixtures.
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 |
|---|---|
| src/siteSettings/views/index.tsx | Sends useLegacyShippingZoneStockAvailability in ShopSettingsInput on save. |
| src/siteSettings/fixtures.ts | Updates site settings fixture shop object with the new field. |
| src/siteSettings/components/SiteSettingsPage/messages.ts | Adds i18n messages for the new Stock availability section. |
| src/siteSettings/components/SiteSettingsPage/SiteSettingsPage.tsx | Renders the new section + checkbox (and webhook info list). |
| src/graphql/types.generated.ts | Regenerates types to include the new shop field in fragments/queries/mutations. |
| src/graphql/hooks.generated.ts | Updates generated Shop fragment document to query the new field. |
| src/fragments/shop.ts | Adds the field to the Shop GraphQL fragment. |
| locale/defaultMessages.json | Adds default message catalog entries for the new i18n strings. |
| "stockAvailabilityDesc": { | ||
| "context": "section description", | ||
| "string": "When enabled, stock availability is filtered by shipping zones and the destination address (legacy behavior). When disabled, it is determined only by the direct warehouse-channel link." | ||
| }, | ||
| "stockAvailabilityWebhooks": { |
There was a problem hiding this comment.
defaultMessages.json adds entries under keys stockAvailabilityDesc and stockAvailabilityWebhooks, but the corresponding defineMessages IDs are 6LdQvx and wmybDi. This will prevent those strings from being picked up/translated correctly (and leaves two unused keys in the messages catalog). Update the JSON keys to match the message IDs (or update the message IDs to match), keeping the catalog consistent with the rest of the file.
| "stockAvailabilityDesc": { | |
| "context": "section description", | |
| "string": "When enabled, stock availability is filtered by shipping zones and the destination address (legacy behavior). When disabled, it is determined only by the direct warehouse-channel link." | |
| }, | |
| "stockAvailabilityWebhooks": { | |
| "6LdQvx": { | |
| "context": "section description", | |
| "string": "When enabled, stock availability is filtered by shipping zones and the destination address (legacy behavior). When disabled, it is determined only by the direct warehouse-channel link." | |
| }, | |
| "wmybDi": { |
| <Box display="flex" flexDirection="column" gap={1}> | ||
| <Text size={2} color="default2"> | ||
| {intl.formatMessage(messages.sectionStockAvailabilityWebhooksIntro)} | ||
| </Text> | ||
| <Box as="ul" margin={0} paddingLeft={5}> | ||
| {stockAvailabilityWebhooks.map(name => ( | ||
| <Box as="li" key={name}> | ||
| <Text size={2}>{name}</Text> | ||
| </Box> | ||
| ))} | ||
| </Box> | ||
| </Box> |
There was a problem hiding this comment.
The copy says these webhooks become available when the setting is disabled, but the intro + list are always rendered regardless of useLegacyShippingZoneStockAvailability. This is misleading in the enabled state; consider rendering the intro/list only when !data.useLegacyShippingZoneStockAvailability (or adjust the copy so it matches the always-visible behavior).
| <Box display="flex" flexDirection="column" gap={1}> | |
| <Text size={2} color="default2"> | |
| {intl.formatMessage(messages.sectionStockAvailabilityWebhooksIntro)} | |
| </Text> | |
| <Box as="ul" margin={0} paddingLeft={5}> | |
| {stockAvailabilityWebhooks.map(name => ( | |
| <Box as="li" key={name}> | |
| <Text size={2}>{name}</Text> | |
| </Box> | |
| ))} | |
| </Box> | |
| </Box> | |
| {!data.useLegacyShippingZoneStockAvailability && ( | |
| <Box display="flex" flexDirection="column" gap={1}> | |
| <Text size={2} color="default2"> | |
| {intl.formatMessage(messages.sectionStockAvailabilityWebhooksIntro)} | |
| </Text> | |
| <Box as="ul" margin={0} paddingLeft={5}> | |
| {stockAvailabilityWebhooks.map(name => ( | |
| <Box as="li" key={name}> | |
| <Text size={2}>{name}</Text> | |
| </Box> | |
| ))} | |
| </Box> | |
| </Box> | |
| )} |
There was a problem hiding this comment.
I don't like the propose changes. Current approach just adds extra info that extra webhooks will be available when the flag is disabled.
| }, | ||
| sectionStockAvailabilityWebhooksIntro: { | ||
| id: "wmybDi", | ||
| defaultMessage: "When disabled, the following channel-scoped stock webhooks become available:", |
There was a problem hiding this comment.
The intro copy says these webhooks “become available” when the setting is disabled, but the Dashboard already lists all async webhook event types unconditionally (e.g. WebhookDetailsPage builds its event list from Object.keys(WebhookEventTypeAsyncEnum)). This makes “available” misleading; consider rewording to reflect that the events are only triggered/fired when the setting is disabled (as described in the GraphQL schema docs), rather than implying they cannot be selected/used otherwise.
| defaultMessage: "When disabled, the following channel-scoped stock webhooks become available:", | |
| defaultMessage: "When disabled, the following channel-scoped stock webhooks are triggered:", |
9c777e5
| {stockAvailabilityWebhooks.map(name => ( | ||
| <Box as="li" key={name}> | ||
| <Text size={2}>{name}</Text> | ||
| </Box> | ||
| ))} |
There was a problem hiding this comment.
The webhook event types are rendered directly from WebhookEventTypeAsyncEnum (e.g. PRODUCT_VARIANT_OUT_OF_STOCK_IN_CHANNEL), which will show up as all-caps with underscores in the UI. Consider formatting these values into a human-readable label (replace _ with spaces, lowercase + capitalize) or reusing the formatting approach used in the webhook events UI so this section is readable for non-technical users.
Scope of the change
Allow changing
shop.useLegacyShippingZoneStockAvailabilitysetting