Merge pull request #1262 from ShivangiKakkar/fixes-885
#885 disables move tab to a new window when only one tab is opened
This commit is contained in:
commit
3d1dcd33d1
1 changed files with 40 additions and 25 deletions
|
@ -212,6 +212,27 @@ const Logic = {
|
|||
return false;
|
||||
},
|
||||
|
||||
async numTabs() {
|
||||
const activeTabs = await browser.tabs.query({windowId: browser.windows.WINDOW_ID_CURRENT});
|
||||
return activeTabs.length;
|
||||
},
|
||||
|
||||
_disableMoveTabs(message) {
|
||||
const moveTabsEl = document.querySelector("#container-info-movetabs");
|
||||
const fragment = document.createDocumentFragment();
|
||||
const incompatEl = document.createElement("div");
|
||||
|
||||
moveTabsEl.classList.remove("clickable");
|
||||
moveTabsEl.setAttribute("title", message);
|
||||
|
||||
fragment.appendChild(incompatEl);
|
||||
incompatEl.setAttribute("id", "container-info-movetabs-incompat");
|
||||
incompatEl.textContent = message;
|
||||
incompatEl.classList.add("container-info-tab-row");
|
||||
|
||||
moveTabsEl.parentNode.insertBefore(fragment, moveTabsEl.nextSibling);
|
||||
},
|
||||
|
||||
async refreshIdentities() {
|
||||
const [identities, state] = await Promise.all([
|
||||
browser.contextualIdentities.query({}),
|
||||
|
@ -698,25 +719,23 @@ Logic.registerPanel(P_CONTAINER_INFO, {
|
|||
});
|
||||
|
||||
// Check if the user has incompatible add-ons installed
|
||||
let incompatible = false;
|
||||
try {
|
||||
const incompatible = await browser.runtime.sendMessage({
|
||||
incompatible = await browser.runtime.sendMessage({
|
||||
method: "checkIncompatibleAddons"
|
||||
});
|
||||
} catch (e) {
|
||||
throw new Error("Could not check for incompatible add-ons.");
|
||||
}
|
||||
const moveTabsEl = document.querySelector("#container-info-movetabs");
|
||||
const numTabs = await Logic.numTabs();
|
||||
if (incompatible) {
|
||||
const fragment = document.createDocumentFragment();
|
||||
const incompatEl = document.createElement("div");
|
||||
|
||||
moveTabsEl.classList.remove("clickable");
|
||||
moveTabsEl.setAttribute("title", "Moving container tabs is incompatible with Pulse, PageShot, and SnoozeTabs.");
|
||||
|
||||
fragment.appendChild(incompatEl);
|
||||
incompatEl.setAttribute("id", "container-info-movetabs-incompat");
|
||||
incompatEl.textContent = "Incompatible with other Experiments.";
|
||||
incompatEl.classList.add("container-info-tab-row");
|
||||
|
||||
moveTabsEl.parentNode.insertBefore(fragment, moveTabsEl.nextSibling);
|
||||
} else {
|
||||
Logic._disableMoveTabs("Moving container tabs is incompatible with Pulse, PageShot, and SnoozeTabs.");
|
||||
return;
|
||||
} else if (numTabs === 1) {
|
||||
Logic._disableMoveTabs("Cannot move a tab from a single-tab window.");
|
||||
return;
|
||||
}
|
||||
Logic.addEnterHandler(moveTabsEl, async function () {
|
||||
await browser.runtime.sendMessage({
|
||||
method: "moveTabsToWindow",
|
||||
|
@ -725,10 +744,6 @@ Logic.registerPanel(P_CONTAINER_INFO, {
|
|||
});
|
||||
window.close();
|
||||
});
|
||||
}
|
||||
} catch (e) {
|
||||
throw new Error("Could not check for incompatible add-ons.");
|
||||
}
|
||||
},
|
||||
|
||||
// This method is called when the panel is shown.
|
||||
|
|
Loading…
Add table
Reference in a new issue