-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Allow changing useLegacyShippingZoneStockAvailability shop settings
#6536
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
2542735
79b7cb9
5b87a77
c0ca391
9c777e5
b59dff0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -13,6 +13,7 @@ import { | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| type PasswordLoginModeEnum, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| type ShopErrorFragment, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| type SiteSettingsQuery, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| WebhookEventTypeAsyncEnum, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } from "@dashboard/graphql"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import useAddressValidation from "@dashboard/hooks/useAddressValidation"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { type SubmitPromise } from "@dashboard/hooks/useForm"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -28,6 +29,13 @@ import SiteCheckoutSettingsCard from "../SiteCheckoutSettingsCard"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { SitePasswordLoginCard } from "../SitePasswordLoginCard/SitePasswordLoginCard"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { messages } from "./messages"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const stockAvailabilityWebhooks = [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| WebhookEventTypeAsyncEnum.PRODUCT_VARIANT_OUT_OF_STOCK_IN_CHANNEL, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| WebhookEventTypeAsyncEnum.PRODUCT_VARIANT_BACK_IN_STOCK_IN_CHANNEL, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| WebhookEventTypeAsyncEnum.PRODUCT_VARIANT_OUT_OF_STOCK_FOR_CLICK_AND_COLLECT, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| WebhookEventTypeAsyncEnum.PRODUCT_VARIANT_BACK_IN_STOCK_FOR_CLICK_AND_COLLECT, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| interface SiteSettingsPageAddressFormData { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| city: string; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| companyName: string; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -46,6 +54,7 @@ export interface SiteSettingsPageFormData extends SiteSettingsPageAddressFormDat | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| limitQuantityPerCheckout: number; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| emailConfirmation: boolean; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| useLegacyUpdateWebhookEmission: boolean; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| useLegacyShippingZoneStockAvailability: boolean; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| preserveAllAddressFields: boolean; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| passwordLoginMode: PasswordLoginModeEnum; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -101,6 +110,7 @@ const SiteSettingsPage = (props: SiteSettingsPageProps) => { | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| limitQuantityPerCheckout: shop?.limitQuantityPerCheckout ?? 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| emailConfirmation: shop?.enableAccountConfirmationByEmail ?? false, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| useLegacyUpdateWebhookEmission: shop?.useLegacyUpdateWebhookEmission ?? true, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| useLegacyShippingZoneStockAvailability: shop?.useLegacyShippingZoneStockAvailability ?? true, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| preserveAllAddressFields: shop?.preserveAllAddressFields ?? false, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| passwordLoginMode: shop?.passwordLoginMode, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -133,6 +143,9 @@ const SiteSettingsPage = (props: SiteSettingsPageProps) => { | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| const handlePreserveAddressFieldsChange = isEnabled => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| change({ target: { name: "preserveAllAddressFields", value: isEnabled } }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const handleLegacyStockAvailabilityChange = isEnabled => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| change({ target: { name: "useLegacyShippingZoneStockAvailability", value: isEnabled } }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <DetailPageLayout gridTemplateColumns={1}> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -251,6 +264,48 @@ const SiteSettingsPage = (props: SiteSettingsPageProps) => { | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| </DashboardCard> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </Box> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <Divider /> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <Box | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| display="grid" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| __gridTemplateColumns="1fr 3fr" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| paddingLeft={6} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| paddingBottom={8} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| > | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <PageSectionHeader | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| title={intl.formatMessage(messages.sectionStockAvailabilityTitle)} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| description={intl.formatMessage(messages.sectionStockAvailabilityDescription)} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <DashboardCard> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <DashboardCard.Header> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <DashboardCard.Title> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| {intl.formatMessage(messages.sectionStockAvailabilityHeader)} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </DashboardCard.Title> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </DashboardCard.Header> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <DashboardCard.Content> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <Box display="flex" flexDirection="column" gap={3}> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <Checkbox | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| data-test-id="legacy-shipping-zone-stock-availability-checkbox" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| checked={data.useLegacyShippingZoneStockAvailability} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| onCheckedChange={handleLegacyStockAvailabilityChange} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| > | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <Text>{intl.formatMessage(messages.sectionStockAvailabilityHeader)}</Text> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </Checkbox> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <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> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ))} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+316
to
+320
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </Box> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </Box> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+311
to
+322
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't like the propose changes. Current approach just adds extra info that extra webhooks will be available when the flag is disabled.
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -88,4 +88,25 @@ export const messages = defineMessages({ | |||||
| "Controls whether users can authenticate using password-based login. You can allow it for everyone, restrict it to customers only, or disable it entirely.", | ||||||
| description: "section description", | ||||||
| }, | ||||||
| sectionStockAvailabilityTitle: { | ||||||
| id: "v5yLSE", | ||||||
| defaultMessage: "Stock availability", | ||||||
| description: "section title", | ||||||
| }, | ||||||
| sectionStockAvailabilityDescription: { | ||||||
| id: "6LdQvx", | ||||||
| defaultMessage: | ||||||
| "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.", | ||||||
| description: "section description", | ||||||
| }, | ||||||
| sectionStockAvailabilityHeader: { | ||||||
| id: "6ZnMfQ", | ||||||
| defaultMessage: "Use legacy shipping zone stock availability", | ||||||
| description: "card header and checkbox label", | ||||||
| }, | ||||||
| sectionStockAvailabilityWebhooksIntro: { | ||||||
| id: "wmybDi", | ||||||
| defaultMessage: "When disabled, the following channel-scoped stock webhooks become available:", | ||||||
|
||||||
| defaultMessage: "When disabled, the following channel-scoped stock webhooks become available:", | |
| defaultMessage: "When disabled, the following channel-scoped stock webhooks are triggered:", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
defaultMessages.jsonadds entries under keysstockAvailabilityDescandstockAvailabilityWebhooks, but the correspondingdefineMessagesIDs are6LdQvxandwmybDi. 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.