Shaheer Kochai 2c87d96d75
feat: trace funnels list page (#7324)
* chore: add a new tab for traces funnels

* feat: funnels list page basic UI

* feat: learn more component

* feat: get funnels list data from mock API, and handle data, loading and empty states

* chore(SignozModal): add width prop and improve button styles

* feat: implement funnel rename

* refactor: overall improvements

* feat: implement sorting in traces funnels list page

* feat: add sort column key and order to url params

* chore: move useFunnels to hooks/TracesFunnels

* feat: implement traces funnels search and refactor search and sort by extracting to custom hooks

* chore: overall improvements to rename trace funnel modal

* chore: make the rename input auto-focusable

* feat: handle create funnel modal

* feat: delete funnel modal and functionality

* fix: fix the layout shift in funnel item caused by getContainer={false}

* chore: overall improvements and use live api in traces funnels

* feat: create traces funnels details basic page + funnel -> details redirection

* fix: funnels traces light mode UI

* fix: properly display created at in funnels list item + preventDefault

* refactor: extract FunnelItemPopover into a separate component

* chore: hide funnel tab from traces explorer

* chore: add check to display trace funnels tab only in dev environment

* chore: improve funnels modals light mode

* chore: overall improvements

* fix: properly pass funnel details link

* chore: address PR review changes
2025-03-22 09:13:18 +00:00

85 lines
2.0 KiB
TypeScript

import '../RenameFunnel/RenameFunnel.styles.scss';
import './DeleteFunnel.styles.scss';
import SignozModal from 'components/SignozModal/SignozModal';
import { REACT_QUERY_KEY } from 'constants/reactQueryKeys';
import { useDeleteFunnel } from 'hooks/TracesFunnels/useFunnels';
import { useNotifications } from 'hooks/useNotifications';
import { Trash2, X } from 'lucide-react';
import { useQueryClient } from 'react-query';
interface DeleteFunnelProps {
isOpen: boolean;
onClose: () => void;
funnelId: string;
}
function DeleteFunnel({
isOpen,
onClose,
funnelId,
}: DeleteFunnelProps): JSX.Element {
const deleteFunnelMutation = useDeleteFunnel();
const { notifications } = useNotifications();
const queryClient = useQueryClient();
const handleDelete = (): void => {
deleteFunnelMutation.mutate(
{
id: funnelId,
},
{
onSuccess: () => {
notifications.success({
message: 'Funnel deleted successfully',
});
onClose();
queryClient.invalidateQueries([REACT_QUERY_KEY.GET_FUNNELS_LIST]);
},
onError: () => {
notifications.error({
message: 'Failed to delete funnel',
});
},
},
);
};
const handleCancel = (): void => {
onClose();
};
return (
<SignozModal
open={isOpen}
title="Delete this funnel"
width={390}
onCancel={handleCancel}
rootClassName="funnel-modal delete-funnel-modal"
cancelText="Cancel"
okText="Delete Funnel"
okButtonProps={{
icon: <Trash2 size={14} />,
loading: deleteFunnelMutation.isLoading,
type: 'primary',
className: 'funnel-modal__ok-btn',
onClick: handleDelete,
}}
cancelButtonProps={{
icon: <X size={14} />,
type: 'text',
className: 'funnel-modal__cancel-btn',
onClick: handleCancel,
}}
destroyOnClose
>
<div className="delete-funnel-modal-content">
Deleting the funnel would stop further analytics using this funnel. This is
irreversible and cannot be undone.
</div>
</SignozModal>
);
}
export default DeleteFunnel;