Add Webhooks list search and fix events any event
This commit is contained in:
parent
28bc919e47
commit
fd39ab1b85
19 changed files with 218 additions and 103 deletions
|
@ -3327,7 +3327,7 @@ type ProductVariantUpdatePrivateMeta {
|
||||||
|
|
||||||
type Query {
|
type Query {
|
||||||
webhook(id: ID!): Webhook
|
webhook(id: ID!): Webhook
|
||||||
webhooks(before: String, after: String, first: Int, last: Int): WebhookCountableConnection
|
webhooks(filter: WebhookFilterInput, before: String, after: String, first: Int, last: Int): WebhookCountableConnection
|
||||||
translations(kind: TranslatableKinds!, before: String, after: String, first: Int, last: Int): TranslatableItemConnection
|
translations(kind: TranslatableKinds!, before: String, after: String, first: Int, last: Int): TranslatableItemConnection
|
||||||
shop: Shop
|
shop: Shop
|
||||||
shippingZone(id: ID!): ShippingZone
|
shippingZone(id: ID!): ShippingZone
|
||||||
|
@ -4319,7 +4319,7 @@ type WebhookEvent {
|
||||||
}
|
}
|
||||||
|
|
||||||
enum WebhookEventTypeEnum {
|
enum WebhookEventTypeEnum {
|
||||||
ALL_EVENTS
|
ANY_EVENTS
|
||||||
ORDER_CREATED
|
ORDER_CREATED
|
||||||
ORDER_FULLY_PAID
|
ORDER_FULLY_PAID
|
||||||
ORDER_UPDATED
|
ORDER_UPDATED
|
||||||
|
@ -4328,6 +4328,11 @@ enum WebhookEventTypeEnum {
|
||||||
PRODUCT_CREATED
|
PRODUCT_CREATED
|
||||||
}
|
}
|
||||||
|
|
||||||
|
input WebhookFilterInput {
|
||||||
|
search: String
|
||||||
|
isActive: Boolean
|
||||||
|
}
|
||||||
|
|
||||||
type WebhookUpdate {
|
type WebhookUpdate {
|
||||||
errors: [Error!]
|
errors: [Error!]
|
||||||
webhook: Webhook
|
webhook: Webhook
|
||||||
|
|
|
@ -273,7 +273,7 @@ export enum VoucherTypeEnum {
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum WebhookEventTypeEnum {
|
export enum WebhookEventTypeEnum {
|
||||||
ALL_EVENTS = "ALL_EVENTS",
|
ANY_EVENTS = "ANY_EVENTS",
|
||||||
CUSTOMER_CREATED = "CUSTOMER_CREATED",
|
CUSTOMER_CREATED = "CUSTOMER_CREATED",
|
||||||
ORDER_CANCELLED = "ORDER_CANCELLED",
|
ORDER_CANCELLED = "ORDER_CANCELLED",
|
||||||
ORDER_CREATED = "ORDER_CREATED",
|
ORDER_CREATED = "ORDER_CREATED",
|
||||||
|
@ -794,6 +794,11 @@ export interface WebhookCreateInput {
|
||||||
secretKey?: string | null;
|
secretKey?: string | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface WebhookFilterInput {
|
||||||
|
search?: string | null;
|
||||||
|
isActive?: boolean | null;
|
||||||
|
}
|
||||||
|
|
||||||
export interface WebhookUpdateInput {
|
export interface WebhookUpdateInput {
|
||||||
name?: string | null;
|
name?: string | null;
|
||||||
targetUrl?: string | null;
|
targetUrl?: string | null;
|
||||||
|
|
|
@ -32,7 +32,7 @@ const WebhookEvents: React.StatelessComponent<WebhookEventsProps> = ({
|
||||||
target: {
|
target: {
|
||||||
name: "events",
|
name: "events",
|
||||||
value: event.target.value
|
value: event.target.value
|
||||||
? WebhookEventTypeEnum.ALL_EVENTS
|
? WebhookEventTypeEnum.ANY_EVENTS
|
||||||
: data.events
|
: data.events
|
||||||
}
|
}
|
||||||
} as any)
|
} as any)
|
||||||
|
|
|
@ -62,7 +62,7 @@ const WebhooksDetailsPage: React.StatelessComponent<
|
||||||
const intl = useIntl();
|
const intl = useIntl();
|
||||||
const initialForm: FormData = {
|
const initialForm: FormData = {
|
||||||
allEvents: !!maybe(() => webhook.events, []).find(
|
allEvents: !!maybe(() => webhook.events, []).find(
|
||||||
event => event.eventType === WebhookEventTypeEnum.ALL_EVENTS
|
event => event.eventType === WebhookEventTypeEnum.ANY_EVENTS
|
||||||
),
|
),
|
||||||
events: maybe(() => webhook.events, []).map(event => event.eventType),
|
events: maybe(() => webhook.events, []).map(event => event.eventType),
|
||||||
id: maybe(() => webhook.id, null),
|
id: maybe(() => webhook.id, null),
|
||||||
|
|
|
@ -1,33 +1,39 @@
|
||||||
import Button from "@material-ui/core/Button";
|
import Button from "@material-ui/core/Button";
|
||||||
|
import Card from "@material-ui/core/Card";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { FormattedMessage, useIntl } from "react-intl";
|
import { FormattedMessage, useIntl } from "react-intl";
|
||||||
|
|
||||||
import AppHeader from "@saleor/components/AppHeader";
|
import AppHeader from "@saleor/components/AppHeader";
|
||||||
import Container from "@saleor/components/Container";
|
import Container from "@saleor/components/Container";
|
||||||
import PageHeader from "@saleor/components/PageHeader";
|
import PageHeader from "@saleor/components/PageHeader";
|
||||||
|
import SearchBar from "@saleor/components/SearchBar";
|
||||||
import { sectionNames } from "@saleor/intl";
|
import { sectionNames } from "@saleor/intl";
|
||||||
import { PageListProps } from "@saleor/types";
|
import { PageListProps, SearchPageProps, TabPageProps } from "@saleor/types";
|
||||||
import { Webhooks_webhooks_edges_node } from "../../types/Webhooks";
|
import { Webhooks_webhooks_edges_node } from "../../types/Webhooks";
|
||||||
import WebhooksList from "../WebhooksList/WebhooksList";
|
import WebhooksList from "../WebhooksList/WebhooksList";
|
||||||
|
|
||||||
export interface WebhooksListPageProps extends PageListProps {
|
export interface WebhooksListPageProps
|
||||||
|
extends PageListProps,
|
||||||
|
SearchPageProps,
|
||||||
|
TabPageProps {
|
||||||
webhooks: Webhooks_webhooks_edges_node[];
|
webhooks: Webhooks_webhooks_edges_node[];
|
||||||
onBack: () => void;
|
onBack: () => void;
|
||||||
onRemove: (id: string) => void;
|
onRemove: (id: string) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
const WebhooksListPage: React.StatelessComponent<WebhooksListPageProps> = ({
|
const WebhooksListPage: React.StatelessComponent<WebhooksListPageProps> = ({
|
||||||
disabled,
|
currentTab,
|
||||||
settings,
|
initialSearch,
|
||||||
onAdd,
|
onAdd,
|
||||||
|
onAll,
|
||||||
onBack,
|
onBack,
|
||||||
onNextPage,
|
onSearchChange,
|
||||||
onPreviousPage,
|
onTabChange,
|
||||||
onRowClick,
|
onTabDelete,
|
||||||
onRemove,
|
onTabSave,
|
||||||
onUpdateListSettings,
|
tabs,
|
||||||
pageInfo,
|
webhooks,
|
||||||
webhooks
|
...listProps
|
||||||
}) => {
|
}) => {
|
||||||
const intl = useIntl();
|
const intl = useIntl();
|
||||||
return (
|
return (
|
||||||
|
@ -43,17 +49,26 @@ const WebhooksListPage: React.StatelessComponent<WebhooksListPageProps> = ({
|
||||||
/>
|
/>
|
||||||
</Button>
|
</Button>
|
||||||
</PageHeader>
|
</PageHeader>
|
||||||
<WebhooksList
|
<Card>
|
||||||
disabled={disabled}
|
<SearchBar
|
||||||
settings={settings}
|
allTabLabel={intl.formatMessage({
|
||||||
webhooks={webhooks}
|
defaultMessage: "All Webhooks",
|
||||||
onNextPage={onNextPage}
|
description: "tab name"
|
||||||
onPreviousPage={onPreviousPage}
|
})}
|
||||||
onRemove={onRemove}
|
currentTab={currentTab}
|
||||||
onUpdateListSettings={onUpdateListSettings}
|
initialSearch={initialSearch}
|
||||||
onRowClick={onRowClick}
|
searchPlaceholder={intl.formatMessage({
|
||||||
pageInfo={pageInfo}
|
defaultMessage: "Search Webhooks"
|
||||||
|
})}
|
||||||
|
tabs={tabs}
|
||||||
|
onAll={onAll}
|
||||||
|
onSearchChange={onSearchChange}
|
||||||
|
onTabChange={onTabChange}
|
||||||
|
onTabDelete={onTabDelete}
|
||||||
|
onTabSave={onTabSave}
|
||||||
/>
|
/>
|
||||||
|
<WebhooksList webhooks={webhooks} {...listProps} />
|
||||||
|
</Card>
|
||||||
</Container>
|
</Container>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
@ -19,31 +19,25 @@ export const services: ServiceList_serviceAccounts_edges_node[] = [
|
||||||
export const webhookList: Webhooks_webhooks_edges_node[] = [
|
export const webhookList: Webhooks_webhooks_edges_node[] = [
|
||||||
{
|
{
|
||||||
__typename: "Webhook",
|
__typename: "Webhook",
|
||||||
events: [],
|
|
||||||
id: "Jzx123sEt==",
|
id: "Jzx123sEt==",
|
||||||
isActive: true,
|
isActive: true,
|
||||||
name: "Webhook Test",
|
name: "Webhook Test",
|
||||||
secretKey: "dsdasdasd_asdas",
|
|
||||||
serviceAccount: {
|
serviceAccount: {
|
||||||
__typename: "ServiceAccount",
|
__typename: "ServiceAccount",
|
||||||
id: "Jzx123sEt==",
|
id: "Jzx123sEt==",
|
||||||
name: "Test Account"
|
name: "Test Account"
|
||||||
},
|
},
|
||||||
targetUrl: "http://www.getsaleor.com"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
__typename: "Webhook",
|
__typename: "Webhook",
|
||||||
events: [],
|
|
||||||
id: "Jzx123sEt==",
|
id: "Jzx123sEt==",
|
||||||
isActive: true,
|
isActive: true,
|
||||||
name: "Webhook Test 2",
|
name: "Webhook Test 2",
|
||||||
secretKey: "zxczx_asdas",
|
|
||||||
serviceAccount: {
|
serviceAccount: {
|
||||||
__typename: "ServiceAccount",
|
__typename: "ServiceAccount",
|
||||||
id: "Jzx1ss23sEt==",
|
id: "Jzx1ss23sEt==",
|
||||||
name: "Test Account 2"
|
name: "Test Account 2"
|
||||||
},
|
},
|
||||||
targetUrl: "http://www.getsaleor.com"
|
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
export const webhook: Webhook_webhook = {
|
export const webhook: Webhook_webhook = {
|
||||||
|
|
|
@ -38,7 +38,7 @@ const Component = () => {
|
||||||
const intl = useIntl();
|
const intl = useIntl();
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<WindowTitle title={intl.formatMessage(sectionNames.plugins)} />
|
<WindowTitle title={intl.formatMessage(sectionNames.webhooks)} />
|
||||||
<Switch>
|
<Switch>
|
||||||
<Route exact path={webhooksListPath} component={WebhookList} />
|
<Route exact path={webhooksListPath} component={WebhookList} />
|
||||||
<Route exact path={webhooksAddUrl} component={WebhookCreate} />
|
<Route exact path={webhooksAddUrl} component={WebhookCreate} />
|
||||||
|
|
|
@ -8,12 +8,7 @@ export const webhooksFragment = gql`
|
||||||
fragment WebhookFragment on Webhook {
|
fragment WebhookFragment on Webhook {
|
||||||
id
|
id
|
||||||
name
|
name
|
||||||
events {
|
|
||||||
eventType
|
|
||||||
}
|
|
||||||
isActive
|
isActive
|
||||||
secretKey
|
|
||||||
targetUrl
|
|
||||||
serviceAccount {
|
serviceAccount {
|
||||||
id
|
id
|
||||||
name
|
name
|
||||||
|
@ -30,8 +25,20 @@ export const webhooksDetailsFragment = gql`
|
||||||
|
|
||||||
const webhooksList = gql`
|
const webhooksList = gql`
|
||||||
${webhooksFragment}
|
${webhooksFragment}
|
||||||
query Webhooks($first: Int, $after: String, $last: Int, $before: String) {
|
query Webhooks(
|
||||||
webhooks(before: $before, after: $after, first: $first, last: $last) {
|
$first: Int
|
||||||
|
$after: String
|
||||||
|
$last: Int
|
||||||
|
$before: String
|
||||||
|
$filter: WebhookFilterInput
|
||||||
|
) {
|
||||||
|
webhooks(
|
||||||
|
first: $first
|
||||||
|
after: $after
|
||||||
|
before: $before
|
||||||
|
last: $last
|
||||||
|
filter: $filter
|
||||||
|
) {
|
||||||
edges {
|
edges {
|
||||||
node {
|
node {
|
||||||
...WebhookFragment
|
...WebhookFragment
|
||||||
|
@ -55,6 +62,11 @@ const webhooksDetails = gql`
|
||||||
query WebhookDetails($id: ID!) {
|
query WebhookDetails($id: ID!) {
|
||||||
webhook(id: $id) {
|
webhook(id: $id) {
|
||||||
...WebhookFragment
|
...WebhookFragment
|
||||||
|
events {
|
||||||
|
eventType
|
||||||
|
}
|
||||||
|
secretKey
|
||||||
|
targetUrl
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
// This file was automatically generated and should not be edited.
|
// This file was automatically generated and should not be edited.
|
||||||
|
|
||||||
import { WebhookCreateInput, WebhookEventTypeEnum } from "./../../types/globalTypes";
|
import { WebhookCreateInput } from "./../../types/globalTypes";
|
||||||
|
|
||||||
// ====================================================
|
// ====================================================
|
||||||
// GraphQL mutation operation: WebhookCreate
|
// GraphQL mutation operation: WebhookCreate
|
||||||
|
@ -14,11 +14,6 @@ export interface WebhookCreate_webhookCreate_errors {
|
||||||
message: string | null;
|
message: string | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface WebhookCreate_webhookCreate_webhook_events {
|
|
||||||
__typename: "WebhookEvent";
|
|
||||||
eventType: WebhookEventTypeEnum | null;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface WebhookCreate_webhookCreate_webhook_serviceAccount {
|
export interface WebhookCreate_webhookCreate_webhook_serviceAccount {
|
||||||
__typename: "ServiceAccount";
|
__typename: "ServiceAccount";
|
||||||
id: string;
|
id: string;
|
||||||
|
@ -29,10 +24,7 @@ export interface WebhookCreate_webhookCreate_webhook {
|
||||||
__typename: "Webhook";
|
__typename: "Webhook";
|
||||||
id: string;
|
id: string;
|
||||||
name: string | null;
|
name: string | null;
|
||||||
events: (WebhookCreate_webhookCreate_webhook_events | null)[] | null;
|
|
||||||
isActive: boolean;
|
isActive: boolean;
|
||||||
secretKey: string | null;
|
|
||||||
targetUrl: string;
|
|
||||||
serviceAccount: WebhookCreate_webhookCreate_webhook_serviceAccount;
|
serviceAccount: WebhookCreate_webhookCreate_webhook_serviceAccount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,26 +8,26 @@ import { WebhookEventTypeEnum } from "./../../types/globalTypes";
|
||||||
// GraphQL query operation: WebhookDetails
|
// GraphQL query operation: WebhookDetails
|
||||||
// ====================================================
|
// ====================================================
|
||||||
|
|
||||||
export interface WebhookDetails_webhook_events {
|
|
||||||
__typename: "WebhookEvent";
|
|
||||||
eventType: WebhookEventTypeEnum | null;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface WebhookDetails_webhook_serviceAccount {
|
export interface WebhookDetails_webhook_serviceAccount {
|
||||||
__typename: "ServiceAccount";
|
__typename: "ServiceAccount";
|
||||||
id: string;
|
id: string;
|
||||||
name: string | null;
|
name: string | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface WebhookDetails_webhook_events {
|
||||||
|
__typename: "WebhookEvent";
|
||||||
|
eventType: WebhookEventTypeEnum | null;
|
||||||
|
}
|
||||||
|
|
||||||
export interface WebhookDetails_webhook {
|
export interface WebhookDetails_webhook {
|
||||||
__typename: "Webhook";
|
__typename: "Webhook";
|
||||||
id: string;
|
id: string;
|
||||||
name: string | null;
|
name: string | null;
|
||||||
events: (WebhookDetails_webhook_events | null)[] | null;
|
|
||||||
isActive: boolean;
|
isActive: boolean;
|
||||||
|
serviceAccount: WebhookDetails_webhook_serviceAccount;
|
||||||
|
events: (WebhookDetails_webhook_events | null)[] | null;
|
||||||
secretKey: string | null;
|
secretKey: string | null;
|
||||||
targetUrl: string;
|
targetUrl: string;
|
||||||
serviceAccount: WebhookDetails_webhook_serviceAccount;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface WebhookDetails {
|
export interface WebhookDetails {
|
||||||
|
|
|
@ -2,17 +2,10 @@
|
||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
// This file was automatically generated and should not be edited.
|
// This file was automatically generated and should not be edited.
|
||||||
|
|
||||||
import { WebhookEventTypeEnum } from "./../../types/globalTypes";
|
|
||||||
|
|
||||||
// ====================================================
|
// ====================================================
|
||||||
// GraphQL fragment: WebhookFragment
|
// GraphQL fragment: WebhookFragment
|
||||||
// ====================================================
|
// ====================================================
|
||||||
|
|
||||||
export interface WebhookFragment_events {
|
|
||||||
__typename: "WebhookEvent";
|
|
||||||
eventType: WebhookEventTypeEnum | null;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface WebhookFragment_serviceAccount {
|
export interface WebhookFragment_serviceAccount {
|
||||||
__typename: "ServiceAccount";
|
__typename: "ServiceAccount";
|
||||||
id: string;
|
id: string;
|
||||||
|
@ -23,9 +16,6 @@ export interface WebhookFragment {
|
||||||
__typename: "Webhook";
|
__typename: "Webhook";
|
||||||
id: string;
|
id: string;
|
||||||
name: string | null;
|
name: string | null;
|
||||||
events: (WebhookFragment_events | null)[] | null;
|
|
||||||
isActive: boolean;
|
isActive: boolean;
|
||||||
secretKey: string | null;
|
|
||||||
targetUrl: string;
|
|
||||||
serviceAccount: WebhookFragment_serviceAccount;
|
serviceAccount: WebhookFragment_serviceAccount;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
// This file was automatically generated and should not be edited.
|
// This file was automatically generated and should not be edited.
|
||||||
|
|
||||||
import { WebhookUpdateInput, WebhookEventTypeEnum } from "./../../types/globalTypes";
|
import { WebhookUpdateInput } from "./../../types/globalTypes";
|
||||||
|
|
||||||
// ====================================================
|
// ====================================================
|
||||||
// GraphQL mutation operation: WebhookUpdate
|
// GraphQL mutation operation: WebhookUpdate
|
||||||
|
@ -14,11 +14,6 @@ export interface WebhookUpdate_webhookUpdate_errors {
|
||||||
message: string | null;
|
message: string | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface WebhookUpdate_webhookUpdate_webhook_events {
|
|
||||||
__typename: "WebhookEvent";
|
|
||||||
eventType: WebhookEventTypeEnum | null;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface WebhookUpdate_webhookUpdate_webhook_serviceAccount {
|
export interface WebhookUpdate_webhookUpdate_webhook_serviceAccount {
|
||||||
__typename: "ServiceAccount";
|
__typename: "ServiceAccount";
|
||||||
id: string;
|
id: string;
|
||||||
|
@ -29,10 +24,7 @@ export interface WebhookUpdate_webhookUpdate_webhook {
|
||||||
__typename: "Webhook";
|
__typename: "Webhook";
|
||||||
id: string;
|
id: string;
|
||||||
name: string | null;
|
name: string | null;
|
||||||
events: (WebhookUpdate_webhookUpdate_webhook_events | null)[] | null;
|
|
||||||
isActive: boolean;
|
isActive: boolean;
|
||||||
secretKey: string | null;
|
|
||||||
targetUrl: string;
|
|
||||||
serviceAccount: WebhookUpdate_webhookUpdate_webhook_serviceAccount;
|
serviceAccount: WebhookUpdate_webhookUpdate_webhook_serviceAccount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,17 +2,12 @@
|
||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
// This file was automatically generated and should not be edited.
|
// This file was automatically generated and should not be edited.
|
||||||
|
|
||||||
import { WebhookEventTypeEnum } from "./../../types/globalTypes";
|
import { WebhookFilterInput } from "./../../types/globalTypes";
|
||||||
|
|
||||||
// ====================================================
|
// ====================================================
|
||||||
// GraphQL query operation: Webhooks
|
// GraphQL query operation: Webhooks
|
||||||
// ====================================================
|
// ====================================================
|
||||||
|
|
||||||
export interface Webhooks_webhooks_edges_node_events {
|
|
||||||
__typename: "WebhookEvent";
|
|
||||||
eventType: WebhookEventTypeEnum | null;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface Webhooks_webhooks_edges_node_serviceAccount {
|
export interface Webhooks_webhooks_edges_node_serviceAccount {
|
||||||
__typename: "ServiceAccount";
|
__typename: "ServiceAccount";
|
||||||
id: string;
|
id: string;
|
||||||
|
@ -23,10 +18,7 @@ export interface Webhooks_webhooks_edges_node {
|
||||||
__typename: "Webhook";
|
__typename: "Webhook";
|
||||||
id: string;
|
id: string;
|
||||||
name: string | null;
|
name: string | null;
|
||||||
events: (Webhooks_webhooks_edges_node_events | null)[] | null;
|
|
||||||
isActive: boolean;
|
isActive: boolean;
|
||||||
secretKey: string | null;
|
|
||||||
targetUrl: string;
|
|
||||||
serviceAccount: Webhooks_webhooks_edges_node_serviceAccount;
|
serviceAccount: Webhooks_webhooks_edges_node_serviceAccount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,4 +50,5 @@ export interface WebhooksVariables {
|
||||||
after?: string | null;
|
after?: string | null;
|
||||||
last?: number | null;
|
last?: number | null;
|
||||||
before?: string | null;
|
before?: string | null;
|
||||||
|
filter?: WebhookFilterInput | null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,17 +2,10 @@
|
||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
// This file was automatically generated and should not be edited.
|
// This file was automatically generated and should not be edited.
|
||||||
|
|
||||||
import { WebhookEventTypeEnum } from "./../../types/globalTypes";
|
|
||||||
|
|
||||||
// ====================================================
|
// ====================================================
|
||||||
// GraphQL fragment: WebhooksDetailsFragment
|
// GraphQL fragment: WebhooksDetailsFragment
|
||||||
// ====================================================
|
// ====================================================
|
||||||
|
|
||||||
export interface WebhooksDetailsFragment_events {
|
|
||||||
__typename: "WebhookEvent";
|
|
||||||
eventType: WebhookEventTypeEnum | null;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface WebhooksDetailsFragment_serviceAccount {
|
export interface WebhooksDetailsFragment_serviceAccount {
|
||||||
__typename: "ServiceAccount";
|
__typename: "ServiceAccount";
|
||||||
id: string;
|
id: string;
|
||||||
|
@ -23,9 +16,6 @@ export interface WebhooksDetailsFragment {
|
||||||
__typename: "Webhook";
|
__typename: "Webhook";
|
||||||
id: string;
|
id: string;
|
||||||
name: string | null;
|
name: string | null;
|
||||||
events: (WebhooksDetailsFragment_events | null)[] | null;
|
|
||||||
isActive: boolean;
|
isActive: boolean;
|
||||||
secretKey: string | null;
|
|
||||||
targetUrl: string;
|
|
||||||
serviceAccount: WebhooksDetailsFragment_serviceAccount;
|
serviceAccount: WebhooksDetailsFragment_serviceAccount;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +1,26 @@
|
||||||
import { stringify as stringifyQs } from "qs";
|
import { stringify as stringifyQs } from "qs";
|
||||||
import urlJoin from "url-join";
|
import urlJoin from "url-join";
|
||||||
|
|
||||||
import { Dialog, Pagination, SingleAction } from "../types";
|
import {
|
||||||
|
ActiveTab,
|
||||||
|
Dialog,
|
||||||
|
Filters,
|
||||||
|
Pagination,
|
||||||
|
SingleAction,
|
||||||
|
TabActionDialog
|
||||||
|
} from "../types";
|
||||||
|
|
||||||
export const webhooksSection = "/webhooks/";
|
export const webhooksSection = "/webhooks/";
|
||||||
|
|
||||||
export const webhooksListPath = webhooksSection;
|
export const webhooksListPath = webhooksSection;
|
||||||
export type WebhookListUrlDialog = "remove";
|
export enum WebhookListUrlFiltersEnum {
|
||||||
export type WebhooksListUrlQueryParams = Dialog<WebhookListUrlDialog> &
|
query = "query"
|
||||||
|
}
|
||||||
|
export type WebhookListUrlFilters = Filters<WebhookListUrlFiltersEnum>;
|
||||||
|
export type WebhookListUrlDialog = "remove" | TabActionDialog;
|
||||||
|
export type WebhooksListUrlQueryParams = ActiveTab &
|
||||||
|
WebhookListUrlFilters &
|
||||||
|
Dialog<WebhookListUrlDialog> &
|
||||||
Pagination &
|
Pagination &
|
||||||
SingleAction;
|
SingleAction;
|
||||||
export const webhooksListUrl = (params?: WebhooksListUrlQueryParams) =>
|
export const webhooksListUrl = (params?: WebhooksListUrlQueryParams) =>
|
||||||
|
|
|
@ -50,7 +50,7 @@ export const WebhooksCreate: React.StatelessComponent<
|
||||||
variables: {
|
variables: {
|
||||||
input: {
|
input: {
|
||||||
events: data.allEvents
|
events: data.allEvents
|
||||||
? [WebhookEventTypeEnum.ALL_EVENTS]
|
? [WebhookEventTypeEnum.ANY_EVENTS]
|
||||||
: data.events,
|
: data.events,
|
||||||
isActive: data.isActive,
|
isActive: data.isActive,
|
||||||
name: data.name,
|
name: data.name,
|
||||||
|
|
|
@ -127,7 +127,7 @@ export const WebhooksDetails: React.StatelessComponent<
|
||||||
id,
|
id,
|
||||||
input: {
|
input: {
|
||||||
events: data.allEvents
|
events: data.allEvents
|
||||||
? [WebhookEventTypeEnum.ALL_EVENTS]
|
? [WebhookEventTypeEnum.ANY_EVENTS]
|
||||||
: data.events,
|
: data.events,
|
||||||
isActive: data.isActive,
|
isActive: data.isActive,
|
||||||
name: data.name,
|
name: data.name,
|
||||||
|
|
|
@ -1,3 +1,7 @@
|
||||||
|
import DeleteFilterTabDialog from "@saleor/components/DeleteFilterTabDialog";
|
||||||
|
import SaveFilterTabDialog, {
|
||||||
|
SaveFilterTabDialogFormData
|
||||||
|
} from "@saleor/components/SaveFilterTabDialog";
|
||||||
import { configurationMenuUrl } from "@saleor/configuration";
|
import { configurationMenuUrl } from "@saleor/configuration";
|
||||||
import useListSettings from "@saleor/hooks/useListSettings";
|
import useListSettings from "@saleor/hooks/useListSettings";
|
||||||
import useNavigator from "@saleor/hooks/useNavigator";
|
import useNavigator from "@saleor/hooks/useNavigator";
|
||||||
|
@ -16,12 +20,21 @@ import { useIntl } from "react-intl";
|
||||||
import WebhooksListPage from "../components/WebhooksListPage/WebhooksListPage";
|
import WebhooksListPage from "../components/WebhooksListPage/WebhooksListPage";
|
||||||
import { TypedWebhookDelete } from "../mutations";
|
import { TypedWebhookDelete } from "../mutations";
|
||||||
import { TypedWebhooksListQuery } from "../queries";
|
import { TypedWebhooksListQuery } from "../queries";
|
||||||
import {
|
import { WebhookListUrlDialog,
|
||||||
|
WebhookListUrlFilters,
|
||||||
webhooksAddUrl,
|
webhooksAddUrl,
|
||||||
webhooksListUrl,
|
webhooksListUrl,
|
||||||
WebhooksListUrlQueryParams,
|
WebhooksListUrlQueryParams,
|
||||||
webhooksUrl
|
webhooksUrl
|
||||||
} from "../urls";
|
} from "../urls";
|
||||||
|
import {
|
||||||
|
areFiltersApplied,
|
||||||
|
deleteFilterTab,
|
||||||
|
getActiveFilters,
|
||||||
|
getFilterTabs,
|
||||||
|
getFilterVariables,
|
||||||
|
saveFilterTab
|
||||||
|
} from "./filter";
|
||||||
|
|
||||||
interface WebhooksListProps {
|
interface WebhooksListProps {
|
||||||
params: WebhooksListUrlQueryParams;
|
params: WebhooksListUrlQueryParams;
|
||||||
|
@ -37,8 +50,23 @@ export const WebhooksList: React.StatelessComponent<WebhooksListProps> = ({
|
||||||
const { updateListSettings, settings } = useListSettings(
|
const { updateListSettings, settings } = useListSettings(
|
||||||
ListViews.WEBHOOK_LIST
|
ListViews.WEBHOOK_LIST
|
||||||
);
|
);
|
||||||
const paginationState = createPaginationState(settings.rowNumber, params);
|
const tabs = getFilterTabs();
|
||||||
|
|
||||||
|
const currentTab =
|
||||||
|
params.activeTab === undefined
|
||||||
|
? areFiltersApplied(params)
|
||||||
|
? tabs.length + 1
|
||||||
|
: 0
|
||||||
|
: parseInt(params.activeTab, 0);
|
||||||
|
|
||||||
|
const changeFilterField = (filter: WebhookListUrlFilters) =>
|
||||||
|
navigate(
|
||||||
|
webhooksListUrl({
|
||||||
|
...getActiveFilters(params),
|
||||||
|
...filter,
|
||||||
|
activeTab: undefined
|
||||||
|
})
|
||||||
|
);
|
||||||
const closeModal = () =>
|
const closeModal = () =>
|
||||||
navigate(
|
navigate(
|
||||||
webhooksListUrl({
|
webhooksListUrl({
|
||||||
|
@ -49,8 +77,45 @@ export const WebhooksList: React.StatelessComponent<WebhooksListProps> = ({
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const openModal = (action: WebhookListUrlDialog, id?: string) =>
|
||||||
|
navigate(
|
||||||
|
webhooksListUrl({
|
||||||
|
...params,
|
||||||
|
action,
|
||||||
|
id
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
const handleTabChange = (tab: number) => {
|
||||||
|
navigate(
|
||||||
|
webhooksListUrl({
|
||||||
|
activeTab: tab.toString(),
|
||||||
|
...getFilterTabs()[tab - 1].data
|
||||||
|
})
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleTabDelete = () => {
|
||||||
|
deleteFilterTab(currentTab);
|
||||||
|
navigate(webhooksListUrl());
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleTabSave = (data: SaveFilterTabDialogFormData) => {
|
||||||
|
saveFilterTab(data.name, getActiveFilters(params));
|
||||||
|
handleTabChange(tabs.length + 1);
|
||||||
|
};
|
||||||
|
|
||||||
|
const paginationState = createPaginationState(settings.rowNumber, params);
|
||||||
|
const queryVariables = React.useMemo(
|
||||||
|
() => ({
|
||||||
|
...paginationState,
|
||||||
|
filter: getFilterVariables(params)
|
||||||
|
}),
|
||||||
|
[params]
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<TypedWebhooksListQuery displayLoader variables={paginationState}>
|
<TypedWebhooksListQuery displayLoader variables={queryVariables}>
|
||||||
{({ data, loading, refetch }) => {
|
{({ data, loading, refetch }) => {
|
||||||
const onWebhookDelete = (data: WebhookDelete) => {
|
const onWebhookDelete = (data: WebhookDelete) => {
|
||||||
if (data.webhookDelete.errors.length === 0) {
|
if (data.webhookDelete.errors.length === 0) {
|
||||||
|
@ -95,6 +160,14 @@ export const WebhooksList: React.StatelessComponent<WebhooksListProps> = ({
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<WebhooksListPage
|
<WebhooksListPage
|
||||||
|
currentTab={currentTab}
|
||||||
|
initialSearch={params.query || ""}
|
||||||
|
onSearchChange={query => changeFilterField({ query })}
|
||||||
|
onAll={() => navigate(webhooksListUrl())}
|
||||||
|
onTabChange={handleTabChange}
|
||||||
|
onTabDelete={() => openModal("delete-search")}
|
||||||
|
onTabSave={() => openModal("save-search")}
|
||||||
|
tabs={tabs.map(tab => tab.name)}
|
||||||
disabled={loading}
|
disabled={loading}
|
||||||
settings={settings}
|
settings={settings}
|
||||||
webhooks={maybe(() =>
|
webhooks={maybe(() =>
|
||||||
|
@ -122,6 +195,19 @@ export const WebhooksList: React.StatelessComponent<WebhooksListProps> = ({
|
||||||
onConfirm={handleRemoveConfirm}
|
onConfirm={handleRemoveConfirm}
|
||||||
open={params.action === "remove"}
|
open={params.action === "remove"}
|
||||||
/>
|
/>
|
||||||
|
<SaveFilterTabDialog
|
||||||
|
open={params.action === "save-search"}
|
||||||
|
confirmButtonState="default"
|
||||||
|
onClose={closeModal}
|
||||||
|
onSubmit={handleTabSave}
|
||||||
|
/>
|
||||||
|
<DeleteFilterTabDialog
|
||||||
|
open={params.action === "delete-search"}
|
||||||
|
confirmButtonState="default"
|
||||||
|
onClose={closeModal}
|
||||||
|
onSubmit={handleTabDelete}
|
||||||
|
tabName={maybe(() => tabs[currentTab - 1].name, "...")}
|
||||||
|
/>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}}
|
}}
|
||||||
|
|
28
src/webhooks/views/filter.ts
Normal file
28
src/webhooks/views/filter.ts
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
import { WebhookFilterInput } from "@saleor/types/globalTypes";
|
||||||
|
import { createFilterTabUtils, createFilterUtils } from "../../utils/filters";
|
||||||
|
import {
|
||||||
|
WebhookListUrlFilters,
|
||||||
|
WebhookListUrlFiltersEnum,
|
||||||
|
WebhooksListUrlQueryParams
|
||||||
|
} from "../urls";
|
||||||
|
|
||||||
|
export const WEBHOOK_FILTERS_KEY = "webhookFilters";
|
||||||
|
|
||||||
|
export function getFilterVariables(
|
||||||
|
params: WebhookListUrlFilters
|
||||||
|
): WebhookFilterInput {
|
||||||
|
return {
|
||||||
|
search: params.query
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export const {
|
||||||
|
deleteFilterTab,
|
||||||
|
getFilterTabs,
|
||||||
|
saveFilterTab
|
||||||
|
} = createFilterTabUtils<WebhookListUrlFilters>(WEBHOOK_FILTERS_KEY);
|
||||||
|
|
||||||
|
export const { areFiltersApplied, getActiveFilters } = createFilterUtils<
|
||||||
|
WebhooksListUrlQueryParams,
|
||||||
|
WebhookListUrlFilters
|
||||||
|
>(WebhookListUrlFiltersEnum);
|
Loading…
Reference in a new issue