From 8d7c9e1fbf20845ade2789c44b5b04db385029d4 Mon Sep 17 00:00:00 2001 From: Sanjula Ganepola Date: Mon, 18 Nov 2024 20:16:25 -0500 Subject: [PATCH] Add history tree item command to open task Signed-off-by: Sanjula Ganepola --- src/views/history/history.ts | 9 ++++++++- src/views/history/historyTreeDataProvider.ts | 10 +++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/views/history/history.ts b/src/views/history/history.ts index 6303a67..2e8a32b 100644 --- a/src/views/history/history.ts +++ b/src/views/history/history.ts @@ -37,11 +37,18 @@ export default class HistoryTreeItem extends TreeItem implements GithubLocalActi this.iconPath = new ThemeIcon('circle-slash', new ThemeColor('GitHubLocalActions.yellow')); break; } - this.tooltip = `Name: ${history.name}\n` + + this.tooltip = `Name: ${history.name} #${history.count}\n` + + `Path: ${history.commandArgs.fsPath}\n` + + `${history.commandArgs.extraHeader.map(header => `${header.key}: ${header.value}`).join('\n')}\n` + `Status: ${history.status}\n` + `Started: ${Utils.getDateString(history.date.start)}\n` + `Ended: ${endTime ? Utils.getDateString(endTime) : 'N/A'}\n` + `Total Duration: ${totalDuration ? totalDuration : 'N/A'}`; + this.command = { + title: 'Focus Task', + command: 'githubLocalActions.focusTask', + arguments: [this] + }; } async getChildren(): Promise { diff --git a/src/views/history/historyTreeDataProvider.ts b/src/views/history/historyTreeDataProvider.ts index 5ad3538..683abb4 100644 --- a/src/views/history/historyTreeDataProvider.ts +++ b/src/views/history/historyTreeDataProvider.ts @@ -1,4 +1,4 @@ -import { CancellationToken, commands, EventEmitter, ExtensionContext, extensions, TreeDataProvider, TreeItem, workspace } from "vscode"; +import { CancellationToken, commands, EventEmitter, ExtensionContext, extensions, TreeDataProvider, TreeItem, window, workspace } from "vscode"; import { act } from "../../extension"; import { HistoryStatus } from "../../historyManager"; import { Utils } from "../../utils"; @@ -26,6 +26,14 @@ export default class HistoryTreeDataProvider implements TreeDataProvider { this.refresh(); }), + commands.registerCommand('githubLocalActions.focusTask', async (historyTreeItem: HistoryTreeItem) => { + const terminals = window.terminals; + for (const terminal of terminals) { + if (terminal.creationOptions.name === `${historyTreeItem.history.name} #${historyTreeItem.history.count}`) { + terminal.show(); + } + } + }), commands.registerCommand('githubLocalActions.viewOutput', async (historyTreeItem: HistoryTreeItem) => { await act.historyManager.viewOutput(historyTreeItem.history); }),