file-attachment: Add a setting option to show downloaded file in file manager.

This commit is contained in:
Akash Nimare
2018-08-01 23:50:02 +05:30
parent 3f6d256910
commit a5c1ae8726
4 changed files with 40 additions and 14 deletions

View File

@@ -388,8 +388,7 @@ i.open-tab-button {
.selected-css-path,
.download-folder-path {
background: #eeeeee;
padding: 10px;
margin-top: 10px;
padding: 5px 10px;
margin-right: 10px;
display: flex;
width: 90%;

View File

@@ -10,6 +10,8 @@ function handleExternalLink(event) {
const { url } = event;
const domainPrefix = DomainUtil.getDomain(this.props.index).url;
const downloadPath = ConfigUtil.getConfigItem('downloadsPath', `${app.getPath('downloads')}`);
const shouldShowInFolder = ConfigUtil.getConfigItem('showDownloadFolder', false);
// Whitelist URLs which are allowed to be opened in the app
const {
isInternalUrl: isWhiteListURL,
@@ -37,7 +39,13 @@ function handleExternalLink(event) {
}
downloadNotification.onclick = () => {
if (shouldShowInFolder) {
// Reveal file in download folder
shell.showItemInFolder(filePath);
} else {
// Open file in the default native app
shell.openItem(filePath);
}
};
ipcRenderer.removeAllListeners('downloadFileFailed');
});

View File

@@ -117,7 +117,8 @@ class ServerManagerView {
showNotification: true,
silent: false
},
downloadsPath: `${app.getPath('downloads')}`
downloadsPath: `${app.getPath('downloads')}`,
showDownloadFolder: false
};
// Platform specific settings

View File

@@ -97,6 +97,10 @@ class GeneralSection extends BaseSection {
</div>
<div class="title">Advanced</div>
<div class="settings-card">
<div class="setting-row" id="show-download-folder">
<div class="setting-description">Show downloaded file in the file manager</div>
<div class="setting-control"></div>
</div>
<div class="setting-row" id="download-folder">
<div class="setting-description">
Default download location
@@ -108,6 +112,7 @@ class GeneralSection extends BaseSection {
<div class="download-folder-path">${ConfigUtil.getConfigItem('downloadsPath', `${app.getPath('downloads')}`)}</div>
</div>
</div>
</div>
<div class="title">Reset Application Data</div>
<div class="settings-card">
@@ -138,6 +143,7 @@ class GeneralSection extends BaseSection {
this.showCustomCSSPath();
this.removeCustomCSS();
this.downloadFolder();
this.showDownloadFolder();
// Platform specific settings
@@ -385,6 +391,18 @@ class GeneralSection extends BaseSection {
});
}
showDownloadFolder() {
this.generateSettingOption({
$element: document.querySelector('#show-download-folder .setting-control'),
value: ConfigUtil.getConfigItem('showDownloadFolder', false),
clickHandler: () => {
const newValue = !ConfigUtil.getConfigItem('showDownloadFolder');
ConfigUtil.setConfigItem('showDownloadFolder', newValue);
this.showDownloadFolder();
}
});
}
}
module.exports = GeneralSection;