Skip to content
This repository was archived by the owner on Jan 14, 2023. It is now read-only.

Commit 29ebfbd

Browse files
committed
refactor: migrate comments to overmind
1 parent e95c778 commit 29ebfbd

File tree

30 files changed

+382
-434
lines changed

30 files changed

+382
-434
lines changed

.eslintrc.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@
8181
"max-classes-per-file": "off",
8282
"no-use-before-define": "off",
8383
"arrow-parens": "off",
84+
"consistent-return": "off",
8485
"react/jsx-filename-extension": [
8586
2,
8687
{ "extensions": [".js", ".jsx", ".ts", ".tsx"] }

main/redmine.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ const createRequestClient = () => {
5454

5555
return {
5656
success: true,
57-
payload
57+
data: payload
5858
};
5959
}
6060

@@ -86,11 +86,17 @@ const createRequestClient = () => {
8686

8787
if (response.statusCode === 200) {
8888
return {
89-
payload: transform({ route: data.route, method: data.method }, response.body),
89+
data: transform({ route: data.route, method: data.method }, response.body),
9090
success: true,
9191
};
9292
}
9393

94+
if (data.method === 'PUT' && response.statusCode === 204) {
95+
return {
96+
success: true
97+
};
98+
}
99+
94100
return handleUnsuccessfulRequest(response.body);
95101
} catch (error) {
96102
return handleUnsuccessfulRequest(error);

main/storage.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ const eventHandlers = (event, message) => {
109109

110110
event.reply(`session-response:${id}`, {
111111
success: true,
112-
payload: sessionWithoutHash
112+
data: sessionWithoutHash
113113
});
114114
break;
115115
}

main/transformers/issues.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,14 @@ const transform = ({ route }, responseBody) => {
2222
totalSpentHours: issue.total_spent_hours,
2323
createdOn: issue.created_on,
2424
updatedOn: issue.updated_on,
25+
journals: issue.journals?.map((journal) => ({
26+
id: journal.id,
27+
user: journal.user,
28+
createdOn: journal.created_on,
29+
notes: journal.notes,
30+
privateNotes: journal.private_notes,
31+
details: journal.details
32+
})) || [],
2533
closedOn: issue.closed_on
2634
})),
2735
total: responseBody.total_count,
@@ -58,7 +66,9 @@ const transform = ({ route }, responseBody) => {
5866
id: journal.id,
5967
user: journal.user,
6068
createdOn: journal.created_on,
61-
notes: journal.notes
69+
notes: journal.notes,
70+
privateNotes: journal.private_notes,
71+
details: journal.details
6272
})) || [],
6373
closedOn: issue.closed_on
6474
};

