Skip to content

Commit 9570c91

Browse files
authored
Feature: Website - show default OS (#2790)
* Feature: Website - show default OS * add os fallback * Update ScriptItem.tsx * Update Buttons.tsx * Update Buttons.tsx * fix duplicate type check * fix import deps * add refreshccw
1 parent 705ad20 commit 9570c91

File tree

2 files changed

+40
-10
lines changed

2 files changed

+40
-10
lines changed

frontend/src/app/scripts/_components/ScriptItem.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ function ScriptItem({
2828
setSelectedScript(null);
2929
};
3030

31+
const defaultInstallMethod = item.install_methods?.[0];
32+
const os = defaultInstallMethod?.resources?.os || "Proxmox Node";
33+
const version = defaultInstallMethod?.resources?.version || "";
34+
3135
return (
3236
<div className="mr-7 mt-0 flex w-full min-w-fit">
3337
<div className="flex w-full min-w-fit">
@@ -60,6 +64,9 @@ function ScriptItem({
6064
<p className="w-full text-sm text-muted-foreground">
6165
Date added: {extractDate(item.date_created)}
6266
</p>
67+
<p className="text-sm text-muted-foreground">
68+
Default OS: {os} {version}
69+
</p>
6370
</div>
6471
<div className="flex gap-5">
6572
<DefaultSettings item={item} />

frontend/src/app/scripts/_components/ScriptItems/Buttons.tsx

Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,22 @@
11
import { Button } from "@/components/ui/button";
22
import { basePath } from "@/config/siteConfig";
33
import { Script } from "@/lib/types";
4-
import { BookOpenText, Code, Globe } from "lucide-react";
4+
import { BookOpenText, Code, Globe, RefreshCcw } from "lucide-react";
55
import Link from "next/link";
66

7-
const generateSourceUrl = (slug: string, type: string) => {
7+
const generateInstallSourceUrl = (slug: string) => {
88
const baseUrl = `https://raw.githubusercontent.com/community-scripts/${basePath}/main`;
9-
return type === "ct"
10-
? `${baseUrl}/install/${slug}-install.sh`
11-
: `${baseUrl}/${type}/${slug}.sh`;
9+
return `${baseUrl}/install/${slug}-install.sh`;
10+
};
11+
12+
const generateSourceUrl = (slug: string) => {
13+
const baseUrl = `https://raw.githubusercontent.com/community-scripts/${basePath}/main`;
14+
return `${baseUrl}/misc/${slug}.sh`;
15+
};
16+
17+
const generateUpdateUrl = (slug: string) => {
18+
const baseUrl = `https://raw.githubusercontent.com/community-scripts/${basePath}/main`;
19+
return `${baseUrl}/update/${slug}-update.sh`;
1220
};
1321

1422
interface ButtonLinkProps {
@@ -29,20 +37,35 @@ const ButtonLink = ({ href, icon, text }: ButtonLinkProps) => (
2937
);
3038

3139
export default function Buttons({ item }: { item: Script }) {
40+
const isCtOrDefault = ["ct"].includes(item.type);
41+
const installSourceUrl = isCtOrDefault ? generateInstallSourceUrl(item.slug) : null;
42+
const updateSourceUrl = isCtOrDefault ? generateUpdateUrl(item.slug) : null;
43+
const sourceUrl = !isCtOrDefault ? generateSourceUrl(item.slug) : null;
44+
3245
const buttons = [
3346
item.website && {
3447
href: item.website,
35-
icon: <Globe className="h-4 w-4" />,
48+
icon: <Globe className="h-4 w-4" />,
3649
text: "Website",
3750
},
3851
item.documentation && {
3952
href: item.documentation,
40-
icon: <BookOpenText className="h-4 w-4" />,
53+
icon: <BookOpenText className="h-4 w-4" />,
4154
text: "Documentation",
4255
},
43-
{
44-
href: generateSourceUrl(item.slug, item.type),
45-
icon: <Code className="h-4 w-4" />,
56+
installSourceUrl && {
57+
href: installSourceUrl,
58+
icon: <Code className="h-4 w-4" />,
59+
text: "Install-Source",
60+
},
61+
updateSourceUrl && {
62+
href: updateSourceUrl,
63+
icon: <RefreshCcw className="h-4 w-4" />,
64+
text: "Update-Source",
65+
},
66+
sourceUrl && {
67+
href: sourceUrl,
68+
icon: <Code className="h-4 w-4" />,
4669
text: "Source Code",
4770
},
4871
].filter(Boolean) as ButtonLinkProps[];

0 commit comments

Comments
 (0)