2019-04-09 14:37:58 +02:00
|
|
|
import * as vscode from 'vscode';
|
2019-04-10 13:45:47 +02:00
|
|
|
|
|
|
|
import { showIssueHTML } from './template.html';
|
2019-07-04 14:45:46 +02:00
|
|
|
import { Issue } from './issue';
|
2020-08-16 20:26:14 +02:00
|
|
|
import { IssueProvider } from './issueProvider';
|
2019-04-09 14:37:58 +02:00
|
|
|
|
2020-08-16 20:26:14 +02:00
|
|
|
export function showIssueInWebPanel(issue: Issue) {
|
2019-07-04 14:45:46 +02:00
|
|
|
const panel = vscode.window.createWebviewPanel('issue', issue.label, vscode.ViewColumn.Active, {});
|
|
|
|
panel.webview.html = showIssueHTML(issue);
|
2020-08-16 20:26:14 +02:00
|
|
|
return panel;
|
|
|
|
}
|
|
|
|
|
|
|
|
export function activate(context: vscode.ExtensionContext) {
|
|
|
|
// Array of issues; This is used to determine whether a issue is already open
|
|
|
|
// in a tab or not.
|
|
|
|
let openIssues: Array<Issue> = [];
|
|
|
|
const openIssuesProvider = new IssueProvider("open");
|
|
|
|
const closedIssuesProvider = new IssueProvider("closed");
|
|
|
|
|
|
|
|
vscode.window.registerTreeDataProvider('open-issues', openIssuesProvider);
|
|
|
|
vscode.window.registerTreeDataProvider('closed-issues', closedIssuesProvider);
|
|
|
|
|
|
|
|
vscode.commands.registerCommand('giteaIssues.openIssue', (issue: Issue) => {
|
|
|
|
const issueOpenable = openIssues.find((c) => c.issueId === issue.issueId) === undefined;
|
|
|
|
|
|
|
|
if (issueOpenable) {
|
|
|
|
const panel = showIssueInWebPanel(issue);
|
|
|
|
openIssues.push(issue);
|
|
|
|
panel.onDidDispose((event) => {
|
|
|
|
openIssues.splice(openIssues.indexOf(issue), 1);
|
|
|
|
});
|
2019-06-14 13:22:17 +02:00
|
|
|
}
|
2019-04-10 08:59:42 +02:00
|
|
|
});
|
|
|
|
|
2020-08-16 20:26:14 +02:00
|
|
|
vscode.commands.registerCommand('giteaIssues.refreshIssues', () => {
|
|
|
|
openIssuesProvider.refresh();
|
|
|
|
closedIssuesProvider.refresh();
|
|
|
|
});
|
2019-04-09 14:37:58 +02:00
|
|
|
}
|
|
|
|
|
2019-07-04 14:45:46 +02:00
|
|
|
export function deactivate() {}
|