Skip to content

Commit

Permalink
Merge branch 'release/3.0.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
VladimirPal committed Feb 18, 2019
2 parents 2b86d39 + 02db76a commit cea3d6e
Show file tree
Hide file tree
Showing 18 changed files with 197 additions and 123 deletions.
2 changes: 1 addition & 1 deletion app/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Chronos",
"version": "3.0.0-beta",
"version": "3.0.0",
"description": "Native app for time-tracking fully integrated with JIRA",
"main": "./dist/main.prod.js",
"author": {
Expand Down
3 changes: 3 additions & 0 deletions app/renderer/actions/actionTypes/attachments.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export const NEXT_ATTACHMENT = 'NEXT_ATTACHMENT';
export const PREV_ATTACHMENT = 'PREV_ATTACHMENT';
export const SELECT_ATTACHMENT = 'SELECT_ATTACHMENT';
1 change: 1 addition & 0 deletions app/renderer/actions/actionTypes/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export * from './sprints';
export * from './issues';
export * from './timer';
export * from './worklogs';
export * from './attachments';

export const INITIAL_CONFIGURE_APP = 'INITIAL_CONFIGURE_APP';
export const __CLEAR_ALL_REDUCERS__ = '__CLEAR_ALL_REDUCERS__';
15 changes: 15 additions & 0 deletions app/renderer/actions/attachments.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import * as types from './actionTypes';


export const nextAttachment = () => ({
type: types.NEXT_ATTACHMENT,
});

export const prevAttachment = () => ({
type: types.PREV_ATTACHMENT,
});

export const selectAttachment = index => ({
type: types.SELECT_ATTACHMENT,
payload: index,
});
2 changes: 2 additions & 0 deletions app/renderer/actions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ export * as sprintsActions from './sprints';
export * as resourcesActions from './resources';
export * as filtersActions from './filters';
export * as updaterActions from './updater';
export * as attachmentsActions from './attachments';


export * as types from './actionTypes';
export * as actionTypes from './actionTypes';
15 changes: 15 additions & 0 deletions app/renderer/attachmentWindow.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,21 @@ const attachmentReducer = (
attachments: action.attachments,
activeIndex: action.activeIndex,
};
case actionTypes.NEXT_ATTACHMENT:
return {
...state,
activeIndex: state.activeIndex + 1,
};
case actionTypes.PREV_ATTACHMENT:
return {
...state,
activeIndex: state.activeIndex - 1,
};
case actionTypes.SELECT_ATTACHMENT:
return {
...state,
activeIndex: action.payload,
};
default:
return state;
}
Expand Down
29 changes: 27 additions & 2 deletions app/renderer/authPreload.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
/* eslint-disable no-param-reassign */
import {
remote,
} from 'electron';
import {
actionTypes,
} from 'actions';
Expand Down Expand Up @@ -84,14 +87,29 @@ function initGoogle(base) {
}));
}

function init2F(base) {
hideNode('header', base);
hideNode('footer', base);

store.dispatch(setRendererUiState({
authFormIsComplete: true,
}));
}

