openreplay/frontend/app/components/Client/Webhooks/Webhooks.tsx
Delirium d604f9920b
feat ui: dashboards redesign (#2230)
* feat ui: dashboards redesign start

* more cards

* fix ui: more different cards...

* feat ui: finish cards, all trigger, all icons

* change(ui): added missin const

* feature(ui): new dashboard modal

* feature(ui): new dashboard modal

* change(ui): new cards

* change(ui): dashboard redesign

* change(ui): dashboard redesign

* change(ui): dashboard redesign

* change(ui): modal context and alert form

* change(ui): table card show more with modal

* change(ui): examples

* change(ui): example categorize and other improvements

* change(ui): example categorize and other improvements

* change(ui): performance cards

* change(ui): insights card

* Various style updates in dashboards and other pages. (#2308)

* Various minor style updates

* Various style improvements

* Update ExampleCards.tsx

* change(ui): fixed an issue with card create

* change(ui): fixed an issue with card create

* change(ui): default filters and events order

* change(ui): random data

* Dashboards redesign - improvments (#2313)

* Various minor style updates

* Various style improvements

* Update ExampleCards.tsx

* various minor improvements in dashbaords.

* revised dashboard widget header

* change(ui): sessions by user

* change(ui): funnel example

* change(ui): modal height and scroll

* change(ui): example cards with data

* change(ui): example cards with data

* change(ui): funnel bar text color

* change(ui): example cards overlay click

* change(ui): path analysis filter card

---------

Co-authored-by: Shekar Siri <sshekarsiri@gmail.com>
Co-authored-by: Sudheer Salavadi <connect.uxmaster@gmail.com>
2024-06-27 19:47:34 +02:00

83 lines
3.2 KiB
TypeScript

import React, { useEffect } from 'react';
import cn from 'classnames';
import withPageTitle from 'HOCs/withPageTitle';
import { Button, Loader, NoContent, Icon, Divider } from 'UI';
import WebhookForm from './WebhookForm';
import ListItem from './ListItem';
import styles from './webhooks.module.css';
import AnimatedSVG, { ICONS } from 'Shared/AnimatedSVG/AnimatedSVG';
import { confirm } from 'UI';
import { toast } from 'react-toastify';
import { useModal } from 'App/components/Modal';
import { useStore } from 'App/mstore';
import { observer } from 'mobx-react-lite'
import { IWebhook } from 'Types/webhook';
function Webhooks() {
const { settingsStore } = useStore()
const { webhooks, hooksLoading: loading } = settingsStore;
const { showModal, hideModal } = useModal();
const customWebhooks = webhooks.filter((hook) => hook.type === 'webhook');
useEffect(() => {
void settingsStore.fetchWebhooks();
}, []);
const init = (webhookInst?: Partial<IWebhook>) => {
settingsStore.initWebhook(webhookInst);
showModal(<WebhookForm onClose={hideModal} onDelete={removeWebhook} />, { right: true });
};
const removeWebhook = async (id: string) => {
if (
await confirm({
header: 'Confirm',
confirmButton: 'Yes, delete',
confirmation: `Are you sure you want to remove this webhook?`,
})
) {
settingsStore.removeWebhook(id).then(() => {
toast.success('Webhook removed successfully');
});
hideModal();
}
};
return (
<div className="bg-white rounded-lg shadow-sm border p-5">
<div className={cn(styles.tabHeader)}>
<h3 className={cn(styles.tabTitle, 'text-2xl')}>{'Webhooks'}</h3>
<Button className="ml-auto" variant="primary" onClick={() => init()}>Add Webhook</Button>
</div>
<div className="text-base text-disabled-text flex items-center my-3 px-5">
<Icon name="info-circle-fill" className="mr-2" size={16} />
Leverage webhook notifications on alerts to trigger custom callbacks.
</div>
<Loader loading={loading}>
<NoContent
title={
<div className="flex flex-col items-center justify-center">
<AnimatedSVG name={ICONS.NO_WEBHOOKS} size={170} />
<div className="text-center my-4">None added yet</div>
</div>
}
size="small"
show={customWebhooks.length === 0}
>
<div className="cursor-pointer">
{customWebhooks.map((webhook) => (
<>
<ListItem key={webhook.webhookId} webhook={webhook} onEdit={() => init(webhook)} />
<Divider className="m-0" />
</>
))}
</div>
</NoContent>
</Loader>
</div>
);
}
export default withPageTitle('Webhooks - OpenReplay Preferences')(observer(Webhooks));