Skip to content
This repository has been archived by the owner on Jun 23, 2023. It is now read-only.

Add sunset notification to popup UI #985

Merged
merged 7 commits into from May 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/_locales/en_US/messages.json
Expand Up @@ -91,7 +91,9 @@
"popupBackButtonLabel": {
"message": "Back"
},

"sunsetMessage": {
"message": "Firefox Private Network will be discontinued on June 15, 2023."
},
"toastProxyOff": {
"message": "Firefox Private Network is off."
},
Expand Down
2 changes: 0 additions & 2 deletions src/background/main.js
Expand Up @@ -12,7 +12,6 @@ import {PrivacySettings} from "./privacySettings.js";
import {ProxyDownChecker} from "./proxyDownChecker.js";
import {ProxyStateObserver} from "./proxyStateObserver.js";
import {StorageUtils} from "./storageUtils.js";
import {Survey} from "./survey.js";
import {Telemetry} from "./telemetry.js";
import {UI} from "./ui.js";

Expand Down Expand Up @@ -47,7 +46,6 @@ class Main {
this.offlineManager = new OfflineManager(this);
this.proxyDownChecker = new ProxyDownChecker(this);
this.proxyStateObserver = new ProxyStateObserver(this);
this.survey = new Survey(this);
this.telemetry = new Telemetry(this);
this.ui = new UI(this);
this.ipinfo = new IPInfo(this);
Expand Down
37 changes: 0 additions & 37 deletions src/background/survey.js

This file was deleted.

41 changes: 5 additions & 36 deletions src/background/ui.js
Expand Up @@ -14,6 +14,7 @@ const PRIVACY_POLICY_URL = "https://www.mozilla.org/privacy/firefox-private-netw
const TERMS_AND_CONDITIONS_URL = "https://www.mozilla.org/about/legal/terms/firefox-private-network";
const GIVE_US_FEEDBACK_URL = "https://qsurvey.mozilla.com/s3/fx-private-network-beta-feedback";
const SUBSCRIPTION_URL = "https://fpn.firefox.com/r/browser/subscriptionNeeded";
const SUMO_URL= "https://support.mozilla.org/kb/firefox-private-network-no-longer-available?utm_source=inproduct&utm_medium=support";
const DEVICELIMIT_URL = "https://fpn.firefox.com/r/browser/devicelimit";

export class UI extends Component {
Expand Down Expand Up @@ -120,7 +121,9 @@ export class UI extends Component {
case "openDeviceLimitLink":
await this.openUrl(DEVICELIMIT_URL);
break;

case "openSumoLink":
await this.openUrl(SUMO_URL);
break;
case "telemetryEvent":
this.syncSendMessage("telemetryEvent", message.data);
break;
Expand Down Expand Up @@ -203,41 +206,7 @@ export class UI extends Component {
await this.showStatusPrompt();
}

await Promise.all([
this.updateIcon(),
this.sendDataToCurrentPort(),
]);
}

async updateIcon() {
if (constants.isAndroid) {
return;
}

let icon;
let text;
if (this.cachedProxyState === PROXY_STATE_INACTIVE ||
this.cachedProxyState === PROXY_STATE_CONNECTING ||
this.cachedProxyState === PROXY_STATE_OFFLINE ||
this.cachedProxyState === PROXY_STATE_CAPTIVE) {
icon = "/img/badge_off.svg";
text = "badgeOffText";
} else if (this.cachedProxyState === PROXY_STATE_ACTIVE) {
icon = "/img/badge_on.svg";
text = "badgeOnText";
} else {
icon = "/img/badge_warning.svg";
text = "badgeWarningText";
}

await Promise.all([
browser.browserAction.setIcon({
path: icon,
}),
browser.browserAction.setTitle({
title: this.getTranslation(text),
}),
]);
await this.sendDataToCurrentPort();
}

async sendDataToCurrentPort(logs = null) {
Expand Down
4 changes: 2 additions & 2 deletions src/manifest.json
Expand Up @@ -2,7 +2,7 @@
"manifest_version": 2,
"name": "__MSG_extensionName__",
"default_locale": "en_US",
"version": "24",
"version": "25",
"author": "Firefox",
"applications": {
"gecko": {
Expand All @@ -17,7 +17,7 @@
"description": "__MSG_extensionDescription__",
"browser_action": {
"browser_style": true,
"default_icon": "img/badge_off.svg",
"default_icon": "img/badge_warning.svg",
"default_title": "__MSG_extensionName__",
"default_popup": "popup/popup.html"
},
Expand Down
20 changes: 18 additions & 2 deletions src/popup/popup.css
Expand Up @@ -50,6 +50,7 @@
--black: #0c0c0D;
--grey-10: #F9F9FA;
--error: #FFBDC5;
--warning: #FFA436;

--link-link: var(--blue-50);
--link-hover: var(--blue-60);
Expand Down Expand Up @@ -635,18 +636,33 @@ footer,
text-decoration: none;
}

.sunset,
#proxyError,
#content p[data-mode="warning"] {
background-color: var(--error);
border-radius: 4px;
margin: 0 var(--edge-padding) var(--edge-padding);
padding: var(--edge-padding);
padding-inline-start: 32px;
position: relative;
display: flex;
text-align: left;
}

#proxyError,
#content p[data-mode="warning"] {
background-color: var(--error);
display: flex;
}

#sunsetSumoLink{
color: var(--grey-90);
}

.sunset {
background-color: var(--warning);
display: inline;
}

.sunset::before,
#proxyError::before,
#content p[data-mode="warning"]::before {
position: absolute;
Expand Down
4 changes: 4 additions & 0 deletions src/popup/popup.html
Expand Up @@ -16,6 +16,10 @@ <h1 id="introHeading">
</h1>
<button id="settingsButton" hidden></button>
</header>
<div class="sunset">
<p id="sunsetMessage"></p>
<a id="sunsetSumoLink" href="/"></a>
</div>
<p id="proxyError" hidden>
</p>
<main id="content">
Expand Down
11 changes: 11 additions & 0 deletions src/popup/popup.js
Expand Up @@ -19,6 +19,17 @@ async function init() {
View.sendMessage("telemetryEvent", { category: "general", event: "loadingError"});
}, loadingTimeout);

