Skip to content

Commit

Permalink
v 0.18.3
Browse files Browse the repository at this point in the history
Bug Fixes

- minor fixes
  • Loading branch information
gioboa committed Sep 11, 2019
1 parent a19b00f commit 43364a1
Show file tree
Hide file tree
Showing 12 changed files with 96 additions and 17 deletions.
8 changes: 8 additions & 0 deletions .github/ISSUE_TEMPLATE/--thank-you.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
name: "\U0001F495 Thank You"
about: If you like this project and wanna just say Hi...
title: ''
labels: ''
assignees: gioboa

---
2 changes: 0 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
"search.exclude": {
"out": true // set this to false to include "out" folder in search results
},
"prettier.printWidth": 140,
"prettier.singleQuote": true,
"workbench.colorCustomizations": {
"titleBar.activeBackground": "#e6e6e6",
"titleBar.activeForeground": "#000000",
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 0.18.3

### Bug Fixes

- minor fixes

## 0.18.2

### Bug Fixes
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "jira-plugin",
"displayName": "Jira Plugin",
"description": "Manage your on-premises/cloud Jira in vscode",
"version": "0.18.2",
"version": "0.18.3",
"publisher": "gioboa",
"icon": "images/icons/icon.png",
"galleryBanner": {
Expand Down
14 changes: 13 additions & 1 deletion src/commands/create-issue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,19 @@ const manageSelectedField = async (fieldToModifySelection: any): Promise<void> =
// update user choices
issueHelper.newIssueIstance[fieldToModifySelection.field] = text;
// update payload
issueHelper.requestJson[fieldToModifySelection.field] = text;
if (issueHelper.isIssueTimetrackingOriginalEstimateField(fieldToModifySelection.field)) {
issueHelper.requestJson[issueHelper.timetrakingJsonField] = {
...issueHelper.requestJson[issueHelper.timetrakingJsonField],
originalEstimate: text
};
} else if (issueHelper.isIssueTimetrackingRemainingEstimateField(fieldToModifySelection.field)) {
issueHelper.requestJson[issueHelper.timetrakingJsonField] = {
...issueHelper.requestJson[issueHelper.timetrakingJsonField],
remainingEstimate: text
};
} else {
issueHelper.requestJson[fieldToModifySelection.field] = text;
}
}
break;
case 'number':
Expand Down
13 changes: 10 additions & 3 deletions src/services/configuration.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,14 +125,21 @@ export default class ConfigurationService {
: `'${DEFAULT_WORKING_ISSUE_STATUS}'`;
}

private quoteValueIfNeeded(assignee: string): string {
const isQuoteNeeded = assignee !== 'currentUser()' && assignee.indexOf('membersOf(') === -1;
return isQuoteNeeded ? `'${assignee}'` : assignee;
}

public workingIssueAssignees(): string {
let assignees = (this.get(CONFIG.WORKING_ISSUE_ASSIGNEES).toString() || DEFAULT_WORKING_ISSUE_ASSIGNEE)
.split(',')
.map((status: string) => status.replace(/CURRENT_USER/g, 'currentUser()').trim());

return assignees && assignees.length > 0
? assignees
.reduce((a: string, b: string) => (a === '' ? a + `'${b}'` : `${a},'${b}'`), '')
.replace(`'currentUser()'`, `currentUser()`)
? assignees.reduce((a: string, b: string, index: number) => {
const quotedB = this.quoteValueIfNeeded(b);
return index === 0 ? `${quotedB}` : `${a},${quotedB}`;
}, '')
: DEFAULT_WORKING_ISSUE_ASSIGNEE;
}
}
3 changes: 3 additions & 0 deletions src/services/git-integration.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,9 @@ export default class GitIntegrationService {

private parseTicket(branchName: string): { project: string; issue: string } | null {
const matched = branchName.match(/([A-Z0-9]+)-(\d+)/);
// read settings and map custom names here
// project: matched[1].replace('MYPROJ', 'MYNEWPROJ'),
// issue: matched[0].replace('MYPROJ', 'MYNEWPROJ')
return (
matched && {
project: matched[1],
Expand Down
15 changes: 14 additions & 1 deletion src/services/http.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ export class Jira implements IJira {
});

patchJiraInstance(this.jiraInstance);

if (!!this.jiraInstance.testConnection) {
this.jiraInstance.testConnection();
}
}

async getCloudSession(): Promise<{ name: string; value: string }> {
Expand Down Expand Up @@ -93,7 +97,16 @@ export class Jira implements IJira {
}

async getProjects(): Promise<IProject[]> {
return await this.jiraInstance.project.getAllProjects();
let projects = [];
try {
projects = await this.jiraInstance.project.getAllProjects({ apiVersion: '3' });
} catch {
//
}
if (!projects.length) {
projects = await this.jiraInstance.project.getAllProjects();
}
return projects;
}

async getIssueByKey(issueKey: string): Promise<IIssue> {
Expand Down
40 changes: 36 additions & 4 deletions src/services/issue-helper.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,29 @@ export default class IssueHelperService {
this.newIssueIstance = {};
this.preloadedListValues = {};
this.requestJson = {};
this.issueTypeSelected = typeSelected;
this.issueTypeSelected = this.customIssueTypeSelected(typeSelected);
}

private customIssueTypeSelected(typeSelected: IIssueType | undefined): IIssueType | undefined {
if (!!typeSelected && !!typeSelected.fields) {
// we split timetraking field in two new fields and we will manage them as string
if (typeSelected.fields['timetracking']) {
typeSelected.fields['timetracking_originalestimate'] = {
...typeSelected.fields['timetracking'],
key: 'timetracking_originalestimate',
name: 'Original Estimate',
schema: { ...typeSelected.fields['timetracking'].schema, type: 'string' }
};
typeSelected.fields['timetracking_remainingestimate'] = {
...typeSelected.fields['timetracking'],
key: 'timetracking_remainingestimate',
name: 'Remaining Estimate',
schema: { ...typeSelected.fields['timetracking'].schema, type: 'string' }
};
delete typeSelected.fields['timetracking'];
}
}
return typeSelected;
}

public get project(): string {
Expand Down Expand Up @@ -115,6 +137,18 @@ export default class IssueHelperService {
return fieldName.toLowerCase() === 'issuelinks';
}

public get timetrakingJsonField(): string {
return 'timetracking';
}

public isIssueTimetrackingOriginalEstimateField(fieldName: string) {
return fieldName.toLowerCase() === 'timetracking_originalestimate';
}

public isIssueTimetrackingRemainingEstimateField(fieldName: string) {
return fieldName.toLowerCase() === 'timetracking_remainingestimate';
}

public isArrayType(type: string) {
return type.toString().toLowerCase() === 'array';
}
Expand Down Expand Up @@ -199,9 +233,7 @@ export default class IssueHelperService {
if (
!this.isEpicLinkFieldSchema(field.schema) &&
!this.isSprintFieldSchema(field.schema) &&
((!!field.schema.custom && (!field.allowedValues && !field.autoCompleteUrl)) ||
field.schema.type === 'date' ||
field.schema.type === 'timetracking')
((!!field.schema.custom && (!field.allowedValues && !field.autoCompleteUrl)) || field.schema.type === 'date')
) {
// output log useful for remote debug
logger.jiraPluginDebugLog(`field`, JSON.stringify(field));
Expand Down
2 changes: 1 addition & 1 deletion src/services/store.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export default class StoreService {
public incrementStateWorkingIssueTimePerSecond(): void {
this.state.workingIssue.trackingTime += 1;
// prevent writing to much on storage
if (this.state.workingIssue.trackingTime % 60 === 0) {
if (this.state.workingIssue.trackingTime % 5 === 0) {
if (this.state.workingIssue.issue.key !== NO_WORKING_ISSUE.key) {
configuration.setGlobalWorkingIssue(this.state.workingIssue);
}
Expand Down
6 changes: 3 additions & 3 deletions src/shared/jira-instance-patch.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
import { configuration } from '../services';
import { CONFIG } from './constants';

const cleanOptions = (options: any): void => {
if (!!options.headers && Object.keys(options.headers).length === 0) {
delete options.header;
Expand All @@ -19,6 +16,9 @@ export const patchJiraInstance = (jiraInstance: any) => {
const customGetAllProjects = (opts: any, callback: any) => {
const options = jiraInstance.project.buildRequestOptions(opts, '', 'GET');
cleanOptions(options);
if (!!opts && !!opts.apiVersion) {
options.uri = options.uri.replace('rest/api/2/', `rest/api/${opts.apiVersion}/`);
}
return jiraInstance.makeRequest(options, callback);
};
jiraInstance.project.getAllProjects = customGetAllProjects;
Expand Down

0 comments on commit 43364a1

Please sign in to comment.