Skip to content

Commit 081146d

Browse files
devvaannshabose
authored andcommitted
feat: dont show add panel button when quick panel is active
1 parent 3e6c619 commit 081146d

2 files changed

Lines changed: 56 additions & 11 deletions

File tree

src/view/PanelView.js

Lines changed: 55 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,12 @@ define(function (require, exports, module) {
100100
/** @type {function} recomputeLayout callback from WorkspaceManager */
101101
let _recomputeLayout = null;
102102

103+
/** @type {string|null} The default/quick-access panel ID */
104+
let _defaultPanelId = null;
105+
106+
/** @type {jQueryObject} The "+" button inside the tab overflow area */
107+
let _$addBtn = null;
108+
103109
// --- Tab helper functions ---
104110

105111
/**
@@ -149,6 +155,12 @@ define(function (require, exports, module) {
149155
$tab.append($('<span class="bottom-panel-tab-close-btn">&times;</span>').attr('title', Strings.CLOSE));
150156
_$tabsOverflow.append($tab);
151157
});
158+
159+
// Re-append the "+" button at the end (after all tabs)
160+
if (_$addBtn) {
161+
_$tabsOverflow.append(_$addBtn);
162+
_updateAddButtonVisibility();
163+
}
152164
}
153165

154166
/**
@@ -190,7 +202,14 @@ define(function (require, exports, module) {
190202
.attr('data-panel-id', panelId);
191203
$tab.append($('<span class="bottom-panel-tab-title"></span>').text(title));
192204
$tab.append($('<span class="bottom-panel-tab-close-btn">&times;</span>').attr('title', Strings.CLOSE));
193-
_$tabsOverflow.append($tab);
205+
206+
// Insert before the "+" button so it stays at the end
207+
if (_$addBtn && _$addBtn.parent().length) {
208+
_$addBtn.before($tab);
209+
} else {
210+
_$tabsOverflow.append($tab);
211+
}
212+
_updateAddButtonVisibility();
194213
}
195214

196215
/**
@@ -204,6 +223,24 @@ define(function (require, exports, module) {
204223
return;
205224
}
206225
_$tabsOverflow.find('.bottom-panel-tab[data-panel-id="' + panelId + '"]').remove();
226+
_updateAddButtonVisibility();
227+
}
228+
229+
/**
230+
* Show or hide the "+" button based on whether the default panel is active.
231+
* The button is hidden when the default panel is the active tab (since
232+
* clicking "+" would be a no-op) and shown otherwise.
233+
* @private
234+
*/
235+
function _updateAddButtonVisibility() {
236+
if (!_$addBtn) {
237+
return;
238+
}
239+
if (_defaultPanelId && _activeId === _defaultPanelId) {
240+
_$addBtn.hide();
241+
} else {
242+
_$addBtn.show();
243+
}
207244
}
208245

209246
/**
@@ -229,6 +266,7 @@ define(function (require, exports, module) {
229266
newPanel.$panel.addClass("active-bottom-panel");
230267
}
231268
_updateActiveTabHighlight();
269+
_updateAddButtonVisibility();
232270
}
233271

234272

@@ -422,13 +460,20 @@ define(function (require, exports, module) {
422460
* @param {jQueryObject} $tabsOverflow The scrollable area holding tab elements.
423461
* @param {jQueryObject} $editorHolder The editor holder element (for maximize height calculation).
424462
* @param {function} recomputeLayoutFn Callback to trigger workspace layout recomputation.
463+
* @param {string} defaultPanelId The ID of the default/quick-access panel.
425464
*/
426-
function init($container, $tabBar, $tabsOverflow, $editorHolder, recomputeLayoutFn) {
465+
function init($container, $tabBar, $tabsOverflow, $editorHolder, recomputeLayoutFn, defaultPanelId) {
427466
_$container = $container;
428467
_$tabBar = $tabBar;
429468
_$tabsOverflow = $tabsOverflow;
430469
_$editorHolder = $editorHolder;
431470
_recomputeLayout = recomputeLayoutFn;
471+
_defaultPanelId = defaultPanelId;
472+
473+
// Create the "+" button inside the tabs overflow area (after all tabs)
474+
_$addBtn = $('<span class="bottom-panel-add-btn"><i class="fa-solid fa-plus"></i></span>')
475+
.attr('title', Strings.BOTTOM_PANEL_OPEN_PANEL);
476+
_$tabsOverflow.append(_$addBtn);
432477

433478
// Tab bar click handlers
434479
_$tabBar.on("click", ".bottom-panel-tab-close-btn", function (e) {
@@ -452,6 +497,14 @@ define(function (require, exports, module) {
452497
}
453498
});
454499

500+
// "+" button opens the default/quick-access panel
501+
_$addBtn.on("click", function (e) {
502+
e.stopPropagation();
503+
if (_defaultPanelId && _panelMap[_defaultPanelId]) {
504+
_panelMap[_defaultPanelId].show();
505+
}
506+
});
507+
455508
// Hide-panel button collapses the container but keeps tabs intact
456509
_$tabBar.on("click", ".bottom-panel-hide-btn", function (e) {
457510
e.stopPropagation();

src/view/WorkspaceManager.js

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -363,8 +363,6 @@ define(function (require, exports, module) {
363363
$bottomPanelContainer = $('<div id="bottom-panel-container" class="vert-resizable top-resizer"></div>');
364364
let $bottomPanelTabBar = $('<div id="bottom-panel-tab-bar"></div>');
365365
let $bottomPanelTabsOverflow = $('<div class="bottom-panel-tabs-overflow"></div>');
366-
let $addPanelBtn = $('<span class="bottom-panel-add-btn"><i class="fa-solid fa-plus"></i></span>')
367-
.attr('title', Strings.BOTTOM_PANEL_OPEN_PANEL);
368366
let $tabBarActions = $('<div class="bottom-panel-tab-bar-actions"></div>');
369367
$tabBarActions.append(
370368
$('<span class="bottom-panel-hide-btn"><i class="fa-solid fa-minus"></i></span>')
@@ -375,15 +373,14 @@ define(function (require, exports, module) {
375373
.attr('title', Strings.BOTTOM_PANEL_MAXIMIZE)
376374
);
377375
$bottomPanelTabBar.append($bottomPanelTabsOverflow);
378-
$bottomPanelTabBar.append($addPanelBtn);
379376
$bottomPanelTabBar.append($tabBarActions);
380377
$bottomPanelContainer.append($bottomPanelTabBar);
381378
$bottomPanelContainer.insertBefore("#status-bar");
382379
$bottomPanelContainer.hide();
383380

384381
// Initialize PanelView with container DOM references and tab bar click handlers
385382
PanelView.init($bottomPanelContainer, $bottomPanelTabBar, $bottomPanelTabsOverflow,
386-
$editorHolder, recomputeLayout);
383+
$editorHolder, recomputeLayout, DEFAULT_PANEL_ID);
387384

388385
// Create status bar chevron toggle for bottom panel
389386
$statusBarPanelToggle = $('<div id="status-panel-toggle" class="indicator global-indicator"><i class="fa-solid fa-chevron-up"></i></div>')
@@ -405,11 +402,6 @@ define(function (require, exports, module) {
405402
_statusBarToggleInProgress = false;
406403
});
407404

408-
// "+" button opens the quick access / default panel
409-
$addPanelBtn.on("click", function () {
410-
_showDefaultPanel();
411-
});
412-
413405
// Make the container resizable (not individual panels)
414406
Resizer.makeResizable($bottomPanelContainer[0], Resizer.DIRECTION_VERTICAL, Resizer.POSITION_TOP,
415407
200, false, undefined, true);

0 commit comments

Comments
 (0)