Skip to content

Commit

Permalink
Merge branch 'release/2.8.4'
Browse files Browse the repository at this point in the history
  • Loading branch information
VladimirPal committed Oct 31, 2018
2 parents 11a174f + f3af673 commit 1431b79
Show file tree
Hide file tree
Showing 8 changed files with 104 additions and 64 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
<a name="2.8.4"></a>
## [2.8.4](https://github.com/web-pal/chronos-timetracker/compare/v2.8.3...v2.8.4) (2018-10-31)


### Bug Fixes

* **Auth:** sso crowd authentication ([7724e46](https://github.com/web-pal/chronos-timetracker/commit/7724e46))
* quit app ([1ef898c](https://github.com/web-pal/chronos-timetracker/commit/1ef898c))



<a name="2.8.3"></a>
## [2.8.3](https://github.com/web-pal/chronos-timetracker/compare/v2.8.2...v2.8.3) (2018-10-30)

Expand Down
7 changes: 5 additions & 2 deletions app/main/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -468,9 +468,11 @@ ipcMain.on('load-issue-window', (event, url) => {
issueWindow.openDevTools();
}
issueWindow.on('close', (cEv) => {
if (!shouldQuit) {
console.log('close', cEv);
console.log('shouldQuit', shouldQuit);
if (process.platform !== 'darwin' || !shouldQuit) {
cEv.preventDefault();
issueWindow.hide();
issueWindow.webContents.send('hideForm');
}
});
ipcMain.on('page-fully-loaded', () => {
Expand All @@ -479,6 +481,7 @@ ipcMain.on('load-issue-window', (event, url) => {
}
});
ipcMain.on('close-issue-window', () => {
console.log('close-issue-window');
if (issueWindow) {
issueWindow.hide();
}
Expand Down
2 changes: 1 addition & 1 deletion app/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "Chronos",
"productName": "Chronos",
"version": "2.8.3",
"version": "2.8.4",
"description": "Native app for time-tracking fully integrated with JIRA",
"main": "./dist/main.prod.js",
"author": {
Expand Down
74 changes: 45 additions & 29 deletions app/renderer/api/profile.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import {
remote,
} from 'electron';
import querystring from 'querystring';
import config from 'config';
import jira from 'utils/jiraClient';
import {
Expand Down Expand Up @@ -194,55 +195,70 @@ export function getPermissions(
return jira.client.myPermissions.getMyPermissions(opts);
}

const handleNetError = (error: string): string => ({
'Error: net::ERR_INTERNET_DISCONNECTED': 'Internet disconnected',
'Error: net::ERR_PROXY_CONNECTION_FAILED': 'Proxy connection failed',
'Error: net::ERR_CONNECTION_RESET': 'Connection reset',
'Error: net::ERR_CONNECTION_CLOSE': 'Connection close',
'Error: net::ERR_NAME_NOT_RESOLVED': 'Page unavailable',
'Error: net::ERR_CONNECTION_TIMED_OUT': 'Nonnection timed out',
}[error] || 'Unknown Error');

export function getAuthCookies(
payload: {
pathname: string,
protocol: string,
username: string,
password: string,
baseUrl: string,
},
): Promise<*> {
const { username, password, baseUrl } = payload;
const url: string = `${baseUrl}/rest/auth/1/session`;
const {
pathname,
protocol,
username,
password,
baseUrl,
} = payload;
const url: string = `${baseUrl}/jira/rest/gadget/1.0/login`;
const request = remote.net.request({
url,
method: 'POST',
});
const form = {
os_username: username,
os_password: password,
};
const postData = querystring.stringify(form);
return new Promise((resolve, reject) => {
request.on('response', (response) => {
const status = response.statusCode;
response.on('data', (chunk) => {
try {
const json = JSON.parse(chunk);
if (status === 200) {
resolve(json);
} else {
reject(json);
}
} catch (e) {
reject(e);
}
});
response.on('error', (error) => {
reject(error);
});
const cookie = response.headers['set-cookie'];
if (response.headers['x-seraph-loginreason'].includes('OK')) {
resolve(cookie.map((d) => {
const name = d.split('=')[0];
const value = d.split(`${name}=`)[1].split(';')[0];
return ({
path: pathname,
name,
value,
httpOnly: protocol === 'http',
});
}));
}
reject(new Error('Incorrect email address and / or password.'));
});
request.on('error', (error) => {
reject(error);
reject(new Error(handleNetError(error)));
});
request.setHeader(
'User-agent',
'request',
);
request.setHeader(
'Content-Type',
'application/json',
'application/x-www-form-urlencoded',
);
request.write(
JSON.stringify({
username,
password,
}),
request.setHeader(
'Content-Length',
Buffer.byteLength(postData),
);
request.write(postData);
request.end();
});
}
44 changes: 28 additions & 16 deletions app/renderer/containers/Popups/IssueForm/IssueForm.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import React, { Component } from 'react';
import React, {
Component,
} from 'react';
import {
ipcRenderer,
} from 'electron';
Expand All @@ -25,6 +27,7 @@ class IssueForm extends Component<{}, any> {
componentDidMount() {
ipcRenderer.on('url', this.onLoadUrl);
ipcRenderer.on('showForm', this.onShowForm);
ipcRenderer.on('hideForm', this.onHideForm);
ipcRenderer.on('page-fully-loaded', () => {
setTimeout(() => {
this.setState({
Expand All @@ -38,6 +41,7 @@ class IssueForm extends Component<{}, any> {
componentWillUnmount() {
ipcRenderer.removeListener('url', this.onLoadUrl);
ipcRenderer.removeListener('showForm', this.onShowForm);
ipcRenderer.removeListener('hideForm', this.onHideForm);
}

onLoadUrl = (ev, url) => {
Expand All @@ -47,22 +51,22 @@ class IssueForm extends Component<{}, any> {
webview.setAttribute('preload', getPreload('issueFormPreload'));
webview.style.height = '100%';

webview.addEventListener('did-finish-load', () => {
if (
config.issueWindowDevTools ||
process.env.DEBUG_PROD === true
) {
webview.openDevTools();
}
});

webview.src = url;
document.getElementById('forWebview').appendChild(webview);
} else {
webview.src = url;
}
}

onHideForm = () => {
const webview = document.querySelector('webview');
webview.executeJavaScript(`
if (window.issueForm) {
window.issueForm.trigger('hide');
}
`);
}

onShowForm = (
ev,
{
Expand All @@ -79,21 +83,27 @@ class IssueForm extends Component<{}, any> {
});
}, 1000);
}
if (
config.issueWindowDevTools
|| process.env.DEBUG_PROD === 'true'
) {
webview.openDevTools();
}
document.getElementById('root').style.display = 'block';
this.setState({
show: true,
});
return webview.executeJavaScript(`
document.getElementById('page').style.display = 'none';
var issueForm = JIRA.Forms
${issueId ?
`.createEditIssueForm({ issueId: ${issueId} })` :
`.createCreateIssueForm({ pid: ${projectId} })`
${issueId
? `.createEditIssueForm({ issueId: ${issueId} })`
: `.createCreateIssueForm({ pid: ${projectId} })`
}
.bind('sessionComplete', function(ev, issues) {
${issueId ?
`ipcRenderer.send("issue-refetch", "${issueId}");` :
'ipcRenderer.send("issue-created", issues);'
${issueId
? `ipcRenderer.send("issue-refetch", "${issueId}");`
: 'ipcRenderer.send("issue-created", issues);'
}
ipcRenderer.send('close-issue-window');
})
Expand All @@ -104,6 +114,7 @@ class IssueForm extends Component<{}, any> {
var jiraDialog = issueForm.$popup[0];
formBody.style.maxHeight = (parseInt(formBody.style.maxHeight.replace('px', ''), 10) + 120).toString() + 'px';
jiraDialog.style.marginTop = (parseInt(jiraDialog.style.marginTop.replace('px', ''), 10) - 65).toString() + 'px';
issueForm.$popupHeading[0].lastElementChild.style.display = 'none';
}, 200);
} catch(err) {
console.log(err);
Expand All @@ -130,6 +141,7 @@ class IssueForm extends Component<{}, any> {
ipcRenderer.send('page-fully-loaded');
}
}, 500);
window.issueForm = issueForm;
`);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ const IssuesHeader: StatelessFunctionalComponent<Props> = ({
filtersApplied,
currentProjectId,
dispatch,
}: Props): Node =>
}: Props): Node => (
<SearchBar>
<SearchIcon
label="Search"
Expand Down Expand Up @@ -101,11 +101,12 @@ const IssuesHeader: StatelessFunctionalComponent<Props> = ({
}}
/>
</span>
{(filtersApplied !== 0) &&
<FiltersAppliedBadge />
{(filtersApplied !== 0)
&& <FiltersAppliedBadge />
}
</SearchOptions>
</SearchBar>;
</SearchBar>
);

function mapStateToProps(state) {
const filters = getUiState('issuesFilters')(state);
Expand Down
19 changes: 8 additions & 11 deletions app/renderer/sagas/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,28 +117,24 @@ export function* authSelfHostFlow(): Generator<*, *, *> {
yield put(uiActions.setUiState('authRequestInProcess', true));
const { href, hostname, port, pathname } = host;
const protocol = host.protocol.slice(0, -1);
const { session } = yield call(Api.getAuthCookies, {
const cookies = yield call(Api.getAuthCookies, {
pathname,
protocol,
username,
password,
baseUrl: href.replace(/\/$/, ''),
});
const cookie = {
path: pathname,
name: session.name,
value: session.value,
httpOnly: protocol === 'http',
};
const data = {
protocol,
hostname,
port,
pathname,
cookies: [cookie],
cookies,
};
yield put(authActions.authRequest(data));
} catch (err) {
if (err.errorMessages) {
yield put(uiActions.setUiState('authError', err.errorMessages[0]));
if (err && err.message) {
yield put(uiActions.setUiState('authError', err.message));
} else {
yield put(uiActions.setUiState(
'authError',
Expand Down Expand Up @@ -224,7 +220,6 @@ export function* authFlow(): Generator<*, *, *> {
} catch (err) {
if (err.debug) {
console.log(err.debug);
err.debug.request.headers.authorization = '***';
yield put(authActions.addAuthDebugMessage([
{
json: err.debug,
Expand All @@ -234,6 +229,8 @@ export function* authFlow(): Generator<*, *, *> {
yield put(uiActions.setUiState('authRequestInProcess', false));
yield put(uiActions.setUiState('authFormStep', 1));
yield put(uiActions.setUiState('authFormIsComplete', false));
yield put(uiActions.setUiState('initializeInProcess', false));
yield put(uiActions.setUiState('authorized', false));
yield put(uiActions.setUiState(
'authError',
'Can not authenticate user. Please try again',
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Chronos",
"version": "2.8.3",
"version": "2.8.4",
"description": "Full functionality time tracking software with direct JIRA integration",
"scripts": {
"dev": "yarn start-renderer-dev",
Expand Down

0 comments on commit 1431b79

Please sign in to comment.