From 6c723fe0a8587db1ad0e145628808dc8b4a22ad8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Chy=C5=82a?= Date: Fri, 3 Jan 2025 09:20:59 +0100 Subject: [PATCH] Fix fetch products data in webhook dry run and add warning (#5323) * Fix fetch products in dry run * Add changeset * Add items that do not work to excluded * Update changeset --- .changeset/mean-chicken-turn.md | 6 +++ src/components/DryRun/utils.ts | 4 +- src/components/DryRunItemsList/utils.ts | 69 ++++++++++--------------- 3 files changed, 35 insertions(+), 44 deletions(-) create mode 100644 .changeset/mean-chicken-turn.md diff --git a/.changeset/mean-chicken-turn.md b/.changeset/mean-chicken-turn.md new file mode 100644 index 00000000000..e0af25723a7 --- /dev/null +++ b/.changeset/mean-chicken-turn.md @@ -0,0 +1,6 @@ +--- +"saleor-dashboard": patch +--- + +Product data is now properly displayed in webhook dry run modal. +Add warning alert in webhook dry run modal for webhooks that don't have a valid object ids. diff --git a/src/components/DryRun/utils.ts b/src/components/DryRun/utils.ts index 437fd818955..4532fed6309 100644 --- a/src/components/DryRun/utils.ts +++ b/src/components/DryRun/utils.ts @@ -3,7 +3,7 @@ import { getWebhookTypes } from "@dashboard/custom-apps/components/WebhookEvents import { WebhookEventTypeAsyncEnum } from "@dashboard/graphql"; import { InlineFragmentNode, ObjectFieldNode, parse, visit } from "graphql"; -import { DocumentMap, ExcludedDocumentMap } from "../DryRunItemsList/utils"; +import { DocumentMap, ExcludedDocumentKeys } from "../DryRunItemsList/utils"; const getEventsFromQuery = (query: string) => { if (query.length === 0) { @@ -56,7 +56,7 @@ const checkEventPresence = (event: string) => { object => !availableObjects.includes(object), ); - Object.keys(ExcludedDocumentMap).forEach( + ExcludedDocumentKeys.forEach( object => !excludedObjects.includes(object) && excludedObjects.push(object), ); diff --git a/src/components/DryRunItemsList/utils.ts b/src/components/DryRunItemsList/utils.ts index f279c6b68e4..8889c594bbd 100644 --- a/src/components/DryRunItemsList/utils.ts +++ b/src/components/DryRunItemsList/utils.ts @@ -8,14 +8,12 @@ import { AttributeListQueryVariables, CategoryDetailsQuery, CategoryDetailsQueryVariables, - ChannelListDocument, CheckoutListDocument, CheckoutListQuery, CheckoutListQueryVariables, CollectionListDocument, CollectionListQuery, CollectionListQueryVariables, - CustomerAddressesDocument, CustomerAddressesQuery, CustomerAddressesQueryVariables, CustomerDetailsQuery, @@ -29,7 +27,6 @@ import { MenuListDocument, MenuListQuery, MenuListQueryVariables, - OrderFulfillDataDocument, OrderFulfillDataQuery, OrderFulfillDataQueryVariables, OrderListDocument, @@ -41,7 +38,6 @@ import { ProductListDocument, ProductListQuery, ProductListQueryVariables, - ProductVariantListDocument, ProductVariantListQuery, ProductVariantListQueryVariables, RootCategoriesDocument, @@ -162,13 +158,6 @@ export const DocumentMap: Record = { displayedAttribute: "email", // TODO inverted name }, - - INVOICE: { - document: OrderListDocument, - variables: DefaultVariables, - collection: "orders", - displayedAttribute: "number", - }, MENU: { document: MenuListDocument, variables: DefaultVariables, @@ -189,6 +178,8 @@ export const DocumentMap: Record = { variables: { first: 100, hasChannel: true, + includeCategories: false, + includeCollections: false, }, displayedAttribute: "name", }, @@ -228,35 +219,29 @@ export const DocumentMap: Record = { // Documents which require parent object or can't be handled ATM // -export const ExcludedDocumentMap: Record = { - ADDRESS: { - document: CustomerAddressesDocument, - variables: { - // USER ID REQUIRED - first: 100, - }, - }, +export const ExcludedDocumentKeys = [ + // USER ID REQUIRED + "ADDRESS", // it's not a countable collection - CHANNEL: { - document: ChannelListDocument, - variables: {}, - }, - FULFILLMENT: { - document: OrderFulfillDataDocument, - variables: { - // ORDER ID REQUIRED - first: 100, - }, - }, - PRODUCT_VARIANT: { - document: ProductVariantListDocument, - variables: { - // PRODUCT ID REQUIRED - first: 100, - }, - }, - TRANSLATION: { - document: null, - variables: {}, - }, -}; + "CHANNEL", + // ORDER ID REQUIRED + "FULFILLMENT", + // PRODUCT ID REQUIRED + "PRODUCT_VARIANT", + "PRODUCT_EXPORT_COMPLETED", + "PRODUCT_MEDIA_CREATED", + "PRODUCT_MEDIA_DELETED", + "PRODUCT_MEDIA_UPDATED", + "PRODUCT_VARIANT_BACK_IN_STOCK", + "PRODUCT_VARIANT_CREATED", + "PRODUCT_VARIANT_DELETED", + "PRODUCT_VARIANT_METADATA_UPDATED", + "PRODUCT_VARIANT_OUT_OF_STOCK", + "PRODUCT_VARIANT_STOCK_UPDATED", + "PRODUCT_VARIANT_UPDATED", + "VOUCHER_CODES_CREATED", + "VOUCHER_CODES_DELETED", + "VOUCHER_CODE_EXPORT_COMPLETED", + "ORDER_BULK_CREATED", + "TRANSLATION", +];