From d685da085e5f1f125a5de14c45ad918596c6aaae Mon Sep 17 00:00:00 2001 From: Matt Cleinman <9295855+mcleinman@users.noreply.github.com> Date: Thu, 14 Nov 2024 13:55:29 -0800 Subject: [PATCH 1/5] FXVPN-32 add message (and fix bug involving lists and shared strings) --- .../downloadFirefox.js | 3 + .../getExtension.js | 3 + .../manifest.json | 63 +++++++++++++++++++ addons/strings.yaml | 37 +++++++---- docs/Components/Addons/index.md | 4 +- docs/Components/{ => Addons}/messages.md | 0 docs/Components/{ => Addons}/replacer.md | 0 scripts/addon/build.py | 11 +++- src/mozillavpn.cpp | 9 +++ 9 files changed, 114 insertions(+), 16 deletions(-) create mode 100644 addons/message_try_firefox_extension/downloadFirefox.js create mode 100644 addons/message_try_firefox_extension/getExtension.js create mode 100644 addons/message_try_firefox_extension/manifest.json rename docs/Components/{ => Addons}/messages.md (100%) rename docs/Components/{ => Addons}/replacer.md (100%) diff --git a/addons/message_try_firefox_extension/downloadFirefox.js b/addons/message_try_firefox_extension/downloadFirefox.js new file mode 100644 index 0000000000..16bbd9e880 --- /dev/null +++ b/addons/message_try_firefox_extension/downloadFirefox.js @@ -0,0 +1,3 @@ +((api) => { + api.urlOpener.openUrlLabel('downloadFirefoxWindows'); +}); diff --git a/addons/message_try_firefox_extension/getExtension.js b/addons/message_try_firefox_extension/getExtension.js new file mode 100644 index 0000000000..afe75188e2 --- /dev/null +++ b/addons/message_try_firefox_extension/getExtension.js @@ -0,0 +1,3 @@ +((api) => { + api.urlOpener.openUrlLabel('downloadExtension'); +}); diff --git a/addons/message_try_firefox_extension/manifest.json b/addons/message_try_firefox_extension/manifest.json new file mode 100644 index 0000000000..367f4f7c97 --- /dev/null +++ b/addons/message_try_firefox_extension/manifest.json @@ -0,0 +1,63 @@ +{ + "api_version": "0.1", + "id": "message_try_firefox_extension", + "name": "Try the Firefox extension", + "type": "message", + "conditions": { + "min_client_version": "2.25.1", + "enabled_features": ["webExtension"], + "trigger_time": 1209600, + "platforms": ["windows"] + }, + "message": { + "date": 1733157651, + "usesSharedStrings": true, + "shortVersion": "N/A", + "id": "message_try_firefox_extension.24", + "title": "vpn.tryFirefoxExtension.title", + "subtitle": "vpn.tryFirefoxExtension.subtitle", + "badge": "new_update", + "blocks": [ + { + "id": "c_1", + "type": "ulist", + "content": [ + { + "id": "l_1", + "type": "text", + "content": "vpn.tryFirefoxExtension.bullet1" + }, + { + "id": "l_2", + "type": "text", + "content": "vpn.tryFirefoxExtension.bullet2" + }, + { + "id": "l_3", + "type": "text", + "content": "vpn.tryFirefoxExtension.bullet3" + } + ] + }, + { + "id": "c_2", + "type": "text", + "content": "vpn.tryFirefoxExtension.finalLine" + }, + { + "id": "c_3", + "type": "button", + "style": "primary", + "content": "vpn.tryFirefoxExtension.getExtension", + "javascript": "getExtension.js" + }, + { + "id": "c_4", + "type": "button", + "style": "link", + "content": "vpn.tryFirefoxExtension.downloadFirefox", + "javascript": "downloadFirefox.js" + } + ] + } +} diff --git a/addons/strings.yaml b/addons/strings.yaml index 82b7afeaf0..b21dde8f41 100644 --- a/addons/strings.yaml +++ b/addons/strings.yaml @@ -33,7 +33,7 @@ # # String can contain just one specific type of argument, the short version number. # Add '%1' where the version should go. This will get replaced with the addons message's -# 'shortVersion' (from manifeste.json), for instance '2.24' +# 'shortVersion' (from manifest.json), for instance '2.24' # # # Strings that are no longer needed should be removed from this file. @@ -60,14 +60,29 @@ commonStrings: getHelpButton: value: Get help comment: Button label - # tester: - # value: shouldn't show up in translation file - # comment: Label for `Get help` button -# 224updateMessage: -# somethingSpecificJustToThisMessage: -# value: This is just an example -# comment: Use this as as template for strings that we expect to only use in one message. - -# These sample commented out translations can be used in testing, to ensure this is working as expected. Feel free to remove in -# the near future, when this file has more translations. +tryFirefoxExtension: + title: + value: Try the Firefox extension + comment: Title for message + subtitle: + value: Personalize your VPN protections to meet your web browsing needs. + comment: Subtitle for message + bullet1: + value: Turn off VPN for specific websites + comment: First bullet point + bullet2: + value: Set different locations for different websites, to see the web as you prefer + comment: Second bullet point + bullet3: + value: Keep protection for Firefox on, even when the Mozilla VPN app is off + comment: Third bullet point + finalLine: + value: Not using Firefox to browse? Give it a try. + comment: Final 'call to action' line of message + getExtension: + value: Get the extension + comment: Button label + downloadFirefox: + value: Download Firefox + comment: Button label diff --git a/docs/Components/Addons/index.md b/docs/Components/Addons/index.md index 8bd6b430c2..e84f908aab 100644 --- a/docs/Components/Addons/index.md +++ b/docs/Components/Addons/index.md @@ -26,12 +26,12 @@ least a manifest.json file. The properties of this JSON file are: | id | The ID of the add-on. It must match the file name | String | Yes | | name | The name of the add-on | String | Yes | | api_version | The version of the add-on framework | String | Yes | -| type | One of the supported types (message, guide, ...) | String | Yes | +| type | One of the supported types (message, replacer, ...) | String | Yes | | conditions | List of conditions to meet | Array of Condition objects | No | | state | Object describing the state of the addon | Collection of state objects | No | Based on the add-on type, extra properties can be in added. See the -[guide](https://github.com/mozilla-mobile/mozilla-vpn-client/blob/main/docs/guides.md), [message](https://github.com/mozilla-mobile/mozilla-vpn-client/blob/main/docs/message.md), and [replacer](https://github.com/mozilla-mobile/mozilla-vpn-client/blob/main/docs/replacer.md) documentation. +[message](./messages.md) and [replacer](./replacer.md) documentation. ## State Object diff --git a/docs/Components/messages.md b/docs/Components/Addons/messages.md similarity index 100% rename from docs/Components/messages.md rename to docs/Components/Addons/messages.md diff --git a/docs/Components/replacer.md b/docs/Components/Addons/replacer.md similarity index 100% rename from docs/Components/replacer.md rename to docs/Components/Addons/replacer.md diff --git a/scripts/addon/build.py b/scripts/addon/build.py index b15cb2ad3d..9f317a0876 100755 --- a/scripts/addon/build.py +++ b/scripts/addon/build.py @@ -97,7 +97,10 @@ def retrieve_strings_blocks(blocks, filename, strings, prefix, shared_strings): block_id = block["id"] legacy_block_string_id = f"{prefix}.block.{block_id}" - block_string_id = legacy_block_string_id if not shared_strings else block["content"] + if block["type"] in ["olist", "ulist"]: + block_string_id = legacy_block_string_id + else: + block_string_id = legacy_block_string_id if not shared_strings else block["content"] block_default_comment = comment_types.get(block["type"], "") if block_string_id in strings: exit(f"Duplicate block enum {block_string_id} when parsing {filename}") @@ -128,7 +131,8 @@ def retrieve_strings_blocks(blocks, filename, strings, prefix, shared_strings): ) subblock_id = subblock["id"] - subblock_string_id = f"{prefix}.block.{block_id}.{subblock_id}" if not shared_strings else subblock["content"] + legacy_subblock_string_id = f"{prefix}.block.{block_id}.{subblock_id}" + subblock_string_id = legacy_subblock_string_id if not shared_strings else subblock["content"] if subblock_string_id in strings: exit( f"Duplicate sub-block enum {subblock_string_id} when parsing {filename}" @@ -138,7 +142,8 @@ def retrieve_strings_blocks(blocks, filename, strings, prefix, shared_strings): translation_obj = find_translation_object(shared_strings, subblock_string_id) strings[subblock_string_id] = { "value": translation_obj['value'][0], - "comments": translation_comment(translation_obj) + "comments": translation_comment(translation_obj), + "legacy_id": legacy_subblock_string_id } else: strings[subblock_string_id] = { diff --git a/src/mozillavpn.cpp b/src/mozillavpn.cpp index 6927e13a79..27427e9614 100644 --- a/src/mozillavpn.cpp +++ b/src/mozillavpn.cpp @@ -1282,6 +1282,15 @@ void MozillaVPN::registerUrlOpenerLabels() { : settingsHolder->captivePortalIpv4Addresses().first()); }); + uo->registerUrlLabel("downloadExtension", []() -> QString { + // TODO: This link MUST be updated with a link to our extension + return "https://addons.mozilla.org/en-US/firefox/"; + }); + + uo->registerUrlLabel("downloadFirefoxWindows", []() -> QString { + return "https://www.mozilla.org/firefox/windows/"; + }); + uo->registerUrlLabel("inspector", []() -> QString { return "https://mozilla-mobile.github.io/mozilla-vpn-client/inspector/"; }); From 3bf28f43a62114b19a0a4cc4e61dc6cc4db41b47 Mon Sep 17 00:00:00 2001 From: Matt Cleinman <9295855+mcleinman@users.noreply.github.com> Date: Thu, 14 Nov 2024 15:52:56 -0800 Subject: [PATCH 2/5] add to addons parser --- addons/message_try_firefox_extension/manifest.json | 3 --- scripts/ci/jsonSchemas/message.json | 8 ++++++++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/addons/message_try_firefox_extension/manifest.json b/addons/message_try_firefox_extension/manifest.json index 367f4f7c97..9738b2570f 100644 --- a/addons/message_try_firefox_extension/manifest.json +++ b/addons/message_try_firefox_extension/manifest.json @@ -24,17 +24,14 @@ "content": [ { "id": "l_1", - "type": "text", "content": "vpn.tryFirefoxExtension.bullet1" }, { "id": "l_2", - "type": "text", "content": "vpn.tryFirefoxExtension.bullet2" }, { "id": "l_3", - "type": "text", "content": "vpn.tryFirefoxExtension.bullet3" } ] diff --git a/scripts/ci/jsonSchemas/message.json b/scripts/ci/jsonSchemas/message.json index 57aff18240..7471b04fe5 100644 --- a/scripts/ci/jsonSchemas/message.json +++ b/scripts/ci/jsonSchemas/message.json @@ -36,6 +36,14 @@ "type": "boolean", "description": "Determines whether we trigger a system notification. Default: true" }, + "usesSharedStrings": { + "type": "boolean", + "description": "Determines whether we use the new shared strings.yaml file. Default: false" + }, + "shortVersion": { + "type": "string", + "description": "Version number, short form. Ex: `2.24`" + }, "blocks": { "type": "array", "description": "The list of text blocks", From 22d3fec4cd0d54201a0b3259b7d0f89b357a0845 Mon Sep 17 00:00:00 2001 From: Matt Cleinman <9295855+mcleinman@users.noreply.github.com> Date: Fri, 22 Nov 2024 15:24:45 -0800 Subject: [PATCH 3/5] PR feedback --- addons/message_try_firefox_extension/downloadFirefox.js | 2 +- addons/message_try_firefox_extension/manifest.json | 2 +- src/mozillavpn.cpp | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/addons/message_try_firefox_extension/downloadFirefox.js b/addons/message_try_firefox_extension/downloadFirefox.js index 16bbd9e880..a8ca5d7fc6 100644 --- a/addons/message_try_firefox_extension/downloadFirefox.js +++ b/addons/message_try_firefox_extension/downloadFirefox.js @@ -1,3 +1,3 @@ ((api) => { - api.urlOpener.openUrlLabel('downloadFirefoxWindows'); + api.urlOpener.openUrlLabel('downloadFirefox'); }); diff --git a/addons/message_try_firefox_extension/manifest.json b/addons/message_try_firefox_extension/manifest.json index 9738b2570f..1e682065e7 100644 --- a/addons/message_try_firefox_extension/manifest.json +++ b/addons/message_try_firefox_extension/manifest.json @@ -12,7 +12,7 @@ "message": { "date": 1733157651, "usesSharedStrings": true, - "shortVersion": "N/A", + "shortVersion": "", "id": "message_try_firefox_extension.24", "title": "vpn.tryFirefoxExtension.title", "subtitle": "vpn.tryFirefoxExtension.subtitle", diff --git a/src/mozillavpn.cpp b/src/mozillavpn.cpp index 27427e9614..08504c6b16 100644 --- a/src/mozillavpn.cpp +++ b/src/mozillavpn.cpp @@ -1287,8 +1287,8 @@ void MozillaVPN::registerUrlOpenerLabels() { return "https://addons.mozilla.org/en-US/firefox/"; }); - uo->registerUrlLabel("downloadFirefoxWindows", []() -> QString { - return "https://www.mozilla.org/firefox/windows/"; + uo->registerUrlLabel("downloadFirefox", []() -> QString { + return "https://www.mozilla.org/firefox/new/"; }); uo->registerUrlLabel("inspector", []() -> QString { From 825f69764ef761d414ec106e8faf72ffb38a8dd3 Mon Sep 17 00:00:00 2001 From: Matt Cleinman <9295855+mcleinman@users.noreply.github.com> Date: Mon, 2 Dec 2024 13:08:22 -0500 Subject: [PATCH 4/5] make sure we don't accidentally show this to users --- addons/message_try_firefox_extension/manifest.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/addons/message_try_firefox_extension/manifest.json b/addons/message_try_firefox_extension/manifest.json index 1e682065e7..4f76b7f047 100644 --- a/addons/message_try_firefox_extension/manifest.json +++ b/addons/message_try_firefox_extension/manifest.json @@ -4,8 +4,7 @@ "name": "Try the Firefox extension", "type": "message", "conditions": { - "min_client_version": "2.25.1", - "enabled_features": ["webExtension"], + "min_client_version": "3.25.1", "trigger_time": 1209600, "platforms": ["windows"] }, From 24e96439415d03f60867acfca9dac87f0968c782 Mon Sep 17 00:00:00 2001 From: Matt Cleinman <9295855+mcleinman@users.noreply.github.com> Date: Mon, 2 Dec 2024 14:44:44 -0500 Subject: [PATCH 5/5] update the conditions --- addons/message_try_firefox_extension/manifest.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/message_try_firefox_extension/manifest.json b/addons/message_try_firefox_extension/manifest.json index 4f76b7f047..baac34c467 100644 --- a/addons/message_try_firefox_extension/manifest.json +++ b/addons/message_try_firefox_extension/manifest.json @@ -4,8 +4,9 @@ "name": "Try the Firefox extension", "type": "message", "conditions": { - "min_client_version": "3.25.1", + "min_client_version": "2.25.0", "trigger_time": 1209600, + "env": "staging", "platforms": ["windows"] }, "message": {