Added unsort tabs functionality
This commit is contained in:
parent
546ee7a098
commit
cff5a432f6
7 changed files with 81 additions and 25 deletions
28
package-lock.json
generated
28
package-lock.json
generated
|
@ -1,12 +1,12 @@
|
||||||
{
|
{
|
||||||
"name": "testpilot-containers",
|
"name": "testpilot-containers",
|
||||||
"version": "8.1.3",
|
"version": "8.2.0",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "testpilot-containers",
|
"name": "testpilot-containers",
|
||||||
"version": "8.1.1",
|
"version": "8.2.0",
|
||||||
"license": "MPL-2.0",
|
"license": "MPL-2.0",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"addons-linter": "^5.28.0",
|
"addons-linter": "^5.28.0",
|
||||||
|
@ -15032,8 +15032,7 @@
|
||||||
"version": "5.3.2",
|
"version": "5.3.2",
|
||||||
"resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.3.2.tgz",
|
"resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.3.2.tgz",
|
||||||
"integrity": "sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==",
|
"integrity": "sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==",
|
||||||
"dev": true,
|
"dev": true
|
||||||
"requires": {}
|
|
||||||
},
|
},
|
||||||
"acorn-walk": {
|
"acorn-walk": {
|
||||||
"version": "7.2.0",
|
"version": "7.2.0",
|
||||||
|
@ -17246,15 +17245,13 @@
|
||||||
"version": "4.0.2",
|
"version": "4.0.2",
|
||||||
"resolved": "https://registry.npmjs.org/eslint-plugin-no-unsanitized/-/eslint-plugin-no-unsanitized-4.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/eslint-plugin-no-unsanitized/-/eslint-plugin-no-unsanitized-4.0.2.tgz",
|
||||||
"integrity": "sha512-Pry0S9YmHoz8NCEMRQh7N0Yexh2MYCNPIlrV52hTmS7qXnTghWsjXouF08bgsrrZqaW9tt1ZiK3j5NEmPE+EjQ==",
|
"integrity": "sha512-Pry0S9YmHoz8NCEMRQh7N0Yexh2MYCNPIlrV52hTmS7qXnTghWsjXouF08bgsrrZqaW9tt1ZiK3j5NEmPE+EjQ==",
|
||||||
"dev": true,
|
"dev": true
|
||||||
"requires": {}
|
|
||||||
},
|
},
|
||||||
"eslint-plugin-promise": {
|
"eslint-plugin-promise": {
|
||||||
"version": "5.2.0",
|
"version": "5.2.0",
|
||||||
"resolved": "https://registry.npmjs.org/eslint-plugin-promise/-/eslint-plugin-promise-5.2.0.tgz",
|
"resolved": "https://registry.npmjs.org/eslint-plugin-promise/-/eslint-plugin-promise-5.2.0.tgz",
|
||||||
"integrity": "sha512-SftLb1pUG01QYq2A/hGAWfDRXqYD82zE7j7TopDOyNdU+7SvvoXREls/+PRTY17vUXzXnZA/zfnyKgRH6x4JJw==",
|
"integrity": "sha512-SftLb1pUG01QYq2A/hGAWfDRXqYD82zE7j7TopDOyNdU+7SvvoXREls/+PRTY17vUXzXnZA/zfnyKgRH6x4JJw==",
|
||||||
"dev": true,
|
"dev": true
|
||||||
"requires": {}
|
|
||||||
},
|
},
|
||||||
"eslint-scope": {
|
"eslint-scope": {
|
||||||
"version": "5.1.1",
|
"version": "5.1.1",
|
||||||
|
@ -19763,8 +19760,7 @@
|
||||||
"version": "7.5.9",
|
"version": "7.5.9",
|
||||||
"resolved": "https://registry.npmjs.org/ws/-/ws-7.5.9.tgz",
|
"resolved": "https://registry.npmjs.org/ws/-/ws-7.5.9.tgz",
|
||||||
"integrity": "sha512-F+P9Jil7UiSKSkppIiD94dN07AwvFixvLIj1Og1Rl9GGMuNipJnV9JzjD6XuqmAeiswGvUmNLjr5cFuXwNS77Q==",
|
"integrity": "sha512-F+P9Jil7UiSKSkppIiD94dN07AwvFixvLIj1Og1Rl9GGMuNipJnV9JzjD6XuqmAeiswGvUmNLjr5cFuXwNS77Q==",
|
||||||
"dev": true,
|
"dev": true
|
||||||
"requires": {}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -21971,8 +21967,7 @@
|
||||||
"version": "0.36.2",
|
"version": "0.36.2",
|
||||||
"resolved": "https://registry.npmjs.org/postcss-syntax/-/postcss-syntax-0.36.2.tgz",
|
"resolved": "https://registry.npmjs.org/postcss-syntax/-/postcss-syntax-0.36.2.tgz",
|
||||||
"integrity": "sha512-nBRg/i7E3SOHWxF3PpF5WnJM/jQ1YpY9000OaVXlAQj6Zp/kIqJxEDWIZ67tAd7NLuk7zqN4yqe9nc0oNAOs1w==",
|
"integrity": "sha512-nBRg/i7E3SOHWxF3PpF5WnJM/jQ1YpY9000OaVXlAQj6Zp/kIqJxEDWIZ67tAd7NLuk7zqN4yqe9nc0oNAOs1w==",
|
||||||
"dev": true,
|
"dev": true
|
||||||
"requires": {}
|
|
||||||
},
|
},
|
||||||
"postcss-value-parser": {
|
"postcss-value-parser": {
|
||||||
"version": "4.2.0",
|
"version": "4.2.0",
|
||||||
|
@ -22826,8 +22821,7 @@
|
||||||
"version": "3.7.0",
|
"version": "3.7.0",
|
||||||
"resolved": "https://registry.npmjs.org/sinon-chai/-/sinon-chai-3.7.0.tgz",
|
"resolved": "https://registry.npmjs.org/sinon-chai/-/sinon-chai-3.7.0.tgz",
|
||||||
"integrity": "sha512-mf5NURdUaSdnatJx3uhoBOrY9dtL19fiOtAdT1Azxg3+lNJFiuN0uzaU3xX1LeAfL17kHQhTAJgpsfhbMJMY2g==",
|
"integrity": "sha512-mf5NURdUaSdnatJx3uhoBOrY9dtL19fiOtAdT1Azxg3+lNJFiuN0uzaU3xX1LeAfL17kHQhTAJgpsfhbMJMY2g==",
|
||||||
"dev": true,
|
"dev": true
|
||||||
"requires": {}
|
|
||||||
},
|
},
|
||||||
"slash": {
|
"slash": {
|
||||||
"version": "3.0.0",
|
"version": "3.0.0",
|
||||||
|
@ -23571,8 +23565,7 @@
|
||||||
"version": "3.0.0",
|
"version": "3.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/stylelint-config-recommended/-/stylelint-config-recommended-3.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/stylelint-config-recommended/-/stylelint-config-recommended-3.0.0.tgz",
|
||||||
"integrity": "sha512-F6yTRuc06xr1h5Qw/ykb2LuFynJ2IxkKfCMf+1xqPffkxh0S09Zc902XCffcsw/XMFq/OzQ1w54fLIDtmRNHnQ==",
|
"integrity": "sha512-F6yTRuc06xr1h5Qw/ykb2LuFynJ2IxkKfCMf+1xqPffkxh0S09Zc902XCffcsw/XMFq/OzQ1w54fLIDtmRNHnQ==",
|
||||||
"dev": true,
|
"dev": true
|
||||||
"requires": {}
|
|
||||||
},
|
},
|
||||||
"stylelint-config-standard": {
|
"stylelint-config-standard": {
|
||||||
"version": "20.0.0",
|
"version": "20.0.0",
|
||||||
|
@ -24946,8 +24939,7 @@
|
||||||
"version": "8.12.0",
|
"version": "8.12.0",
|
||||||
"resolved": "https://registry.npmjs.org/ws/-/ws-8.12.0.tgz",
|
"resolved": "https://registry.npmjs.org/ws/-/ws-8.12.0.tgz",
|
||||||
"integrity": "sha512-kU62emKIdKVeEIOIKVegvqpXMSTAMLJozpHZaJNDYqBjzlSYXQGviYwN1osDLJ9av68qHd4a2oSjd7yD4pacig==",
|
"integrity": "sha512-kU62emKIdKVeEIOIKVegvqpXMSTAMLJozpHZaJNDYqBjzlSYXQGviYwN1osDLJ9av68qHd4a2oSjd7yD4pacig==",
|
||||||
"dev": true,
|
"dev": true
|
||||||
"requires": {}
|
|
||||||
},
|
},
|
||||||
"xdg-basedir": {
|
"xdg-basedir": {
|
||||||
"version": "5.1.0",
|
"version": "5.1.0",
|
||||||
|
|
|
@ -61,8 +61,9 @@ window.assignManager = {
|
||||||
this.area.get([siteStoreKey]).then((storageResponse) => {
|
this.area.get([siteStoreKey]).then((storageResponse) => {
|
||||||
if (storageResponse && siteStoreKey in storageResponse) {
|
if (storageResponse && siteStoreKey in storageResponse) {
|
||||||
resolve(storageResponse[siteStoreKey]);
|
resolve(storageResponse[siteStoreKey]);
|
||||||
|
} else {
|
||||||
|
resolve(null);
|
||||||
}
|
}
|
||||||
resolve(null);
|
|
||||||
}).catch((e) => {
|
}).catch((e) => {
|
||||||
reject(e);
|
reject(e);
|
||||||
});
|
});
|
||||||
|
@ -638,7 +639,7 @@ window.assignManager = {
|
||||||
},
|
},
|
||||||
|
|
||||||
async _maybeRemoveSiteIsolation(userContextId) {
|
async _maybeRemoveSiteIsolation(userContextId) {
|
||||||
const assignments = await this.storageArea.getByContainer(userContextId);
|
const assignments = await this.storageArea.getAssignedSites(userContextId);
|
||||||
const hasAssignments = assignments && Object.keys(assignments).length > 0;
|
const hasAssignments = assignments && Object.keys(assignments).length > 0;
|
||||||
if (hasAssignments) {
|
if (hasAssignments) {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -4,6 +4,8 @@
|
||||||
|
|
||||||
const DEFAULT_TAB = "about:newtab";
|
const DEFAULT_TAB = "about:newtab";
|
||||||
|
|
||||||
|
// let originalTabs = [];
|
||||||
|
|
||||||
const backgroundLogic = {
|
const backgroundLogic = {
|
||||||
NEW_TAB_PAGES: new Set([
|
NEW_TAB_PAGES: new Set([
|
||||||
"about:startpage",
|
"about:startpage",
|
||||||
|
@ -328,13 +330,40 @@ const backgroundLogic = {
|
||||||
await Promise.all(identitiesPromise);
|
await Promise.all(identitiesPromise);
|
||||||
return identitiesOutput;
|
return identitiesOutput;
|
||||||
},
|
},
|
||||||
|
async unsortTabs() {
|
||||||
|
const windowObj = await browser.windows.getCurrent();
|
||||||
|
await this._unsortTabsInternal(windowObj);
|
||||||
|
localStorage.removeItem("originalTabs");
|
||||||
|
},
|
||||||
|
|
||||||
async sortTabs() {
|
async sortTabs() {
|
||||||
const windows = await browser.windows.getAll();
|
const windowObj = await browser.windows.getCurrent();
|
||||||
for (let windowObj of windows) { // eslint-disable-line prefer-const
|
const tabs = await browser.tabs.query({windowId: windowObj.id});
|
||||||
// First the pinned tabs, then the normal ones.
|
for (const tab of tabs){
|
||||||
await this._sortTabsInternal(windowObj, true);
|
if(!(windowObj.id in ORIGINAL_TABS)){
|
||||||
await this._sortTabsInternal(windowObj, false);
|
ORIGINAL_TABS[windowObj.id] = [];
|
||||||
|
}
|
||||||
|
ORIGINAL_TABS[windowObj.id].push(tab.id);
|
||||||
|
}
|
||||||
|
let jsonarray = JSON.stringify(ORIGINAL_TABS);
|
||||||
|
localStorage.setItem("originalTabs", jsonarray);
|
||||||
|
|
||||||
|
// First the pinned tabs, then the normal ones.
|
||||||
|
await this._sortTabsInternal(windowObj, true);
|
||||||
|
await this._sortTabsInternal(windowObj, false);
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
async _unsortTabsInternal(windowObj){
|
||||||
|
let pos = 0;
|
||||||
|
let parsedOriginalTabs = JSON.parse(localStorage.getItem("originalTabs"));
|
||||||
|
let windowSpecificOriginalTabs = parsedOriginalTabs[windowObj.id];
|
||||||
|
for (const tab of windowSpecificOriginalTabs) {
|
||||||
|
++pos;
|
||||||
|
browser.tabs.move(tab, {
|
||||||
|
windowId: windowObj.id,
|
||||||
|
index: pos
|
||||||
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -54,6 +54,9 @@ const messageHandler = {
|
||||||
case "sortTabs":
|
case "sortTabs":
|
||||||
backgroundLogic.sortTabs();
|
backgroundLogic.sortTabs();
|
||||||
break;
|
break;
|
||||||
|
case "unsortTabs":
|
||||||
|
backgroundLogic.unsortTabs();
|
||||||
|
break;
|
||||||
case "showTabs":
|
case "showTabs":
|
||||||
backgroundLogic.unhideContainer(m.cookieStoreId);
|
backgroundLogic.unhideContainer(m.cookieStoreId);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -766,6 +766,17 @@ Logic.registerPanel(P_CONTAINERS_LIST, {
|
||||||
window.close();
|
window.close();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Utils.addEnterHandler(document.querySelector("#unsort-containers-link"), async () => {
|
||||||
|
try {
|
||||||
|
await browser.runtime.sendMessage({
|
||||||
|
method: "unsortTabs"
|
||||||
|
});
|
||||||
|
window.close();
|
||||||
|
} catch (e) {
|
||||||
|
window.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
const mozillaVpnToutName = "moz-tout-main-panel";
|
const mozillaVpnToutName = "moz-tout-main-panel";
|
||||||
const mozillaVpnPermissionsWarningDotName = "moz-permissions-warning-dot";
|
const mozillaVpnPermissionsWarningDotName = "moz-permissions-warning-dot";
|
||||||
|
@ -911,6 +922,16 @@ Logic.registerPanel(P_CONTAINERS_LIST, {
|
||||||
document.addEventListener("input", Logic.filterContainerList);
|
document.addEventListener("input", Logic.filterContainerList);
|
||||||
|
|
||||||
MozillaVPN.handleContainerList(identities);
|
MozillaVPN.handleContainerList(identities);
|
||||||
|
// document.querySelector("#unsort-containers-link").setAttribute("disabled", "true");
|
||||||
|
if (localStorage.getItem("originalTabs") == null){
|
||||||
|
document.querySelector("#unsort-containers-link").setAttribute("disabled", "true");
|
||||||
|
}
|
||||||
|
|
||||||
|
else {
|
||||||
|
document.querySelector("#unsort-containers-link").removeAttribute("disabled");
|
||||||
|
}
|
||||||
|
|
||||||
|
// console.log(localStorage.getItem("originalTabs"));
|
||||||
|
|
||||||
// reset path
|
// reset path
|
||||||
this._previousPanelPath = [];
|
this._previousPanelPath = [];
|
||||||
|
|
|
@ -4,6 +4,7 @@ const DEFAULT_FAVICON = "/img/blank-favicon.svg";
|
||||||
|
|
||||||
// eslint-disable-next-line
|
// eslint-disable-next-line
|
||||||
const CONTAINER_ORDER_STORAGE_KEY = "container-order";
|
const CONTAINER_ORDER_STORAGE_KEY = "container-order";
|
||||||
|
const ORIGINAL_TABS = {};
|
||||||
|
|
||||||
// TODO use export here instead of globals
|
// TODO use export here instead of globals
|
||||||
const Utils = {
|
const Utils = {
|
||||||
|
|
|
@ -140,6 +140,15 @@
|
||||||
</span>
|
</span>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr class="menu-item hover-highlight keyboard-nav" id="unsort-containers-link" tabindex="0">
|
||||||
|
<td>
|
||||||
|
<img class="menu-icon" alt="" src="/img/sort-16_1.svg" />
|
||||||
|
<span class="menu-text" data-i18n-message-id="unsortTabsByContainer"></span>
|
||||||
|
<span class="menu-arrow">
|
||||||
|
</span>
|
||||||
|
</td>
|
||||||
|
|
||||||
|
</tr>
|
||||||
<tr class="menu-item hover-highlight keyboard-nav" id="always-open-in" tabindex="0">
|
<tr class="menu-item hover-highlight keyboard-nav" id="always-open-in" tabindex="0">
|
||||||
<td>
|
<td>
|
||||||
<img class="menu-icon" alt="" src="/img/container-openin-16.svg" />
|
<img class="menu-icon" alt="" src="/img/container-openin-16.svg" />
|
||||||
|
|
Loading…
Add table
Reference in a new issue