Skip to content

Commit c2e8714

Browse files
authored
feat: reopen closed tabs (deephaven#1912)
- Add deephaven#1785 - Add keyboard shortcut (Alt+Shift+A) to reopen last closed tab
1 parent 9b14ee0 commit c2e8714

File tree

4 files changed

+29
-0
lines changed

4 files changed

+29
-0
lines changed

packages/code-studio/src/main/AppMainContainer.tsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,13 @@ export class AppMainContainer extends Component<
234234
shortcut: IRIS_GRID_SHORTCUTS.TABLE.CLEAR_ALL_FILTERS,
235235
isGlobal: true,
236236
},
237+
{
238+
action: () => {
239+
this.sendReopenLast();
240+
},
241+
shortcut: GLOBAL_SHORTCUTS.REOPEN_CLOSED_PANEL,
242+
isGlobal: true,
243+
},
237244
{
238245
action: () => {
239246
log.debug('Consume unhandled save shortcut');
@@ -402,6 +409,10 @@ export class AppMainContainer extends Component<
402409
this.emitLayoutEvent(InputFilterEvent.CLEAR_ALL_FILTERS);
403410
}
404411

412+
sendReopenLast(): void {
413+
this.emitLayoutEvent(PanelEvent.REOPEN_LAST);
414+
}
415+
405416
emitLayoutEvent(event: string, ...args: unknown[]): void {
406417
const { activeTabKey } = this.state;
407418
const layout = this.dashboardLayouts.get(activeTabKey);

packages/components/src/shortcuts/GlobalShortcuts.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,13 @@ const GLOBAL_SHORTCUTS = {
3030
macShortcut: [MODIFIER.CMD, KEY.A],
3131
isEditable: false,
3232
}),
33+
REOPEN_CLOSED_PANEL: ShortcutRegistry.createAndAdd({
34+
id: 'GLOBAL.REOPEN_CLOSED_PANEL',
35+
name: 'Re-open Closed Panel',
36+
shortcut: [MODIFIER.ALT, MODIFIER.SHIFT, KEY.T],
37+
macShortcut: [MODIFIER.OPTION, MODIFIER.SHIFT, KEY.T],
38+
isEditable: true,
39+
}),
3340
LINKER: ShortcutRegistry.createAndAdd({
3441
id: 'GLOBAL.LINKER',
3542
name: 'Linker',

packages/dashboard/src/PanelEvent.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ export default Object.freeze({
3232
// Panel was re-opened from a dehydrated state
3333
REOPEN: 'PanelEvent.REOPEN',
3434

35+
// Reopen last closed panel
36+
REOPEN_LAST: 'PanelEvent.REOPEN_LAST',
37+
3538
// Panel was deleted
3639
DELETE: 'PanelEvent.DELETE',
3740

packages/dashboard/src/PanelManager.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ class PanelManager {
8282
// and PanelEvent.CLOSED for cleanup (delete links, add panel to closed panels list, etc)
8383
this.handleUnmount = this.handleUnmount.bind(this);
8484
this.handleReopen = this.handleReopen.bind(this);
85+
this.handleReopenLast = this.handleReopenLast.bind(this);
8586
this.handleDeleted = this.handleDeleted.bind(this);
8687
this.handleClosed = this.handleClosed.bind(this);
8788
this.handleControlClose = this.handleControlClose.bind(this);
@@ -106,6 +107,7 @@ class PanelManager {
106107
eventHub.on(PanelEvent.MOUNT, this.handleMount);
107108
eventHub.on(PanelEvent.UNMOUNT, this.handleUnmount);
108109
eventHub.on(PanelEvent.REOPEN, this.handleReopen);
110+
eventHub.on(PanelEvent.REOPEN_LAST, this.handleReopenLast);
109111
eventHub.on(PanelEvent.DELETE, this.handleDeleted);
110112
eventHub.on(PanelEvent.CLOSED, this.handleClosed);
111113
eventHub.on(PanelEvent.CLOSE, this.handleControlClose);
@@ -118,6 +120,7 @@ class PanelManager {
118120
eventHub.off(PanelEvent.MOUNT, this.handleMount);
119121
eventHub.off(PanelEvent.UNMOUNT, this.handleUnmount);
120122
eventHub.off(PanelEvent.REOPEN, this.handleReopen);
123+
eventHub.off(PanelEvent.REOPEN_LAST, this.handleReopenLast);
121124
eventHub.off(PanelEvent.DELETE, this.handleDeleted);
122125
eventHub.off(PanelEvent.CLOSED, this.handleClosed);
123126
eventHub.off(PanelEvent.CLOSE, this.handleControlClose);
@@ -291,6 +294,11 @@ class PanelManager {
291294
LayoutUtils.openComponent({ root, config, replaceConfig });
292295
}
293296

297+
handleReopenLast(): void {
298+
if (this.closed.length === 0) return;
299+
this.handleReopen(this.closed[this.closed.length - 1]);
300+
}
301+
294302
handleDeleted(panelConfig: ClosedPanel): void {
295303
log.debug2('Deleted:', panelConfig);
296304

0 commit comments

Comments
 (0)