Skip to content

Commit

Permalink
v 0.15.2
Browse files Browse the repository at this point in the history
- removed copy-paste lib and use new clipboard API
- solved issue in application state when there are multiple VsCode instances
  • Loading branch information
gioboa committed Mar 8, 2019
1 parent b472335 commit 023ce42
Show file tree
Hide file tree
Showing 27 changed files with 357 additions and 381 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## 0.15.2

### Bug Fixes

- removed copy-paste lib and use new clipboard API
- solved issue in application state when there are multiple VsCode instances

## 0.15.1

### Bug Fixes
Expand Down
4 changes: 1 addition & 3 deletions 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": "Jira integration for vscode",
"version": "0.15.1",
"version": "0.15.2",
"publisher": "gioboa",
"icon": "images/icons/icon.png",
"galleryBanner": {
Expand Down Expand Up @@ -363,7 +363,6 @@
}
},
"devDependencies": {
"@types/copy-paste": "^1.1.30",
"@types/mocha": "^5.2.6",
"@types/node": "^11.9.5",
"husky": "^1.3.1",
Expand All @@ -374,7 +373,6 @@
"vscode": "^1.1.30"
},
"dependencies": {
"copy-paste": "^1.3.0",
"jira-connector": "^2.10.0"
}
}
11 changes: 5 additions & 6 deletions src/commands/change-issue-assignee.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
import * as vscode from 'vscode';
import { IssueItem } from '../explorer/item/issue-item';
import state, { canExecuteJiraAPI, isWorkingIssue } from '../store/state';
import { selectValues, logger } from '../services';
import { logger, selectValues, store } from '../services';

