ction-status-box component in Bug 2008854
handleOnOffButtonClick() {
let isEnabled = !this._toggleEnabled;
if (isEnabled) {
this.dispatchEvent(
new CustomEvent(this.TOGGLE_ON_EVENT, {
bubbles: true,
composed: true,
})
);
} else {
this.dispatchEvent(
new CustomEvent(this.TOGGLE_OFF_EVENT, {
bubbles: true,
composed: true,
})
);
}
this._toggleEnabled = isEnabled;
}
focus() {
this.connectionToggleEl?.focus();
}
#keyListener(event) {
let keyCode = event.code;
switch (keyCode) {
case "ArrowUp":
// Intentional fall-through
case "ArrowDown": {
event.stopPropagation();
event.preventDefault();
let direction =
keyCode == "ArrowDown"
? Services.focus.MOVEFOCUS_FORWARD
: Services.focus.MOVEFOCUS_BACKWARD;
Services.focus.moveFocus(
window,
null,
direction,
Services.focus.FLAG_BYKEY
);
break;
}
}
}
updated(changedProperties) {
super.updated(changedProperties);
// If the toggle state isn't set, do so now and let it
// match the protection state.
if (!changedProperties.has("_toggleEnabled")) {
this._toggleEnabled = this.protectionEnabled;
}
if (!this.protectionEnabled && this._toggleEnabled) {
// After pressing the toggle, if somehow protection was turned off
// (eg. error thrown), unset the toggle.
this._toggleEnabled = false;
}
}
cardContentTemplate() {
const statusCardL10nId = this.protectionEnabled
? "ipprotection-connection-status-on"
: "ipprotection-connection-status-off";
const toggleL10nId = this.protectionEnabled
? "ipprotection-toggle-active"
: "ipprotection-toggle-inactive";
const toggleButtonType = this.protectionEnabled ? "secondary" : "primary";
const toggleButtonL10nId = this.protectionEnabled
? "ipprotection-button-turn-vpn-off"
: "ipprotection-button-turn-vpn-on";
const siteSettingsTemplate = this.protectionEnabled
? this.siteSettingsTemplate()
: null;
return html`