File tree Expand file tree Collapse file tree 6 files changed +108
-16
lines changed Expand file tree Collapse file tree 6 files changed +108
-16
lines changed Original file line number Diff line number Diff line change
1
+ import { fetchUngitConfig } from './ungit-config' ;
2
+ import { fetchLatestVersion , fetchGitVersion } from './version' ;
3
+ import { pending } from './common' ;
4
+
5
+ export function bootstrap ( ) {
6
+ return dispatch => {
7
+ dispatch ( pending ( ) ) ;
8
+ dispatch ( fetchUngitConfig ( ) ) ;
9
+ dispatch ( fetchLatestVersion ( ) ) ;
10
+ dispatch ( fetchGitVersion ( ) ) ;
11
+ } ;
12
+ }
Original file line number Diff line number Diff line change
1
+ /* This export common using actionCreator */
2
+ import * as types from 'constants/action-types' ;
3
+
4
+ export function pending ( ) {
5
+ return {
6
+ type : types . PATH_PAGE_PENDING
7
+ } ;
8
+ } ;
9
+
10
+ export function apiError ( message ) {
11
+ return {
12
+ type : types . PATH_PAGE_API_ERR ,
13
+ payload : message
14
+ } ;
15
+ }
Original file line number Diff line number Diff line change 1
1
import * as types from 'constants/action-types' ;
2
+ import { fetchUserConfig } from './user-config' ;
3
+ import { apiError } from './common' ;
2
4
3
5
export function fetchUngitConfig ( ) {
4
6
return dispatch => {
5
- dispatch ( pending ( ) ) ;
6
7
// consider wrap API call in separate modules
7
8
// it will be easy to stub module's function when testing
8
9
fetch ( 'http://localhost:8448/ungit/config' )
9
10
. then ( response => response . json ( ) )
10
11
. then ( json => {
12
+ if ( ! json . config . bugtracking ) {
13
+ dispatch ( fetchUserConfig ( ) ) ;
14
+ }
11
15
dispatch ( receiveUgitConfig ( json ) ) ;
12
16
} )
13
17
. catch ( e => {
@@ -16,22 +20,9 @@ export function fetchUngitConfig() {
16
20
} ;
17
21
} ;
18
22
19
- export function receiveUgitConfig ( ungitConfig ) {
23
+ function receiveUgitConfig ( ungitConfig ) {
20
24
return {
21
25
type : types . RECEIVE_UNGIT_CONFIG ,
22
26
payload : ungitConfig
23
27
} ;
24
- } ;
25
-
26
- export function pending ( ) {
27
- return {
28
- type : types . PATH_PAGE_PENDING
29
- } ;
30
- } ;
31
-
32
- export function apiError ( message ) {
33
- return {
34
- type : types . PATH_PAGE_API_ERR ,
35
- payload : message
36
- } ;
37
- }
28
+ } ;
Original file line number Diff line number Diff line change
1
+ import * as types from 'constants/action-types' ;
2
+ import { apiError } from './common' ;
3
+
4
+ export function fetchUserConfig ( ) {
5
+ return dispatch => {
6
+ // consider wrap API call in separate modules
7
+ // it will be easy to stub module's function when testing
8
+ fetch ( 'http://localhost:8448/api/userconfig' )
9
+ . then ( response => response . json ( ) )
10
+ . then ( json => {
11
+ dispatch ( receiveUserConfig ( json ) ) ;
12
+ } )
13
+ . catch ( e => {
14
+ dispatch ( apiError ( e . message ) ) ;
15
+ } ) ;
16
+ } ;
17
+ } ;
18
+
19
+
20
+ function receiveUserConfig ( userConfig ) {
21
+ return {
22
+ type : types . RECEIVE_USER_CONFIG ,
23
+ payload : userConfig
24
+ } ;
25
+ } ;
Original file line number Diff line number Diff line change
1
+ import * as types from 'constants/action-types' ;
2
+ import { apiError } from './common' ;
3
+
4
+ export function fetchLatestVersion ( ) {
5
+ return dispatch => {
6
+ // consider wrap API call in separate modules
7
+ // it will be easy to stub module's function when testing
8
+ fetch ( 'http://localhost:8448/api/latestversion' )
9
+ . then ( response => response . json ( ) )
10
+ . then ( json => {
11
+ dispatch ( receiveLatestVersion ( json ) ) ;
12
+ } )
13
+ . catch ( e => {
14
+ dispatch ( apiError ( e . message ) ) ;
15
+ } ) ;
16
+ } ;
17
+ }
18
+
19
+ export function fetchGitVersion ( ) {
20
+ return dispatch => {
21
+ // consider wrap API call in separate modules
22
+ // it will be easy to stub module's function when testing
23
+ fetch ( 'http://localhost:8448/api/gitversion' )
24
+ . then ( response => response . json ( ) )
25
+ . then ( json => {
26
+ dispatch ( receiveGitVersion ( json ) ) ;
27
+ } )
28
+ . catch ( e => {
29
+ dispatch ( apiError ( e . message ) ) ;
30
+ } ) ;
31
+ } ;
32
+ }
33
+
34
+ function receiveGitVersion ( gitVersion ) {
35
+ return {
36
+ type : types . RECEIVE_GIT_VERSION ,
37
+ payload : gitVersion
38
+ } ;
39
+ }
40
+
41
+ function receiveLatestVersion ( latestVersion ) {
42
+ return {
43
+ type : types . RECEIVE_LATEST_VERSION ,
44
+ payload : latestVersion
45
+ } ;
46
+ } ;
Original file line number Diff line number Diff line change
1
+ export const RECEIVE_GIT_VERSION = 'RECEIVE_GIT_VERSION' ;
2
+ export const RECEIVE_LATEST_VERSION = 'RECEIVE_LATEST_VERSION' ;
3
+ export const RECEIVE_USER_CONFIG = 'RECEIVE_USER_CONFIG' ;
1
4
export const RECEIVE_UNGIT_CONFIG = 'RECEIVE_UNGIT_CONFIG' ;
2
5
export const PATH_PAGE_PENDING = 'PATH_PAGE_PENDING' ;
3
6
export const PATH_PAGE_API_ERR = 'PATH_PAGE_API_ERR' ;
You can’t perform that action at this time.
0 commit comments