mirror of
https://github.com/Radarr/Radarr.git
synced 2026-04-18 21:35:51 -04:00
Convert MoveMovieModal to TypeScript
Co-authored-by: Mark McDowall <mark@mcdowall.ca>
This commit is contained in:
@@ -3,3 +3,7 @@
|
||||
|
||||
margin-right: auto;
|
||||
}
|
||||
|
||||
.folderRenameMessage {
|
||||
margin-top: 20px;
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
// Please do not change this file!
|
||||
interface CssExports {
|
||||
'doNotMoveButton': string;
|
||||
'folderRenameMessage': string;
|
||||
}
|
||||
export const cssExports: CssExports;
|
||||
export default cssExports;
|
||||
|
||||
@@ -1,93 +0,0 @@
|
||||
import PropTypes from 'prop-types';
|
||||
import React from 'react';
|
||||
import Button from 'Components/Link/Button';
|
||||
import Modal from 'Components/Modal/Modal';
|
||||
import ModalBody from 'Components/Modal/ModalBody';
|
||||
import ModalContent from 'Components/Modal/ModalContent';
|
||||
import ModalFooter from 'Components/Modal/ModalFooter';
|
||||
import ModalHeader from 'Components/Modal/ModalHeader';
|
||||
import { kinds, sizes } from 'Helpers/Props';
|
||||
import translate from 'Utilities/String/translate';
|
||||
import styles from './MoveMovieModal.css';
|
||||
|
||||
function MoveMovieModal(props) {
|
||||
const {
|
||||
originalPath,
|
||||
destinationPath,
|
||||
destinationRootFolder,
|
||||
isOpen,
|
||||
onModalClose,
|
||||
onSavePress,
|
||||
onMoveMoviePress
|
||||
} = props;
|
||||
|
||||
if (
|
||||
isOpen &&
|
||||
!originalPath &&
|
||||
!destinationPath &&
|
||||
!destinationRootFolder
|
||||
) {
|
||||
console.error('orginalPath and destinationPath OR destinationRootFolder must be provided');
|
||||
}
|
||||
|
||||
return (
|
||||
<Modal
|
||||
isOpen={isOpen}
|
||||
size={sizes.MEDIUM}
|
||||
closeOnBackgroundClick={false}
|
||||
onModalClose={onModalClose}
|
||||
>
|
||||
<ModalContent
|
||||
showCloseButton={true}
|
||||
onModalClose={onModalClose}
|
||||
>
|
||||
<ModalHeader>
|
||||
{translate('MoveFiles')}
|
||||
</ModalHeader>
|
||||
|
||||
<ModalBody>
|
||||
{
|
||||
destinationRootFolder ?
|
||||
translate('MoveFolders1', [destinationRootFolder]) :
|
||||
translate('MoveFolders2', [originalPath, destinationPath])
|
||||
}
|
||||
{
|
||||
destinationRootFolder ?
|
||||
<div>
|
||||
{translate('FolderMoveRenameWarning')}
|
||||
</div> :
|
||||
null
|
||||
}
|
||||
</ModalBody>
|
||||
|
||||
<ModalFooter>
|
||||
<Button
|
||||
className={styles.doNotMoveButton}
|
||||
onPress={onSavePress}
|
||||
>
|
||||
{translate('NoMoveFilesSelf')}
|
||||
</Button>
|
||||
|
||||
<Button
|
||||
kind={kinds.DANGER}
|
||||
onPress={onMoveMoviePress}
|
||||
>
|
||||
{translate('YesMoveFiles')}
|
||||
</Button>
|
||||
</ModalFooter>
|
||||
</ModalContent>
|
||||
</Modal>
|
||||
);
|
||||
}
|
||||
|
||||
MoveMovieModal.propTypes = {
|
||||
originalPath: PropTypes.string,
|
||||
destinationPath: PropTypes.string,
|
||||
destinationRootFolder: PropTypes.string,
|
||||
isOpen: PropTypes.bool.isRequired,
|
||||
onModalClose: PropTypes.func.isRequired,
|
||||
onSavePress: PropTypes.func.isRequired,
|
||||
onMoveMoviePress: PropTypes.func.isRequired
|
||||
};
|
||||
|
||||
export default MoveMovieModal;
|
||||
82
frontend/src/Movie/MoveMovie/MoveMovieModal.tsx
Normal file
82
frontend/src/Movie/MoveMovie/MoveMovieModal.tsx
Normal file
@@ -0,0 +1,82 @@
|
||||
import React from 'react';
|
||||
import Button from 'Components/Link/Button';
|
||||
import Modal from 'Components/Modal/Modal';
|
||||
import ModalBody from 'Components/Modal/ModalBody';
|
||||
import ModalContent from 'Components/Modal/ModalContent';
|
||||
import ModalFooter from 'Components/Modal/ModalFooter';
|
||||
import ModalHeader from 'Components/Modal/ModalHeader';
|
||||
import { kinds, sizes } from 'Helpers/Props';
|
||||
import translate from 'Utilities/String/translate';
|
||||
import styles from './MoveMovieModal.css';
|
||||
|
||||
interface MoveMovieModalProps {
|
||||
originalPath?: string;
|
||||
destinationPath?: string;
|
||||
destinationRootFolder?: string;
|
||||
isOpen: boolean;
|
||||
onModalClose: () => void;
|
||||
onSavePress: () => void;
|
||||
onMoveMoviePress: () => void;
|
||||
}
|
||||
|
||||
function MoveMovieModal({
|
||||
originalPath,
|
||||
destinationPath,
|
||||
destinationRootFolder,
|
||||
isOpen,
|
||||
onModalClose,
|
||||
onSavePress,
|
||||
onMoveMoviePress,
|
||||
}: MoveMovieModalProps) {
|
||||
if (isOpen && !originalPath && !destinationPath && !destinationRootFolder) {
|
||||
console.error(
|
||||
'originalPath and destinationPath OR destinationRootFolder must be provided'
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<Modal
|
||||
isOpen={isOpen}
|
||||
size={sizes.MEDIUM}
|
||||
closeOnBackgroundClick={false}
|
||||
onModalClose={onModalClose}
|
||||
>
|
||||
<ModalContent showCloseButton={true} onModalClose={onModalClose}>
|
||||
<ModalHeader>{translate('MoveFiles')}</ModalHeader>
|
||||
|
||||
<ModalBody>
|
||||
{destinationRootFolder
|
||||
? translate('MoveMovieFoldersToRootFolder', {
|
||||
destinationRootFolder,
|
||||
})
|
||||
: null}
|
||||
|
||||
{originalPath && destinationPath
|
||||
? translate('MoveMovieFoldersToNewPath', {
|
||||
originalPath,
|
||||
destinationPath,
|
||||
})
|
||||
: null}
|
||||
|
||||
{destinationRootFolder ? (
|
||||
<div className={styles.folderRenameMessage}>
|
||||
{translate('MoveMovieFoldersRenameFolderWarning')}
|
||||
</div>
|
||||
) : null}
|
||||
</ModalBody>
|
||||
|
||||
<ModalFooter>
|
||||
<Button className={styles.doNotMoveButton} onPress={onSavePress}>
|
||||
{translate('MoveMovieFoldersDontMoveFiles')}
|
||||
</Button>
|
||||
|
||||
<Button kind={kinds.DANGER} onPress={onMoveMoviePress}>
|
||||
{translate('MoveMovieFoldersMoveFiles')}
|
||||
</Button>
|
||||
</ModalFooter>
|
||||
</ModalContent>
|
||||
</Modal>
|
||||
);
|
||||
}
|
||||
|
||||
export default MoveMovieModal;
|
||||
Reference in New Issue
Block a user