Code review fixes

This commit is contained in:
Jiří Vrba
2026-03-09 09:48:37 +01:00
parent b9ca6ea9db
commit 3e4a1b92eb
@@ -11,6 +11,7 @@ import {
} from "lucide-react"; } from "lucide-react";
import React, { useEffect, useMemo, useState } from "react"; import React, { useEffect, useMemo, useState } from "react";
import { toast } from "sonner"; import { toast } from "sonner";
import copy from "copy-to-clipboard";
import { AlertBlock } from "@/components/shared/alert-block"; import { AlertBlock } from "@/components/shared/alert-block";
import { DateTooltip } from "@/components/shared/date-tooltip"; import { DateTooltip } from "@/components/shared/date-tooltip";
import { DialogAction } from "@/components/shared/dialog-action"; import { DialogAction } from "@/components/shared/dialog-action";
@@ -31,7 +32,6 @@ import { ClearDeployments } from "./clear-deployments";
import { KillBuild } from "./kill-build"; import { KillBuild } from "./kill-build";
import { RefreshToken } from "./refresh-token"; import { RefreshToken } from "./refresh-token";
import { ShowDeployment } from "./show-deployment"; import { ShowDeployment } from "./show-deployment";
import copy from "copy-to-clipboard";
interface Props { interface Props {
id: string; id: string;
@@ -99,6 +99,11 @@ export const ShowDeployments = ({
new Set(), new Set(),
); );
const webhookUrl = useMemo(
() => `${url}/api/deploy${type === "compose" ? "/compose" : ""}/${refreshToken}`,
[url, refreshToken, type]
);
const MAX_DESCRIPTION_LENGTH = 200; const MAX_DESCRIPTION_LENGTH = 200;
const truncateDescription = (description: string): string => { const truncateDescription = (description: string): string => {
@@ -231,17 +236,20 @@ export const ShowDeployments = ({
tabIndex={0} tabIndex={0}
className="p-2 rounded-md ml-1 mr-1 hover:border-primary hover:text-primary-foreground hover:bg-primary hover:cursor-pointer whitespace-normal break-all" className="p-2 rounded-md ml-1 mr-1 hover:border-primary hover:text-primary-foreground hover:bg-primary hover:cursor-pointer whitespace-normal break-all"
variant="outline" variant="outline"
onKeyDown={(event) => {
if (event.key === "Enter" || event.key === " ") {
event.preventDefault();
copy(webhookUrl);
toast.success("Copied to clipboard.");
}
}}
onClick={() => { onClick={() => {
copy( copy(webhookUrl);
`${url}/api/deploy${type === "compose" ? "/compose" : ""}/${refreshToken}`,
);
toast.success("Copied to clipboard."); toast.success("Copied to clipboard.");
}} }}
> >
{`${url}/api/deploy${ {webhookUrl}
type === "compose" ? "/compose" : "" <Copy className="h-4 w-4 ml-2" />
}/${refreshToken}`}
<Copy className="h-4 w-4 ml-1 text-muted-foreground" />
</Badge> </Badge>
{(type === "application" || type === "compose") && ( {(type === "application" || type === "compose") && (
<RefreshToken id={id} type={type} /> <RefreshToken id={id} type={type} />