Show tab list if Container is hidden but don't make the rows selectable

This commit is contained in:
baku 2017-01-18 17:32:56 +01:00
parent 71f542b3a5
commit 4331a2612c
2 changed files with 37 additions and 17 deletions

View file

@ -160,12 +160,15 @@ const ContainerService = {
return parseInt(viewFor(tab).getAttribute("usercontextid") || 0, 10); return parseInt(viewFor(tab).getAttribute("usercontextid") || 0, 10);
}, },
_createTabObject(tab) {
return { title: tab.title, url: tab.url, id: tab.id, active: true };
},
_getTabList(userContextId) { _getTabList(userContextId) {
const list = []; const list = [];
for (let tab of tabs) { // eslint-disable-line prefer-const for (let tab of tabs) { // eslint-disable-line prefer-const
if (userContextId === this._getUserContextIdFromTab(tab)) { if (userContextId === this._getUserContextIdFromTab(tab)) {
const object = { title: tab.title, url: tab.url, id: tab.id }; list.push(this._createTabObject(tab));
list.push(object);
} }
} }
@ -186,7 +189,19 @@ const ContainerService = {
continue; continue;
} }
this._identitiesState[args.userContextId].hiddenTabUrls.push(tab.url); const object = this._createTabObject(tab);
// This tab is going to be closed. Let's mark this tabObject as
// non-active.
object.active = false;
getFavicon(object.url).then(url => {
object.favicon = url;
}, () => {
object.favicon = "";
});
this._identitiesState[args.userContextId].hiddenTabUrls.push(object);
tab.close(); tab.close();
} }
@ -201,8 +216,9 @@ const ContainerService = {
const promises = []; const promises = [];
for (let url of this._identitiesState[args.userContextId].hiddenTabUrls) { // eslint-disable-line prefer-const for (let object of this._identitiesState[args.userContextId].hiddenTabUrls) { // eslint-disable-line prefer-const
promises.push(this.openTab({ userContextId: args.userContextId, url })); promises.push(this.openTab({ userContextId: args.userContextId,
url: object.url }));
} }
this._identitiesState[args.userContextId].hiddenTabUrls = []; this._identitiesState[args.userContextId].hiddenTabUrls = [];
@ -279,7 +295,7 @@ const ContainerService = {
} }
Promise.all(promises).then(() => { Promise.all(promises).then(() => {
resolve(list); resolve(list.concat(this._identitiesState[args.userContextId].hiddenTabUrls));
}).catch((e) => { }).catch((e) => {
reject(e); reject(e);
}); });

View file

@ -320,21 +320,25 @@ Logic.registerPanel(P_CONTAINER_INFO, {
for (let tab of tabs) { // eslint-disable-line prefer-const for (let tab of tabs) { // eslint-disable-line prefer-const
const tr = document.createElement("tr"); const tr = document.createElement("tr");
fragment.appendChild(tr); fragment.appendChild(tr);
tr.classList.add("container-info-tab", "clickable"); tr.classList.add("container-info-tab");
tr.innerHTML = ` tr.innerHTML = `
<td><img class="icon" src="${tab.favicon}" /></td> <td><img class="icon" src="${tab.favicon}" /></td>
<td>${tab.title}</td>`; <td>${tab.title}</td>`;
// On click, we activate this tab.
tr.addEventListener("click", () => { // On click, we activate this tab. But only if this tab is active.
browser.runtime.sendMessage({ if (tab.active) {
method: "showTab", tr.classList.add("clickable");
tabId: tab.id, tr.addEventListener("click", () => {
}).then(() => { browser.runtime.sendMessage({
window.close(); method: "showTab",
}).catch(() => { tabId: tab.id,
window.close(); }).then(() => {
window.close();
}).catch(() => {
window.close();
});
}); });
}); }
} }
document.getElementById("container-info-table").appendChild(fragment); document.getElementById("container-info-table").appendChild(fragment);