From 6b668937459b24cfd6d0a59355fdbae423f17cf9 Mon Sep 17 00:00:00 2001 From: Krzysztof Bialoglowicz Date: Wed, 9 Oct 2019 09:31:00 +0200 Subject: [PATCH] Add webhooks section to configuration menu --- src/config.ts | 4 +++ src/configuration/index.tsx | 11 ++++++++ src/icons/Webhooks.tsx | 15 +++++++++++ src/index.tsx | 6 +++++ .../components/WebhookEvents/index.ts | 4 +-- src/webhooks/components/WebhookInfo/index.ts | 4 +-- .../components/WebhookStatus/index.ts | 4 +-- .../components/WebhooksList/WebhooksList.tsx | 27 +------------------ src/webhooks/index.tsx | 14 +++++----- src/webhooks/mutations.ts | 2 +- src/webhooks/urls.ts | 2 +- 11 files changed, 52 insertions(+), 41 deletions(-) create mode 100644 src/icons/Webhooks.tsx diff --git a/src/config.ts b/src/config.ts index 7737bfe0d..7bc422d3a 100644 --- a/src/config.ts +++ b/src/config.ts @@ -27,6 +27,7 @@ export interface AppListViewSettings { [ListViews.SHIPPING_METHODS_LIST]: ListSettings; [ListViews.STAFF_MEMBERS_LIST]: ListSettings; [ListViews.VOUCHER_LIST]: ListSettings; + [ListViews.WEBHOOK_LIST]: ListSettings; } export const defaultListSettings: AppListViewSettings = { [ListViews.CATEGORY_LIST]: { @@ -68,5 +69,8 @@ export const defaultListSettings: AppListViewSettings = { }, [ListViews.VOUCHER_LIST]: { rowNumber: PAGINATE_BY + }, + [ListViews.WEBHOOK_LIST]: { + rowNumber: PAGINATE_BY } }; diff --git a/src/configuration/index.tsx b/src/configuration/index.tsx index 8f70c5297..38af5d7d6 100644 --- a/src/configuration/index.tsx +++ b/src/configuration/index.tsx @@ -15,6 +15,7 @@ import ShippingMethods from "@saleor/icons/ShippingMethods"; import SiteSettings from "@saleor/icons/SiteSettings"; import StaffMembers from "@saleor/icons/StaffMembers"; import Taxes from "@saleor/icons/Taxes"; +import Webhooks from "@saleor/icons/Webhooks"; import { sectionNames } from "@saleor/intl"; import { maybe } from "@saleor/misc"; import { menuListUrl } from "@saleor/navigation/urls"; @@ -27,6 +28,7 @@ import { siteSettingsUrl } from "@saleor/siteSettings/urls"; import { staffListUrl } from "@saleor/staff/urls"; import { taxSection } from "@saleor/taxes/urls"; import { PermissionEnum } from "@saleor/types/globalTypes"; +import { webhooksListUrl } from "@saleor/webhooks/urls"; import ConfigurationPage, { MenuSection } from "./ConfigurationPage"; export function createConfigurationMenu(intl: IntlShape): MenuSection[] { @@ -161,6 +163,15 @@ export function createConfigurationMenu(intl: IntlShape): MenuSection[] { permission: PermissionEnum.MANAGE_SERVICE_ACCOUNTS, title: intl.formatMessage(sectionNames.serviceAccounts), url: serviceListUrl() + }, + { + description: intl.formatMessage({ + defaultMessage: "View and update your site settings" + }), + icon: , + permission: PermissionEnum.MANAGE_WEBHOOKS, + title: intl.formatMessage(sectionNames.webhooks), + url: webhooksListUrl() } ] } diff --git a/src/icons/Webhooks.tsx b/src/icons/Webhooks.tsx new file mode 100644 index 000000000..eaa17aae7 --- /dev/null +++ b/src/icons/Webhooks.tsx @@ -0,0 +1,15 @@ +import createSvgIcon from "@material-ui/icons/utils/createSvgIcon"; +import React from "react"; + +export const Webhooks = createSvgIcon( + <> + + +); +Webhooks.displayName = "Webhooks"; +export default Webhooks; diff --git a/src/index.tsx b/src/index.tsx index 1cf61065b..5ac47a9c0 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -48,6 +48,7 @@ import SiteSettingsSection from "./siteSettings"; import StaffSection from "./staff"; import TaxesSection from "./taxes"; import TranslationsSection from "./translations"; +import WebhooksSection from "./webhooks"; import { PermissionEnum } from "./types/globalTypes"; interface ResponseError extends ErrorResponse { @@ -219,6 +220,11 @@ const Routes: React.FC = () => { path="/translations" component={TranslationsSection} /> + { return ( - // - // - // {maybe(() => plugin.name, )} - // - // - // {maybe( - // () => ( - // - // ), - // - // )} - // - // - //
- // - //
- //
- //
+
); }, () => ( diff --git a/src/webhooks/index.tsx b/src/webhooks/index.tsx index e6fe869ed..2088ff140 100644 --- a/src/webhooks/index.tsx +++ b/src/webhooks/index.tsx @@ -10,15 +10,15 @@ import { WebhooksListUrlQueryParams, webhooksPath } from "./urls"; -import PluginsDetailsComponent from "./views/WebhooksDetails"; -import PluginsListComponent from "./views/WebhooksList"; +import WebhooksDetails from "./views/WebhooksDetails"; +import WebhooksList from "./views/WebhooksList"; -const PluginList: React.StatelessComponent> = ({ +const WebhookList: React.StatelessComponent> = ({ location }) => { const qs = parseQs(location.search.substr(1)); const params: WebhooksListUrlQueryParams = qs; - return ; + return ; }; const PageDetails: React.StatelessComponent> = ({ @@ -28,7 +28,7 @@ const PageDetails: React.StatelessComponent> = ({ const params: WebhooksListUrlQueryParams = qs; return ( - @@ -41,8 +41,8 @@ const Component = () => { <> - - + + ); diff --git a/src/webhooks/mutations.ts b/src/webhooks/mutations.ts index 2b3b899f0..864e482b0 100644 --- a/src/webhooks/mutations.ts +++ b/src/webhooks/mutations.ts @@ -44,7 +44,7 @@ export const TypedWebhookUpdate = TypedMutation< WebhookUpdateVariables >(webhookUpdate); -const WebhookDelete = gql` +const webhookDelete = gql` mutation WebhookDelete($id: ID!) { webhookDelete(id: $id) { errors { diff --git a/src/webhooks/urls.ts b/src/webhooks/urls.ts index f12eae33a..94d423ee3 100644 --- a/src/webhooks/urls.ts +++ b/src/webhooks/urls.ts @@ -8,7 +8,7 @@ export const webhooksSection = "/webhooks/"; export const webhooksListPath = webhooksSection; export type WebhooksListUrlQueryParams = Pagination & SingleAction; export const webhooksListUrl = (params?: WebhooksListUrlQueryParams) => - webhooksPath + "?" + stringifyQs(params); +webhooksListPath + "?" + stringifyQs(params); export const webhooksPath = (id: string) => urlJoin(webhooksSection, id); export type WebhooksUrlQueryParams = SingleAction;