/
AdvancedSettingsSection.js
290 lines (280 loc) · 11.7 KB
/
AdvancedSettingsSection.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
import PropTypes from 'prop-types'
import React from 'react'
import { ipcRenderer } from 'electron'
import { settingsActions } from 'stores/settings'
import { userStore } from 'stores/user'
import CustomCodeEditingDialog from 'Components/CustomCodeEditingDialog'
import DistributionConfig from 'Runtime/DistributionConfig'
import { AppSettings } from 'shared/Models/Settings'
import SettingsListSection from 'wbui/SettingsListSection'
import SettingsListItemSwitch from 'wbui/SettingsListItemSwitch'
import { withStyles } from '@material-ui/core/styles'
import WarningIcon from '@material-ui/icons/Warning'
import CodeIcon from '@material-ui/icons/Code'
import SettingsListItemButton from 'wbui/SettingsListItemButton'
import TuneIcon from '@material-ui/icons/Tune'
import SettingsListTypography from 'wbui/SettingsListTypography'
import modelCompare from 'wbui/react-addons-model-compare'
import partialShallowCompare from 'wbui/react-addons-partial-shallow-compare'
import { WB_OPEN_CERTIFICATES_FOLDER } from 'shared/ipcEvents'
import Platform from 'shared/Platform'
import SettingsListItemSelectInline from 'wbui/SettingsListItemSelectInline'
const styles = {}
@withStyles(styles)
class AdvancedSettingsSection extends React.Component {
/* **************************************************************************/
// Class
/* **************************************************************************/
static propTypes = {
showRestart: PropTypes.func.isRequired,
app: PropTypes.object.isRequired,
language: PropTypes.object.isRequired,
ui: PropTypes.object.isRequired,
os: PropTypes.object.isRequired
}
/* **************************************************************************/
// Data lifecycle
/* **************************************************************************/
state = {
customCSSEditorOpen: false
}
/* **************************************************************************/
// Rendering
/* **************************************************************************/
shouldComponentUpdate (nextProps, nextState) {
return (
modelCompare(this.props.app, nextProps.app, [
'ignoreGPUBlacklist',
'disableHardwareAcceleration',
'isolateMailboxProcesses',
'enableMixedSandboxMode',
'enableUseZoomForDSF',
'disableSmoothScrolling',
'enableAutofillService',
'enableWindowOpeningEngine',
'enableMouseNavigationDarwin',
'polyfillUserAgents',
'concurrentServiceLoadLimit',
'searchProvider',
'experimentalMicrosoftHTTP'
]) ||
modelCompare(this.props.language, nextProps.language, [
'inProcessSpellchecking'
]) ||
modelCompare(this.props.ui, nextProps.ui, [
'customMainCSS',
'showCtxMenuAdvancedLinkOptions'
]) ||
modelCompare(this.props.os, nextProps.os, [
'rawUseAsyncDownloadHandler'
]) ||
partialShallowCompare(
{ showRestart: this.props.showRestart },
this.state,
{ showRestart: nextProps.showRestart },
nextState
)
)
}
render () {
const {
showRestart,
app,
language,
ui,
os,
classes,
...passProps
} = this.props
const {
customCSSEditorOpen
} = this.state
return (
<SettingsListSection {...passProps} title='Advanced' icon={<TuneIcon />}>
<SettingsListItemSwitch
label='Ignore GPU Blacklist (Requires Restart)'
onChange={(evt, toggled) => {
showRestart()
settingsActions.sub.app.ignoreGPUBlacklist(toggled)
}}
checked={app.ignoreGPUBlacklist} />
<SettingsListItemSwitch
label='Hardware acceleration (Requires Restart)'
onChange={(evt, toggled) => {
showRestart()
settingsActions.sub.app.disableHardwareAcceleration(!toggled)
}}
checked={!app.disableHardwareAcceleration} />
<SettingsListItemSwitch
label='Isolate Account Processes (Requires Restart)'
onChange={(evt, toggled) => {
showRestart()
settingsActions.sub.app.setIsolateMailboxProcesses(toggled)
}}
checked={app.isolateMailboxProcesses} />
{AppSettings.SUPPORTS_MIXED_SANDBOX_MODE ? (
<SettingsListItemSwitch
label='Sandboxing (Requires Restart)'
onChange={(evt, toggled) => {
showRestart()
settingsActions.sub.app.setEnableMixedSandboxMode(toggled)
}}
checked={app.enableMixedSandboxMode} />
) : undefined}
<SettingsListItemSwitch
label='Automatically Polyfill UserAgents (Requires Restart)'
onChange={(evt, toggled) => {
showRestart()
settingsActions.sub.app.setPolyfillUserAgents(toggled)
}}
checked={app.polyfillUserAgents} />
<SettingsListItemSwitch
label='Use Zoom For DSF (Requires Restart)'
onChange={(evt, toggled) => {
showRestart()
settingsActions.sub.app.enableUseZoomForDSF(toggled)
}}
checked={app.enableUseZoomForDSF} />
<SettingsListItemSwitch
label='Smooth Scrolling (Requires Restart)'
onChange={(evt, toggled) => {
showRestart()
settingsActions.sub.app.disableSmoothScrolling(!toggled)
}}
checked={!app.disableSmoothScrolling} />
{process.platform === 'darwin' ? (
<SettingsListItemSwitch
label='Touchpad swipe Navigation (Requires Restart)'
onChange={(evt, toggled) => {
showRestart()
settingsActions.sub.app.setEnableMouseNavigationDarwin(toggled)
}}
checked={app.enableMouseNavigationDarwin} />
) : undefined}
{DistributionConfig.isSnapInstall ? undefined : (
<SettingsListItemSwitch
label='Autofill passwords on right click'
onChange={(evt, toggled) => { settingsActions.sub.app.setEnableAutofillServie(toggled) }}
checked={app.enableAutofillService} />
)}
<SettingsListItemSwitch
label='Show advanced link options on right click (experimental)'
onChange={(evt, toggled) => { settingsActions.sub.ui.setShowCtxMenuAdvancedLinkOptions(toggled) }}
checked={ui.showCtxMenuAdvancedLinkOptions} />
<SettingsListItemSwitch
label='In process spellchecking (Requires Restart)'
onChange={(evt, toggled) => {
showRestart()
settingsActions.sub.language.setInProcessSpellchecking(toggled)
}}
checked={language.inProcessSpellchecking} />
<SettingsListItemSwitch
label='Window opening engine (Recommended)'
secondary={app.enableWindowOpeningEngine === false ? (
<SettingsListTypography type='warning' icon={<WarningIcon />}>
All links will open in your default browser. You may experience
broken links and blank windows with this setting
</SettingsListTypography>
) : (
<SettingsListTypography>
All links will open in your default browser. You may experience
broken links and blank windows with this setting
</SettingsListTypography>
)}
onChange={(evt, toggled) => {
settingsActions.sub.app.setEnableWindowOpeningEngine(toggled)
}}
checked={app.enableWindowOpeningEngine} />
<SettingsListItemSwitch
label='Experimental Download Handler'
onChange={(evt, toggled) => settingsActions.sub.os.setUseAsyncDownloadHandler(toggled)}
checked={userStore.getState().wceUseAsyncDownloadHandler(os.rawUseAsyncDownloadHandler)} />
<SettingsListItemSwitch
label='Experimental Microsoft Account HTTP stack (Requires Restart)'
onChange={(evt, toggled) => {
showRestart()
settingsActions.sub.app.setExperimentalMicrosoftHTTP(toggled)
}}
checked={app.experimentalMicrosoftHTTP} />
<SettingsListItemSelectInline
label='Concurrent service load limit (Requires Restart)'
value={app.concurrentServiceLoadLimit}
options={[
{ value: 0, label: 'Auto', primaryText: 'Auto (Recommended)' },
{ value: -1, label: 'Unlimited (Not Recommended)' },
{ divider: true }
].concat(
Array.from(Array(20)).map((_, i) => {
return { value: i + 1, label: `${i + 1}` }
})
)}
onChange={(evt, value) => {
showRestart()
settingsActions.sub.app.setConcurrentServiceLoadLimit(value)
}} />
<SettingsListItemSelectInline
label='Search Provider'
value={app.searchProvider}
options={[
{
value: AppSettings.SEARCH_PROVIDERS.GOOGLE,
label: AppSettings.SEARCH_PROVIDER_NAMES[AppSettings.SEARCH_PROVIDERS.GOOGLE],
primaryText: AppSettings.SEARCH_PROVIDER_NAMES[AppSettings.SEARCH_PROVIDERS.GOOGLE]
},
{
value: AppSettings.SEARCH_PROVIDERS.GOOGLE_WB,
label: `${AppSettings.SEARCH_PROVIDER_NAMES[AppSettings.SEARCH_PROVIDERS.GOOGLE_WB]} (Wavebox)`,
primaryText: `${AppSettings.SEARCH_PROVIDER_NAMES[AppSettings.SEARCH_PROVIDERS.GOOGLE_WB]} - Opens in Wavebox`
},
{
value: AppSettings.SEARCH_PROVIDERS.BING,
label: AppSettings.SEARCH_PROVIDER_NAMES[AppSettings.SEARCH_PROVIDERS.BING],
primaryText: AppSettings.SEARCH_PROVIDER_NAMES[AppSettings.SEARCH_PROVIDERS.BING]
},
{
value: AppSettings.SEARCH_PROVIDERS.BING_WB,
label: `${AppSettings.SEARCH_PROVIDER_NAMES[AppSettings.SEARCH_PROVIDERS.BING_WB]} (Wavebox)`,
primaryText: `${AppSettings.SEARCH_PROVIDER_NAMES[AppSettings.SEARCH_PROVIDERS.BING_WB]} - Opens in Wavebox`
},
{
value: AppSettings.SEARCH_PROVIDERS.DUCK_DUCK,
label: AppSettings.SEARCH_PROVIDER_NAMES[AppSettings.SEARCH_PROVIDERS.DUCK_DUCK],
primaryText: AppSettings.SEARCH_PROVIDER_NAMES[AppSettings.SEARCH_PROVIDERS.DUCK_DUCK]
},
{
value: AppSettings.SEARCH_PROVIDERS.DUCK_DUCK_WB,
label: `${AppSettings.SEARCH_PROVIDER_NAMES[AppSettings.SEARCH_PROVIDERS.DUCK_DUCK_WB]} (Wavebox)`,
primaryText: `${AppSettings.SEARCH_PROVIDER_NAMES[AppSettings.SEARCH_PROVIDERS.DUCK_DUCK_WB]} - Opens in Wavebox`
}
]}
onChange={(evt, value) => settingsActions.sub.app.setSearchProvider(value)} />
<SettingsListItemButton
label='Main Window Custom CSS'
icon={<CodeIcon />}
onClick={() => {
this.setState({ customCSSEditorOpen: true })
}} />
<SettingsListItemButton
label='Site permissions'
onClick={() => { window.location.hash = '/site_permissions' }} />
<SettingsListItemButton
label='Custom HTTPS Certificates'
divider={false}
onClick={() => {
ipcRenderer.send(WB_OPEN_CERTIFICATES_FOLDER)
}} />
<CustomCodeEditingDialog
title='Main Window Custom CSS'
open={customCSSEditorOpen}
code={ui.customMainCSS}
mode='css'
onCancel={() => this.setState({ customCSSEditorOpen: false })}
onSave={(evt, css) => {
this.setState({ customCSSEditorOpen: false })
settingsActions.sub.ui.setCustomMainCSS(css)
}} />
</SettingsListSection>
)
}
}
export default AdvancedSettingsSection