diff --git a/.github/ISSUE_TEMPLATE/--thank-you.md b/.github/ISSUE_TEMPLATE/--thank-you.md new file mode 100644 index 0000000..9a8ea81 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/--thank-you.md @@ -0,0 +1,8 @@ +--- +name: "\U0001F495 Thank You" +about: If you like this project and wanna just say Hi... +title: '' +labels: '' +assignees: gioboa + +--- diff --git a/.vscode/settings.json b/.vscode/settings.json index 69ceda2..11be390 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -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", diff --git a/CHANGELOG.md b/CHANGELOG.md index 166d095..d871c32 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## 0.18.3 + +### Bug Fixes + +- minor fixes + ## 0.18.2 ### Bug Fixes diff --git a/package-lock.json b/package-lock.json index a7c25d9..230e750 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "jira-plugin", - "version": "0.18.1", + "version": "0.18.3", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 55e5b54..5816dcc 100644 --- a/package.json +++ b/package.json @@ -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": { diff --git a/src/commands/create-issue.ts b/src/commands/create-issue.ts index 3a98e79..9f1e9e5 100644 --- a/src/commands/create-issue.ts +++ b/src/commands/create-issue.ts @@ -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': diff --git a/src/services/configuration.service.ts b/src/services/configuration.service.ts index 8b98ac0..3bc2dba 100644 --- a/src/services/configuration.service.ts +++ b/src/services/configuration.service.ts @@ -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; } } diff --git a/src/services/git-integration.service.ts b/src/services/git-integration.service.ts index 13bab2e..bb82e31 100644 --- a/src/services/git-integration.service.ts +++ b/src/services/git-integration.service.ts @@ -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], diff --git a/src/services/http.service.ts b/src/services/http.service.ts index 2cf17a9..240eeaa 100644 --- a/src/services/http.service.ts +++ b/src/services/http.service.ts @@ -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 }> { @@ -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> { diff --git a/src/services/issue-helper.service.ts b/src/services/issue-helper.service.ts index 3c1cf83..3cea295 100644 --- a/src/services/issue-helper.service.ts +++ b/src/services/issue-helper.service.ts @@ -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 { @@ -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'; } @@ -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)); diff --git a/src/services/store.service.ts b/src/services/store.service.ts index f55bf16..9e591f5 100644 --- a/src/services/store.service.ts +++ b/src/services/store.service.ts @@ -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); } diff --git a/src/shared/jira-instance-patch.ts b/src/shared/jira-instance-patch.ts index f027187..05684d2 100644 --- a/src/shared/jira-instance-patch.ts +++ b/src/shared/jira-instance-patch.ts @@ -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; @@ -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;