2023-07-22 13:07:53 +02:00
|
|
|
import React from "react";
|
2024-01-16 08:33:43 +01:00
|
|
|
import commands from "../../../common/commands";
|
2024-09-01 14:01:45 +02:00
|
|
|
import { useAtomValue } from "jotai";
|
|
|
|
import { translationAtom } from "@/atoms/translations-atom";
|
2023-07-22 13:07:53 +02:00
|
|
|
|
|
|
|
type CustomModelsFolderSelectProps = {
|
|
|
|
customModelsPath: string;
|
|
|
|
setCustomModelsPath: (arg: string) => void;
|
|
|
|
};
|
|
|
|
|
|
|
|
export function CustomModelsFolderSelect({
|
|
|
|
customModelsPath,
|
|
|
|
setCustomModelsPath,
|
|
|
|
}: CustomModelsFolderSelectProps) {
|
2024-09-01 14:01:45 +02:00
|
|
|
const t = useAtomValue(translationAtom);
|
|
|
|
|
2023-07-22 13:07:53 +02:00
|
|
|
return (
|
|
|
|
<div className="flex flex-col items-start gap-2">
|
2024-09-03 09:34:58 +02:00
|
|
|
<p className="text-sm font-medium">{t("SETTINGS.CUSTOM_MODELS.TITLE")}</p>
|
2024-01-16 08:33:43 +01:00
|
|
|
<p className="text-xs text-base-content/80">
|
2024-09-03 09:34:58 +02:00
|
|
|
{t("SETTINGS.CUSTOM_MODELS.DESCRIPTION")}
|
2024-01-16 08:33:43 +01:00
|
|
|
<a
|
|
|
|
href="https://github.com/upscayl/custom-models/blob/main/README.md"
|
2024-09-01 14:01:45 +02:00
|
|
|
className="link underline"
|
|
|
|
target="_blank"
|
|
|
|
>
|
2024-09-03 09:34:58 +02:00
|
|
|
{t("SETTINGS.CUSTOM_MODELS.LINK_TITLE")}
|
2024-01-16 08:33:43 +01:00
|
|
|
</a>
|
|
|
|
</p>
|
2023-07-22 13:07:53 +02:00
|
|
|
<p className="text-sm text-base-content/60">{customModelsPath}</p>
|
|
|
|
<button
|
2024-09-01 14:01:45 +02:00
|
|
|
className="btn btn-primary"
|
2023-07-22 13:07:53 +02:00
|
|
|
onClick={async () => {
|
|
|
|
const customModelPath = await window.electron.invoke(
|
2024-09-01 14:01:45 +02:00
|
|
|
commands.SELECT_CUSTOM_MODEL_FOLDER,
|
2023-07-22 13:07:53 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
if (customModelPath !== null) {
|
|
|
|
setCustomModelsPath(customModelPath);
|
|
|
|
window.electron.send(commands.GET_MODELS_LIST, customModelPath);
|
|
|
|
} else {
|
|
|
|
setCustomModelsPath("");
|
|
|
|
}
|
2024-09-01 14:01:45 +02:00
|
|
|
}}
|
|
|
|
>
|
2024-09-03 09:34:58 +02:00
|
|
|
{t("SETTINGS.CUSTOM_MODELS.BUTTON_FOLDER")}
|
2023-07-22 13:07:53 +02:00
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|