From 272c29b9cd60c9afd5e955474ad46224c2429a45 Mon Sep 17 00:00:00 2001 From: Orlando Valverde Date: Thu, 17 Oct 2024 13:37:19 -0600 Subject: [PATCH] Use in WorkflowLayout as a container in Route element prop --- .../packages/core/src/AppProvider/index.tsx | 32 +++++++++++++------ .../core/src/AppProvider/workflow.tsx | 3 ++ .../core/src/WorkflowLayout/index.tsx | 10 +++--- 3 files changed, 31 insertions(+), 14 deletions(-) diff --git a/frontend/packages/core/src/AppProvider/index.tsx b/frontend/packages/core/src/AppProvider/index.tsx index 39595f623a..04f7634e74 100644 --- a/frontend/packages/core/src/AppProvider/index.tsx +++ b/frontend/packages/core/src/AppProvider/index.tsx @@ -15,6 +15,7 @@ import Landing from "../landing"; import type { ClutchError } from "../Network/errors"; import NotFound from "../not-found"; import type { AppConfiguration } from "../Types"; +import WorkflowLayout, { LayoutProps } from "../WorkflowLayout"; import { registeredWorkflows } from "./registrar"; import ShortLinkProxy, { ShortLinkBaseRoute } from "./short-link-proxy"; @@ -214,21 +215,32 @@ const ClutchApp = ({ const heading = route.displayName ? `${workflow.displayName}: ${route.displayName}` : workflow.displayName; + + // We define these props in order to avoid UI changes before refactoring + const workflowLayoutProps: LayoutProps = { + variant: "custom", + showHeader: false, + heading: route.layoutProps?.heading || heading, + ...route.layoutProps, + }; return ( - {React.cloneElement(, { - ...route.componentProps, - heading, - })} - + + + {React.cloneElement(, { + ...route.componentProps, + // This is going to be removed to be used in the WorkflowLayout only + heading, + })} + + } /> ); diff --git a/frontend/packages/core/src/AppProvider/workflow.tsx b/frontend/packages/core/src/AppProvider/workflow.tsx index ae110423b1..2f00198e7c 100644 --- a/frontend/packages/core/src/AppProvider/workflow.tsx +++ b/frontend/packages/core/src/AppProvider/workflow.tsx @@ -4,6 +4,7 @@ import { Alert, Grid, IconButton } from "@mui/material"; import { Dialog, DialogContent } from "../dialog"; import Code from "../text"; +import type { LayoutProps } from "../WorkflowLayout"; import type { WorkflowIcon } from "./index"; @@ -90,6 +91,8 @@ export interface Route { * If this is not set the route will always be registered. */ featureFlag?: string; + + layoutProps?: LayoutProps; } export interface ConfiguredRoute extends Route { diff --git a/frontend/packages/core/src/WorkflowLayout/index.tsx b/frontend/packages/core/src/WorkflowLayout/index.tsx index 6eba76f682..f97ed486bb 100644 --- a/frontend/packages/core/src/WorkflowLayout/index.tsx +++ b/frontend/packages/core/src/WorkflowLayout/index.tsx @@ -4,10 +4,10 @@ import type { CSSObject, Theme } from "@mui/material"; import styled from "../styled"; import { Typography } from "../typography"; -type LayoutVariant = "standard" | "wizard"; +export type LayoutVariant = "standard" | "wizard" | "custom"; -type LayoutProps = { - variant: LayoutVariant; +export type LayoutProps = { + variant?: LayoutVariant; heading?: string | React.ReactElement; showHeader?: boolean; }; @@ -36,6 +36,8 @@ const getContainerVariantStyles = (variant: LayoutVariant, theme: Theme) => { padding: theme.spacing(theme.clutch.spacing.lg, theme.clutch.spacing.none), margin: theme.spacing(theme.clutch.spacing.none, "auto"), }, + // No styles + custom: {}, }; return layoutVariantStylesMap[variant]; }; @@ -58,7 +60,7 @@ const HeaderTitle = styled(Typography)({ }); const WorkflowLayout = ({ - variant, + variant = "custom", showHeader, heading, children,