Skip to content

Commit b424143

Browse files
committed
Hide needless UI in group items
1 parent ca45bda commit b424143

4 files changed

Lines changed: 36 additions & 6 deletions

File tree

webextensions/common/constants.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ export const kNOTIFY_CONFIRMATION_DIALOG_READY = 'treestyletab:confirmation-dia
128128
export const kCONNECTION_HEARTBEAT = 'treestyletab:connection-heartbeat';
129129

130130
export const kAPI_TAB_ID = 'data-tab-id';
131+
export const kAPI_GROUP_ID = 'data-group-id';
131132
export const kAPI_WINDOW_ID = 'data-window-id';
132133

133134
export const kPARENT = 'data-parent-id';

webextensions/sidebar/components/TabElement.js

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -251,15 +251,27 @@ export class TabElement extends HTMLElement {
251251

252252
// Elements restored from cache are initialized without bundled tabs.
253253
// Thus we provide abiltiy to get tab and service objects from cached/restored information.
254-
get tab() {
255-
return this._raw || (this._raw = Tab.get(parseInt(this.getAttribute(Constants.kAPI_TAB_ID))));
254+
get raw() {
255+
return this._raw || (
256+
this._raw = (this.getAttribute('type') == 'group' ?
257+
TabsStore.windows.get(parseInt(this.getAttribute(Constants.kAPI_GROUP_ID))) :
258+
Tab.get(parseInt(this.getAttribute(Constants.kAPI_TAB_ID)))
259+
)
260+
);
256261
}
257-
set tab(value) {
262+
set raw(value) {
258263
return this._raw = value;
259264
}
260265

266+
get tab() { // for backward compatibility
267+
return this.raw;
268+
}
269+
set tab(value) {
270+
return this.raw = value;
271+
}
272+
261273
get $TST() {
262-
return this._$TST || (this._$TST = this.tab && this.tab.$TST);
274+
return this._$TST || (this._$TST = this.raw && this.raw.$TST);
263275
}
264276
set $TST(value) {
265277
return this._$TST = value;
@@ -308,7 +320,8 @@ export class TabElement extends HTMLElement {
308320
this._labelElement.setAttribute(Constants.kAPI_TAB_ID, this.getAttribute(Constants.kAPI_TAB_ID));
309321
this._labelElement.setAttribute(Constants.kAPI_WINDOW_ID, this.getAttribute(Constants.kAPI_WINDOW_ID));
310322

311-
if (this.tab)
323+
if (this.getAttribute('type') == 'tab' &&
324+
this.tab)
312325
this.dataset.index =
313326
this.substanceElement.dataset.index =
314327
this._labelElement.dataset.index =this.tab.index;

webextensions/sidebar/sidebar-tabs.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,13 @@ export function renderTab(tab, { containerElement, insertBefore } = {}) {
239239
document.createElement(kTAB_ELEMENT_NAME);
240240
tab.$TST.bindElement(tabElement);
241241
tab.$TST.setAttribute('id', getTabElementId(tab));
242-
tab.$TST.setAttribute(Constants.kAPI_TAB_ID, tab.id || -1);
242+
tab.$TST.setAttribute('type', tab.$TST.type);
243+
if (tab.$TST.type == 'group') {
244+
tab.$TST.setAttribute(Constants.kAPI_GROUP_ID, tab.id || -1);
245+
}
246+
else {
247+
tab.$TST.setAttribute(Constants.kAPI_TAB_ID, tab.id || -1);
248+
}
243249
tab.$TST.setAttribute(Constants.kAPI_WINDOW_ID, tab.windowId || -1);
244250
tab.$TST.addState(Constants.kTAB_STATE_THROBBER_UNSYNCHRONIZED);
245251
TabsStore.addUnsynchronizedTab(tab);

webextensions/sidebar/styles/base.css

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1001,6 +1001,16 @@ tab-item.faviconized .contextual-identity-marker {
10011001
}
10021002

10031003

1004+
/* tab groups */
1005+
1006+
tab-item[type="group"] tab-favicon,
1007+
tab-item[type="group"] tab-closebox,
1008+
tab-item[type="group"] .highlighter,
1009+
tab-item[type="group"] .contextual-identity-marker {
1010+
display: none;
1011+
}
1012+
1013+
10041014
/* non-tab items */
10051015

10061016
#tabbar-top,

0 commit comments

Comments
 (0)