export default async function changeIssueAssigneeCommand(issueItem: IssueItem): Promise<void> {
try {
if (issueItem && issueItem.issue && canExecuteJiraAPI()) {
if (issueItem && issueItem.issue && store.canExecuteJiraAPI()) {
let issue = issueItem.issue;
// verify if it's the current working issue
if (!isWorkingIssue(issue.key)) {
if (!store.isWorkingIssue(issue.key)) {
let assignee = await selectValues.selectAssignee(false, false, true, undefined);
if (!!assignee) {
// call Jira API
const res = await state.jira.setAssignIssue({ issueKey: issue.key, assignee: <string>assignee });
const res = await store.state.jira.setAssignIssue({ issueKey: issue.key, assignee: <string>assignee });
await vscode.commands.executeCommand('jira-plugin.refresh');
}
}
} else {
if (canExecuteJiraAPI()) {
if (store.canExecuteJiraAPI()) {
logger.printErrorMessageInOutputAndShowAlert('Use this command from Jira Plugin EXPLORER');
}
}
Expand Down
11 changes: 5 additions & 6 deletions src/commands/change-issue-status.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
import * as vscode from 'vscode';
import { IssueItem } from '../explorer/item/issue-item';
import { logger, selectValues } from '../services';
import state, { canExecuteJiraAPI, isWorkingIssue } from '../store/state';
import { logger, selectValues, store } from '../services';

export default async function changeIssueStatusCommand(issueItem: IssueItem): Promise<void> {
try {
if (issueItem && issueItem.issue && canExecuteJiraAPI()) {
if (issueItem && issueItem.issue && store.canExecuteJiraAPI()) {
let issue = issueItem.issue;
// verify if it's the current working issue
if (!isWorkingIssue(issue.key)) {
if (!store.isWorkingIssue(issue.key)) {
const newTransitionId = await selectValues.selectTransition(issue.key);
if (newTransitionId) {
// call Jira API
const result = await state.jira.setTransition({
const result = await store.state.jira.setTransition({
issueKey: issue.key,
transition: {
transition: {
Expand All @@ -24,7 +23,7 @@ export default async function changeIssueStatusCommand(issueItem: IssueItem): Pr
}
}
} else {
if (canExecuteJiraAPI()) {
if (store.canExecuteJiraAPI()) {
logger.printErrorMessageInOutputAndShowAlert('Use this command from Jira Plugin EXPLORER');
}
}
Expand Down
7 changes: 3 additions & 4 deletions src/commands/create-issue.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
import * as vscode from 'vscode';
import { IssueItem } from '../explorer/item/issue-item';
import { configuration, createIssue, logger, selectValues } from '../services';
import { configuration, createIssue, logger, selectValues, store } from '../services';
import { IPickValue } from '../services/configuration.model';
import { CONFIG } from '../shared/constants';
import state, { verifyCurrentProject } from '../store/state';

export default async function createIssueCommand(issueItem: IssueItem): Promise<void> {
const project = configuration.get(CONFIG.WORKING_PROJECT);
if (verifyCurrentProject(project)) {
if (store.verifyCurrentProject(project)) {
try {
// first of first we decide the type of the ticket
const availableTypes = await state.jira.getAllIssueTypesWithFields(project);
const availableTypes = await store.state.jira.getAllIssueTypesWithFields(project);
if (!!availableTypes) {
// here the user select which type of issue create
createIssue.init(await selectValues.selectIssueType(false, availableTypes));
Expand Down
2 changes: 1 addition & 1 deletion src/commands/favourites-filters.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { logger, selectValues } from '../services';
import { SEARCH_MODE } from '../shared/constants';
import { selectValues, logger } from '../services';

export default async function favouritesFiltersCommand(): Promise<void> {
try {
Expand Down
9 changes: 4 additions & 5 deletions src/commands/issue-add-comment.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import * as vscode from 'vscode';
import { IssueItem } from '../explorer/item/issue-item';
import { configuration, logger, selectValues, store } from '../services';
import { CONFIG } from '../shared/constants';
import state, { canExecuteJiraAPI } from '../store/state';
import { selectValues, logger, configuration } from '../services';

export default async function issueAddCommentCommand(issueItem: IssueItem): Promise<void> {
try {
if (issueItem && issueItem.issue && canExecuteJiraAPI()) {
if (issueItem && issueItem.issue && store.canExecuteJiraAPI()) {
let issue = issueItem.issue;
let text = await vscode.window.showInputBox({
ignoreFocusOut: true,
Expand All @@ -25,7 +24,7 @@ export default async function issueAddCommentCommand(issueItem: IssueItem): Prom
}
}
// call Jira API
const response = await state.jira.addNewComment({ issueKey: issue.key, comment: { body: text } });
const response = await store.state.jira.addNewComment({ issueKey: issue.key, comment: { body: text } });
await vscode.commands.executeCommand('jira-plugin.refresh');
// modal
const action = await vscode.window.showInformationMessage('Comment created', 'Open in browser');
Expand All @@ -40,7 +39,7 @@ export default async function issueAddCommentCommand(issueItem: IssueItem): Prom
}
}
} else {
if (canExecuteJiraAPI()) {
if (store.canExecuteJiraAPI()) {
logger.printErrorMessageInOutputAndShowAlert('Use this command from Jira Plugin EXPLORER');
}
}
Expand Down
7 changes: 3 additions & 4 deletions src/commands/issue-add-worklog.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import { logger, store } from '../services';
import { NO_WORKING_ISSUE } from '../shared/constants';
import state, { canExecuteJiraAPI } from '../store/state';
import { logger } from '../services';

export default async function issueAddWorklogCommand(issueKey: string, timeSpentSeconds: number, comment: string): Promise<void> {
try {
if (issueKey !== NO_WORKING_ISSUE.key) {
if (canExecuteJiraAPI()) {
if (store.canExecuteJiraAPI()) {
// call Jira API
const response = await state.jira.addWorkLog({
const response = await store.state.jira.addWorkLog({
issueKey: issueKey,
worklog: { timeSpentSeconds: Math.ceil(timeSpentSeconds / 60) * 60, comment }
});
Expand Down
23 changes: 12 additions & 11 deletions src/commands/set-working-issue.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import * as vscode from 'vscode';
import { IIssue, IWorkingIssue } from '../services/http.model';
import NoWorkingIssuePick from '../picks/no-working-issue-pick';
import { configuration, selectValues, statusBar, utilities } from '../services';
import { configuration, selectValues, statusBar, store, utilities } from '../services';
import { IIssue, IWorkingIssue } from '../services/http.model';
import { ACTIONS, CONFIG, NO_WORKING_ISSUE, TRACKING_TIME_MODE } from '../shared/constants';
import state, { changeStateWorkingIssue } from '../store/state';

export default async function setWorkingIssueCommand(storedWorkingIssue: IWorkingIssue, preloadedIssue: IIssue): Promise<void> {
// run it's called from status bar there is a working issue in the storage
Expand All @@ -13,19 +12,21 @@ export default async function setWorkingIssueCommand(storedWorkingIssue: IWorkin
const issue = workingIssues.find((issue: IIssue) => issue.key === storedWorkingIssue.issue.key);
if (!!issue) {
// YES - restart tracking time for the stored working issue
state.workingIssue = storedWorkingIssue;
store.state.workingIssue = storedWorkingIssue;
vscode.window.showInformationMessage(
`PENDING WORKING ISSUE: ${state.workingIssue.issue.key} | timeSpent: ${utilities.secondsToHHMMSS(state.workingIssue.trackingTime)}`
`PENDING WORKING ISSUE: ${store.state.workingIssue.issue.key} | timeSpent: ${utilities.secondsToHHMMSS(
store.state.workingIssue.trackingTime
)}`
);
// set stored working issue
changeStateWorkingIssue(state.workingIssue.issue, state.workingIssue.trackingTime);
store.changeStateWorkingIssue(store.state.workingIssue.issue, store.state.workingIssue.trackingTime);
} else {
// NO - set no working issue
changeStateWorkingIssue(new NoWorkingIssuePick().pickValue, 0);
store.changeStateWorkingIssue(new NoWorkingIssuePick().pickValue, 0);
}
} else {
// normal workflow, user must select a working issue
const workingIssue = state.workingIssue || new NoWorkingIssuePick().pickValue;
const workingIssue = store.state.workingIssue || new NoWorkingIssuePick().pickValue;
const newIssue = preloadedIssue || (await selectValues.selectChangeWorkingIssue());
if (!!newIssue && newIssue.key !== workingIssue.issue.key) {
if (
Expand Down Expand Up @@ -55,14 +56,14 @@ export default async function setWorkingIssueCommand(storedWorkingIssue: IWorkin
if (action === ACTIONS.YES || action === ACTIONS.YES_WITH_COMMENT) {
await vscode.commands.executeCommand(
'jira-plugin.issueAddWorklogCommand',
state.workingIssue.issue.key,
state.workingIssue.trackingTime,
store.state.workingIssue.issue.key,
store.state.workingIssue.trackingTime,
comment || ''
);
}
}
// set the new working issue
changeStateWorkingIssue(newIssue, 0);
store.changeStateWorkingIssue(newIssue, 0);
}
}
}
5 changes: 2 additions & 3 deletions src/commands/set-working-project.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { selectValues } from '../services';
import { changeStateProject } from '../store/state';
import { selectValues, store } from '../services';

export default async function setWorkingProjectCommand(): Promise<void> {
changeStateProject(await selectValues.selectProject());
store.changeStateProject(await selectValues.selectProject());
}
5 changes: 2 additions & 3 deletions src/commands/setup-credentials.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import * as vscode from 'vscode';
import { configuration } from '../services';
import { configuration, store } from '../services';
import { CONFIG } from '../shared/constants';
import { connectToJira } from '../store/state';

export default async function setupCredentials(): Promise<void> {
const baseUrl = configuration.get(CONFIG.BASE_URL);
Expand Down Expand Up @@ -41,5 +40,5 @@ export default async function setupCredentials(): Promise<void> {
})
);

await connectToJira();
await store.connectToJira();
}
17 changes: 10 additions & 7 deletions src/explorer/issues-explorer.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import * as vscode from 'vscode';
import { configuration, logger } from '../services';
import { configuration, logger, store } from '../services';
import { IIssue } from '../services/http.model';
import { CONFIG, GROUP_BY_FIELDS, LOADING } from '../shared/constants';
import state from '../store/state';
import { DividerItem } from './item/divider-item';
import { FilterInfoItem } from './item/filter-info-item';
import { IssueItem } from './item/issue-item';
Expand Down Expand Up @@ -115,7 +114,7 @@ export default class IssuesExplorer implements vscode.TreeDataProvider<IssueItem
// issue
if (!element) {
let project = await configuration.get(CONFIG.WORKING_PROJECT);
let issues = state.issues;
let issues = store.state.issues;
// generate all the item from issues saved in global state
if (issues.length > 0) {
if (issues.some(issue => !issue.fields.hasOwnProperty(this.groupByField.value))) {
Expand Down Expand Up @@ -148,7 +147,7 @@ export default class IssuesExplorer implements vscode.TreeDataProvider<IssueItem
return descA < descB ? -1 : descA > descB ? 1 : 0;
});
// add in the firt possition 'filter-info-item' and then the 'divider-item'
items.unshift(<any>new FilterInfoItem(project, state.currentFilter, issues.length), <any>new DividerItem('------'));
items.unshift(<any>new FilterInfoItem(project, store.state.currentSearch.filter, issues.length), <any>new DividerItem('------'));
// loop items and insert a separator when field value change
this.addSeparators(items, this.groupByField);
if (issues.length === configuration.get(CONFIG.NUMBER_ISSUES_IN_LIST)) {
Expand All @@ -158,11 +157,15 @@ export default class IssuesExplorer implements vscode.TreeDataProvider<IssueItem
return items;
} else {
// used for show loading item in the explorer
if (state.currentFilter === LOADING.text) {
return [new LoadingItem()];
if (store.state.currentSearch.filter === LOADING.text) {
return [!!project ? new LoadingItem() : []];
}
// no result
return [new FilterInfoItem(project, state.currentFilter, issues.length), new DividerItem('------'), new NoResultItem(project)];
return [
new FilterInfoItem(project, store.state.currentSearch.filter, issues.length),
new DividerItem('------'),
new NoResultItem(project)
];
}
} else {
// subtasks
Expand Down
13 changes: 5 additions & 8 deletions src/extension.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
import * as vscode from 'vscode';
import commands from './commands';
import './services';
import { gitIntegration, issuesExplorer, statusBar } from './services';
import { gitIntegration, issuesExplorer, statusBar, store } from './services';
import { CONFIG_NAME } from './shared/constants';
import state, { connectToJira } from './store/state';

let channel: vscode.OutputChannel;

export const activate = async (context: vscode.ExtensionContext): Promise<void> => {
channel = vscode.window.createOutputChannel(CONFIG_NAME.toUpperCase());
state.channel = channel;
const channel: vscode.OutputChannel = vscode.window.createOutputChannel(CONFIG_NAME.toUpperCase());
context.subscriptions.push(channel);
state.context = context;
store.state.channel = channel;
store.state.context = context;
vscode.window.registerTreeDataProvider('issuesExplorer', issuesExplorer);
context.subscriptions.push(statusBar);
context.subscriptions.push(gitIntegration);
context.subscriptions.push(...commands.register());
// create Jira Instance and try to connect
await connectToJira();
await store.connectToJira();
};
Loading

0 comments on commit 023ce42

Please sign in to comment.