Skip to content

Commit

Permalink
feat(Tracking): add checkbox to post worklog comment also as issue co…
Browse files Browse the repository at this point in the history
…mment

ISSUES CLOSED: #90
  • Loading branch information
shafua committed Mar 23, 2018
1 parent ae57962 commit dc29640
Show file tree
Hide file tree
Showing 6 changed files with 83 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
EditButtonContainer,
} from './styled';

import WorklogCommentOptions from './WorklogCommentOptions';

type Props = {
issue: Issue,
Expand Down Expand Up @@ -106,6 +107,7 @@ class WorklogCommentDialog extends PureComponent<Props, State> {
onConfirm={this.onConfirm}
onCancel={this.onCancel}
/>
<WorklogCommentOptions />
<RemainingEstimatePicker
issue={this.props.issue}
value={this.props.remainingEstimateValue}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
// @flow
import React from 'react';
import { connect } from 'react-redux';
import { compose, withHandlers } from 'recompose';

import {
CheckboxStateless as Checkbox,
CheckboxGroup,
} from '@atlaskit/checkbox';

import {
uiActions,
} from 'actions';
import {
getUiState,
} from 'selectors';

import type {
StatelessFunctionalComponent,
Node,
} from 'react';

import type {
Dispatch,
} from 'types';

import {
IssueCommentCheckboxWrapper,
} from './styled';

type Props = {
postAlsoAsIssueComment: boolean,
changePostOption: () => void,
};

const WorklogCommentOptions: StatelessFunctionalComponent<Props> = ({
postAlsoAsIssueComment,
changePostOption,
}: Props): Node =>
<IssueCommentCheckboxWrapper>
<CheckboxGroup>
<Checkbox
isChecked={postAlsoAsIssueComment}
value={postAlsoAsIssueComment}
name="postAlsoAsIssueComment"
label="Post also as comment to issue"
onChange={changePostOption}
/>
</CheckboxGroup>
</IssueCommentCheckboxWrapper>;

export default compose(
connect(
state => ({
postAlsoAsIssueComment: getUiState('postAlsoAsIssueComment')(state),
}),
dispatch => ({ dispatch }),
),
withHandlers({
changePostOption: ({
dispatch,
postAlsoAsIssueComment,
}: {
postAlsoAsIssueComment: boolean,
dispatch: Dispatch,
}) => () => dispatch(uiActions.setUiState('postAlsoAsIssueComment', !postAlsoAsIssueComment))
})
)(WorklogCommentOptions);
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,7 @@ export const EditButton = styled(EditFilledIcon)`
export const EditButtonContainer = styled.div`
cursor: pointer;
`;

export const IssueCommentCheckboxWrapper = styled.div`
margin-left: -10px;
`;
1 change: 1 addition & 0 deletions app/reducers/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ const initialState: UiState = {
editWorklogId: null,
worklogFormIssueId: null,
worklogComment: '',
postAlsoAsIssueComment: false,
remainingEstimateValue: 'auto',
remainingEstimateNewValue: '',
remainingEstimateReduceByValue: '',
Expand Down
7 changes: 7 additions & 0 deletions app/sagas/worklogs.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
import {
types,
uiActions,
issuesActions,
} from 'actions';
import {
getResourceIds,
Expand Down Expand Up @@ -266,9 +267,15 @@ export function* uploadWorklog(options: any): Generator<*, *, *> {
},
});

const postAlsoAsIssueComment = yield select(getUiState('postAlsoAsIssueComment'));
if (postAlsoAsIssueComment && options.comment) {
yield put(issuesActions.commentRequest(options.comment, options.issueId));
}

// reset ui state
yield put(uiActions.resetUiState([
'worklogComment',
'postAlsoAsIssueComment',
'remainingEstimateValue',
'remainingEstimateNewValue',
'remainingEstimateReduceByValue',
Expand Down
1 change: 1 addition & 0 deletions app/types/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ export type UiState = {|
editWorklogId: Id | null,
worklogFormIssueId: Id | null,
worklogComment: string,
postAlsoAsIssueComment: boolean,
remainingEstimateValue: RemainingEstimate,
remainingEstimateNewValue: string,
remainingEstimateReduceByValue: string,
Expand Down

0 comments on commit dc29640

Please sign in to comment.