forked from nukeop/nuclear
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a box for setting the downloads dir in the downloads section
- Loading branch information
Showing
4 changed files
with
109 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { | ||
Button, | ||
Icon, | ||
Segment | ||
} from 'semantic-ui-react'; | ||
import { remote } from 'electron'; | ||
import { withTranslation } from 'react-i18next'; | ||
import { compose, withHandlers } from 'recompose'; | ||
|
||
import styles from './styles.scss'; | ||
|
||
const DownloadsHeader = ({ | ||
directory, | ||
setDirectory, | ||
t | ||
}) => { | ||
return ( | ||
<Segment className={styles.downloads_header}> | ||
<span className={styles.label}> | ||
Saving in: | ||
<span className={styles.directory}> | ||
{ directory } | ||
</span> | ||
</span> | ||
<Button | ||
icon | ||
inverted | ||
labelPosition='left' | ||
onClick={setDirectory} | ||
> | ||
<Icon name='folder open' /> | ||
{ t('downloads-dir-button') } | ||
</Button> | ||
</Segment> | ||
); | ||
}; | ||
|
||
DownloadsHeader.propTypes = { | ||
directory: PropTypes.string, | ||
setDirectory: PropTypes.func, | ||
setStringOption: PropTypes.func | ||
}; | ||
|
||
DownloadsHeader.defaultProps = { | ||
directory: '', | ||
setDirectory: () => {}, | ||
setStringOption: () => {} | ||
}; | ||
|
||
export default compose( | ||
withTranslation('settings'), | ||
withHandlers({ | ||
setDirectory: ({setStringOption}) => () => { | ||
let dialogResult = remote.dialog.showOpenDialog({ | ||
properties: ['openDirectory'] | ||
}); | ||
if (!_.isNil(dialogResult)) { | ||
setStringOption( | ||
'downloads.dir', | ||
_.head(dialogResult) | ||
); | ||
} | ||
} | ||
}) | ||
)(DownloadsHeader); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
.downloads_header { | ||
display: flex; | ||
flex-flow: row; | ||
justify-content: space-between; | ||
|
||
.label, .directory { | ||
display: flex; | ||
align-items: center; | ||
} | ||
|
||
.directory { | ||
margin-left: 1rem; | ||
font-weight: bold; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters