Fixes #11
Advanced logging of the url if the request fails. Removed SSL option.
This commit is contained in:
parent
79d6755e72
commit
7378f58665
2
package-lock.json
generated
2
package-lock.json
generated
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "gitea-vscode",
|
||||
"version": "0.0.8",
|
||||
"version": "1.0.1",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
|
21
package.json
21
package.json
@ -71,17 +71,16 @@
|
||||
"default": "",
|
||||
"description": "The token for the gitea server."
|
||||
},
|
||||
"gitea.domain": {
|
||||
"gitea.instanceURL": {
|
||||
"scope": "resource",
|
||||
"type": "string",
|
||||
"default": "",
|
||||
"description": "The remote gitea instance's domain."
|
||||
},
|
||||
"gitea.port": {
|
||||
"scope": "resource",
|
||||
"type": "number",
|
||||
"default": 80,
|
||||
"description": "The remote gitea instance's port."
|
||||
"examples": [
|
||||
"http://example.com:3000",
|
||||
"https://gitea.com"
|
||||
],
|
||||
"description": "The remote gitea instance's url. Should not end with a slash.",
|
||||
"pattern": "^(https|http)://"
|
||||
},
|
||||
"gitea.owner": {
|
||||
"scope": "resource",
|
||||
@ -94,12 +93,6 @@
|
||||
"type": "string",
|
||||
"default": "",
|
||||
"description": "The repository name."
|
||||
},
|
||||
"gitea.ssl": {
|
||||
"scope": "resource",
|
||||
"type": "boolean",
|
||||
"default": true,
|
||||
"description": "If https should be used or not."
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,11 +2,9 @@ import { workspace, window } from 'vscode';
|
||||
|
||||
interface ConfigStorage {
|
||||
token: string;
|
||||
domain: string;
|
||||
port: number;
|
||||
instanceURL: string;
|
||||
owner: string;
|
||||
repo: string;
|
||||
ssl: boolean;
|
||||
}
|
||||
|
||||
export interface ConfigTypes extends ConfigStorage {
|
||||
@ -44,20 +42,12 @@ export class Config implements ConfigTypes {
|
||||
this.storage.update('token', value);
|
||||
}
|
||||
|
||||
public get domain() {
|
||||
return this.loadConfigValue('domain', 'string');
|
||||
public set instanceUrl(value: string) {
|
||||
this.storage.update('instanceURL', value);
|
||||
}
|
||||
|
||||
public set domain(value) {
|
||||
this.storage.update('domain', value);
|
||||
}
|
||||
|
||||
public get port() {
|
||||
return this.loadConfigValue('port', 'number');
|
||||
}
|
||||
|
||||
public set port(value) {
|
||||
this.storage.update('port', value);
|
||||
public get instanceURL(): any {
|
||||
return this.loadConfigValue('instanceURL', 'string');
|
||||
}
|
||||
|
||||
public get owner() {
|
||||
@ -76,18 +66,7 @@ export class Config implements ConfigTypes {
|
||||
this.storage.update('repo', value);
|
||||
}
|
||||
|
||||
public get ssl() {
|
||||
return this.loadConfigValue('ssl', 'boolean', true);
|
||||
}
|
||||
|
||||
public set ssl(value) {
|
||||
this.storage.update('ssl', value);
|
||||
}
|
||||
|
||||
public get repoApiUrl() {
|
||||
if (this.ssl || this.port === 443) {
|
||||
return 'https://' + this.domain + '/api/v1/repos/' + this.owner + '/' + this.repo + '/issues';
|
||||
}
|
||||
return 'http://' + this.domain + ':' + this.port + '/api/v1/repos/' + this.owner + '/' + this.repo + '/issues';
|
||||
return this.instanceURL + '/api/v1/repos/' + this.owner + '/' + this.repo + '/issues';
|
||||
}
|
||||
}
|
||||
|
@ -40,7 +40,6 @@ export class OpenIssuesProvider implements vscode.TreeDataProvider<Issue> {
|
||||
await axios
|
||||
.get(repoUri + '?page=' + i, { headers: { Authorization: 'token ' + token } })
|
||||
.then((res) => {
|
||||
console.log(res.data);
|
||||
if (res.data.length === 0) {
|
||||
stop = true;
|
||||
return;
|
||||
@ -48,9 +47,8 @@ export class OpenIssuesProvider implements vscode.TreeDataProvider<Issue> {
|
||||
parseToIssues(res, this.issueList);
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err);
|
||||
stop = true;
|
||||
vscode.window.showErrorMessage("Can't fetch issues; HTTP Error!");
|
||||
vscode.window.showErrorMessage("An error occoured. Please check your repository url: " + repoUri);
|
||||
return;
|
||||
});
|
||||
if (stop) {
|
||||
@ -103,7 +101,7 @@ export class ClosedIssuesProvider implements vscode.TreeDataProvider<Issue> {
|
||||
})
|
||||
.catch(() => {
|
||||
stop = true;
|
||||
vscode.window.showErrorMessage("Can't fetch issues; HTTP Error!");
|
||||
vscode.window.showErrorMessage("An error occoured. Please check your repository url: " + repoUri);
|
||||
return;
|
||||
});
|
||||
if (stop) {
|
||||
|
Loading…
Reference in New Issue
Block a user