// Set 'FPN is being sunset' strings.
const sunsetMessage = document.getElementById("sunsetMessage");
sunsetMessage.textContent = browser.i18n.getMessage("sunsetMessage");
// Reusing 'Learn more' string
const sunsetSumoLink = document.getElementById("sunsetSumoLink");
sunsetSumoLink.textContent = browser.i18n.getMessage("viewDeviceLimitLink");
sunsetSumoLink.addEventListener("click", () => {
View.sendMessage("openSumoLink");
View.close();
});

let lastMessage;

let settingsButton = document.getElementById("settingsButton");
Expand Down
16 changes: 1 addition & 15 deletions test/extension.js
Expand Up @@ -150,20 +150,6 @@ module.exports = class ExtensionHelper {
By.id("secure-proxy_mozilla_com-browser-action")
);
assert.ok(!!id, "We have secure-proxy installed");

const style = await id.getAttribute("style");
if (style.includes("badge_warning.svg")) {
return "warning";
}

if (style.includes("badge_off.svg")) {
return "off";
}

if (style.includes("badge_on.svg")) {
return "on";
}

return "unknown";
return "warning";
lesleyjanenorton marked this conversation as resolved.
Show resolved Hide resolved
}
};
6 changes: 3 additions & 3 deletions test/testBasic.js
Expand Up @@ -169,15 +169,15 @@ describe("Secure-Proxy", function() {
buttonElm = await eh.driver.findElement(By.id("onboardingDoneButton"));
await buttonElm.click();

assert.equal(await eh.icon(), "off");
assert.equal(await eh.icon(), "warning");
});

it("Settings", async () => {
const popupHandle = await eh.openPanel();

assert.equal(await eh.settingsButtonStatus(), true);
assert.equal(await eh.backButtonStatus(), false);
assert.equal(await eh.icon(), "off");
assert.equal(await eh.icon(), "warning");

await eh.driver.setContext("content");

Expand Down Expand Up @@ -212,7 +212,7 @@ describe("Secure-Proxy", function() {

assert.equal(await eh.settingsButtonStatus(), true);
assert.equal(await eh.backButtonStatus(), false);
assert.equal(await eh.icon(), "off");
assert.equal(await eh.icon(), "warning");

await eh.driver.setContext("content");

Expand Down