From 081d8a506a9276cee1a4f284c8626bf52d1fa972 Mon Sep 17 00:00:00 2001 From: Kendall Werts Date: Tue, 18 Feb 2020 15:11:24 -0600 Subject: [PATCH] working on info panel --- src/js/background/assignManager.js | 1 - src/js/pageAction.js | 16 +--------------- src/js/popup.js | 19 +++++++------------ src/js/utils.js | 20 ++++++++++++++++++++ src/pageActionPopup.html | 2 +- src/popup.html | 4 ++-- 6 files changed, 31 insertions(+), 31 deletions(-) diff --git a/src/js/background/assignManager.js b/src/js/background/assignManager.js index 861b928..9dd6e88 100644 --- a/src/js/background/assignManager.js +++ b/src/js/background/assignManager.js @@ -474,7 +474,6 @@ window.assignManager = { }, async _setOrRemoveAssignment(tabId, pageUrl, userContextId, remove) { - console.log(userContextId) let actionName; // https://github.com/mozilla/testpilot-containers/issues/626 diff --git a/src/js/pageAction.js b/src/js/pageAction.js index 74f670e..0a58c46 100644 --- a/src/js/pageAction.js +++ b/src/js/pageAction.js @@ -22,21 +22,7 @@ async function init() { tr.appendChild(td); Utils.addEnterHandler(tr, async () => { - const currentTab = await Utils.currentTab(); - const assignedUserContextId = Utils.userContextId(identity.cookieStoreId); - Utils.setOrRemoveAssignment( - currentTab.id, - currentTab.url, - assignedUserContextId, - false - ); - Utils.reloadInContainer( - currentTab.url, - false, - assignedUserContextId, - currentTab.index + 1, - currentTab.active - ); + Utils.alwaysOpenInContainer(identity); window.close(); }); }); diff --git a/src/js/popup.js b/src/js/popup.js index bb3508f..671df11 100644 --- a/src/js/popup.js +++ b/src/js/popup.js @@ -740,8 +740,6 @@ Logic.registerPanel(P_CONTAINER_INFO, { // This method is called when the object is registered. async initialize() { const closeContEl = document.querySelector("#close-container-info-panel"); - closeContEl.setAttribute("tabindex", "0"); - closeContEl.classList.add("firstTabindex"); Utils.addEnterHandler(closeContEl, () => { Logic.showPreviousPanel(); }); @@ -777,7 +775,12 @@ Logic.registerPanel(P_CONTAINER_INFO, { // Populating the panel: name and icon document.getElementById("container-info-title").textContent = identity.name; - + + const alwaysOpen = document.querySelector("#always-open-in-info-panel"); + Utils.addEnterHandler(alwaysOpen, async () => { + Utils.alwaysOpenInContainer(identity); + window.close(); + }); // Show or not the has-tabs section. for (let trHasTabs of document.getElementsByClassName("container-info-has-tabs")) { // eslint-disable-line prefer-const trHasTabs.style.display = !identity.hasHiddenTabs && !identity.hasOpenTabs ? "none" : ""; @@ -894,7 +897,6 @@ Logic.registerPanel(P_CONTAINERS_EDIT, { pickedFunction = async function (identity) { const currentTab = await Utils.currentTab(); const newUserContextId = Utils.userContextId(identity.cookieStoreId); - console.log(currentTab); Utils.reloadInContainer( currentTab.url, false, @@ -909,14 +911,7 @@ Logic.registerPanel(P_CONTAINERS_EDIT, { default: document.getElementById("picker-title").textContent = "Always Open This Site in"; pickedFunction = async function (identity) { - const currentTab = await Utils.currentTab(); - const assignedUserContextId = Utils.userContextId(identity.cookieStoreId); - Utils.setOrRemoveAssignment( - currentTab.id, - currentTab.url, - assignedUserContextId, - false - ); + Utils.alwaysOpenInContainer(identity); window.close(); }; break; diff --git a/src/js/utils.js b/src/js/utils.js index be7eb49..65480f3 100644 --- a/src/js/utils.js +++ b/src/js/utils.js @@ -99,6 +99,26 @@ const Utils = { tabIndex, active }); + }, + + async alwaysOpenInContainer(identity) { + const currentTab = await this.currentTab(); + const assignedUserContextId = this.userContextId(identity.cookieStoreId); + Utils.setOrRemoveAssignment( + currentTab.id, + currentTab.url, + assignedUserContextId, + false + ); + if (currentTab.cookieStoreId !== identity.cookieStoreId) { + Utils.reloadInContainer( + currentTab.url, + false, + assignedUserContextId, + currentTab.index + 1, + currentTab.active + ); + } } }; diff --git a/src/pageActionPopup.html b/src/pageActionPopup.html index 2449ff2..999218e 100644 --- a/src/pageActionPopup.html +++ b/src/pageActionPopup.html @@ -9,7 +9,7 @@

- Reopen and Always Open this Site in... + Always Open this Site in...


diff --git a/src/popup.html b/src/popup.html index cbe4e12..62ff714 100644 --- a/src/popup.html +++ b/src/popup.html @@ -202,7 +202,7 @@

Personal

- +
@@ -224,7 +224,7 @@