mirror of
https://github.com/community-scripts/ProxmoxVE.git
synced 2025-07-05 13:37:39 +00:00
* Update ScriptAccordion and ScriptItem components for improved styling * Add README.md for Proxmox VE Helper-Scripts Frontend * Remove testing dependencies and related test files from the frontend project * Update analytics URL in siteConfig to point to community-scripts.org * Refactor ESLint configuration to have one source of truth and run "npm lint" to apply new changes * Update lint script in package.json to remove npm * Add 'next' option to ESLint configuration for improved compatibility * Update package dependencies and versions in package.json and package-lock.json * Refactor theme provider import and enhance calendar component for dynamic icon rendering * rename sidebar, alerts and buttons * rename description and interfaces files * rename more files * change folder name * Refactor tooltip logic to improve updateable condition handling * Enhance CommandMenu to prevent duplicate scripts across categories * Remove test step from frontend CI/CD workflow
105 lines
3.1 KiB
TypeScript
105 lines
3.1 KiB
TypeScript
import { BookOpenText, Code, Globe, LinkIcon, RefreshCcw } from "lucide-react";
|
|
|
|
import type { Script } from "@/lib/types";
|
|
|
|
import {
|
|
DropdownMenu,
|
|
DropdownMenuContent,
|
|
DropdownMenuItem,
|
|
DropdownMenuTrigger,
|
|
} from "@/components/ui/dropdown-menu";
|
|
import { Button } from "@/components/ui/button";
|
|
import { basePath } from "@/config/site-config";
|
|
|
|
function generateInstallSourceUrl(slug: string) {
|
|
const baseUrl = `https://raw.githubusercontent.com/community-scripts/${basePath}/main`;
|
|
return `${baseUrl}/install/${slug}-install.sh`;
|
|
}
|
|
|
|
function generateSourceUrl(slug: string, type: string) {
|
|
const baseUrl = `https://raw.githubusercontent.com/community-scripts/${basePath}/main`;
|
|
|
|
switch (type) {
|
|
case "vm":
|
|
return `${baseUrl}/vm/${slug}.sh`;
|
|
case "pve":
|
|
return `${baseUrl}/tools/pve/${slug}.sh`;
|
|
case "addon":
|
|
return `${baseUrl}/tools/addon/${slug}.sh`;
|
|
case "turnkey":
|
|
return `${baseUrl}/turnkey/${slug}.sh`;
|
|
default:
|
|
return `${baseUrl}/ct/${slug}.sh`; // fallback for "ct"
|
|
}
|
|
}
|
|
|
|
function generateUpdateUrl(slug: string) {
|
|
const baseUrl = `https://raw.githubusercontent.com/community-scripts/${basePath}/main`;
|
|
return `${baseUrl}/ct/${slug}.sh`;
|
|
}
|
|
|
|
type LinkItem = {
|
|
href: string;
|
|
icon: React.ReactNode;
|
|
text: string;
|
|
};
|
|
|
|
export default function Buttons({ item }: { item: Script }) {
|
|
const isCtOrDefault = ["ct"].includes(item.type);
|
|
const installSourceUrl = isCtOrDefault ? generateInstallSourceUrl(item.slug) : null;
|
|
const updateSourceUrl = isCtOrDefault ? generateUpdateUrl(item.slug) : null;
|
|
const sourceUrl = !isCtOrDefault ? generateSourceUrl(item.slug, item.type) : null;
|
|
|
|
const links = [
|
|
item.website && {
|
|
href: item.website,
|
|
icon: <Globe className="h-4 w-4" />,
|
|
text: "Website",
|
|
},
|
|
item.documentation && {
|
|
href: item.documentation,
|
|
icon: <BookOpenText className="h-4 w-4" />,
|
|
text: "Documentation",
|
|
},
|
|
installSourceUrl && {
|
|
href: installSourceUrl,
|
|
icon: <Code className="h-4 w-4" />,
|
|
text: "Install Source",
|
|
},
|
|
updateSourceUrl && item.updateable && {
|
|
href: updateSourceUrl,
|
|
icon: <RefreshCcw className="h-4 w-4" />,
|
|
text: "Update Source",
|
|
},
|
|
sourceUrl && {
|
|
href: sourceUrl,
|
|
icon: <Code className="h-4 w-4" />,
|
|
text: "Source Code",
|
|
},
|
|
].filter(Boolean) as LinkItem[];
|
|
|
|
if (links.length === 0)
|
|
return null;
|
|
|
|
return (
|
|
<DropdownMenu>
|
|
<DropdownMenuTrigger asChild>
|
|
<Button variant="outline" className="flex items-center gap-2">
|
|
<LinkIcon className="size-4" />
|
|
Links
|
|
</Button>
|
|
</DropdownMenuTrigger>
|
|
<DropdownMenuContent align="end">
|
|
{links.map((link, index) => (
|
|
<DropdownMenuItem key={index} asChild>
|
|
<a href={link.href} target="_blank" rel="noopener noreferrer" className="flex items-center gap-2">
|
|
<span className="text-muted-foreground size-4">{link.icon}</span>
|
|
<span>{link.text}</span>
|
|
</a>
|
|
</DropdownMenuItem>
|
|
))}
|
|
</DropdownMenuContent>
|
|
</DropdownMenu>
|
|
);
|
|
}
|