Skip to content

Commit

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

- managed error message when configuration is empty
- credentials in json format
  • Loading branch information
gioboa committed May 3, 2019
1 parent f3d2354 commit 1c24476
Show file tree
Hide file tree
Showing 11 changed files with 39 additions and 11 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## 0.16.1

### Bug Fixes

- managed error message when configuration is empty
- credentials in json format

## 0.16.0

### Features
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ The extension store credentials in VS Code settings.<br><br>
Automatically watch for branch switching and select appropriate project and working issue
- **Group Task And Subtasks** <br>
Group task and subtasks into explorer
- **Issue List Auto Refresh Interval** <br>
- **Issue List Auto Refresh Interval** <br>
Refresh explorer every x minutes (n.b: setting to 0 disables auto-refresh)
- **Number Of Issues In List** <br>
Number of issues to show in list (n.b: If you define high numbers the research can be slow)
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": "Jira integration for vscode",
"version": "0.16.0",
"version": "0.16.1",
"publisher": "gioboa",
"icon": "images/icons/icon.png",
"galleryBanner": {
Expand Down
18 changes: 17 additions & 1 deletion src/services/configuration.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,22 @@ export default class ConfigurationService {
public get credentials(): { username: string; password: string } {
const config = this.settings;
const credentials: string = (config && this.globalState.get(`${CONFIG_NAME}:${config.baseUrl}`)) || '';
let jsonCredentials = undefined;
try {
jsonCredentials = JSON.parse(credentials);
} catch (e) {
//
}
if (!!jsonCredentials) {
return jsonCredentials;
}
return this.OLD_credentials;
}

// DEPRECATED
public get OLD_credentials(): { username: string; password: string } {
const config = this.settings;
const credentials: string = (config && this.globalState.get(`${CONFIG_NAME}:${config.baseUrl}`)) || '';
const [username = '', password = ''] = credentials.split(CREDENTIALS_SEPARATOR);
return { username, password };
}
Expand Down Expand Up @@ -61,7 +76,8 @@ export default class ConfigurationService {
public async setPassword(password: string | undefined): Promise<void> {
const config = this.settings;
return (
config && this.globalState.update(`${CONFIG_NAME}:${config.baseUrl}`, `${config.username}${CREDENTIALS_SEPARATOR}${password || ''}`)
config &&
this.globalState.update(`${CONFIG_NAME}:${config.baseUrl}`, JSON.stringify({ username: config.username, password: password || '' }))
);
}

Expand Down
1 change: 1 addition & 0 deletions src/services/http.model.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export interface IJira {
baseUrl: string;
getCloudSession(): Promise<{ name: string; value: string }>;
search(params: { jql: string; maxResults: number }): Promise<ISearch>;
getStatuses(): Promise<IStatus[]>;
Expand Down
8 changes: 5 additions & 3 deletions src/services/http.service.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { configuration, logger } from '.';
import { ASSIGNEES_MAX_RESULTS, CONFIG } from '../shared/constants';
import { ASSIGNEES_MAX_RESULTS, CONFIG, ERROR_WRONG_CONFIGURATION } from '../shared/constants';
import { patchJiraInstance } from '../shared/jira-instance-patch';
import {
IAddComment,
Expand Down Expand Up @@ -34,9 +34,11 @@ export class Jira implements IJira {

constructor() {
if (!configuration.isValid()) {
if (!!configuration.get(CONFIG.BASE_URL) && !!configuration.credentials.username && !!configuration.credentials.password) {
logger.printErrorMessageInOutputAndShowAlert('Check Jira Plugin settings in VSCode.');
}
this.baseUrl = '';
logger.printErrorMessageInOutputAndShowAlert('Error: Check Jira Plugin settings in VSCode.');
return;
throw new Error(ERROR_WRONG_CONFIGURATION);
}

this.baseUrl = configuration.get(CONFIG.BASE_URL);
Expand Down
1 change: 1 addition & 0 deletions src/services/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import IssuesExplorer from '../explorer/issues-explorer';
import ConfigurationService from './configuration.service';
import CreateIssueService from './create-issue.service';
import GitIntegrationService from './git-integration.service';
import IssueHelperService from './issue-helper.service';
import LoggerService from './logger.service';
Expand Down
6 changes: 3 additions & 3 deletions src/services/logger.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ import { store } from '.';
export default class LoggerService {
public printErrorMessageInOutputAndShowAlert(err: any) {
if (store.state.channel) {
vscode.window.showErrorMessage(`Error: Check logs in Jira Plugin terminal output.`);
store.state.channel.append(`Error: ${err}\n`);
vscode.window.showErrorMessage(`Check logs in Jira Plugin terminal output.`);
store.state.channel.append(`${err.message || err}\n`);
}
}

public printErrorMessageInOutput(err: any) {
if (store.state.channel) {
store.state.channel.append(`Error: ${err}\n`);
store.state.channel.append(`${err.message || err}\n`);
}
}

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 @@ -54,7 +54,7 @@ export default class StoreService {
statusBar.updateWorkingProjectItem('', true);
}, 1000);
this.changeStateIssues('', '', []);
logger.printErrorMessageInOutputAndShowAlert(err);
logger.printErrorMessageInOutput(err);
}
}

Expand Down
1 change: 1 addition & 0 deletions src/shared/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ export const LOADING = { text: 'LOADING', file: 'cloud.png' };
export const UNASSIGNED = 'Unassigned';
export const NO_WORKING_ISSUE = { text: 'No working issue', key: 'NO_WORKING_ISSUE' };
export const BACK_PICK_LABEL = '$(arrow-left) Back';
export const ERROR_WRONG_CONFIGURATION = 'Wrong configuration';

export const SEARCH_MAX_RESULTS = 1000;
export const ASSIGNEES_MAX_RESULTS = 1000;
Expand Down

0 comments on commit 1c24476

Please sign in to comment.