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';
|
2019-04-10 13:45:47 +02:00
|
|
|
import { OpenIssuesProvider, ClosedIssuesProvider } from './issueProvider';
|
2019-04-09 14:37:58 +02:00
|
|
|
|
2019-04-10 13:45:47 +02:00
|
|
|
export function activate(context: vscode.ExtensionContext) {
|
2019-07-04 14:45:46 +02:00
|
|
|
let openIssues: Array<Issue> = [];
|
|
|
|
const openIssuesProvider = new OpenIssuesProvider();
|
|
|
|
const closedIssuesProvider = new ClosedIssuesProvider();
|
|
|
|
|
|
|
|
vscode.window.registerTreeDataProvider('open-issues', openIssuesProvider);
|
|
|
|
vscode.window.registerTreeDataProvider('closed-issues', closedIssuesProvider);
|
|
|
|
|
|
|
|
// TODO: Implement in next version.
|
|
|
|
// vscode.commands.registerCommand('giteaIssues.createIssue', async () => {
|
|
|
|
// const panel = vscode.window.createWebviewPanel('createIssue', 'Create an new Issue', vscode.ViewColumn.Active, {});
|
|
|
|
// panel.webview.html = "";
|
|
|
|
// });
|
|
|
|
|
|
|
|
vscode.commands.registerCommand('giteaIssues.openIssue', (issue: Issue) => {
|
|
|
|
for (let i = 0; i !== openIssues.length; i++) {
|
|
|
|
let openIssue = openIssues[i];
|
|
|
|
if (openIssue.issueId === issue.issueId) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
const panel = vscode.window.createWebviewPanel('issue', issue.label, vscode.ViewColumn.Active, {});
|
|
|
|
panel.webview.html = showIssueHTML(issue);
|
|
|
|
openIssues.push(issue);
|
|
|
|
panel.onDidDispose((event) => {
|
|
|
|
for (let i = 0; i !== openIssues.length; i++) {
|
|
|
|
let openIssue = openIssues[i];
|
|
|
|
if (openIssue.issueId === issue.issueId) {
|
|
|
|
openIssues.splice(openIssues.indexOf(issue), 1);
|
2019-06-14 13:22:17 +02:00
|
|
|
}
|
2019-07-04 14:45:46 +02:00
|
|
|
}
|
2019-04-10 08:59:42 +02:00
|
|
|
});
|
2019-07-04 14:45:46 +02:00
|
|
|
});
|
2019-04-10 08:59:42 +02:00
|
|
|
|
2019-07-04 14:45:46 +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() {}
|