function init() {
store.dispatch(setRendererUiState({
authFormIsComplete: false,
}));
if (global.location.host === 'id.atlassian.com' && global.location.pathname === '/login') {
if (
global.location.host === 'id.atlassian.com'
&& global.location.pathname === '/login'
) {
const base = document.getElementById('root');
const reset = document.getElementById('resetPassword');
if (base && reset) {
if (
base
&& reset
) {
initAtlassian(base, reset);
} else {
setTimeout(init, 500);
Expand All @@ -103,6 +121,13 @@ function init() {
} else {
setTimeout(init, 500);
}
} else if (global.location.host === 'auth.atlassian.com') {
const base = document.getElementById('root');
if (base) {
init2F(base);
} else {
setTimeout(init, 500);
}
} else if (global.location.pathname === '/login') {
back('Something has gone wrong');
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,14 @@ export const ItemContainer = styled.div`
&:hover {
background: rgb(239,239,239);
cursor:pointer;
}
`;

export const ItemImage = styled.img`
width: 150px;
height: 120px;
display:block;
max-width: 50%;
height: auto;
`;

export const InfoConatiner = styled.div`
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import {
remote,
} from 'electron';
import React, {
Component,
} from 'react';
Expand Down Expand Up @@ -76,10 +79,13 @@ class CloudLoginStep extends Component<Props, {}> {
});
}
});
webview.focus();
if (config.loginWindowDevTools) {
webview.openDevTools();
}
/* Focus will not work on webview without this blur */
remote.getCurrentWindow().blur();
remote.getCurrentWindow().focus();
webview.focus();

if (url.includes('login.jsp')) {
this.props.onError('Team not found');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class SelfHostLoginStep extends Component<Props> {
name="username"
type="text"
placeholder="Enter username"
withRef
forwardRef
ref={(el) => {
this.usernameInput = el;
}}
Expand Down
11 changes: 9 additions & 2 deletions app/renderer/containers/IssueView/IssueDetails/IssueDetails.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ const IssueDetails: StatelessFunctionalComponent<Props> = ({
<IssueDetailsContainer>
<Flex row spaceBetween>
<DetailsColumn>

<Flex row spaceBetween>
<DetailsLabel>
Type:
Expand Down Expand Up @@ -275,7 +274,15 @@ const IssueDetails: StatelessFunctionalComponent<Props> = ({
if (tag && (tag === 'img' || tag === 'a')) {
e.preventDefault();
if (tag === 'img') {
dispatch(issuesActions.showAttachmentWindow({ issueId: issue.id, activeIndex: null }));
const imgName = e.target.getAttribute('data-attachment-name');
const attachments = issue.fields.attachment;
const activeIndex = attachments.findIndex(item => item.filename === imgName);
dispatch(issuesActions.showAttachmentWindow(
{
issueId: issue.id,
activeIndex,
},
));
} else {
// external links only
const url = e.target.getAttribute(tag === 'a' ? 'href' : 'src');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,19 @@ const IssueWorklogs: StatelessFunctionalComponent<Props> = ({
dispatch(uiActions.setUiState({
editWorklogId: worklog.id,
worklogFormIssueId: issue.id,
worklog: true,
modalState: {
_merge: true,
worklog: true,
},
}));
}}
onDeleteWorklog={() => {
dispatch(uiActions.setUiState({
confirmDeleteWorklog: true,
deleteWorklogId: worklog.id,
modalState: {
_merge: true,
confirmDeleteWorklog: true,
},
}));
}}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,28 +64,39 @@ const WorklogItem: StatelessFunctionalComponent<Props> = ({
)}
<WorklogActions>
<Tooltip description="Open worklog in JIRA" position="left">
<LinkIcon
<span
onClick={openWorklogInBrowser(worklog.id, issueKey, baseUrl)}
label="Open in browser"
size="small"
primaryColor="#707070"
/>
>
<LinkIcon
label="Open in browser"
size="small"
primaryColor="#707070"
/>
</span>
</Tooltip>
<Tooltip description="Edit worklog" position="left">
<EditFilledIcon
onClick={() => onEditWorklog()}
label="Edit"
size="small"
primaryColor="#707070"
/>
<span
onClick={() => {
onEditWorklog();
}}
>
<EditFilledIcon
label="Edit"
size="small"
primaryColor="#707070"
/>
</span>
</Tooltip>
<Tooltip description="Delete worklog" position="left">
<TrashIcon
<span
onClick={() => onDeleteWorklog()}
label="Delete"
size="small"
primaryColor="#707070"
/>
>
<TrashIcon
label="Delete"
size="small"
primaryColor="#707070"
/>
</span>
</Tooltip>
</WorklogActions>
</Flex>
Expand Down
100 changes: 29 additions & 71 deletions app/renderer/containers/Popups/AttachmentPopup/AttachmentPopup.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,78 +7,36 @@ import {
import AttachmentPopupComponent from 'components/AttachmentPopup';
import LoaderAttachmentPopup from 'components/AttachmentPopup/LoaderAttachment';

class AttachmentPopup extends Component {
constructor(props) {
super(props);
this.state = {
activeIndex: 0,
};
}

componentWillReceiveProps(nextProps) {
const { attachments } = this.props;
if (nextProps.attachments.length !== attachments.length) {
this.setState({
activeIndex: 0,
});
}

if (nextProps.activeIndex !== null) {
this.setState({
activeIndex: nextProps.activeIndex,
});
}
}


selectAttachment = (index) => {
this.setState({
activeIndex: index,
});
};

nextAttachment = () => {
this.setState(prevState => ({
activeIndex: prevState.activeIndex + 1,
}));
};

prevAttachment = () => {
this.setState(prevState => ({
activeIndex: prevState.activeIndex - 1,
}));
};


render() {
const { activeIndex } = this.state;
const { attachments } = this.props;


return (
<React.Fragment>
{
attachments.length !== 0 ? (
<div>
<AttachmentPopupComponent
attachmentSize={attachments.length}
activeIndex={activeIndex}
attachmentItem={attachments[activeIndex]}
attachment={attachments}
nextAttachment={this.nextAttachment}
prevAttachment={this.prevAttachment}
selectAttachment={this.selectAttachment}
/>
</div>
) : (
<LoaderAttachmentPopup />
)
}
</React.Fragment>
);
}
import {
attachmentsActions,
}

from 'actions';

const AttachmentPopup = (
{
attachments,
activeIndex,
dispatch,
},
) => (
<React.Fragment>
{
attachments.length !== 0 ? (
<AttachmentPopupComponent
attachmentSize={attachments.length}
activeIndex={activeIndex}
attachmentItem={attachments[activeIndex]}
attachment={attachments}
nextAttachment={() => dispatch(attachmentsActions.nextAttachment())}
prevAttachment={() => dispatch(attachmentsActions.prevAttachment())}
selectAttachment={index => dispatch(attachmentsActions.selectAttachment(index))}
/>
) : (
<LoaderAttachmentPopup />
)
}
</React.Fragment>
);

function mapStateToProps(state) {
return {
Expand Down
Loading

0 comments on commit cea3d6e

Please sign in to comment.