diff --git a/webextension/js/popup.js b/webextension/js/popup.js index 37666c1..2375d4c 100644 --- a/webextension/js/popup.js +++ b/webextension/js/popup.js @@ -595,6 +595,7 @@ Logic.registerPanel(P_CONTAINERS_LIST, { const hasTabs = (identity.hasHiddenTabs || identity.hasOpenTabs); const tr = document.createElement("tr"); const context = document.createElement("td"); + const hide = document.createElement("td"); const manage = document.createElement("td"); tr.classList.add("container-panel-row"); @@ -615,11 +616,24 @@ Logic.registerPanel(P_CONTAINERS_LIST, { context.querySelector(".container-name").textContent = identity.name; manage.innerHTML = ""; + hide.classList.add("hide-or-show-tabs", "pop-button"); + const img = document.createElement("img"); + img.classList.add("hide-or-show-tabs", "pop-button-image-small"); + if (identity.hasHiddenTabs) { + hide.title = escaped`Show ${identity.name} container`; + img.setAttribute("src", CONTAINER_HIDE_SRC); + } else { + hide.title = escaped`Hide ${identity.name} container`; + img.setAttribute("src", CONTAINER_UNHIDE_SRC); + } + hide.appendChild(img); + fragment.appendChild(tr); tr.appendChild(context); if (hasTabs) { + tr.appendChild(hide); tr.appendChild(manage); } @@ -627,16 +641,19 @@ Logic.registerPanel(P_CONTAINERS_LIST, { if (e.target.matches(".open-newtab") || e.target.parentNode.matches(".open-newtab") || e.type === "keydown") { - try { - browser.tabs.create({ - cookieStoreId: identity.cookieStoreId - }); - window.close(); - } catch (e) { - window.close(); - } - } else if (hasTabs) { + browser.tabs.create({ + cookieStoreId: identity.cookieStoreId + }).then(window.close).catch(window.close); + } else if (e.target.matches(".show-tabs") + || e.target.parentNode.matches(".show-tabs")) { Logic.showPanel(P_CONTAINER_INFO, identity); + } else if (e.target.matches(".hide-or-show-tabs") + || e.target.parentNode.matches(".hide-or-show-tabs")) { + browser.runtime.sendMessage({ + method: identity.hasHiddenTabs ? "showTabs" : "hideTabs", + windowId: browser.windows.WINDOW_ID_CURRENT, + cookieStoreId: identity.cookieStoreId + }).then(window.close).catch(window.close); } }); });