Display default password even if there isn't a default username (#4900)

This fixes the display of the Deluge script.
This commit is contained in:
risc
2025-06-02 02:56:23 -05:00
committed by GitHub
parent 6239075c2d
commit 87f6c9ebde

View File

@ -5,7 +5,7 @@ import { Script } from "@/lib/types";
export default function DefaultPassword({ item }: { item: Script }) {
const { username, password } = item.default_credentials;
const hasDefaultLogin = username && password;
const hasDefaultLogin = username || password;
if (!hasDefaultLogin) return null;
@ -23,14 +23,17 @@ export default function DefaultPassword({ item }: { item: Script }) {
<p className="mb-2 text-sm">
You can use the following credentials to login to the {item.name} {item.type}.
</p>
{["username", "password"].map((type) => (
<div key={type} className="text-sm">
{type.charAt(0).toUpperCase() + type.slice(1)}:{" "}
<Button variant="secondary" size="null" onClick={() => copyCredential(type as "username" | "password")}>
{item.default_credentials[type as "username" | "password"]}
</Button>
</div>
))}
{["username", "password"].map((type) => {
const value = item.default_credentials[type as "username" | "password"];
return value && value.trim() !== "" ? (
<div key={type} className="text-sm">
{type.charAt(0).toUpperCase() + type.slice(1)}:{" "}
<Button variant="secondary" size="null" onClick={() => copyCredential(type as "username" | "password")}>
{value}
</Button>
</div>
) : null;
})}
</div>
</div>
);