Skip to content

Commit

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

- Added work log time begins at submitted time
  • Loading branch information
gioboa committed Oct 2, 2020
1 parent e97b3e8 commit f8b4ef0
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 7 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 0.22.1

### Bug Fixes

- Added work log time begins at submitted time

## 0.22.0

### Features
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.22.0",
"version": "0.22.1",
"publisher": "gioboa",
"icon": "images/icons/icon.png",
"galleryBanner": {
Expand Down
9 changes: 6 additions & 3 deletions src/commands/issue-add-worklog.ts
Original file line number Diff line number Diff line change
@@ -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';

Expand All @@ -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') {
Expand Down
1 change: 1 addition & 0 deletions src/services/http.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ export interface IAddWorkLog {
issueKey: string;
timeSpentSeconds: number;
comment?: string;
started: string;
}

export interface IIssueType {
Expand Down
15 changes: 13 additions & 2 deletions src/services/utilities.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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}`);
});
Expand Down Expand Up @@ -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')
);
}
}

0 comments on commit f8b4ef0

Please sign in to comment.