mirror of
https://github.com/hydralauncher/hydra.git
synced 2026-01-26 04:11:02 +00:00
feat: adding wine prefix to backup creation on linux
This commit is contained in:
@@ -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} />}
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
1
src/renderer/src/declaration.d.ts
vendored
1
src/renderer/src/declaration.d.ts
vendored
@@ -179,6 +179,7 @@ declare global {
|
||||
onExtractionComplete: (
|
||||
cb: (shop: GameShop, objectId: string) => void
|
||||
) => () => Electron.IpcRenderer;
|
||||
getDefaultWinePrefixSelectionPath: () => Promise<string | null>;
|
||||
|
||||
/* Download sources */
|
||||
putDownloadSource: (
|
||||
|
||||
@@ -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 ? (
|
||||
|
||||
@@ -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")
|
||||
);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user