Skip to content

Commit

Permalink
feat: open agent refname url in new tab from agent page (#604)
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanhopperlowe authored Nov 15, 2024
1 parent e71a8c5 commit a082d6f
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 20 deletions.
25 changes: 20 additions & 5 deletions ui/admin/app/components/agent/AgentPublishStatus.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { $path } from "remix-routes";
import useSWR from "swr";

import { AgentBase } from "~/lib/model/agents";
import { ConsumptionUrl } from "~/lib/routers/baseRouter";
import { AssistantApiService } from "~/lib/service/api/assistantApiService";

import { TypographySmall } from "~/components/Typography";
Expand Down Expand Up @@ -86,12 +87,26 @@ export function AgentPublishStatus({

if (!agent.refNameAssigned) return <div />;

const agentUrl = ConsumptionUrl(`/${agent.refName}`);

return (
<CopyText
className="h-8 text-muted-foreground text-sm bg-background flex-row-reverse"
holdStatusDelay={10000}
text={`${window.location.protocol}//${window.location.host}/${agent.refName}`}
/>
<div className="flex items-center gap-2">
<CopyText
className="h-8 text-muted-foreground text-sm bg-background flex-row-reverse"
holdStatusDelay={6000}
text={agentUrl}
iconOnly
/>

<Link
target="_blank"
rel="noreferrer"
className="text-muted-foreground underline"
to={agentUrl}
>
{agentUrl}
</Link>
</div>
);
}
}
34 changes: 19 additions & 15 deletions ui/admin/app/components/composed/CopyText.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@ export function CopyText({
displayText = text,
className,
holdStatusDelay,
iconOnly,
}: {
text: string;
displayText?: string;
className?: string;
holdStatusDelay?: number;
iconOnly?: boolean;
}) {
const [isCopied, setIsCopied] = useState(false);

Expand All @@ -40,22 +42,24 @@ export function CopyText({
className
)}
>
<Tooltip>
<TooltipTrigger
type="button"
onClick={() => handleCopy(text)}
className="decoration-dotted underline-offset-4 underline text-ellipsis overflow-hidden text-nowrap"
>
<TypographyP className="truncate break-words p-2">
{displayText}
</TypographyP>
</TooltipTrigger>
{!iconOnly && (
<Tooltip>
<TooltipTrigger
type="button"
onClick={() => handleCopy(text)}
className="decoration-dotted underline-offset-4 underline text-ellipsis overflow-hidden text-nowrap"
>
<TypographyP className="truncate break-words p-2">
{displayText}
</TypographyP>
</TooltipTrigger>

<TooltipContent>
<b>Copy: </b>
{text}
</TooltipContent>
</Tooltip>
<TooltipContent>
<b>Copy: </b>
{text}
</TooltipContent>
</Tooltip>
)}

<Button
size="icon"
Expand Down
4 changes: 4 additions & 0 deletions ui/admin/app/lib/routers/baseRouter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,7 @@ export const ApiUrl = () => {

return window.location.origin + "/api";
};

export const ConsumptionUrl = (route: string) => {
return window.location.protocol + "//" + window.location.host + route;
};

0 comments on commit a082d6f

Please sign in to comment.