From 260fd1a7e37eb789fc8412926093d09f252e8d82 Mon Sep 17 00:00:00 2001 From: Rishabh Date: Wed, 5 Feb 2025 12:11:45 +0530 Subject: [PATCH 1/5] refactor: move webhook events to utils folder --- ui/src/containers/webhooks/create/index.tsx | 8 ++++++-- .../webhooks/create/events.ts => utils/webhook_events.ts} | 0 2 files changed, 6 insertions(+), 2 deletions(-) rename ui/src/{containers/webhooks/create/events.ts => utils/webhook_events.ts} (100%) diff --git a/ui/src/containers/webhooks/create/index.tsx b/ui/src/containers/webhooks/create/index.tsx index 8f7db4493..b16a2a1de 100644 --- a/ui/src/containers/webhooks/create/index.tsx +++ b/ui/src/containers/webhooks/create/index.tsx @@ -7,7 +7,7 @@ import { FormProvider, useForm } from "react-hook-form"; import { zodResolver } from "@hookform/resolvers/zod"; import { Form, FormSubmit } from "@radix-ui/react-form"; import { CustomFieldName } from "~/components/CustomField"; -import events from "./events"; +import events from "~/utils/webhook_events"; import { SheetFooter } from "~/components/sheet/footer"; import { useFrontier } from "@raystack/frontier/react"; import { V1Beta1WebhookRequestBody } from "@raystack/frontier"; @@ -77,7 +77,11 @@ export default function CreateWebhooks() { >
- + Date: Wed, 5 Feb 2025 12:45:21 +0530 Subject: [PATCH 2/5] feat: add action dropdown for service user --- ui/src/containers/webhooks/columns.tsx | 35 ++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/ui/src/containers/webhooks/columns.tsx b/ui/src/containers/webhooks/columns.tsx index 5b0dbd2c3..2de6db90d 100644 --- a/ui/src/containers/webhooks/columns.tsx +++ b/ui/src/containers/webhooks/columns.tsx @@ -1,4 +1,5 @@ -import { ApsaraColumnDef } from "@raystack/apsara"; +import { DotsVerticalIcon, TrashIcon, UpdateIcon } from "@radix-ui/react-icons"; +import { ApsaraColumnDef, DropdownMenu, Flex } from "@raystack/apsara"; import { V1Beta1Webhook } from "@raystack/frontier"; export const getColumns: () => ApsaraColumnDef[] = () => { @@ -33,7 +34,37 @@ export const getColumns: () => ApsaraColumnDef[] = () => { { header: "Action", accessorKey: "id", - cell: () => null, + cell: () => ( + + + + + + + + + + Update + + + + + + Delete + + + + + + ), }, ]; }; From 71f594c8d849b824b3c39bd24c9aca5e162eb597 Mon Sep 17 00:00:00 2001 From: Rishabh Date: Wed, 5 Feb 2025 13:53:02 +0530 Subject: [PATCH 3/5] chore: add callback function to edit webhook button --- ui/src/containers/webhooks/columns.tsx | 13 ++++++++++--- ui/src/containers/webhooks/index.tsx | 9 +++++++-- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/ui/src/containers/webhooks/columns.tsx b/ui/src/containers/webhooks/columns.tsx index 2de6db90d..8e2cc9fae 100644 --- a/ui/src/containers/webhooks/columns.tsx +++ b/ui/src/containers/webhooks/columns.tsx @@ -2,7 +2,13 @@ import { DotsVerticalIcon, TrashIcon, UpdateIcon } from "@radix-ui/react-icons"; import { ApsaraColumnDef, DropdownMenu, Flex } from "@raystack/apsara"; import { V1Beta1Webhook } from "@raystack/frontier"; -export const getColumns: () => ApsaraColumnDef[] = () => { +interface getColumnsOptions { + openEditPage: (id: string) => void; +} + +export const getColumns: ( + opt: getColumnsOptions +) => ApsaraColumnDef[] = ({ openEditPage }) => { return [ { header: "Description", @@ -34,7 +40,7 @@ export const getColumns: () => ApsaraColumnDef[] = () => { { header: "Action", accessorKey: "id", - cell: () => ( + cell: ({ getValue }) => ( @@ -46,12 +52,13 @@ export const getColumns: () => ApsaraColumnDef[] = () => { style={{ padding: "12px" }} gap={"small"} data-test-id="admin-ui-webhook-update-btn" + onClick={() => openEditPage(getValue())} > Update - + ([]); const [isLoading, setIsLoading] = useState(false); @@ -28,7 +29,11 @@ export default function WebhooksList() { fetchWebhooks(); }, [client]); - const columns = getColumns(); + function openEditPage(id: string) { + naviagte(`/webhooks/${id}`); + } + + const columns = getColumns({ openEditPage }); return ( Date: Wed, 5 Feb 2025 14:43:22 +0530 Subject: [PATCH 4/5] feat: add page to update webhook --- ui/src/components/CustomField.tsx | 163 ++++++++-------- ui/src/containers/webhooks/update/index.tsx | 198 ++++++++++++++++++++ ui/src/routes.tsx | 2 + 3 files changed, 286 insertions(+), 77 deletions(-) create mode 100644 ui/src/containers/webhooks/update/index.tsx diff --git a/ui/src/components/CustomField.tsx b/ui/src/components/CustomField.tsx index 1722d1d2c..2bf19d430 100644 --- a/ui/src/components/CustomField.tsx +++ b/ui/src/components/CustomField.tsx @@ -11,9 +11,11 @@ import React, { CSSProperties } from "react"; import { Control, Controller, UseFormRegister } from "react-hook-form"; import { capitalizeFirstLetter } from "~/utils/helper"; import { MultiSelect } from "./multiselect"; +import Skeleton from "react-loading-skeleton"; type CustomFieldNameProps = { name: string; + isLoading?: boolean; title?: string; disabled?: boolean; register: UseFormRegister; @@ -33,6 +35,7 @@ export const CustomFieldName = ({ style = {}, placeholder, options = [], + isLoading = false, ...props }: FormFieldProps & CustomFieldNameProps & @@ -64,86 +67,92 @@ export const CustomFieldName = ({ - { - switch (variant) { - case "textarea": { - return ( -