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';
|
|
|
|
import { Issue } from "./issue";
|
2019-04-10 08:59:42 +02:00
|
|
|
import { RepositoryInformationManager } from './configurationProvider';
|
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) {
|
|
|
|
let disposable = vscode.commands.registerCommand('giteaIssues.initRepo', () => {
|
|
|
|
initializeIssueTracker();
|
2019-04-10 08:59:42 +02:00
|
|
|
});
|
|
|
|
context.subscriptions.push(disposable);
|
|
|
|
|
2019-04-10 13:45:47 +02:00
|
|
|
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 = "";
|
|
|
|
// });
|
|
|
|
|
2019-04-10 08:59:42 +02:00
|
|
|
vscode.commands.registerCommand('giteaIssues.openIssue', (issue: Issue) => {
|
|
|
|
const panel = vscode.window.createWebviewPanel('issue', issue.label,
|
|
|
|
vscode.ViewColumn.Active,
|
|
|
|
{});
|
2019-04-10 13:45:47 +02:00
|
|
|
panel.webview.html = showIssueHTML(issue);
|
2019-04-10 08:59:42 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
vscode.commands.registerCommand('giteaIssues.refreshIssues', () => {
|
2019-04-10 13:45:47 +02:00
|
|
|
openIssuesProvider.refresh();
|
|
|
|
closedIssuesProvider.refresh();
|
2019-04-10 08:59:42 +02:00
|
|
|
});
|
|
|
|
|
2019-04-09 14:37:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
export function deactivate() { }
|
2019-04-10 13:45:47 +02:00
|
|
|
|
|
|
|
export async function initializeIssueTracker() {
|
|
|
|
if (vscode.workspace.rootPath === undefined) {
|
|
|
|
return vscode.window.showErrorMessage("No project opened!");
|
|
|
|
}
|
|
|
|
let Token, Domain, Owner, Name;
|
|
|
|
await vscode.window.showInputBox({
|
|
|
|
placeHolder: "Enter your gitea token here",
|
|
|
|
}).then(token => {
|
|
|
|
Token = token === undefined ? "" : token;
|
|
|
|
});
|
|
|
|
await vscode.window.showInputBox({
|
|
|
|
placeHolder: "Domain from your gitea server without 'https://'",
|
|
|
|
}).then(domain => {
|
|
|
|
Domain = domain === undefined ? "" : domain;
|
|
|
|
});
|
|
|
|
await vscode.window.showInputBox({
|
|
|
|
placeHolder: "Repository Owner",
|
|
|
|
}).then(owner => {
|
|
|
|
Owner = owner === undefined ? "" : owner;
|
|
|
|
});
|
|
|
|
await vscode.window.showInputBox({
|
|
|
|
placeHolder: "Repository Name",
|
|
|
|
}).then(name => {
|
|
|
|
Name = name === undefined ? "" : name;
|
|
|
|
});
|
|
|
|
const repoInfo = {
|
|
|
|
token: Token,
|
|
|
|
domain: Domain,
|
|
|
|
repo_owner: Owner,
|
|
|
|
repo_name: Name,
|
|
|
|
};
|
|
|
|
const rpim = new RepositoryInformationManager();
|
|
|
|
rpim.saveRepoInformation(vscode.workspace.rootPath, repoInfo);
|
|
|
|
}
|