@@ -9,23 +9,22 @@ import tw from 'twin.macro';
99import Button from '@/components/elements/Button' ;
1010import useServer from '@/plugins/useServer' ;
1111import useFileManagerSwr from '@/plugins/useFileManagerSwr' ;
12- import useFlash from '@/plugins/useFlash ' ;
12+ import withFlash , { WithFlashProps } from '@/hoc/withFlash ' ;
1313
1414interface FormikValues {
1515 name : string ;
1616}
1717
18- type Props = RequiredModalProps & { files : string [ ] ; useMoveTerminology ?: boolean } ;
18+ type OwnProps = WithFlashProps & RequiredModalProps & { files : string [ ] ; useMoveTerminology ?: boolean } ;
1919
20- export default ( { files, useMoveTerminology, ...props } : Props ) => {
20+ const RenameFileModal = ( { flash , files, useMoveTerminology, ...props } : OwnProps ) => {
2121 const { uuid } = useServer ( ) ;
2222 const { mutate } = useFileManagerSwr ( ) ;
23- const { clearFlashes, clearAndAddHttpError } = useFlash ( ) ;
2423 const directory = ServerContext . useStoreState ( state => state . files . directory ) ;
2524 const setSelectedFiles = ServerContext . useStoreActions ( actions => actions . files . setSelectedFiles ) ;
2625
2726 const submit = ( { name } : FormikValues , { setSubmitting } : FormikHelpers < FormikValues > ) => {
28- clearFlashes ( 'files' ) ;
27+ flash . clearFlashes ( 'files' ) ;
2928
3029 const len = name . split ( '/' ) . length ;
3130 if ( files . length === 1 ) {
@@ -51,7 +50,7 @@ export default ({ files, useMoveTerminology, ...props }: Props) => {
5150 . catch ( error => {
5251 mutate ( ) ;
5352 setSubmitting ( false ) ;
54- clearAndAddHttpError ( { key : 'files' , error } ) ;
53+ flash . clearAndAddHttpError ( { key : 'files' , error } ) ;
5554 } )
5655 . then ( ( ) => props . onDismissed ( ) ) ;
5756 } ;
@@ -96,3 +95,5 @@ export default ({ files, useMoveTerminology, ...props }: Props) => {
9695 </ Formik >
9796 ) ;
9897} ;
98+
99+ export default withFlash ( RenameFileModal ) ;
0 commit comments