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-01 14:01:45 +02:00
|
|
|
<p className="text-sm font-medium">{t("APP.INFOS.CUSTOM_MODELS.ADD")}</p>
|
2024-01-16 08:33:43 +01:00
|
|
|
<p className="text-xs text-base-content/80">
|
2024-09-01 14:01:45 +02:00
|
|
|
{t("APP.INFOS.CUSTOM_MODELS.INFO")}
|
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"
|
|
|
|
>
|
|
|
|
{t("APP.INFOS.CUSTOM_MODELS.LINK_TEXT")}
|
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
|
|
|
}}
|
|
|
|
>
|
|
|
|
{t("APP.INFOS.CUSTOM_MODELS.SELECT_FOLDER")}
|
2023-07-22 13:07:53 +02:00
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|