Fix: add set updateUrl option
This commit is contained in:
parent
ba4c06ae82
commit
0852b56ce4
|
@ -405,6 +405,19 @@
|
||||||
"message": "Install update",
|
"message": "Install update",
|
||||||
"description": "Label for the button to install an update for a single style"
|
"description": "Label for the button to install an update for a single style"
|
||||||
},
|
},
|
||||||
|
"installUpdateFrom": {
|
||||||
|
"message": "Currently the style is updated from $url$",
|
||||||
|
"description": "Label to describe where the style gets update",
|
||||||
|
"placeholders": {
|
||||||
|
"url": {
|
||||||
|
"content": "$1"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"installUpdateFromLabel": {
|
||||||
|
"message": "Install update from this URL",
|
||||||
|
"description": "Label for the checkbox to save current URL for update check"
|
||||||
|
},
|
||||||
"license": {
|
"license": {
|
||||||
"message": "License",
|
"message": "License",
|
||||||
"description": "Label for the license"
|
"description": "Label for the license"
|
||||||
|
|
|
@ -49,7 +49,7 @@ h1 small {
|
||||||
margin: 15px 0;
|
margin: 15px 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.live-reload {
|
.actions label {
|
||||||
width: fit-content;
|
width: fit-content;
|
||||||
width: -moz-fit-content;
|
width: -moz-fit-content;
|
||||||
display: flex;
|
display: flex;
|
||||||
|
@ -57,7 +57,7 @@ h1 small {
|
||||||
margin: 0.5em 0;
|
margin: 0.5em 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.live-reload input {
|
.actions label input {
|
||||||
margin: 0 0.5em 0 0;
|
margin: 0 0.5em 0 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,8 +7,7 @@ let pendingResource;
|
||||||
function install(style) {
|
function install(style) {
|
||||||
const request = Object.assign(style, {
|
const request = Object.assign(style, {
|
||||||
method: 'saveUsercss',
|
method: 'saveUsercss',
|
||||||
reason: 'update',
|
reason: 'update'
|
||||||
updateUrl: location.protocol === 'file:' ? null : location.href
|
|
||||||
});
|
});
|
||||||
return runtimeSend(request)
|
return runtimeSend(request)
|
||||||
.then(result => {
|
.then(result => {
|
||||||
|
@ -17,6 +16,9 @@ function install(style) {
|
||||||
$('button.install').textContent = 'Installed';
|
$('button.install').textContent = 'Installed';
|
||||||
$('button.install').disabled = true;
|
$('button.install').disabled = true;
|
||||||
$('button.install').classList.add('installed');
|
$('button.install').classList.add('installed');
|
||||||
|
$('.set-update-url').disabled = true;
|
||||||
|
$('.set-update-url-label').title = result.updateUrl ?
|
||||||
|
t('installUpdateFrom', result.updateUrl) : '';
|
||||||
window.dispatchEvent(new CustomEvent('installed', {detail: result}));
|
window.dispatchEvent(new CustomEvent('installed', {detail: result}));
|
||||||
})
|
})
|
||||||
.catch(err => {
|
.catch(err => {
|
||||||
|
@ -76,6 +78,21 @@ function initInstallPage({style, dup}, sourceLoader) {
|
||||||
install(style);
|
install(style);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
if (dup && dup.updateUrl === location.href) {
|
||||||
|
$('.set-update-url').checked = true;
|
||||||
|
// there is no way to "unset" updateUrl, you can only overwrite it.
|
||||||
|
$('.set-update-url').disabled = true;
|
||||||
|
} else if (!dup && location.protocol !== 'file:') {
|
||||||
|
$('.set-update-url').checked = true;
|
||||||
|
style.updateUrl = location.href;
|
||||||
|
}
|
||||||
|
$('.set-update-url').onchange = e => {
|
||||||
|
if (e.target.checked) {
|
||||||
|
style.updateUrl = location.href;
|
||||||
|
} else {
|
||||||
|
delete style.updateUrl;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
if (location.protocol === 'file:') {
|
if (location.protocol === 'file:') {
|
||||||
initLiveReload(sourceLoader);
|
initLiveReload(sourceLoader);
|
||||||
|
@ -85,7 +102,20 @@ function initInstallPage({style, dup}, sourceLoader) {
|
||||||
return $element({className: 'container', appendChild: [
|
return $element({className: 'container', appendChild: [
|
||||||
$element({className: 'header', appendChild: [
|
$element({className: 'header', appendChild: [
|
||||||
$element({className: 'actions', appendChild: [
|
$element({className: 'actions', appendChild: [
|
||||||
$element({tag: 'button', className: 'install', textContent: installButtonLabel()})
|
$element({tag: 'button', className: 'install', textContent: installButtonLabel()}),
|
||||||
|
$element({
|
||||||
|
tag: 'label',
|
||||||
|
title: dup && dup.updateUrl && t('installUpdateFrom', dup.updateUrl) || '',
|
||||||
|
className: 'set-update-url-label',
|
||||||
|
appendChild: [
|
||||||
|
$element({
|
||||||
|
tag: 'input',
|
||||||
|
type: 'checkbox',
|
||||||
|
className: 'set-update-url'
|
||||||
|
}),
|
||||||
|
$element({tag: 'span', textContent: t('installUpdateFromLabel')})
|
||||||
|
]
|
||||||
|
})
|
||||||
]}),
|
]}),
|
||||||
$element({tag: 'h1', appendChild: [
|
$element({tag: 'h1', appendChild: [
|
||||||
data.name,
|
data.name,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user