render/App.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ const App = ({ dispatch }) => {
8585
if (response.success) {
8686
const loginResponse = await actions.users.login({
8787
apiKey: token,
88-
redmineEndpoint: response.payload.endpoint
88+
redmineEndpoint: response.data.endpoint
8989
});
9090
if (loginResponse.success) {
9191
navigate('/issues', { replace: true });

render/about/AboutPage.jsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { version, name } from '../../package.json';
88
import LogoIcon from '../../assets/icon.png';
99

1010
import DragArea from '../components/DragArea';
11-
import Link from '../components/Link';
11+
import { Link } from '../components/Link';
1212
// import { report } from '../../common/reporter';
1313
import License from './License';
1414

@@ -141,7 +141,7 @@ class AboutPage extends Component {
141141
<IconContainer>
142142
<Link
143143
href="https://www.dvasylenko.com/redshape/"
144-
type="external"
144+
external
145145
>
146146
<img alt="App icon" height="70" src={LogoIcon} />
147147
</Link>
@@ -163,7 +163,7 @@ class AboutPage extends Component {
163163
<span>&nbsp;issues/proposals on Github or </span>
164164
<Link
165165
href="mailto:redshape.app@gmail.com"
166-
type="external"
166+
external
167167
>
168168
by e-mail
169169
</Link>
@@ -172,7 +172,7 @@ class AboutPage extends Component {
172172
<span>Visit the Redshape</span>
173173
<Link
174174
href="https://www.dvasylenko.com/redshape/"
175-
type="external"
175+
external
176176
>
177177
homepage
178178
</Link>
@@ -187,14 +187,14 @@ class AboutPage extends Component {
187187
Copyright © 2020&nbsp;
188188
<Link
189189
href="https://www.dvasylenko.com/redshape/"
190-
type="external"
190+
external
191191
>
192192
Daniyil Vasylenko
193193
</Link>
194194
&
195195
<Link
196196
href="https://github.com/Spring3/redshape/graphs/contributors"
197-
type="external"
197+
external
198198
>
199199
Contributors
200200
</Link>

render/about/License.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import React from 'react';
44
import styled from 'styled-components';
55

6-
import Link from '../components/Link';
6+
import { Link } from '../components/Link';
77

88
const Container = styled.div`
99
text-align: justify;
@@ -15,7 +15,7 @@ export default () => (
1515
<p align="center">Version 3, 29 June 2007</p>
1616
<p>
1717
Copyright &copy; 2007 Free Software Foundation, Inc. &lt;
18-
<Link href="http://fsf.org/" type="external">http://fsf.org/</Link>
18+
<Link href="http://fsf.org/" external>http://fsf.org/</Link>
1919
&gt;
2020
</p>
2121
<p>Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.</p>

render/actions/issues.actions.js

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,9 @@
11
import _ from 'lodash';
2-
import moment from 'moment';
32

43
import request, { notify } from './helper';
54

6-
export const ISSUES_COMMENTS_SEND = 'ISSUES_COMMENTS_SEND';
75
export const ISSUES_TIME_ENTRY_GET = 'ISSUES_TIME_ENTRY_GET';
86

9-
const sendComments = (issueId, comments) => (dispatch, getState) => {
10-
const { user = {} } = getState();
11-
12-
dispatch(notify.start(ISSUES_COMMENTS_SEND, { subject: 'comments' }));
13-
14-
return request({
15-
url: `/issues/${issueId}.json`,
16-
data: {
17-
issue: {
18-
notes: comments
19-
}
20-
},
21-
method: 'PUT'
22-
}).then(() => dispatch(
23-
notify.ok(
24-
ISSUES_COMMENTS_SEND,
25-
{
26-
created_on: moment().toLocaleString(),
27-
details: [],
28-
id: Date.now(),
29-
notes: comments,
30-
private_notes: false,
31-
user: {
32-
id: user.id,
33-
name: user.name
34-
}
35-
},
36-
{ subject: 'comments' }
37-
)
38-
))
39-
.catch((error) => {
40-
// eslint-disable-next-line
41-
console.error(`Error when trying to assign the issue with id ${issueId}:`, error.message);
42-
dispatch(notify.nok(ISSUES_COMMENTS_SEND, error, { subject: 'comments' }));
43-
});
44-
};
45-
467
const getTimeEntriesPage = (issueId, projectId, pageNumber, batchSize) => (dispatch, getState) => {
478
const { issues } = getState();
489
const { page, limit } = issues.selected.spentTime;
@@ -72,5 +33,4 @@ const getTimeEntriesPage = (issueId, projectId, pageNumber, batchSize) => (dispa
7233

7334
export default {
7435
getTimeEntriesPage,
75-
sendComments,
7636
};

render/components/Copyrights.jsx

Lines changed: 0 additions & 21 deletions
This file was deleted.

render/components/Copyrights.tsx

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import React from 'react';
2+
import { css } from '@emotion/react';
3+
4+
import { Link } from './Link';
5+
6+
const Copyrights = () => (
7+
<p css={css`color: #FF7079`}>
8+
Created by&nbsp;
9+
<Link
10+
external
11+
href="https://www.dvasylenko.com/redshape"
12+
testId="copyrights-link"
13+
>
14+
danv
15+
</Link>
16+
</p>
17+
);
18+
19+
export {
20+
Copyrights
21+
}

0 commit comments

Comments
 (0)