ADDED: Version 0.0.5 - Child items

This commit is contained in:
IJustDev 2019-04-12 08:09:19 +02:00
parent 7c709a5b6d
commit fcfe39add4
5 changed files with 68 additions and 94 deletions

View File

@ -29,6 +29,14 @@ Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how
### Fixed:
- [Issue 1][#1] - `\n` is now represented as ´<br/>´-tag
- [Issue 2][#2] - Markdown is now represented as HTML
## [0.0.5] - 2019-04-12
### Added:
- Child items to root items. Collapsable item now shows assignee, state, id and list all labels from the issue
### Refactored:
- Created two methods that are used in both classes (the closed and the open issues provider)
## [Unreleased]
- Initial release

41
package-lock.json generated
View File

@ -1,6 +1,6 @@
{
"name": "gitea-vscode",
"version": "0.0.3",
"version": "0.0.4",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
@ -62,6 +62,7 @@
"version": "1.0.10",
"resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz",
"integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==",
"dev": true,
"requires": {
"sprintf-js": "~1.0.2"
}
@ -304,11 +305,6 @@
"safer-buffer": "^2.1.0"
}
},
"entities": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/entities/-/entities-1.1.2.tgz",
"integrity": "sha512-f2LZMYl1Fzu7YSBKg+RoROelpOaNrcGmE9AZubeDfrCEia483oW4MI4VyFd5VNHIgQ/7qm1I0wUHK1eJnn2y2w=="
},
"es6-promise": {
"version": "4.2.6",
"resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.6.tgz",
@ -594,36 +590,11 @@
"verror": "1.10.0"
}
},
"linkify-it": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/linkify-it/-/linkify-it-2.1.0.tgz",
"integrity": "sha512-4REs8/062kV2DSHxNfq5183zrqXMl7WP0WzABH9IeJI+NLm429FgE1PDecltYfnOoFDFlZGh2T8PfZn0r+GTRg==",
"requires": {
"uc.micro": "^1.0.1"
}
},
"markdown-it": {
"version": "8.4.2",
"resolved": "https://registry.npmjs.org/markdown-it/-/markdown-it-8.4.2.tgz",
"integrity": "sha512-GcRz3AWTqSUphY3vsUqQSFMbgR38a4Lh3GWlHRh/7MRwz8mcu9n2IO7HOh+bXHrR9kOPDl5RNCaEsrneb+xhHQ==",
"requires": {
"argparse": "^1.0.7",
"entities": "~1.1.1",
"linkify-it": "^2.0.0",
"mdurl": "^1.0.1",
"uc.micro": "^1.0.5"
}
},
"marked": {
"version": "0.6.2",
"resolved": "https://registry.npmjs.org/marked/-/marked-0.6.2.tgz",
"integrity": "sha512-LqxwVH3P/rqKX4EKGz7+c2G9r98WeM/SW34ybhgNGhUQNKtf1GmmSkJ6cDGJ/t6tiyae49qRkpyTw2B9HOrgUA=="
},
"mdurl": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/mdurl/-/mdurl-1.0.1.tgz",
"integrity": "sha1-/oWy7HWlkDfyrf7BAP1sYBdhFS4="
},
"mime-db": {
"version": "1.38.0",
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.38.0.tgz",
@ -865,7 +836,8 @@
"sprintf-js": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz",
"integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw="
"integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=",
"dev": true
},
"sshpk": {
"version": "1.16.1",
@ -974,11 +946,6 @@
"integrity": "sha512-Og2Vn6Mk7JAuWA1hQdDQN/Ekm/SchX80VzLhjKN9ETYrIepBFAd8PkOdOTK2nKt0FCkmMZKBJvQ1dV1gIxPu/A==",
"dev": true
},
"uc.micro": {
"version": "1.0.6",
"resolved": "https://registry.npmjs.org/uc.micro/-/uc.micro-1.0.6.tgz",
"integrity": "sha512-8Y75pvTYkLJW2hWQHXxoqRgV7qb9B+9vFEtidML+7koHUFapnVJAZ6cKs+Qjz5Aw3aZWHMC6u0wJE3At+nSGwA=="
},
"uri-js": {
"version": "4.2.2",
"resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.2.2.tgz",

View File

@ -3,7 +3,7 @@
"displayName": "Gitea-VSCode",
"description": "Gitea Issue Tracker for vs-code",
"publisher": "IJustDev",
"version": "0.0.4",
"version": "0.0.5",
"engines": {
"vscode": "^1.32.0"
},

View File

@ -7,8 +7,8 @@ export class Issue extends vscode.TreeItem {
public body: string,
public issueState: string,
public assignee: string,
public firstlabel: string,
public readonly collapsibleState: vscode.TreeItemCollapsibleState,
public labels: any[],
public collapsibleState: vscode.TreeItemCollapsibleState,
public readonly command?: vscode.Command) {
super(label, collapsibleState);
}

View File

@ -1,7 +1,6 @@
import axios from "axios";
import * as vscode from "vscode";
// const MarkdownIt = require('markdown-it'), md = new MarkdownIt();
const marked = require("marked");
import { Issue } from "./issue";
import { RepositoryInformationManager } from "./configurationProvider";
@ -40,31 +39,10 @@ export class OpenIssuesProvider implements vscode.TreeDataProvider<Issue> {
let stop = false;
for (let i = 0; i !== 10; i++) {
await axios.get(repoUri + "?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 = marked(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(() => {
console.log(res.data);
parseToIssues(res, this.issueList);
}).catch((err) => {
console.log(err);
stop = true;
vscode.window.showErrorMessage("Can't fetch issues; HTTP Error!");
return;
@ -75,7 +53,7 @@ export class OpenIssuesProvider implements vscode.TreeDataProvider<Issue> {
}
}
getChildren(element?: Issue): vscode.ProviderResult<any[]> {
return this.issueList;
return getChildren(element, this.issueList);
}
@ -111,10 +89,45 @@ export class ClosedIssuesProvider implements vscode.TreeDataProvider<Issue> {
let stop = false;
for (let i = 0; i !== 10; i++) {
await axios.get(repoUri + "?state=closed&page=" + i, { headers: { Authorization: "token " + token } }).then(res => {
parseToIssues(res, this.issueList);
}).catch(() => {
stop = true; vscode.window.showErrorMessage("Can't fetch issues; HTTP Error!");
return;
});
if (stop) {
return;
}
}
}
getChildren(element?: Issue): vscode.ProviderResult<any[]> {
return getChildren(element, this.issueList);
}
}
export function getChildren(element: Issue | undefined, issueList: Issue[]) {
for (const issue of issueList) {
if (element === issue) {
let childItems: vscode.TreeItem[] = [
new vscode.TreeItem("Assignee - " + element.assignee, vscode.TreeItemCollapsibleState.None),
new vscode.TreeItem("State - " + element.issueState, vscode.TreeItemCollapsibleState.None),
new vscode.TreeItem("ID - " + element.issueId, vscode.TreeItemCollapsibleState.None)
];
for (let i = 0; i != element.labels.length; i++) {
const label = element.labels[i];
childItems.push(new vscode.TreeItem(label.name, vscode.TreeItemCollapsibleState.None));
}
return Promise.resolve(childItems);
}
}
return issueList;
}
export function parseToIssues(res: any, issueList: any[], collapsibleState: vscode.TreeItemCollapsibleState = vscode.TreeItemCollapsibleState.Collapsed) {
for (const issue of res.data) {
const id = issue["number"];
let isAlreadyInList = false;
this.issueList.forEach((issueOfList) => {
issueList.forEach((issueOfList) => {
if (id === issueOfList.issueId) {
isAlreadyInList = true;
}
@ -126,28 +139,14 @@ export class ClosedIssuesProvider implements vscode.TreeDataProvider<Issue> {
const body = marked(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 labels = issue["labels"];
const tmpIssue = new Issue("#" + id + " - " + title, id, body, state, assignee, labels, collapsibleState);
const issueForList = new Issue(tmpIssue.label, tmpIssue.issueId, tmpIssue.body, tmpIssue.issueState,
tmpIssue.assignee, tmpIssue.firstlabel, tmpIssue.collapsibleState, {
tmpIssue.assignee, tmpIssue.labels, 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;
issueList.push(issueForList);
}
}
}
getChildren(element?: Issue): vscode.ProviderResult<any[]> {
return this.issueList;
}
}