From de81217662c98a576b6bd69ecdeda16a47e51ddc Mon Sep 17 00:00:00 2001 From: Sidney Alcantara Date: Mon, 29 Nov 2021 15:48:31 +1100 Subject: [PATCH] update webhooks copy --- .../TableHeader/Extensions/ExtensionModal.tsx | 2 +- .../TableHeader/Webhooks/Schemas/basic.tsx | 14 +++- .../TableHeader/Webhooks/Schemas/sendgrid.tsx | 30 ++++---- .../TableHeader/Webhooks/Schemas/typeform.tsx | 28 ++++---- .../TableHeader/Webhooks/Step1Auth.tsx | 43 ++++++------ .../TableHeader/Webhooks/Step3Parser.tsx | 4 +- .../TableHeader/Webhooks/WebhookModal.tsx | 70 +++++++++++-------- src/components/TableHeader/Webhooks/utils.tsx | 5 +- 8 files changed, 112 insertions(+), 84 deletions(-) diff --git a/src/components/TableHeader/Extensions/ExtensionModal.tsx b/src/components/TableHeader/Extensions/ExtensionModal.tsx index b112c339..d9bc2e18 100644 --- a/src/components/TableHeader/Extensions/ExtensionModal.tsx +++ b/src/components/TableHeader/Extensions/ExtensionModal.tsx @@ -162,7 +162,7 @@ export default function ExtensionModal({ onClick: () => { let warningMessage; if (!validation.condition && !validation.extensionBody) { - warningMessage = "Condition and extension body are not valid"; + warningMessage = "Condition and Extension body are not valid"; } else if (!validation.condition) { warningMessage = "Condition is not valid"; } else if (!validation.extensionBody) { diff --git a/src/components/TableHeader/Webhooks/Schemas/basic.tsx b/src/components/TableHeader/Webhooks/Schemas/basic.tsx index b59e9c71..105ed038 100644 --- a/src/components/TableHeader/Webhooks/Schemas/basic.tsx +++ b/src/components/TableHeader/Webhooks/Schemas/basic.tsx @@ -1,3 +1,6 @@ +import { Typography } from "@mui/material"; +import WarningIcon from "@mui/icons-material/WarningAmber"; + export const webhookTypes = [ "basic", "typeform", @@ -36,7 +39,7 @@ const additionalVariables = [ }, ]; -export default { +export const webhookBasic = { name: "Basic", parser: { additionalVariables, @@ -60,6 +63,13 @@ export default { }`, }, auth: (webhookObject, setWebhookObject) => { - return <>no auth option for basic atm; + return ( + + +   Verification is not currently available for basic webhooks + + ); }, }; + +export default webhookBasic; diff --git a/src/components/TableHeader/Webhooks/Schemas/sendgrid.tsx b/src/components/TableHeader/Webhooks/Schemas/sendgrid.tsx index 62a15e6f..e91e804c 100644 --- a/src/components/TableHeader/Webhooks/Schemas/sendgrid.tsx +++ b/src/components/TableHeader/Webhooks/Schemas/sendgrid.tsx @@ -1,7 +1,8 @@ import { Typography, Link, TextField } from "@mui/material"; +import InlineOpenInNewIcon from "@src/components/InlineOpenInNewIcon"; -export default { - name: "Sendgrid", +export const webhookSendgrid = { + name: "SendGrid", parser: { additionalVariables: null, extraLibs: null, @@ -32,24 +33,25 @@ export default { return ( <> - To verify the webhook call is sent from Sendgrid, You can enable - signed event webhooks + Enable Signed Event Webhooks on SendGrid by following{" "} - here - {" "} - to set the secret, then add it below + these instructions + + +
+ Then add the secret below.
{ setWebhookObject({ @@ -62,3 +64,5 @@ export default { ); }, }; + +export default webhookSendgrid; diff --git a/src/components/TableHeader/Webhooks/Schemas/typeform.tsx b/src/components/TableHeader/Webhooks/Schemas/typeform.tsx index b345ec06..9d97d2c8 100644 --- a/src/components/TableHeader/Webhooks/Schemas/typeform.tsx +++ b/src/components/TableHeader/Webhooks/Schemas/typeform.tsx @@ -1,6 +1,7 @@ import { Typography, Link, TextField } from "@mui/material"; +import InlineOpenInNewIcon from "@src/components/InlineOpenInNewIcon"; -export default { +export const webhookTypeform = { name: "Typeform", parser: { additionalVariables: null, @@ -55,23 +56,24 @@ export default { return ( <> - To verify the webhook call is sent from typeform, you need to add - secret on your webhook config on be follow the instructions{" "} + Add a secret to your Typeform webhook config by following{" "} - here - {" "} - to set the secret, then add it below + these instructions + + +
+ Then add the secret below.
{ setWebhookObject({ @@ -84,3 +86,5 @@ export default { ); }, }; + +export default webhookTypeform; diff --git a/src/components/TableHeader/Webhooks/Step1Auth.tsx b/src/components/TableHeader/Webhooks/Step1Auth.tsx index bc8369c7..e252e979 100644 --- a/src/components/TableHeader/Webhooks/Step1Auth.tsx +++ b/src/components/TableHeader/Webhooks/Step1Auth.tsx @@ -1,25 +1,23 @@ import { IWebhookModalStepProps } from "./WebhookModal"; -import { - FormControl, - FormLabel, - FormControlLabel, - Switch, - Typography, -} from "@mui/material"; + +import { FormControlLabel, Checkbox, Typography } from "@mui/material"; + import { webhookSchemas } from "./utils"; + export default function Step1Endpoint({ webhookObject, setWebhookObject, }: IWebhookModalStepProps) { return ( - - - Verification - + <> + + Verification prevents malicious requests from being sent to this webhook + endpoint + + setWebhookObject({ @@ -32,17 +30,16 @@ export default function Step1Endpoint({ } /> } - label="Enable Verification" + label="Enable verification for this webhook" + sx={{ mb: 2 }} /> - {webhookObject.auth?.enabled ? ( - webhookSchemas[webhookObject.type].auth(webhookObject, setWebhookObject) - ) : ( - - Verification of webhooks is optional however it prevents malicious - actors from spoofing the original sender - - )} + + {webhookObject.auth?.enabled && + webhookSchemas[webhookObject.type].auth( + webhookObject, + setWebhookObject + )} {} - + ); } diff --git a/src/components/TableHeader/Webhooks/Step3Parser.tsx b/src/components/TableHeader/Webhooks/Step3Parser.tsx index 789dd031..62b169e0 100644 --- a/src/components/TableHeader/Webhooks/Step3Parser.tsx +++ b/src/components/TableHeader/Webhooks/Step3Parser.tsx @@ -34,8 +34,8 @@ export default function Step4Body({ return ( <> - Write the webhook parsed function. The returned object of the parser - will be added as new row{" "} + Write a function to parse webhook requests. Return an object, which will + be added as a new row.{" "} ; + export interface IWebhookModalStepProps { webhookObject: IWebhook; setWebhookObject: React.Dispatch>; @@ -128,36 +136,39 @@ export default function WebhookModal({ }activated`} /> -
- URL: -
- - - {baseUrl} - {webhookObject.endpoint} - - -
- - - navigator.clipboard.writeText( - `${baseUrl}${webhookObject.endpoint}` - ) - } - > - - - -
+ + + Endpoint URL: + +   + + + {baseUrl} + {webhookObject.endpoint} + + + + + navigator.clipboard.writeText( + `${baseUrl}${webhookObject.endpoint}` + ) + } + sx={{ flexShrink: 0, mr: -0.75 }} + > + + + + + , }, ]} + style={{ marginTop: "var(--dialog-contents-spacing)" }} /> } diff --git a/src/components/TableHeader/Webhooks/utils.tsx b/src/components/TableHeader/Webhooks/utils.tsx index 1d93adc5..5701f875 100644 --- a/src/components/TableHeader/Webhooks/utils.tsx +++ b/src/components/TableHeader/Webhooks/utils.tsx @@ -40,9 +40,9 @@ const additionalVariables = [ export type WebhookType = typeof webhookTypes[number]; export const webhookNames: Record = { - sendgrid: "Sendgrid", + sendgrid: "SendGrid", typeform: "Typeform", - //github:"Github", + //github:"GitHub", // shopify: "Shopify", // twitter: "Twitter", // stripe: "Stripe", @@ -73,6 +73,7 @@ export const webhookSchemas = { typeform, sendgrid, }; + export function emptyWebhookObject( type: WebhookType, user: IWebhookEditor