Skip to content
This repository has been archived by the owner on Feb 25, 2022. It is now read-only.

Commit

Permalink
Minor fixes and functionality improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
Semyonic committed Jun 24, 2019
1 parent 47441ce commit 98f6d0d
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 40 deletions.
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,25 @@
# Change Log

## [1.0.1] - 2019-06-24

## Added
- Multiple issue view support
- JIRA task polling frequency configuration

## Changed
- Issue polling default frequency now 1800000 ms

## Removed
- Total task count notification (Due to every refresh on views was showing notification many times)

## Fixes
- Open Issue functionality
- More error controls added


## [1.0.0] - 2019-06-23

- Initial release

[1.0.1]: https://github.com/Semyonic/jira-aux/releases/tag/v1.0.1
[1.0.0]: https://github.com/Semyonic/jira-aux/releases/tag/v1.0.0
10 changes: 9 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "jiraux",
"displayName": "JirAux",
"description": "List and view your issues and create Git-flow like branches from them",
"version": "1.0.0",
"version": "1.0.1",
"author": "Semih Onay",
"publisher": "SemihOnay",
"engines": {
Expand Down Expand Up @@ -133,6 +133,14 @@
"default": "",
"description": "JIRA password"
},
"jira.poll": {
"type": [
"number",
"null"
],
"default": 1800000,
"description": "Polling frequency in miliseconds"
},
"jira.jqlExpression": {
"type": [
"string",
Expand Down
1 change: 1 addition & 0 deletions src/JiraFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ function instantiateJira(config: ExtensionConfig) {
port: config.port,
username: config.username,
password: config.password,
poll: config.poll,
apiVersion: '2',
strictSSL: false,
};
Expand Down
1 change: 1 addition & 0 deletions src/models/interfaces/JiraConfig.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export interface JiraConfig {
port?: string;
username: string;
password: string;
poll?: number;
apiVersion?: string;
strictSSL?: boolean;
jql?: string;
Expand Down
69 changes: 39 additions & 30 deletions src/providers/JiraProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ import jiraFactory from '../JiraFactory';
import { ExtensionConfig, IssueItem, IssueTypes, JiraResponse } from '../models/interfaces';
import { JiraIssue } from '../models/JiraIssue';
import { IssueDetailPanel } from '../views';

let jiraClient: { loadError: any; searchWithQueryFromConfig?: any };
let config: vscode.WorkspaceConfiguration;

try {
const config = vscode.workspace.getConfiguration('jira');
config = vscode.workspace.getConfiguration('jira');
jiraClient = jiraFactory.instantiateJira(config);
} catch (error) {
jiraClient = {
Expand Down Expand Up @@ -118,9 +120,7 @@ export class JiraProvider implements vscode.TreeDataProvider<vscode.TreeItem> {
const data: JiraResponse = await jiraClient.searchWithQueryFromConfig();
const total = data.issues.length;

data.total > 0
? vscode.window.showInformationMessage(`You got ${total} tasks`)
: vscode.window.showInformationMessage(`No issues, enjoy your day !`);
// data.total > 0 ? '' : vscode.window.showInformationMessage(`No issues, enjoy your day !`);

let children: JiraIssue[] = [];
const promises = data.issues.map(async (issue: IssueItem) => {
Expand All @@ -143,11 +143,11 @@ export class JiraProvider implements vscode.TreeDataProvider<vscode.TreeItem> {
}
}

private async refresh(config?: ExtensionConfig): Promise<void> {
private async refresh(configuration?: ExtensionConfig): Promise<void> {
if (!this.fetching) {
if (config) {
if (configuration) {
try {
jiraClient = jiraFactory.instantiateJira(config);
jiraClient = jiraFactory.instantiateJira(configuration);
} catch (error) {
jiraClient = {
loadError: error.message,
Expand All @@ -160,21 +160,21 @@ export class JiraProvider implements vscode.TreeDataProvider<vscode.TreeItem> {
}

private async poll(): Promise<void> {
const thirtyMinutes = 30 * 60 * 1000;
if (!this.lastFetch || this.lastFetch + thirtyMinutes < Date.now()) {
if (!this.lastFetch || this.lastFetch + config.poll < Date.now()) {
return this.refresh();
}
}

private openIssue(issue: JiraIssue): void {
const base = issue.item.self
.split('/rest')
.entries()
.next().value;
vscode.commands.executeCommand(
'vscode.open',
vscode.Uri.parse(`${base}/browse/${issue.item.key}`),
);
const base = issue.item.self.split('/rest')[0];
try {
vscode.commands.executeCommand(
'vscode.open',
vscode.Uri.parse(`${base}/browse/${issue.item.key}`),
);
} catch (error) {
console.error(error);
}
}

private showDescription({ item }: JiraIssue): void {
Expand All @@ -194,22 +194,31 @@ export class JiraProvider implements vscode.TreeDataProvider<vscode.TreeItem> {
const switchAndCreate: any = await childProc.exec(
`cd ${vscode.workspace.rootPath} && git fetch && git checkout -b ${branchName}`,
);
switchAndCreate.stderr.on('data', async x => {
if (x.includes('already')) {
try {
await this.switchBranch(branchName);
return await vscode.window.showInformationMessage(
`Switched to branch ${branchName}`,
);
} catch (err) {
vscode.window.showErrorMessage(err);
try {
switchAndCreate.stderr.on('data', async x => {
if (x.includes('already')) {
try {
await this.switchBranch(branchName);
return await vscode.window.showInformationMessage(
`Switched to branch ${branchName}`,
);
} catch (error) {
console.error(error);
vscode.window.showErrorMessage(error);
}
}
}
vscode.window.showInformationMessage(`${branchName} created and switched`);
});
vscode.window.showInformationMessage(`${branchName} created and switched`);
});
} catch (error) {
console.error(error);
}
}

private async switchBranch(branchName: string): Promise<void> {
await childProc.exec(`cd ${vscode.workspace.rootPath} && git checkout ${branchName}`);
try {
await childProc.exec(`cd ${vscode.workspace.rootPath} && git checkout ${branchName}`);
} catch (error) {
console.error(error);
}
}
}
10 changes: 1 addition & 9 deletions src/views/IssueDetailPanel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,6 @@ export class IssueDetailPanel {
? vscode.window.activeTextEditor.viewColumn
: undefined;

// If we already have a panel, show it.
if (IssueDetailPanel.currentPanel) {
IssueDetailPanel.currentPanel.panel.reveal(column);
return;
}

// Otherwise, create a new panel.
const panel = vscode.window.createWebviewPanel(
IssueDetailPanel.viewType,
Expand All @@ -39,7 +33,7 @@ export class IssueDetailPanel {
IssueDetailPanel.currentPanel = new IssueDetailPanel(panel, extensionPath);
}

private constructor(panel: vscode.WebviewPanel, extensionPath: string) {
constructor(panel: vscode.WebviewPanel, extensionPath: string) {
this.panel = panel;
this.extensionPath = extensionPath;

Expand Down Expand Up @@ -131,8 +125,6 @@ export class IssueDetailPanel {
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" href="" type="image/svg+xml" />
<link href="https://stackpath.bootstrapcdn.com/bootswatch/4.3.1/darkly/bootstrap.min.css" rel="stylesheet" integrity="sha384-w+8Gqjk9Cuo6XH9HKHG5t5I1VR4YBNdPt/29vwgfZR485eoEJZ8rJRbm3TR32P6k" crossorigin="anonymous">
</head>
<body>
<header>
Expand Down

0 comments on commit 98f6d0d

Please sign in to comment.