mirror of
https://github.com/hydralauncher/hydra.git
synced 2025-01-23 13:34:54 +03:00
feat: add modal to confirm remove from library
This commit is contained in:
parent
ceb8f164b7
commit
8669c1d660
@ -106,7 +106,9 @@
|
||||
"open_folder": "Open folder",
|
||||
"open_download_location": "Abrir local de download",
|
||||
"create_shortcut": "Create shortcut",
|
||||
"remove_files": "Remove files"
|
||||
"remove_files": "Remove files",
|
||||
"remove_from_library_title": "Are you sure?",
|
||||
"remove_from_library_description": "This will remove {{game}} from your library"
|
||||
},
|
||||
"activation": {
|
||||
"title": "Activate Hydra",
|
||||
|
@ -103,7 +103,9 @@
|
||||
"open_folder": "Abrir pasta",
|
||||
"open_download_location": "Abrir local de download",
|
||||
"create_shortcut": "Criar atalho",
|
||||
"remove_files": "Remover arquivos"
|
||||
"remove_files": "Remover arquivos",
|
||||
"remove_from_library_description": "Tem certeza que deseja remover {{game}} da sua biblioteca?",
|
||||
"remove_from_library_title": "Tem certeza?"
|
||||
},
|
||||
"activation": {
|
||||
"title": "Ativação",
|
||||
|
@ -7,6 +7,7 @@ import { gameDetailsContext } from "../game-details.context";
|
||||
import { NoEntryIcon, TrashIcon } from "@primer/octicons-react";
|
||||
import { DeleteGameModal } from "@renderer/pages/downloads/delete-game-modal";
|
||||
import { useDownload } from "@renderer/hooks";
|
||||
import { RemoveGameFromLibraryModal } from "./remove-from-library-modal";
|
||||
|
||||
export interface GameOptionsModalProps {
|
||||
visible: boolean;
|
||||
@ -26,6 +27,7 @@ export function GameOptionsModal({
|
||||
const { updateGame, openRepacksModal } = useContext(gameDetailsContext);
|
||||
|
||||
const [showDeleteModal, setShowDeleteModal] = useState(false);
|
||||
const [showRemoveGameModal, setShowRemoveGameModal] = useState(false);
|
||||
|
||||
const { removeGameInstaller, removeGameFromLibrary, isGameDeleting } =
|
||||
useDownload();
|
||||
@ -83,6 +85,13 @@ export function GameOptionsModal({
|
||||
deleteGame={handleDeleteGame}
|
||||
/>
|
||||
|
||||
<RemoveGameFromLibraryModal
|
||||
visible={showRemoveGameModal}
|
||||
onClose={() => setShowRemoveGameModal(false)}
|
||||
removeGameFromLibrary={handleRemoveGameFromLibrary}
|
||||
game={game}
|
||||
/>
|
||||
|
||||
<div className={styles.optionsContainer}>
|
||||
<div className={styles.gameOptionRow}>
|
||||
<Button
|
||||
@ -150,7 +159,7 @@ export function GameOptionsModal({
|
||||
</Button>
|
||||
|
||||
<Button
|
||||
onClick={handleRemoveGameFromLibrary}
|
||||
onClick={() => setShowRemoveGameModal(true)}
|
||||
style={{ alignSelf: "flex-end" }}
|
||||
theme="outline"
|
||||
disabled={deleting}
|
||||
|
@ -0,0 +1,10 @@
|
||||
import { SPACING_UNIT } from "../../../theme.css";
|
||||
import { style } from "@vanilla-extract/css";
|
||||
|
||||
export const deleteActionsButtonsCtn = style({
|
||||
display: "flex",
|
||||
width: "100%",
|
||||
justifyContent: "end",
|
||||
alignItems: "center",
|
||||
gap: `${SPACING_UNIT}px`,
|
||||
});
|
@ -0,0 +1,44 @@
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Button, Modal } from "@renderer/components";
|
||||
import * as styles from "./remove-from-library-modal.css";
|
||||
import { Game } from "@types";
|
||||
|
||||
interface RemoveGameFromLibraryModalProps {
|
||||
visible: boolean;
|
||||
game: Game;
|
||||
onClose: () => void;
|
||||
removeGameFromLibrary: () => Promise<void>;
|
||||
}
|
||||
|
||||
export function RemoveGameFromLibraryModal({
|
||||
onClose,
|
||||
game,
|
||||
visible,
|
||||
removeGameFromLibrary,
|
||||
}: RemoveGameFromLibraryModalProps) {
|
||||
const { t } = useTranslation("game_details");
|
||||
|
||||
const handleRemoveGame = async () => {
|
||||
await removeGameFromLibrary();
|
||||
onClose();
|
||||
};
|
||||
|
||||
return (
|
||||
<Modal
|
||||
visible={visible}
|
||||
title={t("remove_from_library_title")}
|
||||
description={t("remove_from_library_description", { game: game.title })}
|
||||
onClose={onClose}
|
||||
>
|
||||
<div className={styles.deleteActionsButtonsCtn}>
|
||||
<Button onClick={handleRemoveGame} theme="outline">
|
||||
{t("remove")}
|
||||
</Button>
|
||||
|
||||
<Button onClick={onClose} theme="primary">
|
||||
{t("cancel")}
|
||||
</Button>
|
||||
</div>
|
||||
</Modal>
|
||||
);
|
||||
}
|
Loading…
Reference in New Issue
Block a user