From be8095b22fa5497b9244803a1e0b6483b8730ecc Mon Sep 17 00:00:00 2001 From: Krzysztof Bialoglowicz Date: Wed, 9 Oct 2019 08:56:46 +0200 Subject: [PATCH] Update types --- schema.graphql | 69 +++++++++++++++---- src/types.ts | 3 +- src/types/globalTypes.ts | 28 ++++++++ .../WebhooksDetailsPage.tsx | 54 ++++++++++++--- .../components/WebhooksList/WebhooksList.tsx | 4 +- src/webhooks/components/WebhooksList/index.ts | 4 +- .../WebhooksListPage/WebhooksListPage.tsx | 4 +- src/webhooks/mutations.ts | 6 +- src/webhooks/queries.ts | 7 +- src/webhooks/types/Webhook.ts | 37 ++++++++++ src/webhooks/types/WebhookCreate.ts | 51 ++++++++++++++ src/webhooks/types/WebhookDelete.ts | 26 +++++++ src/webhooks/types/WebhookFragment.ts | 29 ++++++++ src/webhooks/types/WebhookUpdate.ts | 52 ++++++++++++++ src/webhooks/types/Webhooks.ts | 59 ++++++++++++++++ src/webhooks/types/WebhooksDetailsFragment.ts | 29 ++++++++ src/webhooks/views/WebhooksDetails.tsx | 52 +++++++------- src/webhooks/views/WebhooksList.tsx | 14 ++-- 18 files changed, 457 insertions(+), 71 deletions(-) create mode 100644 src/webhooks/types/Webhook.ts create mode 100644 src/webhooks/types/WebhookCreate.ts create mode 100644 src/webhooks/types/WebhookDelete.ts create mode 100644 src/webhooks/types/WebhookFragment.ts create mode 100644 src/webhooks/types/WebhookUpdate.ts create mode 100644 src/webhooks/types/Webhooks.ts create mode 100644 src/webhooks/types/WebhooksDetailsFragment.ts diff --git a/schema.graphql b/schema.graphql index 2cac71003..eaa7a9b2a 100644 --- a/schema.graphql +++ b/schema.graphql @@ -604,7 +604,7 @@ type Checkout implements Node { privateMeta: [MetaStore]! meta: [MetaStore]! availableShippingMethods: [ShippingMethod]! - availablePaymentGateways: [String]! + availablePaymentGateways: [PaymentGateway]! email: String! isShippingRequired: Boolean! lines: [CheckoutLine] @@ -625,13 +625,13 @@ type CheckoutBillingAddressUpdate { checkoutErrors: [CheckoutError!] } -type CheckoutClearStoredMeta { +type CheckoutClearMeta { errors: [Error!] checkoutErrors: [CheckoutError!] checkout: Checkout } -type CheckoutClearStoredPrivateMeta { +type CheckoutClearPrivateMeta { errors: [Error!] checkoutErrors: [CheckoutError!] checkout: Checkout @@ -1610,6 +1610,11 @@ input FulfillmentUpdateTrackingInput { notifyCustomer: Boolean } +type GatewayConfigLine { + field: String! + value: String +} + scalar GenericScalar type Geolocalization { @@ -2107,12 +2112,16 @@ type Mutations { orderAddNote(order: ID!, input: OrderAddNoteInput!): OrderAddNote orderCancel(id: ID!, restock: Boolean!): OrderCancel orderCapture(amount: Decimal!, id: ID!): OrderCapture + orderClearPrivateMeta(id: ID!, input: MetaPath!): OrderClearPrivateMeta + orderClearMeta(id: ID!, input: MetaPath!): OrderClearMeta orderFulfillmentCancel(id: ID!, input: FulfillmentCancelInput!): FulfillmentCancel orderFulfillmentCreate(input: FulfillmentCreateInput!, order: ID): FulfillmentCreate orderFulfillmentUpdateTracking(id: ID!, input: FulfillmentUpdateTrackingInput!): FulfillmentUpdateTracking orderMarkAsPaid(id: ID!): OrderMarkAsPaid orderRefund(amount: Decimal!, id: ID!): OrderRefund orderUpdate(id: ID!, input: OrderUpdateInput!): OrderUpdate + orderUpdateMeta(id: ID!, input: MetaInput!): OrderUpdateMeta + orderUpdatePrivateMeta(id: ID!, input: MetaInput!): OrderUpdatePrivateMeta orderUpdateShipping(order: ID!, input: OrderUpdateShippingInput): OrderUpdateShipping orderVoid(id: ID!): OrderVoid orderBulkCancel(ids: [ID]!, restock: Boolean!): OrderBulkCancel @@ -2165,14 +2174,14 @@ type Mutations { checkoutShippingMethodUpdate(checkoutId: ID, shippingMethodId: ID!): CheckoutShippingMethodUpdate checkoutUpdateVoucher(checkoutId: ID!, voucherCode: String): CheckoutUpdateVoucher checkoutUpdateMetadata(id: ID!, input: MetaInput!): CheckoutUpdateMeta - checkoutClearMetadata(id: ID!, input: MetaPath!): CheckoutClearStoredMeta + checkoutClearMetadata(id: ID!, input: MetaPath!): CheckoutClearMeta checkoutUpdatePrivateMetadata(id: ID!, input: MetaInput!): CheckoutUpdatePrivateMeta - checkoutClearPrivateMetadata(id: ID!, input: MetaPath!): CheckoutClearStoredPrivateMeta + checkoutClearPrivateMetadata(id: ID!, input: MetaPath!): CheckoutClearPrivateMeta requestPasswordReset(email: String!, redirectUrl: String!): RequestPasswordReset setPassword(token: String!, email: String!, password: String!): SetPassword passwordChange(newPassword: String!, oldPassword: String!): PasswordChange userUpdateMetadata(id: ID!, input: MetaInput!): UserUpdateMeta - userClearStoredMetadata(id: ID!, input: MetaPath!): UserClearStoredMeta + userClearMetadata(id: ID!, input: MetaPath!): UserClearMeta accountAddressCreate(input: AddressInput!, type: AddressTypeEnum): AccountAddressCreate accountAddressUpdate(id: ID!, input: AddressInput!): AccountAddressUpdate accountAddressDelete(id: ID!): AccountAddressDelete @@ -2202,12 +2211,12 @@ type Mutations { userAvatarDelete: UserAvatarDelete userBulkSetActive(ids: [ID]!, isActive: Boolean!): UserBulkSetActive userUpdatePrivateMetadata(id: ID!, input: MetaInput!): UserUpdatePrivateMeta - userClearStoredPrivateMetadata(id: ID!, input: MetaPath!): UserClearStoredPrivateMeta + userClearPrivateMetadata(id: ID!, input: MetaPath!): UserClearPrivateMeta serviceAccountCreate(input: ServiceAccountInput!): ServiceAccountCreate serviceAccountUpdate(id: ID!, input: ServiceAccountInput!): ServiceAccountUpdate serviceAccountDelete(id: ID!): ServiceAccountDelete serviceAccountUpdatePrivateMetadata(id: ID!, input: MetaInput!): ServiceAccountUpdatePrivateMeta - serviceAccountClearStoredPrivateMetadata(id: ID!, input: MetaPath!): ServiceAccountClearStoredPrivateMeta + serviceAccountClearPrivateMetadata(id: ID!, input: MetaPath!): ServiceAccountClearPrivateMeta serviceAccountTokenCreate(input: ServiceAccountTokenInput!): ServiceAccountTokenCreate serviceAccountTokenDelete(id: ID!): ServiceAccountTokenDelete passwordReset(email: String!): PasswordReset @@ -2252,6 +2261,8 @@ type Order implements Node { displayGrossPrices: Boolean! customerNote: String! weight: Weight + privateMeta: [MetaStore]! + meta: [MetaStore]! fulfillments: [Fulfillment]! lines: [OrderLine]! actions: [OrderAction]! @@ -2310,6 +2321,16 @@ type OrderCapture { orderErrors: [OrderError!] } +type OrderClearMeta { + errors: [Error!] + order: Order +} + +type OrderClearPrivateMeta { + errors: [Error!] + order: Order +} + type OrderCountableConnection { pageInfo: PageInfo! edges: [OrderCountableEdge!]! @@ -2504,6 +2525,16 @@ input OrderUpdateInput { shippingAddress: AddressInput } +type OrderUpdateMeta { + errors: [Error!] + order: Order +} + +type OrderUpdatePrivateMeta { + errors: [Error!] + order: Order +} + type OrderUpdateShipping { errors: [Error!] order: Order @@ -2689,6 +2720,11 @@ enum PaymentErrorCode { UNIQUE } +type PaymentGateway { + name: String! + config: [GatewayConfigLine!]! +} + input PaymentInput { gateway: String! token: String! @@ -2800,11 +2836,11 @@ type Product implements Node { meta: [MetaStore]! url: String! thumbnail(size: Int): Image - availability: ProductPricingInfo @deprecated(reason: "DEPRECATED: Will be removed in Saleor 2.10, Has been renamed to 'pricing'.") + availability: ProductPricingInfo @deprecated(reason: "DEPRECATED: Will be removed in Saleor 2.10, Has been renamed to `pricing`.") pricing: ProductPricingInfo isAvailable: Boolean basePrice: Money - price: Money @deprecated(reason: "DEPRECATED: Will be removed in Saleor 2.10, has been replaced by 'basePrice'") + price: Money @deprecated(reason: "DEPRECATED: Will be removed in Saleor 2.10, has been replaced by `basePrice`") minimalVariantPrice: Money taxType: TaxType attributes: [SelectedAttribute!]! @@ -3168,7 +3204,7 @@ type ProductVariant implements Node { stockQuantity: Int! priceOverride: Money price: Money @deprecated(reason: "DEPRECATED: Will be removed in Saleor 2.10, has been replaced by 'pricing.priceUndiscounted'") - availability: VariantPricingInfo @deprecated(reason: "DEPRECATED: Will be removed in Saleor 2.10, has been renamed to 'pricing'.") + availability: VariantPricingInfo @deprecated(reason: "DEPRECATED: Will be removed in Saleor 2.10, has been renamed to `pricing`.") pricing: VariantPricingInfo isAvailable: Boolean attributes: [SelectedAttribute!]! @@ -3313,7 +3349,7 @@ type Query { reportProductSales(period: ReportingPeriod!, before: String, after: String, first: Int, last: Int): ProductVariantCountableConnection payment(id: ID!): Payment payments(before: String, after: String, first: Int, last: Int): PaymentCountableConnection - paymentClientToken(gateway: String!): String + paymentClientToken(gateway: String!): String @deprecated(reason: "DEPRECATED: Will be removed in Saleor 2.10, use payment gateway config instead in availablePaymentGateways.") page(id: ID, slug: String): Page pages(query: String, filter: PageFilterInput, before: String, after: String, first: Int, last: Int): PageCountableConnection homepageEvents(before: String, after: String, first: Int, last: Int): OrderEventCountableConnection @@ -3484,7 +3520,7 @@ type ServiceAccount implements Node { name: String } -type ServiceAccountClearStoredPrivateMeta { +type ServiceAccountClearPrivateMeta { errors: [Error!] accountErrors: [AccountError!] serviceAccount: ServiceAccount @@ -4026,13 +4062,13 @@ type UserBulkSetActive { accountErrors: [AccountError!] } -type UserClearStoredMeta { +type UserClearMeta { errors: [Error!] accountErrors: [AccountError!] user: User } -type UserClearStoredPrivateMeta { +type UserClearPrivateMeta { errors: [Error!] accountErrors: [AccountError!] user: User @@ -4223,6 +4259,7 @@ type VoucherUpdate { } type Webhook implements Node { + name: String serviceAccount: ServiceAccount! targetUrl: String! isActive: Boolean! @@ -4249,6 +4286,7 @@ type WebhookCreate { } input WebhookCreateInput { + name: String targetUrl: String events: [WebhookEventTypeEnum] serviceAccount: ID @@ -4297,6 +4335,7 @@ type WebhookUpdate { } input WebhookUpdateInput { + name: String targetUrl: String events: [WebhookEventTypeEnum] serviceAccount: ID diff --git a/src/types.ts b/src/types.ts index 77ffb5cbd..c466b2fe2 100644 --- a/src/types.ts +++ b/src/types.ts @@ -28,7 +28,8 @@ export enum ListViews { SALES_LIST = "SALES_LIST", SHIPPING_METHODS_LIST = "SHIPPING_METHODS_LIST", STAFF_MEMBERS_LIST = "STAFF_MEMBERS_LIST", - VOUCHER_LIST = "VOUCHER_LIST" + VOUCHER_LIST = "VOUCHER_LIST", + WEBHOOK_LIST = "WEBHOOK_LIST" } export interface ListProps { diff --git a/src/types/globalTypes.ts b/src/types/globalTypes.ts index 1e8cfaf3a..d3754b168 100644 --- a/src/types/globalTypes.ts +++ b/src/types/globalTypes.ts @@ -272,6 +272,16 @@ export enum VoucherTypeEnum { SPECIFIC_PRODUCT = "SPECIFIC_PRODUCT", } +export enum WebhookEventTypeEnum { + ALL_EVENTS = "ALL_EVENTS", + CUSTOMER_CREATED = "CUSTOMER_CREATED", + ORDER_CANCELLED = "ORDER_CANCELLED", + ORDER_CREATED = "ORDER_CREATED", + ORDER_FULLY_PAID = "ORDER_FULLY_PAID", + ORDER_UPDATED = "ORDER_UPDATED", + PRODUCT_CREATED = "PRODUCT_CREATED", +} + export enum WeightUnitsEnum { G = "G", KG = "KG", @@ -775,6 +785,24 @@ export interface VoucherInput { usageLimit?: number | null; } +export interface WebhookCreateInput { + name?: string | null; + targetUrl?: string | null; + events?: (WebhookEventTypeEnum | null)[] | null; + serviceAccount?: string | null; + isActive?: boolean | null; + secretKey?: string | null; +} + +export interface WebhookUpdateInput { + name?: string | null; + targetUrl?: string | null; + events?: (WebhookEventTypeEnum | null)[] | null; + serviceAccount?: string | null; + isActive?: boolean | null; + secretKey?: string | null; +} + //============================================================== // END Enums and Input Objects //============================================================== diff --git a/src/webhooks/components/WebhooksDetailsPage/WebhooksDetailsPage.tsx b/src/webhooks/components/WebhooksDetailsPage/WebhooksDetailsPage.tsx index 0a9f722d0..94318ebfa 100644 --- a/src/webhooks/components/WebhooksDetailsPage/WebhooksDetailsPage.tsx +++ b/src/webhooks/components/WebhooksDetailsPage/WebhooksDetailsPage.tsx @@ -13,19 +13,28 @@ import { ConfigurationItemInput } from "@saleor/types/globalTypes"; import React from "react"; import { useIntl } from "react-intl"; -import { Plugin_plugin } from "../../types/Plugin"; -import WebhookInfo from "../WebhookInfo"; +import { + Webhook_webhook, + Webhook_webhook_events, + Webhook_webhook_serviceAccount +} from "../../types/Webhook"; import WebhookEvents from "../WebhookEvents"; +import WebhookInfo from "../WebhookInfo"; +import WebhookStatus from "../WebhookStatus"; export interface FormData { - active: boolean; - configuration: ConfigurationItemInput[]; + id: string; + events: Webhook_webhook_events; + isActive: boolean; + secretKey: string | null; + targetUrl: string; + serviceAccount: Webhook_webhook_serviceAccount; } export interface WebhooksDetailsPageProps { disabled: boolean; errors: UserError[]; - plugin: Plugin_plugin; + webhook: Webhook_webhook; saveButtonBarState: ConfirmButtonTransitionState; onBack: () => void; onSubmit: (data: FormData) => void; @@ -33,16 +42,20 @@ export interface WebhooksDetailsPageProps { const WebhooksDetailsPage: React.StatelessComponent< WebhooksDetailsPageProps -> = ({ disabled, errors, plugin, saveButtonBarState, onBack, onSubmit }) => { +> = ({ disabled, errors, webhook, saveButtonBarState, onBack, onSubmit }) => { const intl = useIntl(); const initialForm: FormData = { - active: maybe(() => plugin.active, false), - configuration: maybe(() => plugin.configuration, []) + events: maybe(() => webhook.events, []), + id: maybe(() => webhook.id, null), + isActive: maybe(() => webhook.isActive, false), + secretKey: maybe(() => webhook.secretKey, ""), + serviceAccount: maybe(() => webhook.serviceAccount, []), + targetUrl: maybe(() => webhook.targetUrl, "") }; return (
- {({ data, errors, hasChanged, submit, set, triggerChange }) => { + {({ data, errors, hasChanged, submit, change }) => { return ( @@ -60,7 +73,28 @@ const WebhooksDetailsPage: React.StatelessComponent< )} /> -
+
+ plugin.description, "")} + errors={errors} + onChange={change} + /> +
+
+ plugin.name, "")} + onChange={change} + /> + plugin.name, "")} + onChange={change} + /> +
diff --git a/src/webhooks/components/WebhooksList/index.ts b/src/webhooks/components/WebhooksList/index.ts index b3d7c9391..a9be5a3b1 100644 --- a/src/webhooks/components/WebhooksList/index.ts +++ b/src/webhooks/components/WebhooksList/index.ts @@ -1,2 +1,2 @@ -export { default } from "./WebhooksListt"; -export * from "./WebhooksListt"; +export { default } from "./WebhooksList"; +export * from "./WebhooksList"; diff --git a/src/webhooks/components/WebhooksListPage/WebhooksListPage.tsx b/src/webhooks/components/WebhooksListPage/WebhooksListPage.tsx index 20ced1671..018577960 100644 --- a/src/webhooks/components/WebhooksListPage/WebhooksListPage.tsx +++ b/src/webhooks/components/WebhooksListPage/WebhooksListPage.tsx @@ -6,11 +6,11 @@ import Container from "@saleor/components/Container"; import PageHeader from "@saleor/components/PageHeader"; import { sectionNames } from "@saleor/intl"; import { PageListProps } from "@saleor/types"; -import { Plugins_plugins_edges_node } from "../../types/Plugins"; +import { Webhooks_webhooks_edges_node } from "../../types/Webhooks"; import WebhooksList from "../WebhooksList/WebhooksList"; export interface WebhooksListPageProps extends PageListProps { - plugins: Plugins_plugins_edges_node[]; + webhooks: Webhooks_webhooks_edges_node[]; onBack: () => void; } diff --git a/src/webhooks/mutations.ts b/src/webhooks/mutations.ts index e766cd8f4..2b3b899f0 100644 --- a/src/webhooks/mutations.ts +++ b/src/webhooks/mutations.ts @@ -9,7 +9,7 @@ import { WebhookUpdate, WebhookUpdateVariables } from "./types/WebhookUpdate"; const webhookCreate = gql` ${webhooksDetailsFragment} mutation WebhookCreate($input: WebhookCreateInput!) { - WebhookCreate(input: $input) { + webhookCreate(input: $input) { errors { field message @@ -28,7 +28,7 @@ export const TypedWebhookCreate = TypedMutation< const webhookUpdate = gql` ${webhooksDetailsFragment} mutation WebhookUpdate($id: ID!, $input: WebhookUpdateInput!) { - WebhookUpdate(id: $id, input: $input) { + webhookUpdate(id: $id, input: $input) { errors { field message @@ -46,7 +46,7 @@ export const TypedWebhookUpdate = TypedMutation< const WebhookDelete = gql` mutation WebhookDelete($id: ID!) { - WebhookDelete(id: $id) { + webhookDelete(id: $id) { errors { field message diff --git a/src/webhooks/queries.ts b/src/webhooks/queries.ts index f24e185ee..76c1799b0 100644 --- a/src/webhooks/queries.ts +++ b/src/webhooks/queries.ts @@ -7,6 +7,7 @@ import { Webhooks, WebhooksVariables } from "./types/Webhooks"; export const webhooksFragment = gql` fragment WebhookFragment on Webhook { id + name events { eventType } @@ -23,7 +24,7 @@ export const webhooksFragment = gql` export const webhooksDetailsFragment = gql` ${webhooksFragment} fragment WebhooksDetailsFragment on Webhook { - ...WebhooksFragment + ...WebhookFragment } `; @@ -33,7 +34,7 @@ const webhooksList = gql` webhooks(before: $before, after: $after, first: $first, last: $last) { edges { node { - ...WebhooksFragment + ...WebhookFragment } } pageInfo { @@ -53,7 +54,7 @@ const webhooksDetails = gql` ${webhooksFragment} query Webhook($id: ID!) { webhook(id: $id) { - ...WebhooksFragment + ...WebhookFragment } } `; diff --git a/src/webhooks/types/Webhook.ts b/src/webhooks/types/Webhook.ts new file mode 100644 index 000000000..8286a50f2 --- /dev/null +++ b/src/webhooks/types/Webhook.ts @@ -0,0 +1,37 @@ +/* tslint:disable */ +/* eslint-disable */ +// This file was automatically generated and should not be edited. + +// ==================================================== +// GraphQL query operation: Webhook +// ==================================================== + +export interface Webhook_webhook_events { + __typename: "WebhookEvent"; + eventType: string | null; +} + +export interface Webhook_webhook_serviceAccount { + __typename: "ServiceAccount"; + id: string; + name: string | null; +} + +export interface Webhook_webhook { + __typename: "Webhook"; + id: string; + name: string | null; + events: (Webhook_webhook_events | null)[] | null; + isActive: boolean; + secretKey: string | null; + targetUrl: string; + serviceAccount: Webhook_webhook_serviceAccount; +} + +export interface Webhook { + webhook: Webhook_webhook | null; +} + +export interface WebhookVariables { + id: string; +} diff --git a/src/webhooks/types/WebhookCreate.ts b/src/webhooks/types/WebhookCreate.ts new file mode 100644 index 000000000..1e5fcac94 --- /dev/null +++ b/src/webhooks/types/WebhookCreate.ts @@ -0,0 +1,51 @@ +/* tslint:disable */ +/* eslint-disable */ +// This file was automatically generated and should not be edited. + +import { WebhookCreateInput } from "./../../types/globalTypes"; + +// ==================================================== +// GraphQL mutation operation: WebhookCreate +// ==================================================== + +export interface WebhookCreate_webhookCreate_errors { + __typename: "Error"; + field: string | null; + message: string | null; +} + +export interface WebhookCreate_webhookCreate_webhook_events { + __typename: "WebhookEvent"; + eventType: string | null; +} + +export interface WebhookCreate_webhookCreate_webhook_serviceAccount { + __typename: "ServiceAccount"; + id: string; + name: string | null; +} + +export interface WebhookCreate_webhookCreate_webhook { + __typename: "Webhook"; + id: string; + name: string | null; + events: (WebhookCreate_webhookCreate_webhook_events | null)[] | null; + isActive: boolean; + secretKey: string | null; + targetUrl: string; + serviceAccount: WebhookCreate_webhookCreate_webhook_serviceAccount; +} + +export interface WebhookCreate_webhookCreate { + __typename: "WebhookCreate"; + errors: WebhookCreate_webhookCreate_errors[] | null; + webhook: WebhookCreate_webhookCreate_webhook | null; +} + +export interface WebhookCreate { + webhookCreate: WebhookCreate_webhookCreate | null; +} + +export interface WebhookCreateVariables { + input: WebhookCreateInput; +} diff --git a/src/webhooks/types/WebhookDelete.ts b/src/webhooks/types/WebhookDelete.ts new file mode 100644 index 000000000..7dcfe4301 --- /dev/null +++ b/src/webhooks/types/WebhookDelete.ts @@ -0,0 +1,26 @@ +/* tslint:disable */ +/* eslint-disable */ +// This file was automatically generated and should not be edited. + +// ==================================================== +// GraphQL mutation operation: WebhookDelete +// ==================================================== + +export interface WebhookDelete_webhookDelete_errors { + __typename: "Error"; + field: string | null; + message: string | null; +} + +export interface WebhookDelete_webhookDelete { + __typename: "WebhookDelete"; + errors: WebhookDelete_webhookDelete_errors[] | null; +} + +export interface WebhookDelete { + webhookDelete: WebhookDelete_webhookDelete | null; +} + +export interface WebhookDeleteVariables { + id: string; +} diff --git a/src/webhooks/types/WebhookFragment.ts b/src/webhooks/types/WebhookFragment.ts new file mode 100644 index 000000000..04132dc9f --- /dev/null +++ b/src/webhooks/types/WebhookFragment.ts @@ -0,0 +1,29 @@ +/* tslint:disable */ +/* eslint-disable */ +// This file was automatically generated and should not be edited. + +// ==================================================== +// GraphQL fragment: WebhookFragment +// ==================================================== + +export interface WebhookFragment_events { + __typename: "WebhookEvent"; + eventType: string | null; +} + +export interface WebhookFragment_serviceAccount { + __typename: "ServiceAccount"; + id: string; + name: string | null; +} + +export interface WebhookFragment { + __typename: "Webhook"; + id: string; + name: string | null; + events: (WebhookFragment_events | null)[] | null; + isActive: boolean; + secretKey: string | null; + targetUrl: string; + serviceAccount: WebhookFragment_serviceAccount; +} diff --git a/src/webhooks/types/WebhookUpdate.ts b/src/webhooks/types/WebhookUpdate.ts new file mode 100644 index 000000000..d58000b70 --- /dev/null +++ b/src/webhooks/types/WebhookUpdate.ts @@ -0,0 +1,52 @@ +/* tslint:disable */ +/* eslint-disable */ +// This file was automatically generated and should not be edited. + +import { WebhookUpdateInput } from "./../../types/globalTypes"; + +// ==================================================== +// GraphQL mutation operation: WebhookUpdate +// ==================================================== + +export interface WebhookUpdate_webhookUpdate_errors { + __typename: "Error"; + field: string | null; + message: string | null; +} + +export interface WebhookUpdate_webhookUpdate_webhook_events { + __typename: "WebhookEvent"; + eventType: string | null; +} + +export interface WebhookUpdate_webhookUpdate_webhook_serviceAccount { + __typename: "ServiceAccount"; + id: string; + name: string | null; +} + +export interface WebhookUpdate_webhookUpdate_webhook { + __typename: "Webhook"; + id: string; + name: string | null; + events: (WebhookUpdate_webhookUpdate_webhook_events | null)[] | null; + isActive: boolean; + secretKey: string | null; + targetUrl: string; + serviceAccount: WebhookUpdate_webhookUpdate_webhook_serviceAccount; +} + +export interface WebhookUpdate_webhookUpdate { + __typename: "WebhookUpdate"; + errors: WebhookUpdate_webhookUpdate_errors[] | null; + webhook: WebhookUpdate_webhookUpdate_webhook | null; +} + +export interface WebhookUpdate { + webhookUpdate: WebhookUpdate_webhookUpdate | null; +} + +export interface WebhookUpdateVariables { + id: string; + input: WebhookUpdateInput; +} diff --git a/src/webhooks/types/Webhooks.ts b/src/webhooks/types/Webhooks.ts new file mode 100644 index 000000000..6b0801cda --- /dev/null +++ b/src/webhooks/types/Webhooks.ts @@ -0,0 +1,59 @@ +/* tslint:disable */ +/* eslint-disable */ +// This file was automatically generated and should not be edited. + +// ==================================================== +// GraphQL query operation: Webhooks +// ==================================================== + +export interface Webhooks_webhooks_edges_node_events { + __typename: "WebhookEvent"; + eventType: string | null; +} + +export interface Webhooks_webhooks_edges_node_serviceAccount { + __typename: "ServiceAccount"; + id: string; + name: string | null; +} + +export interface Webhooks_webhooks_edges_node { + __typename: "Webhook"; + id: string; + name: string | null; + events: (Webhooks_webhooks_edges_node_events | null)[] | null; + isActive: boolean; + secretKey: string | null; + targetUrl: string; + serviceAccount: Webhooks_webhooks_edges_node_serviceAccount; +} + +export interface Webhooks_webhooks_edges { + __typename: "WebhookCountableEdge"; + node: Webhooks_webhooks_edges_node; +} + +export interface Webhooks_webhooks_pageInfo { + __typename: "PageInfo"; + hasPreviousPage: boolean; + hasNextPage: boolean; + startCursor: string | null; + endCursor: string | null; +} + +export interface Webhooks_webhooks { + __typename: "WebhookCountableConnection"; + edges: Webhooks_webhooks_edges[]; + pageInfo: Webhooks_webhooks_pageInfo; +} + +export interface Webhooks { + webhooks: Webhooks_webhooks | null; +} + +export interface WebhooksVariables { + first?: number | null; + after?: string | null; + last?: number | null; + before?: string | null; +} diff --git a/src/webhooks/types/WebhooksDetailsFragment.ts b/src/webhooks/types/WebhooksDetailsFragment.ts new file mode 100644 index 000000000..b54fc69c0 --- /dev/null +++ b/src/webhooks/types/WebhooksDetailsFragment.ts @@ -0,0 +1,29 @@ +/* tslint:disable */ +/* eslint-disable */ +// This file was automatically generated and should not be edited. + +// ==================================================== +// GraphQL fragment: WebhooksDetailsFragment +// ==================================================== + +export interface WebhooksDetailsFragment_events { + __typename: "WebhookEvent"; + eventType: string | null; +} + +export interface WebhooksDetailsFragment_serviceAccount { + __typename: "ServiceAccount"; + id: string; + name: string | null; +} + +export interface WebhooksDetailsFragment { + __typename: "Webhook"; + id: string; + name: string | null; + events: (WebhooksDetailsFragment_events | null)[] | null; + isActive: boolean; + secretKey: string | null; + targetUrl: string; + serviceAccount: WebhooksDetailsFragment_serviceAccount; +} diff --git a/src/webhooks/views/WebhooksDetails.tsx b/src/webhooks/views/WebhooksDetails.tsx index a6e8d6cd9..858050ad3 100644 --- a/src/webhooks/views/WebhooksDetails.tsx +++ b/src/webhooks/views/WebhooksDetails.tsx @@ -6,35 +6,35 @@ import { useIntl } from "react-intl"; import { getMutationState, maybe } from "../../misc"; import WebhooksDetailsPage from "../components/WebhooksDetailsPage"; -import { TypedPluginUpdate } from "../mutations"; -import { TypedPluginsDetailsQuery } from "../queries"; -import { pluginsListUrl, PluginsListUrlQueryParams } from "../urls"; +import { TypedWebhookUpdate } from "../mutations"; +import { TypedWebhooksDetailsQuery } from "../queries"; +import { webhooksListUrl, WebhooksListUrlQueryParams } from "../urls"; -export interface PluginsDetailsProps { +export interface WebhooksDetailsProps { id: string; - params: PluginsListUrlQueryParams; + params: WebhooksListUrlQueryParams; } -export const PluginsDetails: React.StatelessComponent = ({ - id -}) => { +export const WebhooksDetails: React.StatelessComponent< + WebhooksDetailsProps +> = ({ id }) => { const navigate = useNavigator(); const notify = useNotifier(); const intl = useIntl(); return ( - - {(pluginUpdate, pluginUpdateOpts) => ( - - {PluginDetails => { + + {(webhookUpdate, webhookUpdateOpts) => ( + + {WebhookDetails => { const formTransitionState = getMutationState( - pluginUpdateOpts.called, - pluginUpdateOpts.loading, - maybe(() => pluginUpdateOpts.data.pluginUpdate.errors) + webhookUpdateOpts.called, + webhookUpdateOpts.loading, + maybe(() => webhookUpdateOpts.data.webhookUpdate.errors) ); const formErrors = maybe( - () => pluginUpdateOpts.data.pluginUpdate.errors, + () => webhookUpdateOpts.data.webhookUpdate.errors, [] ); @@ -45,7 +45,7 @@ export const PluginsDetails: React.StatelessComponent = ({ }); }); } else { - if (pluginUpdateOpts.data) { + if (webhookUpdateOpts.data) { notify({ text: intl.formatMessage({ defaultMessage: "Succesfully updated plugin settings", @@ -58,14 +58,14 @@ export const PluginsDetails: React.StatelessComponent = ({ return ( <> PluginDetails.data.plugin.name)} + title={maybe(() => WebhookDetails.data.webhook.name)} /> PluginDetails.data.plugin)} - onBack={() => navigate(pluginsListUrl())} + webhook={maybe(() => WebhookDetails.data.webook)} + onBack={() => navigate(webhooksListUrl())} onSubmit={formData => { const configurationInput = formData.configuration && @@ -75,7 +75,7 @@ export const PluginsDetails: React.StatelessComponent = ({ value: item.value.toString() }; }); - pluginUpdate({ + webhookUpdate({ variables: { id, input: { @@ -91,10 +91,10 @@ export const PluginsDetails: React.StatelessComponent = ({ ); }} - + )} - + ); }; -PluginsDetails.displayName = "PluginsDetails"; -export default PluginsDetails; +WebhooksDetails.displayName = "WebhooksDetails"; +export default WebhooksDetails; diff --git a/src/webhooks/views/WebhooksList.tsx b/src/webhooks/views/WebhooksList.tsx index 67d7793d7..48ace5c7b 100644 --- a/src/webhooks/views/WebhooksList.tsx +++ b/src/webhooks/views/WebhooksList.tsx @@ -8,21 +8,21 @@ import { maybe } from "@saleor/misc"; import { ListViews } from "@saleor/types"; import React from "react"; -import WebhooksListPage from "../components/WebhooksListPage/PluginsListPage"; +import WebhooksListPage from "../components/WebhooksListPage/WebhooksListPage"; import { TypedWebhooksListQuery } from "../queries"; import { WebhooksListUrlQueryParams, webhooksUrl } from "../urls"; -interface PluginsListProps { +interface WebhooksListProps { params: WebhooksListUrlQueryParams; } -export const PluginsList: React.StatelessComponent = ({ +export const WebhooksList: React.StatelessComponent = ({ params }) => { const navigate = useNavigator(); const paginate = usePaginator(); const { updateListSettings, settings } = useListSettings( - ListViews.PLUGINS_LIST + ListViews.WEBHOOK_LIST ); const paginationState = createPaginationState(settings.rowNumber, params); @@ -30,7 +30,7 @@ export const PluginsList: React.StatelessComponent = ({ {({ data, loading }) => { const { loadNextPage, loadPreviousPage, pageInfo } = paginate( - maybe(() => data.plugins.pageInfo), + maybe(() => data.webhooks.pageInfo), paginationState, params ); @@ -39,7 +39,7 @@ export const PluginsList: React.StatelessComponent = ({ data.plugins.edges.map(edge => edge.node))} + webhooks={maybe(() => data.webhooks.edges.map(edge => edge.node))} pageInfo={pageInfo} onAdd={() => navigate(configurationMenuUrl)} onBack={() => navigate(configurationMenuUrl)} @@ -55,4 +55,4 @@ export const PluginsList: React.StatelessComponent = ({ ); }; -export default PluginsList; +export default WebhooksList;