From f8b4ef07ecceedced2eb70015440efcb2cbfd7b6 Mon Sep 17 00:00:00 2001 From: gioboa Date: Fri, 2 Oct 2020 11:05:10 +0200 Subject: [PATCH] v 0.22.1 Bug Fixes - Added work log time begins at submitted time --- CHANGELOG.md | 6 ++++++ package-lock.json | 2 +- package.json | 2 +- src/commands/issue-add-worklog.ts | 9 ++++++--- src/services/http.model.ts | 1 + src/services/utilities.service.ts | 15 +++++++++++++-- 6 files changed, 28 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2d45b19..fda7dc4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## 0.22.1 + +### Bug Fixes + +- Added work log time begins at submitted time + ## 0.22.0 ### Features diff --git a/package-lock.json b/package-lock.json index 740ba29..8035502 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "jira-plugin", - "version": "0.21.0", + "version": "0.22.1", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index b7a2360..7161681 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.22.0", + "version": "0.22.1", "publisher": "gioboa", "icon": "images/icons/icon.png", "galleryBanner": { diff --git a/src/commands/issue-add-worklog.ts b/src/commands/issue-add-worklog.ts index 8d2403c..0b8d4cd 100644 --- a/src/commands/issue-add-worklog.ts +++ b/src/commands/issue-add-worklog.ts @@ -1,5 +1,5 @@ import * as vscode from 'vscode'; -import { logger, store } from '../services'; +import { logger, store, utilities } from '../services'; import { NO_WORKING_ISSUE } from '../shared/constants'; import openIssue from './open-issue'; @@ -8,10 +8,13 @@ export default async function issueAddWorklog(issueKey: string, timeSpentSeconds if (issueKey !== NO_WORKING_ISSUE.key) { if (store.canExecuteJiraAPI()) { // call Jira API + const actualTimeSpentSeconds = Math.ceil(timeSpentSeconds / 60) * 60; + const startedTime = new Date(Date.now() - actualTimeSpentSeconds * 1000); const response = await store.state.jira.addWorkLog({ issueKey, - timeSpentSeconds: Math.ceil(timeSpentSeconds / 60) * 60, - comment + timeSpentSeconds: actualTimeSpentSeconds, + comment, + started: utilities.dateToLocalISO(startedTime), }); const action = await vscode.window.showInformationMessage(`Worklog added`, 'Open in browser'); if (action === 'Open in browser') { diff --git a/src/services/http.model.ts b/src/services/http.model.ts index dae3060..5586ed8 100644 --- a/src/services/http.model.ts +++ b/src/services/http.model.ts @@ -113,6 +113,7 @@ export interface IAddWorkLog { issueKey: string; timeSpentSeconds: number; comment?: string; + started: string; } export interface IIssueType { diff --git a/src/services/utilities.service.ts b/src/services/utilities.service.ts index 7f0e9e6..d657646 100644 --- a/src/services/utilities.service.ts +++ b/src/services/utilities.service.ts @@ -11,7 +11,7 @@ export default class UtilitiesService { addStatusIcon(status: string, withDescription: boolean): string { let icon = STATUS_ICONS.DEFAULT.icon; if (!!status) { - Object.values(STATUS_ICONS).forEach(value => { + Object.values(STATUS_ICONS).forEach((value) => { if (status.toUpperCase().indexOf(value.text.toUpperCase()) !== -1) { icon = value.icon; } @@ -80,7 +80,7 @@ export default class UtilitiesService { insertWorkingIssueComment() { const editor = vscode.window.activeTextEditor; if (editor && store.state.workingIssue) { - editor.edit(edit => { + editor.edit((edit) => { const workingIssue = store.state.workingIssue; edit.insert(editor.selection.active, `// ${workingIssue.issue.key} - ${workingIssue.issue.fields.summary}`); }); @@ -113,4 +113,15 @@ export default class UtilitiesService { } return projects; } + + dateToLocalISO(date: Date): string { + const off = date.getTimezoneOffset(); + const absoff = Math.abs(off); + return ( + new Date(date.getTime() - off * 60 * 1000).toISOString().substr(0, 23) + + (off > 0 ? '-' : '+') + + (absoff / 60).toFixed(0).padStart(2, '0') + + (absoff % 60).toString().padStart(2, '0') + ); + } }