feat: adding wine prefix to backup creation on linux

This commit is contained in:
Chubby Granny Chaser
2025-05-12 10:55:44 +01:00
parent 427b77c597
commit 749a88b2b6
9 changed files with 98 additions and 19 deletions

View File

@@ -1,12 +1,16 @@
import cn from "classnames";
import { PlacesType, Tooltip } from "react-tooltip";
import "./button.scss";
import { useId } from "react";
export interface ButtonProps
extends React.DetailedHTMLProps<
React.ButtonHTMLAttributes<HTMLButtonElement>,
HTMLButtonElement
> {
tooltip?: string;
tooltipPlace?: PlacesType;
theme?: "primary" | "outline" | "dark" | "danger";
}
@@ -14,15 +18,32 @@ export function Button({
children,
theme = "primary",
className,
tooltip,
tooltipPlace = "top",
...props
}: Readonly<ButtonProps>) {
const id = useId();
const tooltipProps = tooltip
? {
"data-tooltip-id": id,
"data-tooltip-place": tooltipPlace,
"data-tooltip-content": tooltip,
}
: {};
return (
<button
type="button"
className={cn("button", `button--${theme}`, className)}
{...props}
>
{children}
</button>
<>
<button
type="button"
className={cn("button", `button--${theme}`, className)}
{...props}
{...tooltipProps}
>
{children}
</button>
{tooltip && <Tooltip id={id} />}
</>
);
}

View File

@@ -179,6 +179,7 @@ declare global {
onExtractionComplete: (
cb: (shop: GameShop, objectId: string) => void
) => () => Electron.IpcRenderer;
getDefaultWinePrefixSelectionPath: () => Promise<string | null>;
/* Download sources */
putDownloadSource: (

View File

@@ -43,7 +43,7 @@ export function CloudSyncModal({ visible, onClose }: CloudSyncModalProps) {
getGameBackupPreview,
} = useContext(cloudSyncContext);
const { objectId, shop, gameTitle, lastDownloadedOption } =
const { objectId, shop, gameTitle, game, lastDownloadedOption } =
useContext(gameDetailsContext);
const { showSuccessToast, showErrorToast } = useToast();
@@ -148,6 +148,8 @@ export function CloudSyncModal({ visible, onClose }: CloudSyncModalProps) {
]);
const disableActions = uploadingBackup || restoringBackup || deletingArtifact;
const isMissingWinePrefix =
window.electron.platform === "linux" && !game?.winePrefixPath;
return (
<Modal
@@ -175,10 +177,13 @@ export function CloudSyncModal({ visible, onClose }: CloudSyncModalProps) {
<Button
type="button"
onClick={() => uploadSaveGame(lastDownloadedOption?.title ?? null)}
tooltip={isMissingWinePrefix ? t("missing_wine_prefix") : undefined}
tooltipPlace="left"
disabled={
disableActions ||
!backupPreview?.overall.totalGames ||
artifacts.length >= backupsPerGameLimit
artifacts.length >= backupsPerGameLimit ||
isMissingWinePrefix
}
>
{uploadingBackup ? (

View File

@@ -144,6 +144,7 @@ export function GameOptionsModal({
const handleChangeWinePrefixPath = async () => {
const { filePaths } = await window.electron.showOpenDialog({
properties: ["openDirectory"],
defaultPath: await window.electron.getDefaultWinePrefixSelectionPath(),
});
if (filePaths && filePaths.length > 0) {
@@ -155,7 +156,10 @@ export function GameOptionsModal({
);
await updateGame();
} catch (error) {
showErrorToast(t("invalid_wine_prefix_path"));
showErrorToast(
t("invalid_wine_prefix_path"),
t("invalid_wine_prefix_path_description")
);
}
}
};