Skip to content

Commit ec61bcf

Browse files
committed
feat(workspace): add app-drawer toolbar button for Quick Access panel
Add a grid icon above the profile button in the right toolbar that toggles the Quick Access (default) panel. The button shows a selected/pressed state when the panel is open and deselects when the panel is hidden or another panel opens. Also remove unused $pluginIconsBar variable in MainViewManager tests and add 5 integration tests for the new button behavior.
1 parent 4f5c370 commit ec61bcf

3 files changed

Lines changed: 109 additions & 4 deletions

File tree

src/styles/images/app-drawer.svg

Lines changed: 6 additions & 0 deletions
Loading

src/view/DefaultPanelView.js

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ define(function (require, exports, module) {
3131
CommandManager = require("command/CommandManager"),
3232
Strings = require("strings"),
3333
WorkspaceManager = require("view/WorkspaceManager"),
34-
PanelView = require("view/PanelView");
34+
PanelView = require("view/PanelView"),
35+
ExtensionUtils = require("utils/ExtensionUtils");
3536

3637
/**
3738
* Descriptors for each launcher button.
@@ -177,14 +178,43 @@ define(function (require, exports, module) {
177178
}
178179
});
179180

180-
// Auto-hide when any other panel is shown.
181-
// hide() is a no-op if the panel is already closed, so no guard needed.
181+
// Create the app-drawer toolbar icon above the profile button
182+
const iconURL = ExtensionUtils.getModulePath(module, "../styles/images/app-drawer.svg");
183+
const $drawerBtn = $("<a>")
184+
.attr({
185+
id: "app-drawer-button",
186+
href: "#",
187+
title: Strings.BOTTOM_PANEL_DEFAULT_TITLE
188+
})
189+
.css({
190+
"background-image": "url('" + iconURL + "')",
191+
"background-position": "center",
192+
"background-size": "16px"
193+
})
194+
.prependTo($("#main-toolbar .bottom-buttons"));
195+
196+
$drawerBtn.on("click", function () {
197+
if (_panel.isVisible()) {
198+
_panel.hide();
199+
} else {
200+
_panel.show();
201+
}
202+
});
203+
204+
// Auto-hide when any other panel is shown; update drawer button state.
182205
PanelView.on(PanelView.EVENT_PANEL_SHOWN, function (event, panelID) {
183206
if (panelID !== WorkspaceManager.DEFAULT_PANEL_ID) {
184207
_panel.hide();
185208
} else {
186209
_updateButtonVisibility();
187210
}
211+
$drawerBtn.toggleClass("selected-button", panelID === WorkspaceManager.DEFAULT_PANEL_ID);
212+
});
213+
214+
PanelView.on(PanelView.EVENT_PANEL_HIDDEN, function (event, panelID) {
215+
if (panelID === WorkspaceManager.DEFAULT_PANEL_ID) {
216+
$drawerBtn.removeClass("selected-button");
217+
}
188218
});
189219

190220
// Initial visibility update and set up live observers

test/spec/MainViewManager-integ-test.js

Lines changed: 70 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1304,7 +1304,6 @@ define(function (require, exports, module) {
13041304
it("should clamp panel width when shown after window was resized", function () {
13051305
// Panel is hidden; compute what the max toolbar width would be
13061306
const sidebarWidth = _$("#sidebar").outerWidth() || 0;
1307-
const $pluginIconsBar = _$("#plugin-icons-bar");
13081307
const maxToolbarWidth = Math.min(
13091308
testWindow.innerWidth * 0.75,
13101309
testWindow.innerWidth - sidebarWidth - 100
@@ -1334,5 +1333,75 @@ define(function (require, exports, module) {
13341333
expect(rightOffset).toEqual($mainToolbar.width());
13351334
});
13361335
});
1336+
1337+
describe("Quick Access panel (app drawer button)", function () {
1338+
const DEFAULT_PANEL_ID = "workspace.defaultPanel";
1339+
1340+
function getDrawerButton() {
1341+
return _$("#app-drawer-button");
1342+
}
1343+
1344+
function isDefaultPanelVisible() {
1345+
return _$("#default-panel").is(":visible");
1346+
}
1347+
1348+
function isDrawerSelected() {
1349+
return getDrawerButton().hasClass("selected-button");
1350+
}
1351+
1352+
beforeEach(function () {
1353+
// Ensure a clean state: hide any open panels
1354+
const panel = WorkspaceManager.getPanelForID(DEFAULT_PANEL_ID);
1355+
if (panel && panel.isVisible()) {
1356+
panel.hide();
1357+
}
1358+
});
1359+
1360+
it("should have the app-drawer button in the toolbar", function () {
1361+
expect(getDrawerButton().length).toBe(1);
1362+
});
1363+
1364+
it("should open Quick Access panel on drawer button click", function () {
1365+
expect(isDefaultPanelVisible()).toBeFalse();
1366+
1367+
getDrawerButton().click();
1368+
1369+
expect(isDefaultPanelVisible()).toBeTrue();
1370+
});
1371+
1372+
it("should show selected state when panel is open", function () {
1373+
expect(isDrawerSelected()).toBeFalse();
1374+
1375+
getDrawerButton().click();
1376+
1377+
expect(isDrawerSelected()).toBeTrue();
1378+
});
1379+
1380+
it("should close Quick Access panel on second click", function () {
1381+
getDrawerButton().click();
1382+
expect(isDefaultPanelVisible()).toBeTrue();
1383+
expect(isDrawerSelected()).toBeTrue();
1384+
1385+
getDrawerButton().click();
1386+
1387+
expect(isDefaultPanelVisible()).toBeFalse();
1388+
expect(isDrawerSelected()).toBeFalse();
1389+
});
1390+
1391+
it("should deselect drawer when another panel opens", async function () {
1392+
getDrawerButton().click();
1393+
expect(isDefaultPanelVisible()).toBeTrue();
1394+
expect(isDrawerSelected()).toBeTrue();
1395+
1396+
// Open a different panel (Problems)
1397+
await CommandManager.execute(Commands.VIEW_TOGGLE_PROBLEMS);
1398+
1399+
expect(isDefaultPanelVisible()).toBeFalse();
1400+
expect(isDrawerSelected()).toBeFalse();
1401+
1402+
// Clean up: close Problems panel
1403+
await CommandManager.execute(Commands.VIEW_TOGGLE_PROBLEMS);
1404+
});
1405+
});
13371406
});
13381407
});

0 commit comments

Comments
 (0)