@@ -10,38 +10,20 @@ import { AllowedFrontendChannels } from '../../../shared/ipc-channels';
10
10
import { FileFormatInfo , Log } from '../../../shared/shared-types' ;
11
11
import { text } from '../../../shared/text' ;
12
12
import { getDotOpossumFilePath } from '../../../shared/write-file' ;
13
- import {
14
- LoggingListener ,
15
- ShowImportDialogListener ,
16
- useIpcRenderer ,
17
- } from '../../util/use-ipc-renderer' ;
13
+ import { LoggingListener , useIpcRenderer } from '../../util/use-ipc-renderer' ;
18
14
import { FilePathInput } from '../FilePathInput/FilePathInput' ;
19
15
import { LogDisplay } from '../LogDisplay/LogDisplay' ;
20
16
import { NotificationPopup } from '../NotificationPopup/NotificationPopup' ;
21
17
22
- export const ImportDialog : React . FC = ( ) => {
23
- const [ isOpen , setIsOpen ] = useState < boolean > ( false ) ;
24
- const [ fileFormat , setFileFormat ] = useState < FileFormatInfo > ( {
25
- name : '' ,
26
- extensions : [ ] ,
27
- } ) ;
28
-
29
- function resetState ( ) {
30
- setInputFilePath ( '' ) ;
31
- setOpossumFilePath ( '' ) ;
32
- setCurrentLog ( null ) ;
33
- }
34
-
35
- useIpcRenderer < ShowImportDialogListener > (
36
- AllowedFrontendChannels . ImportFileShowDialog ,
37
- ( _ , fileFormat ) => {
38
- resetState ( ) ;
39
- setFileFormat ( fileFormat ) ;
40
- setIsOpen ( true ) ;
41
- } ,
42
- [ ] ,
43
- ) ;
18
+ export interface ImportDialogProps {
19
+ fileFormat : FileFormatInfo ;
20
+ closeDialog : ( ) => void ;
21
+ }
44
22
23
+ export const ImportDialog : React . FC < ImportDialogProps > = ( {
24
+ fileFormat,
25
+ closeDialog,
26
+ } ) => {
45
27
const [ inputFilePath , setInputFilePath ] = useState < string > ( '' ) ;
46
28
const [ opossumFilePath , setOpossumFilePath ] = useState < string > ( '' ) ;
47
29
@@ -92,19 +74,20 @@ export const ImportDialog: React.FC = () => {
92
74
}
93
75
94
76
function onCancel ( ) : void {
95
- setIsOpen ( false ) ;
77
+ closeDialog ( ) ;
96
78
}
97
79
98
80
async function onConfirm ( ) : Promise < void > {
99
81
setIsLoading ( true ) ;
100
82
101
83
const success = await window . electronAPI . importFileConvertAndLoad (
102
84
inputFilePath ,
85
+ fileFormat . fileType ,
103
86
opossumFilePath ,
104
87
) ;
105
88
106
89
if ( success ) {
107
- setIsOpen ( false ) ;
90
+ closeDialog ( ) ;
108
91
}
109
92
110
93
setIsLoading ( false ) ;
@@ -113,6 +96,9 @@ export const ImportDialog: React.FC = () => {
113
96
return (
114
97
< NotificationPopup
115
98
header = { text . importDialog . title ( fileFormat ) }
99
+ width = { '80vw' }
100
+ minWidth = { '300px' }
101
+ maxWidth = { '700px' }
116
102
content = {
117
103
< div style = { { display : 'flex' , flexDirection : 'column' } } >
118
104
< MuiTypography > { text . importDialog . explanationText [ 0 ] } </ MuiTypography >
@@ -126,6 +112,7 @@ export const ImportDialog: React.FC = () => {
126
112
) }
127
113
text = { inputFilePath }
128
114
onClick = { selectInputFilePath }
115
+ tooltipProps = { { placement : 'top' } }
129
116
/>
130
117
< FilePathInput
131
118
label = { text . importDialog . opossumFilePath . textFieldLabel (
@@ -136,7 +123,7 @@ export const ImportDialog: React.FC = () => {
136
123
/>
137
124
</ div >
138
125
}
139
- isOpen = { isOpen }
126
+ isOpen = { true }
140
127
customAction = {
141
128
currentLog ? (
142
129
< MuiBox
0 commit comments