fixed merge conflicts

This commit is contained in:
Alberto Miranda
2016-08-19 01:09:43 -03:00
28 changed files with 493 additions and 203 deletions

View File

@@ -23,7 +23,8 @@ function renderGeneralSection (state) {
description: '',
icon: 'settings'
}, [
renderDownloadDirSelector(state)
renderDownloadPathSelector(state),
renderFileHandlers(state)
])
}
@@ -50,7 +51,7 @@ function renderPlayInVlcSelector (state) {
})
}
function renderDownloadDirSelector (state) {
function renderDownloadPathSelector (state) {
return renderFileSelector({
key: 'download-path',
label: 'Download Path',
@@ -63,10 +64,33 @@ function renderDownloadDirSelector (state) {
},
state.unsaved.prefs.downloadPath,
function (filePath) {
setStateValue('downloadPath', filePath)
dispatch('updatePreferences', 'downloadPath', filePath)
})
}
function renderFileHandlers (state) {
var definition = {
key: 'file-handlers',
label: 'Handle Torrent Files'
}
var buttonText = state.unsaved.prefs.isFileHandler
? 'Remove default app for torrent files'
: 'Make WebTorrent the default app for torrent files'
var controls = [(
<button key='toggle-handlers'
className='btn'
onClick={toggleFileHandlers}>
{buttonText}
</button>
)]
return renderControlGroup(definition, controls)
function toggleFileHandlers () {
var isFileHandler = state.unsaved.prefs.isFileHandler
dispatch('updatePreferences', 'isFileHandler', !isFileHandler)
}
}
// Renders a prefs section.
// - definition should be {icon, title, description}
// - controls should be an array of vdom elements
@@ -126,25 +150,24 @@ function renderCheckbox (definition, value, callback) {
// - value should be the current pref, a file or folder path
// - callback takes a new file or folder path
function renderFileSelector (definition, value, callback) {
return (
<div key={definition.key} className='control-group'>
<div className='controls'>
<label className='control-label'>
<div className='preference-title'>{definition.label}</div>
<div className='preference-description'>{definition.description}</div>
</label>
<div className='controls'>
<input type='text' className='file-picker-text'
id={definition.property}
disabled='disabled'
value={value} />
<button className='btn' onClick={handleClick}>
<i className='icon'>folder_open</i>
</button>
</div>
</div>
</div>
)
var controls = [(
<input
type='text'
className='file-picker-text'
key={definition.property}
id={definition.property}
disabled='disabled'
value={value} />
), (
<button
key={definition.property + '-btn'}
className='btn'
onClick={handleClick}>
<i className='icon'>folder_open</i>
</button>
)]
return renderControlGroup(definition, controls)
function handleClick () {
dialog.showOpenDialog(remote.getCurrentWindow(), definition.options, function (filenames) {
if (!Array.isArray(filenames)) return
@@ -153,6 +176,18 @@ function renderFileSelector (definition, value, callback) {
}
}
function setStateValue (property, value) {
dispatch('updatePreferences', property, value)
function renderControlGroup (definition, controls) {
return (
<div key={definition.key} className='control-group'>
<div className='controls'>
<label className='control-label'>
<div className='preference-title'>{definition.label}</div>
<div className='preference-description'>{definition.description}</div>
</label>
<div className='controls'>
{controls}
</div>
</div>
</div>
)
}