From 19fa1dd20c20dd1a0aad44cc613421544469d4d8 Mon Sep 17 00:00:00 2001 From: Xiaoyun Zhang Date: Sat, 12 Oct 2024 01:04:00 -0700 Subject: [PATCH] [WebUI] Fix small bugs (#87) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * update * update“ * update --- stepwise-studio/components/markdown.tsx | 2 +- stepwise-studio/components/parameter-card.tsx | 7 +-- stepwise-studio/components/step-node.tsx | 34 ++++++++--- .../components/step-run-sidebar.tsx | 19 +++---- stepwise-studio/components/variable-card.tsx | 10 ++-- stepwise-studio/components/workflow.tsx | 57 ++++++++++++++++--- 6 files changed, 91 insertions(+), 38 deletions(-) diff --git a/stepwise-studio/components/markdown.tsx b/stepwise-studio/components/markdown.tsx index 5003c67..45e6d18 100644 --- a/stepwise-studio/components/markdown.tsx +++ b/stepwise-studio/components/markdown.tsx @@ -10,7 +10,7 @@ export const Markdown = (props: ReactMarkdownOptions) => { return ( { diff --git a/stepwise-studio/components/parameter-card.tsx b/stepwise-studio/components/parameter-card.tsx index f99bc17..4e1578c 100644 --- a/stepwise-studio/components/parameter-card.tsx +++ b/stepwise-studio/components/parameter-card.tsx @@ -40,23 +40,22 @@ export const ParameterCard: React.FC = (props) => {
setCollapsed(!collapsed)} > -
+

{name}

{parameterType != "" && (

{getDisplayType(parameterType)} diff --git a/stepwise-studio/components/step-node.tsx b/stepwise-studio/components/step-node.tsx index 2e83430..3f223c2 100644 --- a/stepwise-studio/components/step-node.tsx +++ b/stepwise-studio/components/step-node.tsx @@ -81,7 +81,7 @@ export interface StepNodeProps extends StepRunDTO { onClearClick: (step: StepDTO) => void; onSubmitOutput: (output: VariableDTO) => void; onCancelInput: () => void; - onResize: (height: number, width: number) => void; + onResize: (height?: number, width?: number) => void; isWorkflowRunning: boolean; width?: number; height?: number; @@ -346,6 +346,24 @@ const StepNode: React.FC> = (prop) => { useEffect(() => { if (stepNodeRef.current) { + // this usually means that the content of this node has changed + // so we want to automatically adjust the weight to present the content in a nicer way + // by setting the width to undefined, the prop.data.onResize will be invoked + // and the new width will be re-calculated when the node is re-rendered + // if ( + // height !== stepNodeRef.current.offsetHeight && + // width === stepNodeRef.current.offsetWidth && + // width !== undefined + // ) { + // console.log("Setting width to undefined"); + // prop.data.onResize( + // undefined, + // undefined, + // ); + + // return; + // } + if ( height !== stepNodeRef.current.offsetHeight || width !== stepNodeRef.current.offsetWidth @@ -354,6 +372,8 @@ const StepNode: React.FC> = (prop) => { stepNodeRef.current.offsetHeight ?? height, width ?? stepNodeRef.current.offsetWidth, ); + + return; } } }, [ @@ -370,7 +390,7 @@ const StepNode: React.FC> = (prop) => { "border-2 rounded-md shadow-md p-2 bg-background/50 group", // set weight and height isSelected ? "border-primary/40" : "border-transparent", - width ?? "max-w-48", + width ?? "max-w-80", shouldWaitForInput(status, stepType) ? "border-primary" : "", )} ref={stepNodeRef} @@ -383,11 +403,11 @@ const StepNode: React.FC> = (prop) => { border: "none", }} onResize={(event, param) => { - setWidth(param.width); - setHeight(param.height); + if (Math.abs(param.width - width) > 10) { + setWidth(param.width); + } }} onResizeEnd={(event, param) => { - setHeight(stepNodeRef.current!.offsetHeight); setWidth(stepNodeRef.current!.offsetWidth); }} minWidth={128} @@ -406,10 +426,10 @@ const StepNode: React.FC> = (prop) => { )} {/* settings bar */} {/* appear when hover */} -

+