From b7b42cd30edea514d2bdbac363ae01a9f7e48a32 Mon Sep 17 00:00:00 2001 From: Jay Kumar Date: Fri, 22 Nov 2024 13:17:18 +0000 Subject: [PATCH] feat: extraction side panel --- .../create-or-update-extraction-rule.tsx | 26 ++--- keep-ui/app/(keep)/extraction/extraction.tsx | 102 +++++++++++++----- keep-ui/app/(keep)/extraction/layout.tsx | 13 +-- keep-ui/components/SidePanel.tsx | 51 +++++++++ 4 files changed, 137 insertions(+), 55 deletions(-) create mode 100644 keep-ui/components/SidePanel.tsx diff --git a/keep-ui/app/(keep)/extraction/create-or-update-extraction-rule.tsx b/keep-ui/app/(keep)/extraction/create-or-update-extraction-rule.tsx index ca50f4b4d..c2c36291c 100644 --- a/keep-ui/app/(keep)/extraction/create-or-update-extraction-rule.tsx +++ b/keep-ui/app/(keep)/extraction/create-or-update-extraction-rule.tsx @@ -93,6 +93,7 @@ export default function CreateOrUpdateExtractionRule({ }), }); if (response.ok) { + exitEditOrCreateMode(); clearForm(); mutate(); toast.success("Extraction rule created successfully"); @@ -126,7 +127,7 @@ export default function CreateOrUpdateExtractionRule({ } ); if (response.ok) { - exitEditMode(); + exitEditOrCreateMode(); mutate(); toast.success("Extraction updated successfully"); } else { @@ -136,7 +137,7 @@ export default function CreateOrUpdateExtractionRule({ } }; - const exitEditMode = async () => { + const exitEditOrCreateMode = async () => { editCallback(null); clearForm(); }; @@ -301,19 +302,14 @@ export default function CreateOrUpdateExtractionRule({
- {/*If we are in the editMode we need an extra cancel button option for the user*/} - {editMode ? ( - - ) : ( - <> - )} +
- + + + handleSidePanelExit(null)} + > +
+ +
+
+
+
+ {isLoading ? ( + + ) : extractions && extractions.length > 0 ? ( + + ) : ( + + No extraction rules found. Configure new extraction rule using + the + Create Extraction + + )} +
+
+
+ ); } diff --git a/keep-ui/app/(keep)/extraction/layout.tsx b/keep-ui/app/(keep)/extraction/layout.tsx index 5e930dc8d..67f020d69 100644 --- a/keep-ui/app/(keep)/extraction/layout.tsx +++ b/keep-ui/app/(keep)/extraction/layout.tsx @@ -1,14 +1,3 @@ -import { Title, Subtitle } from "@tremor/react"; - export default function Layout({ children }: { children: any }) { - return ( -
- Extractions - - Easily extract more attributes from your alerts using Regex - - - {children} -
- ); + return
{children}
; } diff --git a/keep-ui/components/SidePanel.tsx b/keep-ui/components/SidePanel.tsx new file mode 100644 index 000000000..b0d6e10c9 --- /dev/null +++ b/keep-ui/components/SidePanel.tsx @@ -0,0 +1,51 @@ +import React, { Fragment } from 'react'; +import { Dialog, Transition } from '@headlessui/react'; + +interface SidePanelProps { + isOpen: boolean; + onClose: () => void; + children: React.ReactNode; + panelWidth?: string; + overlayOpacity?: string; +} + +const SidePanel: React.FC = ({ + isOpen, + onClose, + children, + panelWidth = 'w-1/2', // Default width + overlayOpacity = 'bg-black/30', // Default overlay opacity +}) => { + return ( + + + + + + ); +}; + +export default SidePanel;