Version 0.0.3 - View Changelog for more information

This commit is contained in:
IJustDev 2019-04-10 13:45:47 +02:00
parent aa18debda1
commit 5410d7e9ea
12 changed files with 222 additions and 94 deletions

View File

@ -12,6 +12,18 @@ Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how
### Removed: ### Removed:
- Interval for updating - Interval for updating
## [0.0.3] - 2019-04-10
### Added:
- Implemented [Create issue icon](./resources/dark/create.svg)
- Interval for updating (Issuelist now gets updated every ten minutes)
- Closed Issues View
- SSL server support
- License
### Refactored:
- [IssueProvider](./src/issueProvider.ts) splitted up in two parts: OpenIssuesProvider and ClosedIssuesProvider
- class Issue is now in [issue.ts](./src/issue.ts)
- organizing imports
- renaming
## [Unreleased] ## [Unreleased]
- Initial release - Initial release

21
LICENSE Normal file
View File

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2019 Panov Alexander
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

15
package-lock.json generated
View File

@ -1,6 +1,6 @@
{ {
"name": "gitea-vscode", "name": "gitea-vscode",
"version": "0.0.1", "version": "0.0.2",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {
@ -252,9 +252,12 @@
"dev": true "dev": true
}, },
"configparser": { "configparser": {
"version": "0.2.6", "version": "0.3.6",
"resolved": "https://registry.npmjs.org/configparser/-/configparser-0.2.6.tgz", "resolved": "https://registry.npmjs.org/configparser/-/configparser-0.3.6.tgz",
"integrity": "sha512-u0k0Xs6CBDUcCfHHX0rMgZ4QoRQm6V3sb9AuNYkKK+4kwTlBophxBQjuVbI61vTQSRTDx4Ds7CWDQTGusf5q0A==" "integrity": "sha512-qCYjKDEK69qRtm3n+RYM55b8XiH2uKfnI6qOKg+ZLrKSG5vY59RBcZhLxxVd18+B5C5Zc7Jy8KpFsB5YOAD+hw==",
"requires": {
"mkdirp": "^0.5.1"
}
}, },
"core-util-is": { "core-util-is": {
"version": "1.0.2", "version": "1.0.2",
@ -614,14 +617,12 @@
"minimist": { "minimist": {
"version": "0.0.8", "version": "0.0.8",
"resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz",
"integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=", "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0="
"dev": true
}, },
"mkdirp": { "mkdirp": {
"version": "0.5.1", "version": "0.5.1",
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz",
"integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=",
"dev": true,
"requires": { "requires": {
"minimist": "0.0.8" "minimist": "0.0.8"
} }

View File

@ -3,7 +3,7 @@
"displayName": "Gitea-VSCode", "displayName": "Gitea-VSCode",
"description": "Gitea Issue Tracker for vs-code", "description": "Gitea Issue Tracker for vs-code",
"publisher": "IJustDev", "publisher": "IJustDev",
"version": "0.0.2", "version": "0.0.3",
"engines": { "engines": {
"vscode": "^1.32.0" "vscode": "^1.32.0"
}, },
@ -11,7 +11,9 @@
"Other" "Other"
], ],
"activationEvents": [ "activationEvents": [
"onView:open-issues" "onView:open-issues",
"onCommand:giteaIssues.initRepo",
"onCommand:giteaIssues.refreshIssues"
], ],
"main": "./out/extension.js", "main": "./out/extension.js",
"contributes": { "contributes": {
@ -29,6 +31,10 @@
{ {
"id": "open-issues", "id": "open-issues",
"name": "Open Issues" "name": "Open Issues"
},
{
"id": "closed-issues",
"name": "Closed Issues"
} }
] ]
}, },
@ -77,7 +83,7 @@
}, },
"dependencies": { "dependencies": {
"axios": "^0.18.0", "axios": "^0.18.0",
"configparser": "^0.2.6" "configparser": "^0.3.6"
}, },
"repository": { "repository": {
"type": "github", "type": "github",

View File

@ -0,0 +1,4 @@
<svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">
<rect y="14" width="32" height="4" fill="#C5C5C5"/>
<rect x="14" y="32" width="32" height="4" transform="rotate(-90 14 32)" fill="#C5C5C5"/>
</svg>

After

Width:  |  Height:  |  Size: 244 B

View File

@ -0,0 +1,4 @@
<svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">
<rect y="14" width="32" height="4" fill="#424242"/>
<rect x="14" y="32" width="32" height="4" transform="rotate(-90 14 32)" fill="#424242"/>
</svg>

After

Width:  |  Height:  |  Size: 244 B

View File

@ -1,8 +1,5 @@
const ConfigParser = require("configparser"); const ConfigParser = require("configparser");
// import * as path from "path";
const path = require("path"); const path = require("path");
import * as fs from "fs";
export class RepositoryInformationManager { export class RepositoryInformationManager {
public token(rootPath: string | undefined) { public token(rootPath: string | undefined) {
@ -16,15 +13,12 @@ export class RepositoryInformationManager {
const domain = config.get("REPO", "domain"); const domain = config.get("REPO", "domain");
const repo_owner = config.get("REPO", "repo_owner"); const repo_owner = config.get("REPO", "repo_owner");
const repo_name = config.get("REPO", "repo_name"); const repo_name = config.get("REPO", "repo_name");
return "http://" + domain + "/api/v1/repos/" + repo_owner + "/" + repo_name + "/issues"; const ssl = config.get("REPO", "ssl");
const prefix = ssl ? "https" : "http";
return prefix + "://" + domain + "/api/v1/repos/" + repo_owner + "/" + repo_name + "/issues";
} }
public saveRepoInformation(rootPath: string | undefined, repoInformations: any) { public saveRepoInformation(rootPath: string | undefined, repoInformations: any) {
const file_path = path.join(rootPath as string, ".gitea/config.ini"); const file_path = path.join(rootPath as string, ".gitea/config.ini");
try {
fs.mkdirSync(path.join(rootPath as string, ".gitea/"));
} catch (error) {
}
const config = new ConfigParser(); const config = new ConfigParser();
config.addSection("PRIVATE"); config.addSection("PRIVATE");
config.addSection("REPO"); config.addSection("REPO");
@ -32,6 +26,7 @@ export class RepositoryInformationManager {
config.set("REPO", "domain", repoInformations.domain); config.set("REPO", "domain", repoInformations.domain);
config.set("REPO", "repo_owner", repoInformations.repo_owner); config.set("REPO", "repo_owner", repoInformations.repo_owner);
config.set("REPO", "repo_name", repoInformations.repo_name); config.set("REPO", "repo_name", repoInformations.repo_name);
config.write(file_path); config.set("REPO", "ssl", true);
config.write(file_path, true);
} }
} }

View File

@ -1,68 +1,75 @@
import { html } from './template.html';
// The module 'vscode' contains the VS Code extensibility API
// Import the module and reference it with the alias vscode in your code below
import * as vscode from 'vscode'; import * as vscode from 'vscode';
import { IssueProvider, Issue } from './issueProvider';
import { RepositoryInformationManager } from './configurationProvider';
// this method is called when your extension is activated
// your extension is activated the very first time the command is executed
export function activate(context: vscode.ExtensionContext) {
const issueProvider = new IssueProvider();
// Use the console to output diagnostic information (console.log) and errors (console.error)
// This line of code will only be executed once when your extension is activated
let disposable = vscode.commands.registerCommand('giteaIssues.initRepo', async () => { import { showIssueHTML } from './template.html';
if (vscode.workspace.rootPath === undefined) { import { Issue } from "./issue";
return vscode.window.showErrorMessage("No project opened!"); import { RepositoryInformationManager } from './configurationProvider';
} import { OpenIssuesProvider, ClosedIssuesProvider } from './issueProvider';
let Token, Domain, Owner, Name;
await vscode.window.showInputBox({ export function activate(context: vscode.ExtensionContext) {
placeHolder: "Enter your gitea token here", let disposable = vscode.commands.registerCommand('giteaIssues.initRepo', () => {
}).then(token => { initializeIssueTracker();
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);
}); });
context.subscriptions.push(disposable); context.subscriptions.push(disposable);
vscode.window.registerTreeDataProvider('open-issues', issueProvider); 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) => { vscode.commands.registerCommand('giteaIssues.openIssue', (issue: Issue) => {
const panel = vscode.window.createWebviewPanel('issue', issue.label, const panel = vscode.window.createWebviewPanel('issue', issue.label,
vscode.ViewColumn.Active, vscode.ViewColumn.Active,
{}); {});
panel.webview.html = html(issue); panel.webview.html = showIssueHTML(issue);
}); });
vscode.commands.registerCommand('giteaIssues.refreshIssues', () => { vscode.commands.registerCommand('giteaIssues.refreshIssues', () => {
issueProvider.refresh(); openIssuesProvider.refresh();
closedIssuesProvider.refresh();
}); });
// The command has been defined in the package.json file
// Now provide the implementation of the command with registerCommand
// The commandId parameter must match the command field in package.json
} }
// this method is called when your extension is deactivated
export function deactivate() { } export function deactivate() { }
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);
}

20
src/issue.ts Normal file
View File

@ -0,0 +1,20 @@
import * as vscode from "vscode";
export class Issue extends vscode.TreeItem {
constructor(public readonly label: string,
public issueId: number,
public body: string,
public issueState: string,
public assignee: string,
public firstlabel: string,
public readonly collapsibleState: vscode.TreeItemCollapsibleState,
public readonly command?: vscode.Command) {
super(label, collapsibleState);
}
get tooltip() {
return this.label + " - " + this.assignee;
}
contextValue = 'issue';
}

View File

@ -1,8 +1,10 @@
import * as vscode from "vscode";
import axios from "axios"; import axios from "axios";
import * as vscode from "vscode";
import { Issue } from "./issue";
import { RepositoryInformationManager } from "./configurationProvider"; import { RepositoryInformationManager } from "./configurationProvider";
export class IssueProvider implements vscode.TreeDataProvider<Issue> { export class OpenIssuesProvider implements vscode.TreeDataProvider<Issue> {
private _onDidChangeTreeData: vscode.EventEmitter<Issue | undefined> = new vscode.EventEmitter<Issue | undefined>(); private _onDidChangeTreeData: vscode.EventEmitter<Issue | undefined> = new vscode.EventEmitter<Issue | undefined>();
readonly onDidChangeTreeData: vscode.Event<Issue | undefined> = this._onDidChangeTreeData.event; readonly onDidChangeTreeData: vscode.Event<Issue | undefined> = this._onDidChangeTreeData.event;
@ -14,17 +16,24 @@ export class IssueProvider implements vscode.TreeDataProvider<Issue> {
this._onDidChangeTreeData.fire(); this._onDidChangeTreeData.fire();
} }
constructor() { } constructor() {
// Auto update the issuelist after 10 minutes
setInterval(() => {
this.refresh();
}, 10 * 60 * 1000);
}
getTreeItem(element: Issue): vscode.TreeItem | Thenable<vscode.TreeItem> { getTreeItem(element: Issue): vscode.TreeItem | Thenable<vscode.TreeItem> {
return element; return element;
} }
/**
* Returns a list of all open issues;
*/
async getChildrenAsync() { async getChildrenAsync() {
this.issueList = []; this.issueList = [];
const repoMng = new RepositoryInformationManager(); const repoMng = new RepositoryInformationManager();
const repoUri = repoMng.repoApiUrl(vscode.workspace.rootPath); const repoUri = repoMng.repoApiUrl(vscode.workspace.rootPath);
console.log(repoUri);
const token = repoMng.token(vscode.workspace.rootPath); const token = repoMng.token(vscode.workspace.rootPath);
let stop = false; let stop = false;
for (let i = 0; i !== 10; i++) { for (let i = 0; i !== 10; i++) {
@ -53,8 +62,7 @@ export class IssueProvider implements vscode.TreeDataProvider<Issue> {
}); });
this.issueList.push(issueForList); this.issueList.push(issueForList);
} }
}).catch(err => { }).catch(() => {
console.log(err);
stop = true; stop = true;
vscode.window.showErrorMessage("Can't fetch issues; HTTP Error!"); vscode.window.showErrorMessage("Can't fetch issues; HTTP Error!");
return; return;
@ -63,8 +71,6 @@ export class IssueProvider implements vscode.TreeDataProvider<Issue> {
return; return;
} }
} }
console.log(this.issueList);
} }
getChildren(element?: Issue): vscode.ProviderResult<any[]> { getChildren(element?: Issue): vscode.ProviderResult<any[]> {
return this.issueList; return this.issueList;
@ -73,21 +79,73 @@ export class IssueProvider implements vscode.TreeDataProvider<Issue> {
} }
export class Issue extends vscode.TreeItem { export class ClosedIssuesProvider implements vscode.TreeDataProvider<Issue> {
constructor(public readonly label: string, private _onDidChangeTreeData: vscode.EventEmitter<Issue | undefined> = new vscode.EventEmitter<Issue | undefined>();
public issueId: number, readonly onDidChangeTreeData: vscode.Event<Issue | undefined> = this._onDidChangeTreeData.event;
public body: string,
public issueState: string, issueList: Issue[] = [];
public assignee: string,
public firstlabel: string, async refresh() {
public readonly collapsibleState: vscode.TreeItemCollapsibleState, await this.getChildrenAsync();
public readonly command?: vscode.Command) { this._onDidChangeTreeData.fire();
super(label, collapsibleState);
} }
get tooltip() { constructor() {
return this.label + " - " + this.assignee; setInterval(() => {
this.refresh();
}, 10 * 60 * 1000);
} }
contextValue = 'issue';
getTreeItem(element: Issue): vscode.TreeItem | Thenable<vscode.TreeItem> {
return element;
}
async getChildrenAsync() {
this.issueList = [];
const repoMng = new RepositoryInformationManager();
const repoUri = repoMng.repoApiUrl(vscode.workspace.rootPath);
const token = repoMng.token(vscode.workspace.rootPath);
let stop = false;
for (let i = 0; i !== 10; i++) {
await axios.get(repoUri + "?state=closed&page=" + i, { headers: { Authorization: "token " + token } }).then(res => {
for (const issue of res.data) {
const id = issue["number"];
let isAlreadyInList = false;
this.issueList.forEach((issueOfList) => {
if (id === issueOfList.issueId) {
isAlreadyInList = true;
}
});
if (isAlreadyInList) {
continue;
}
const title = issue["title"];
const body = issue["body"];
const state = issue["state"];
const assignee = issue["assignee"] === null ? "None" : issue["assignee"]["username"];
const tmpIssue = new Issue("#" + id + " - " + title, id, body, state, assignee, "Frontend", vscode.TreeItemCollapsibleState.None);
const issueForList = new Issue(tmpIssue.label, tmpIssue.issueId, tmpIssue.body, tmpIssue.issueState,
tmpIssue.assignee, tmpIssue.firstlabel, tmpIssue.collapsibleState, {
command: 'giteaIssues.openIssue',
title: '',
arguments: [tmpIssue],
});
this.issueList.push(issueForList);
}
}).catch(() => {
stop = true;
vscode.window.showErrorMessage("Can't fetch issues; HTTP Error!");
return;
});
if (stop) {
return;
}
}
}
getChildren(element?: Issue): vscode.ProviderResult<any[]> {
return this.issueList;
}
} }

View File

@ -1,6 +1,6 @@
import { Issue } from "./issueProvider"; import { Issue } from "./issue";
export function html(issue: Issue) { export function showIssueHTML(issue: Issue) {
return `<body> return `<body>
<h1>{{label}}</h1> <h1>{{label}}</h1>

Binary file not shown.