Commit 2a3c2495 authored by Thomas Greiner's avatar Thomas Greiner

Issue 6760 - Hide filter list title if none passed via subscribe link

parent caa99306
......@@ -181,8 +181,9 @@ options page.
To aid testing, the behavior of this page is affected by a number of URL
parameters:
* `addSubscription=true`: this parameter should trigger a dialog for adding
subscriptions as initiated by clicking on an "abp:subscribe" link
* `addSubscription=true`: triggers a dialog for adding
subscriptions as initiated by clicking on an "abp:subscribe" link (use
`title-none` or `title-url` as its value for links that don't include a title)
* `showPageOptions=true`: shows page-specific options
desktop-options.html
......@@ -196,8 +197,9 @@ parameters:
* `addonVersion`: sets addon version application parameter that is used for
creating the link to the version-specific release notes
* `addSubscription=true`: this parameter should trigger a dialog for adding
subscriptions as initiated by clicking on an "abp:subscribe" link
* `addSubscription=true`: triggers a dialog for adding
subscriptions as initiated by clicking on an "abp:subscribe" link (use
`title-none` or `title-url` as its value for links that don't include a title)
* `additionalSubscriptions`: A comma-separated list of subscription URLs that
simulates scenario of persistent filter lists preinstalled by administrators.
* `filterError=true`: causes filter validation to fail, showing validation
......
......@@ -528,11 +528,26 @@
// so we'll post the message after one second
setTimeout(() =>
{
const url = "http://example.com/custom.txt";
let title = "Custom subscription";
switch (params.addSubscription)
{
case "title-none":
title = null;
break;
// The extension falls back to the given URL
// when the link doesn't specify a title
// https://hg.adblockplus.org/adblockpluschrome/file/56f54c897e3a/subscriptionLink.postload.js#l86
case "title-url":
title = url;
break;
}
window.postMessage({
type: "message",
payload: {
title: "Custom subscription",
url: "http://example.com/custom.txt",
title, url,
confirm: true,
type: "subscriptions.add"
}
......
......@@ -1544,6 +1544,11 @@ body[data-dialog] #dialog-background
word-wrap: break-word;
}
#dialog-content-predefined h3:empty
{
display: none;
}
body:not([data-dialog="about"]) #dialog-title-about,
body:not([data-dialog="about"]) #dialog-content-about,
body:not([data-dialog="import"]) #dialog-title-import,
......
......@@ -1444,8 +1444,15 @@ port.onMessage.addListener((message) =>
case "addSubscription":
const subscription = message.args[0];
const dialog = E("dialog-content-predefined");
dialog.querySelector("h3").textContent = subscription.title || "";
dialog.querySelector(".url").textContent = subscription.url;
let {title, url} = subscription;
if (!title || title == url)
{
title = "";
}
dialog.querySelector("h3").textContent = title;
dialog.querySelector(".url").textContent = url;
openDialog("predefined");
break;
case "focusSection":
......
......@@ -21,10 +21,6 @@
}
}
},
"mops_error_title": {
"description": "Error for omitting filter list title when adding a new filter list",
"message": "Please enter a title"
},
"mops_error_url": {
"description": "Error for omitting filter list URL when adding a new filter list",
"message": "Enter a valid URL"
......
......@@ -76,7 +76,6 @@
<p>
<input name="title" type="text">
<label class="i18n_mops_subscribe_title"></label>
<span class="i18n_mops_error_title error" data-error="title"></span>
</p>
<p>
......
......@@ -335,11 +335,7 @@
const title = fields.title.value;
const url = fields.url.value;
if (!title)
{
setError(dialogSubscribe, "title");
}
else if (!url)
if (!url)
{
setError(dialogSubscribe, "url");
}
......@@ -362,10 +358,14 @@
{
case "addSubscription":
const [subscription] = msg.args;
setDialog(dialogSubscribe, {
title: subscription.title,
url: subscription.url
});
let {title, url} = subscription;
if (!title || title == url)
{
title = "";
}
setDialog(dialogSubscribe, {title, url});
break;
case "showPageOptions":
const [{host, whitelisted}] = msg.args;
......
......@@ -283,14 +283,18 @@ ul + button
color: #C11D26;
}
#dialog-subscribe [name="title"]:placeholder-shown,
#dialog-subscribe [name="title"]:placeholder-shown ~ *
{
display: none;
}
[role="dialog"]:not([data-error]) .error,
#dialog-subscribe:not([data-error="title"]) .error[data-error="title"],
#dialog-subscribe:not([data-error="url"]) .error[data-error="url"]
{
visibility: hidden;
}
#dialog-subscribe[data-error="title"] [name="title"]:placeholder-shown,
#dialog-subscribe[data-error="url"] [name="url"]:placeholder-shown
{
border-color: #C11D26;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment