From b267f723235256a887f9af7c5032eb19272e6a77 Mon Sep 17 00:00:00 2001 From: mazuh Date: Thu, 22 Feb 2024 22:46:12 -0300 Subject: [PATCH] url display length, change workspace content on switching --- .../ProjectWorkspacePage.tsx | 47 +++++++++++++++---- 1 file changed, 39 insertions(+), 8 deletions(-) diff --git a/src/features/project-workspace/ProjectWorkspacePage.tsx b/src/features/project-workspace/ProjectWorkspacePage.tsx index ae64ffa..30d3604 100644 --- a/src/features/project-workspace/ProjectWorkspacePage.tsx +++ b/src/features/project-workspace/ProjectWorkspacePage.tsx @@ -78,7 +78,7 @@ function WorkspaceBody() { selected={selectedSpec} setSelected={setSelectedSpec} /> - + ); } @@ -139,11 +139,12 @@ function RequestsSpecsList(props: { }; return ( -
+
    {specs.map((spec) => (
  • setHovered(spec.uuid)} onMouseLeave={() => setHovered(null)} onClick={handleSpecClickFn(spec)} @@ -153,9 +154,11 @@ function RequestsSpecsList(props: { props.selected === spec.uuid ? "bg-accent" : "" )} > - - - + @@ -325,10 +328,38 @@ function RequestSpecRemovalButton(props: { spec: ProjectRequestSpec }) { ); } -function RequestSpecText(props: { spec: ProjectRequestSpec }) { +function RequestSpecText(props: { + spec: ProjectRequestSpec; + className?: string; + maxUrlLength?: number; +}) { + const getUrlVisibleText = (): string => { + const url = props.spec.url.trim(); + + if (!url) { + return "?"; + } + + if (!props.maxUrlLength) { + return props.spec.url; + } + + if (url.length <= props.maxUrlLength + "...".length) { + return props.spec.url; + } + + return "..." + url.slice(url.length - props.maxUrlLength); + }; + return ( - - {props.spec.method} {props.spec.url || "..."} + + {props.spec.method}{" "} + {getUrlVisibleText()} ); }