Skip to content

Commit

Permalink
Fix fetch products data in webhook dry run and add warning (#5323)
Browse files Browse the repository at this point in the history
* Fix fetch products in dry run

* Add changeset

* Add items that do not work to excluded

* Update changeset
  • Loading branch information
poulch authored Jan 3, 2025
1 parent ab543c5 commit 6c723fe
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 44 deletions.
6 changes: 6 additions & 0 deletions .changeset/mean-chicken-turn.md
Original file line number Diff line number Diff line change
@@ -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.
4 changes: 2 additions & 2 deletions src/components/DryRun/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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),
);

Expand Down
69 changes: 27 additions & 42 deletions src/components/DryRunItemsList/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,12 @@ import {
AttributeListQueryVariables,
CategoryDetailsQuery,
CategoryDetailsQueryVariables,
ChannelListDocument,
CheckoutListDocument,
CheckoutListQuery,
CheckoutListQueryVariables,
CollectionListDocument,
CollectionListQuery,
CollectionListQueryVariables,
CustomerAddressesDocument,
CustomerAddressesQuery,
CustomerAddressesQueryVariables,
CustomerDetailsQuery,
Expand All @@ -29,7 +27,6 @@ import {
MenuListDocument,
MenuListQuery,
MenuListQueryVariables,
OrderFulfillDataDocument,
OrderFulfillDataQuery,
OrderFulfillDataQueryVariables,
OrderListDocument,
Expand All @@ -41,7 +38,6 @@ import {
ProductListDocument,
ProductListQuery,
ProductListQueryVariables,
ProductVariantListDocument,
ProductVariantListQuery,
ProductVariantListQueryVariables,
RootCategoriesDocument,
Expand Down Expand Up @@ -162,13 +158,6 @@ export const DocumentMap: Record<string, Document> = {
displayedAttribute: "email",
// TODO inverted name
},

INVOICE: {
document: OrderListDocument,
variables: DefaultVariables,
collection: "orders",
displayedAttribute: "number",
},
MENU: {
document: MenuListDocument,
variables: DefaultVariables,
Expand All @@ -189,6 +178,8 @@ export const DocumentMap: Record<string, Document> = {
variables: {
first: 100,
hasChannel: true,
includeCategories: false,
includeCollections: false,
},
displayedAttribute: "name",
},
Expand Down Expand Up @@ -228,35 +219,29 @@ export const DocumentMap: Record<string, Document> = {

// Documents which require parent object or can't be handled ATM
//
export const ExcludedDocumentMap: Record<string, Document> = {
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",
];

0 comments on commit 6c723fe

Please sign in to comment.