mirror of
https://github.com/community-scripts/ProxmoxVE.git
synced 2025-06-30 02:57:38 +00:00
Enhance InstallCommand component to support Gitea as an alternative source for installation scripts. Added informational alert for Gitea usage and refactored command generation logic to accommodate the new option.
This commit is contained in:
@ -1,17 +1,20 @@
|
|||||||
import CodeCopyButton from "@/components/ui/code-copy-button";
|
import CodeCopyButton from "@/components/ui/code-copy-button";
|
||||||
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
|
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
|
||||||
|
import { Alert, AlertDescription } from "@/components/ui/alert";
|
||||||
|
import { Info } from "lucide-react";
|
||||||
import { basePath } from "@/config/siteConfig";
|
import { basePath } from "@/config/siteConfig";
|
||||||
import { Script } from "@/lib/types";
|
import { Script } from "@/lib/types";
|
||||||
import { getDisplayValueFromType } from "../ScriptInfoBlocks";
|
import { getDisplayValueFromType } from "../ScriptInfoBlocks";
|
||||||
|
|
||||||
const getInstallCommand = (scriptPath = "", isAlpine = false) => {
|
const getInstallCommand = (scriptPath = "", isAlpine = false, useGitea = false) => {
|
||||||
const url = `https://raw.githubusercontent.com/community-scripts/${basePath}/main/${scriptPath}`;
|
const githubUrl = `https://raw.githubusercontent.com/community-scripts/${basePath}/main/${scriptPath}`;
|
||||||
return isAlpine ? `bash -c "$(curl -fsSL ${url})"` : `bash -c "$(curl -fsSL ${url})"`;
|
const giteaUrl = `https://git.community-scripts.org/community-scripts/${basePath}/raw/branch/main/${scriptPath}`;
|
||||||
|
const url = useGitea ? giteaUrl : githubUrl;
|
||||||
|
return `bash -c "$(curl -fsSL ${url})"`;
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function InstallCommand({ item }: { item: Script }) {
|
export default function InstallCommand({ item }: { item: Script }) {
|
||||||
const alpineScript = item.install_methods.find((method) => method.type === "alpine");
|
const alpineScript = item.install_methods.find((method) => method.type === "alpine");
|
||||||
|
|
||||||
const defaultScript = item.install_methods.find((method) => method.type === "default");
|
const defaultScript = item.install_methods.find((method) => method.type === "default");
|
||||||
|
|
||||||
const renderInstructions = (isAlpine = false) => (
|
const renderInstructions = (isAlpine = false) => (
|
||||||
@ -49,9 +52,20 @@ export default function InstallCommand({ item }: { item: Script }) {
|
|||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
const renderGiteaInfo = () => (
|
||||||
<div className="p-4">
|
<Alert className="mt-3 mb-3">
|
||||||
{alpineScript ? (
|
<Info className="h-4 w-4" />
|
||||||
|
<AlertDescription className="text-sm">
|
||||||
|
<strong>When to use Gitea:</strong> GitHub may have issues including slow connections, delayed updates after bug
|
||||||
|
fixes, no IPv6 support, API rate limits (60/hour). Use our Gitea mirror as a reliable alternative when
|
||||||
|
experiencing these issues.
|
||||||
|
</AlertDescription>
|
||||||
|
</Alert>
|
||||||
|
);
|
||||||
|
|
||||||
|
const renderScriptTabs = (useGitea = false) => {
|
||||||
|
if (alpineScript) {
|
||||||
|
return (
|
||||||
<Tabs defaultValue="default" className="mt-2 w-full max-w-4xl">
|
<Tabs defaultValue="default" className="mt-2 w-full max-w-4xl">
|
||||||
<TabsList>
|
<TabsList>
|
||||||
<TabsTrigger value="default">Default</TabsTrigger>
|
<TabsTrigger value="default">Default</TabsTrigger>
|
||||||
@ -59,19 +73,40 @@ export default function InstallCommand({ item }: { item: Script }) {
|
|||||||
</TabsList>
|
</TabsList>
|
||||||
<TabsContent value="default">
|
<TabsContent value="default">
|
||||||
{renderInstructions()}
|
{renderInstructions()}
|
||||||
<CodeCopyButton>{getInstallCommand(defaultScript?.script)}</CodeCopyButton>
|
<CodeCopyButton>{getInstallCommand(defaultScript?.script, false, useGitea)}</CodeCopyButton>
|
||||||
</TabsContent>
|
</TabsContent>
|
||||||
<TabsContent value="alpine">
|
<TabsContent value="alpine">
|
||||||
{renderInstructions(true)}
|
{renderInstructions(true)}
|
||||||
<CodeCopyButton>{getInstallCommand(alpineScript.script, true)}</CodeCopyButton>
|
<CodeCopyButton>{getInstallCommand(alpineScript.script, true, useGitea)}</CodeCopyButton>
|
||||||
</TabsContent>
|
</TabsContent>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
) : defaultScript?.script ? (
|
);
|
||||||
|
} else if (defaultScript?.script) {
|
||||||
|
return (
|
||||||
<>
|
<>
|
||||||
{renderInstructions()}
|
{renderInstructions()}
|
||||||
<CodeCopyButton>{getInstallCommand(defaultScript.script)}</CodeCopyButton>
|
<CodeCopyButton>{getInstallCommand(defaultScript.script, false, useGitea)}</CodeCopyButton>
|
||||||
</>
|
</>
|
||||||
) : null}
|
);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="p-4">
|
||||||
|
<Tabs defaultValue="github" className="w-full max-w-4xl">
|
||||||
|
<TabsList>
|
||||||
|
<TabsTrigger value="github">GitHub</TabsTrigger>
|
||||||
|
<TabsTrigger value="gitea">Gitea</TabsTrigger>
|
||||||
|
</TabsList>
|
||||||
|
<TabsContent value="github">
|
||||||
|
{renderScriptTabs(false)}
|
||||||
|
</TabsContent>
|
||||||
|
<TabsContent value="gitea">
|
||||||
|
{renderGiteaInfo()}
|
||||||
|
{renderScriptTabs(true)}
|
||||||
|
</TabsContent>
|
||||||
|
</Tabs>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
Reference in New Issue
Block a user