Allow configuring gpgPath in browser settings (#45)
This commit is contained in:
@@ -680,17 +680,26 @@ async function receiveMessage(message, sender, sendResponse) {
|
||||
* @return void
|
||||
*/
|
||||
async function saveSettings(settings) {
|
||||
// 'default' is our reserved name for the default store
|
||||
delete settings.stores.default;
|
||||
let settingsToSave = deepCopy(settings);
|
||||
|
||||
var response = await hostAction(settings, "configure");
|
||||
// 'default' is our reserved name for the default store
|
||||
delete settingsToSave.stores.default;
|
||||
|
||||
var response = await hostAction(settingsToSave, "configure");
|
||||
if (response.status != "ok") {
|
||||
throw new Error(JSON.stringify(response)); // TODO handle host error
|
||||
}
|
||||
|
||||
// before save, make sure to remove store settings that we receive from the host app
|
||||
if (typeof settingsToSave.stores === "object") {
|
||||
for (var store in settingsToSave.stores) {
|
||||
delete settingsToSave.stores[store].settings;
|
||||
}
|
||||
}
|
||||
|
||||
for (var key in defaultSettings) {
|
||||
if (settings.hasOwnProperty(key)) {
|
||||
localStorage.setItem(key, JSON.stringify(settings[key]));
|
||||
if (settingsToSave.hasOwnProperty(key)) {
|
||||
localStorage.setItem(key, JSON.stringify(settingsToSave[key]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -50,6 +50,7 @@ function view(ctl, params) {
|
||||
var nodes = [];
|
||||
nodes.push(m("h3", "Basic settings"));
|
||||
nodes.push(createCheckbox.call(this, "autoSubmit", "Automatically submit forms after filling"));
|
||||
nodes.push(createInput.call(this, "gpgPath", "Custom gpg binary"));
|
||||
|
||||
nodes.push(m("h3", "Custom store locations"));
|
||||
nodes.push(
|
||||
@@ -97,6 +98,31 @@ function view(ctl, params) {
|
||||
return nodes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates vnode for a input setting
|
||||
*
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param string key Settings key
|
||||
* @param string title Settings title
|
||||
* @return Vnode
|
||||
*/
|
||||
function createInput(key, title) {
|
||||
return m("div.option", { class: key }, [
|
||||
m("label", [
|
||||
title,
|
||||
m("input[type=text]", {
|
||||
value: this.settings[key],
|
||||
placeholder: "/path/to/gpg",
|
||||
onchange: e => {
|
||||
this.settings[key] = e.target.value;
|
||||
this.saveEnabled = true;
|
||||
}
|
||||
})
|
||||
])
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates vnode for a checkbox setting
|
||||
*
|
||||
|
@@ -10,7 +10,7 @@ body {
|
||||
}
|
||||
|
||||
h3 {
|
||||
margin-top: 20px;
|
||||
margin-top: 25px;
|
||||
}
|
||||
|
||||
h3:first-child {
|
||||
@@ -19,16 +19,18 @@ h3:first-child {
|
||||
|
||||
.notice {
|
||||
margin-top: -10px;
|
||||
margin-bottom: 10px;
|
||||
color: gray;
|
||||
font-size: 10px;
|
||||
}
|
||||
|
||||
.option {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
height: 16px;
|
||||
line-height: 16px;
|
||||
margin-bottom: 10px;
|
||||
margin-top: 10px;
|
||||
margin-bottom: 5px;
|
||||
margin-top: 5px;
|
||||
}
|
||||
|
||||
.option input[type="checkbox"] {
|
||||
@@ -37,13 +39,28 @@ h3:first-child {
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.option.gpgPath input[type="text"] {
|
||||
background-color: white;
|
||||
color: black;
|
||||
border: none;
|
||||
border-bottom: 1px solid #aaa;
|
||||
border-radius: 0;
|
||||
min-height: 0px;
|
||||
height: 21px;
|
||||
overflow: hidden;
|
||||
padding: 0;
|
||||
width: 125px;
|
||||
margin-left: 5px;
|
||||
}
|
||||
|
||||
.option.custom-store input[type="text"] {
|
||||
background-color: white;
|
||||
color: black;
|
||||
border: none;
|
||||
border-bottom: 1px solid #aaa;
|
||||
height: 16px;
|
||||
line-height: 16px;
|
||||
border-radius: 0;
|
||||
min-height: 0px;
|
||||
height: 21px;
|
||||
margin: -4px 0 0 0;
|
||||
overflow: hidden;
|
||||
padding: 0;
|
||||
|
Reference in New Issue
Block a user