@@ -18,11 +18,14 @@ import StatedMenu from '../../shared/stated-menu';
18
18
19
19
import connectComponent from '../../../helpers/connect-component' ;
20
20
21
+ import { getInstallingAppsAsList } from '../../../state/app-management/utils' ;
22
+
21
23
import {
22
24
requestOpenInBrowser ,
23
25
requestResetPreferences ,
24
26
requestSetPreference ,
25
27
requestShowRequireRestartDialog ,
28
+ requestShowMessageBox ,
26
29
requestOpenInstallLocation ,
27
30
} from '../../../senders' ;
28
31
@@ -71,7 +74,7 @@ const getInstallLocationString = (installLocation) => {
71
74
} ;
72
75
73
76
const Preferences = ( {
74
- theme, classes, errorMonitoring, installLocation,
77
+ theme, classes, errorMonitoring, installLocation, installingAppCount ,
75
78
} ) => (
76
79
< div className = { classes . root } >
77
80
< AppBar position = "static" className = { classes . appBar } elevation = { 2 } >
@@ -134,18 +137,30 @@ const Preferences = ({
134
137
</ Typography >
135
138
< Paper className = { classes . paper } >
136
139
< List dense >
137
- < StatedMenu
138
- id = "installLocation"
139
- buttonElement = { (
140
- < ListItem button >
141
- < ListItemText primary = "Installation path" secondary = { getInstallLocationString ( installLocation ) } />
142
- < ChevronRightIcon color = "action" />
143
- </ ListItem >
144
- ) }
145
- >
146
- < MenuItem onClick = { ( ) => requestSetPreference ( 'installLocation' , 'home' ) } > ~/Applications/WebCatalog Apps (default)</ MenuItem >
147
- < MenuItem onClick = { ( ) => requestSetPreference ( 'installLocation' , 'root' ) } > /Applications/WebCatalog Apps (requires sudo)</ MenuItem >
148
- </ StatedMenu >
140
+ { installingAppCount > 0 ? (
141
+ < ListItem
142
+ button
143
+ onClick = { ( ) => {
144
+ requestShowMessageBox ( 'This preference cannot be changed when installing or updating apps.' ) ;
145
+ } }
146
+ >
147
+ < ListItemText primary = "Installation path" secondary = { getInstallLocationString ( installLocation ) } />
148
+ < ChevronRightIcon color = "action" />
149
+ </ ListItem >
150
+ ) : (
151
+ < StatedMenu
152
+ id = "installLocation"
153
+ buttonElement = { (
154
+ < ListItem button >
155
+ < ListItemText primary = "Installation path" secondary = { getInstallLocationString ( installLocation ) } />
156
+ < ChevronRightIcon color = "action" />
157
+ </ ListItem >
158
+ ) }
159
+ >
160
+ < MenuItem onClick = { ( ) => requestSetPreference ( 'installLocation' , 'home' ) } > ~/Applications/WebCatalog Apps (default)</ MenuItem >
161
+ < MenuItem onClick = { ( ) => requestSetPreference ( 'installLocation' , 'root' ) } > /Applications/WebCatalog Apps (requires sudo)</ MenuItem >
162
+ </ StatedMenu >
163
+ ) }
149
164
< Divider />
150
165
< ListItem button onClick = { requestOpenInstallLocation } >
151
166
< ListItemText primary = "Open installation path in Finder" />
@@ -174,12 +189,14 @@ Preferences.propTypes = {
174
189
classes : PropTypes . object . isRequired ,
175
190
errorMonitoring : PropTypes . bool . isRequired ,
176
191
installLocation : PropTypes . string . isRequired ,
192
+ installingAppCount : PropTypes . number . isRequired ,
177
193
} ;
178
194
179
195
const mapStateToProps = state => ( {
180
196
theme : state . preferences . theme ,
181
197
errorMonitoring : state . preferences . errorMonitoring ,
182
198
installLocation : state . preferences . installLocation ,
199
+ installingAppCount : getInstallingAppsAsList ( state ) . length ,
183
200
} ) ;
184
201
185
202
export default connectComponent (
0 commit comments