Skip to content

Commit 3b925bb

Browse files
update: webhooks
1 parent df17ea8 commit 3b925bb

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

dashboard/src/components/UpdateWebhookModal.tsx

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,12 @@ import {
2828
WebhookInputDataFields,
2929
WebhookInputHeaderFields,
3030
UpdateWebhookModalViews,
31+
webhookVerifiedStatus,
3132
} from '../constants';
3233
import { capitalizeFirstLetter, validateURI } from '../utils';
3334
import { AddWebhook, EditWebhook } from '../graphql/mutation';
3435
import { rest } from 'lodash';
36+
import { BiCheckCircle, BiError, BiErrorCircle } from 'react-icons/bi';
3537

3638
interface headersDataType {
3739
[WebhookInputHeaderFields.KEY]: string;
@@ -100,12 +102,16 @@ const UpdateWebhookModal = ({
100102
const toast = useToast();
101103
const { isOpen, onOpen, onClose } = useDisclosure();
102104
const [loading, setLoading] = useState<boolean>(false);
105+
const [verifyingEndpoint, setVerifyingEndpoint] = useState<boolean>(false);
103106
const [webhook, setWebhook] = useState<webhookDataType>({
104107
...initWebhookData,
105108
});
106109
const [validator, setValidator] = useState<validatorDataType>({
107110
...initWebhookValidatorData,
108111
});
112+
const [verifiedStatus, setVerifiedStatus] = useState<webhookVerifiedStatus>(
113+
webhookVerifiedStatus.PENDING
114+
);
109115
const inputChangehandler = (
110116
inputType: string,
111117
value: any,
@@ -201,6 +207,7 @@ const UpdateWebhookModal = ({
201207
const validateData = () => {
202208
return (
203209
!loading &&
210+
!verifyingEndpoint &&
204211
webhook[WebhookInputDataFields.EVENT_NAME].length > 0 &&
205212
webhook[WebhookInputDataFields.ENDPOINT].length > 0 &&
206213
validator[WebhookInputDataFields.ENDPOINT] &&
@@ -515,6 +522,31 @@ const UpdateWebhookModal = ({
515522
</Flex>
516523
</ModalBody>
517524
<ModalFooter>
525+
<Button
526+
colorScheme={
527+
verifiedStatus === webhookVerifiedStatus.VERIFIED
528+
? 'green'
529+
: verifiedStatus === webhookVerifiedStatus.PENDING
530+
? 'yellow'
531+
: 'red'
532+
}
533+
variant="outline"
534+
onClick={saveData}
535+
isLoading={verifyingEndpoint}
536+
isDisabled={!validateData()}
537+
marginRight="5"
538+
leftIcon={
539+
verifiedStatus === webhookVerifiedStatus.VERIFIED ? (
540+
<BiCheckCircle />
541+
) : verifiedStatus === webhookVerifiedStatus.PENDING ? (
542+
<BiErrorCircle />
543+
) : (
544+
<BiError />
545+
)
546+
}
547+
>
548+
Test Endpoint
549+
</Button>
518550
<Button
519551
colorScheme="blue"
520552
variant="solid"

dashboard/src/constants.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,3 +182,9 @@ export const webhookEventNames = {
182182
USER_ACCESS_ENABLED: 'user.access_enabled',
183183
USER_ACCESS_REVOKED: 'user.access_revoked',
184184
};
185+
186+
export enum webhookVerifiedStatus {
187+
VERIFIED = 'verified',
188+
NOT_VERIFIED = 'not_verified',
189+
PENDING = 'verification_pending',
190+
}

0 commit comments

Comments
 (0)