diff --git a/ui-v2/src/components/automations/automation-details.tsx b/ui-v2/src/components/automations/automation-details.tsx new file mode 100644 index 000000000000..0e18f34fc260 --- /dev/null +++ b/ui-v2/src/components/automations/automation-details.tsx @@ -0,0 +1,56 @@ +import { type Automation } from "@/api/automations"; +import { ActionDetails } from "@/components/automations/action-details"; +import { Typography } from "@/components/ui/typography"; + +type AutomationDetailsProps = { + data: Automation; +}; + +export const AutomationDetails = ({ data }: AutomationDetailsProps) => ( +
+ + + +
+); + +const AutomationDescription = ({ data }: AutomationDetailsProps) => { + return ( +
+ + Description + + + {data.description || "None"} + +
+ ); +}; + +const AutomationTrigger = ({ data }: AutomationDetailsProps) => { + const { trigger } = data; + return ( +
+ Trigger + + TODO: {JSON.stringify(trigger)} + +
+ ); +}; + +const AutomationActions = ({ data }: AutomationDetailsProps) => { + const { actions } = data; + return ( +
+ {`Action${actions.length > 1 ? "s" : ""}`} + +
+ ); +}; diff --git a/ui-v2/src/components/automations/automation-details/automation-details.stories.tsx b/ui-v2/src/components/automations/automation-details/automation-details.stories.tsx deleted file mode 100644 index 12369fe5bb42..000000000000 --- a/ui-v2/src/components/automations/automation-details/automation-details.stories.tsx +++ /dev/null @@ -1,21 +0,0 @@ -import type { Meta, StoryObj } from "@storybook/react"; - -import { createFakeAutomation } from "@/mocks"; -import { reactQueryDecorator, routerDecorator } from "@/storybook/utils"; -import { AutomationDetails } from "./automation-details"; - -const meta: Meta = { - title: "Components/Automations/AutomationDetails", - decorators: [routerDecorator, reactQueryDecorator], - component: AutomationDetails, - args: { data: createFakeAutomation() }, -}; -export default meta; - -export const Page: StoryObj = { - args: { displayType: "page" }, -}; - -export const Item: StoryObj = { - args: { displayType: "item" }, -}; diff --git a/ui-v2/src/components/automations/automation-details/automation-details.tsx b/ui-v2/src/components/automations/automation-details/automation-details.tsx deleted file mode 100644 index 22edf110c757..000000000000 --- a/ui-v2/src/components/automations/automation-details/automation-details.tsx +++ /dev/null @@ -1,186 +0,0 @@ -import { type Automation } from "@/api/automations"; -import { ActionDetails } from "@/components/automations/action-details"; -import { AutomationEnableToggle } from "@/components/automations/automation-enable-toggle"; -import { AutomationsActionsMenu } from "@/components/automations/automations-actions-menu"; -import { useDeleteAutomationConfirmationDialog } from "@/components/automations/use-delete-automation-confirmation-dialog"; -import { - Breadcrumb, - BreadcrumbItem, - BreadcrumbLink, - BreadcrumbList, - BreadcrumbPage, - BreadcrumbSeparator, -} from "@/components/ui/breadcrumb"; -import { Card } from "@/components/ui/card"; -import { DeleteConfirmationDialog } from "@/components/ui/delete-confirmation-dialog"; -import { Typography } from "@/components/ui/typography"; - -type DisplayType = "page" | "item"; - -type AutomationDetailsProps = { - data: Automation; - displayType: DisplayType; -}; - -export const AutomationDetails = ({ - data, - displayType, -}: AutomationDetailsProps) => { - if (displayType === "item") { - return ( - - - - ); - } - return ; -}; - -const AutomationDetailsContent = ({ - data, - displayType, -}: AutomationDetailsProps) => { - const [dialogState, confirmDelete] = useDeleteAutomationConfirmationDialog(); - - const handleDelete = () => - confirmDelete(data, { shouldNavigate: displayType === "page" }); - - return ( - <> -
- -
- - - -
-
- - - ); -}; - -type AutomationDetailsHeaderProps = { - data: Automation; - displayType: DisplayType; - onDelete: () => void; -}; - -const AutomationDetailsHeader = ({ - data, - onDelete, - displayType, -}: AutomationDetailsHeaderProps) => { - return ( -
- -
- - -
-
- ); -}; - -type AutomationDescriptionProps = { - data: Automation; -}; - -const AutomationDescription = ({ data }: AutomationDescriptionProps) => { - return ( -
- - Description - - - {data.description || "None"} - -
- ); -}; - -type AutomationTriggerProps = { - data: Automation; -}; - -const AutomationTrigger = ({ data }: AutomationTriggerProps) => { - const { trigger } = data; - return ( -
- Trigger - - TODO: {JSON.stringify(trigger)} - -
- ); -}; - -type AutomationActionsProps = { - data: Automation; -}; - -const AutomationActions = ({ data }: AutomationActionsProps) => { - const { actions } = data; - return ( -
- {`Action${actions.length > 1 ? "s" : ""}`} -
    - {actions.map((action, i) => ( -
  • - -
  • - ))} -
-
- ); -}; - -type NavHeaderProps = { - data: Automation; - displayType: DisplayType; -}; - -const NavHeader = ({ displayType, data }: NavHeaderProps) => { - if (displayType === "page") { - return ( -
- - - - - Automations - - - - - {data.name} - - - -
- ); - } - - return ( - - - - - {data.name} - - - - - ); -}; diff --git a/ui-v2/src/components/automations/automation-details/index.ts b/ui-v2/src/components/automations/automation-details/index.ts deleted file mode 100644 index f60511fd4947..000000000000 --- a/ui-v2/src/components/automations/automation-details/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { AutomationDetails } from "./automation-details"; diff --git a/ui-v2/src/components/automations/automation-page.tsx b/ui-v2/src/components/automations/automation-page.tsx new file mode 100644 index 000000000000..026c70773392 --- /dev/null +++ b/ui-v2/src/components/automations/automation-page.tsx @@ -0,0 +1,65 @@ +import { type Automation, buildGetAutomationQuery } from "@/api/automations"; +import { + Breadcrumb, + BreadcrumbItem, + BreadcrumbLink, + BreadcrumbList, + BreadcrumbPage, + BreadcrumbSeparator, +} from "@/components/ui/breadcrumb"; +import { DeleteConfirmationDialog } from "@/components/ui/delete-confirmation-dialog"; +import { useSuspenseQuery } from "@tanstack/react-query"; +import { AutomationDetails } from "./automation-details"; +import { AutomationEnableToggle } from "./automation-enable-toggle"; +import { AutomationsActionsMenu } from "./automations-actions-menu"; + +import { useDeleteAutomationConfirmationDialog } from "./use-delete-automation-confirmation-dialog"; + +type AutomationsPageProps = { + id: string; +}; + +export const AutomationPage = ({ id }: AutomationsPageProps) => { + const [dialogState, confirmDelete] = useDeleteAutomationConfirmationDialog(); + const { data } = useSuspenseQuery(buildGetAutomationQuery(id)); + + const handleDelete = () => confirmDelete(data, { shouldNavigate: true }); + + return ( + <> +
+
+ +
+ + +
+
+ +
+ + + ); +}; + +type NavHeaderProps = { + data: Automation; +}; + +const PageNavHeader = ({ data }: NavHeaderProps) => { + return ( + + + + + Automations + + + + + {data.name} + + + + ); +}; diff --git a/ui-v2/src/components/automations/automations-page.tsx b/ui-v2/src/components/automations/automations-page.tsx index e2d1a7eca3d6..3072735066da 100644 --- a/ui-v2/src/components/automations/automations-page.tsx +++ b/ui-v2/src/components/automations/automations-page.tsx @@ -1,29 +1,97 @@ -import { buildListAutomationsQuery } from "@/api/automations"; +import { type Automation, buildListAutomationsQuery } from "@/api/automations"; +import { + Breadcrumb, + BreadcrumbItem, + BreadcrumbLink, + BreadcrumbList, +} from "@/components/ui/breadcrumb"; +import { Card } from "@/components/ui/card"; +import { DeleteConfirmationDialog } from "@/components/ui/delete-confirmation-dialog"; import { useSuspenseQuery } from "@tanstack/react-query"; + import { AutomationDetails } from "./automation-details"; +import { AutomationEnableToggle } from "./automation-enable-toggle"; +import { AutomationsActionsMenu } from "./automations-actions-menu"; import { AutomationsEmptyState } from "./automations-empty-state"; import { AutomationsHeader } from "./automations-header"; +import { useDeleteAutomationConfirmationDialog } from "./use-delete-automation-confirmation-dialog"; export const AutomationsPage = () => { + const [dialogState, confirmDelete] = useDeleteAutomationConfirmationDialog(); const { data } = useSuspenseQuery(buildListAutomationsQuery()); + const handleDelete = (automation: Automation) => confirmDelete(automation); + + return ( + <> +
+ + {data.length === 0 ? ( + + ) : ( +
    + {data.map((automation) => ( +
  • + +
  • + ))} +
+ )} +
+ + + ); +}; + +type AutomationCardDetailsProps = { + data: Automation; + onDelete: (data: Automation) => void; +}; +const AutomationCardDetails = ({ + data, + onDelete, +}: AutomationCardDetailsProps) => { + return ( + +
+ +
+ + onDelete(data)} + /> +
+
+ +
+ ); +}; + +type NavHeaderProps = { + data: Automation; +}; + +const CardNavHeader = ({ data }: NavHeaderProps) => { return ( -
- - {data.length === 0 ? ( - - ) : ( -
    - {data.map((automation) => ( -
  • - -
  • - ))} -
- )} -
+ + + + + {data.name} + + + + ); }; diff --git a/ui-v2/src/components/automations/use-delete-automation-confirmation-dialog.ts b/ui-v2/src/components/automations/use-delete-automation-confirmation-dialog.ts index bdbdf0f0e9c7..eb820ac70812 100644 --- a/ui-v2/src/components/automations/use-delete-automation-confirmation-dialog.ts +++ b/ui-v2/src/components/automations/use-delete-automation-confirmation-dialog.ts @@ -19,7 +19,7 @@ export const useDeleteAutomationConfirmationDialog = () => { }: { /** Should navigate back to /automations */ shouldNavigate?: boolean; - }, + } = {}, ) => confirmDelete({ title: "Delete Automation", diff --git a/ui-v2/src/routes/automations/automation.$id.tsx b/ui-v2/src/routes/automations/automation.$id.tsx index 4159a4802983..b75eee89c196 100644 --- a/ui-v2/src/routes/automations/automation.$id.tsx +++ b/ui-v2/src/routes/automations/automation.$id.tsx @@ -1,8 +1,7 @@ import { createFileRoute } from "@tanstack/react-router"; import { buildGetAutomationQuery } from "@/api/automations"; -import { AutomationDetails } from "@/components/automations/automation-details"; -import { useSuspenseQuery } from "@tanstack/react-query"; +import { AutomationPage } from "@/components/automations/automation-page"; export const Route = createFileRoute("/automations/automation/$id")({ component: RouteComponent, @@ -13,6 +12,5 @@ export const Route = createFileRoute("/automations/automation/$id")({ function RouteComponent() { const { id } = Route.useParams(); - const { data } = useSuspenseQuery(buildGetAutomationQuery(id)); - return ; + return ; }