1
- import React , { Component , PropTypes } from 'react'
2
- import { Modal , Button , Checkbox , Carousel } from 'react-bootstrap'
1
+ import Icon from '@conveyal/woonerf/components/icon'
2
+ import React , { Component , PropTypes } from 'react'
3
+ import { Modal , Button , ButtonToolbar , Checkbox } from 'react-bootstrap'
4
+ import { LinkContainer } from 'react-router-bootstrap'
5
+
6
+ import { getConfigProperty } from '../../common/util/config'
3
7
4
8
export default class EditorHelpModal extends Component {
5
9
static propTypes = {
@@ -13,6 +17,22 @@ export default class EditorHelpModal extends Component {
13
17
14
18
_onToggleTutorial = ( ) => this . setState ( { hideTutorial : ! this . state . hideTutorial } )
15
19
20
+ _buildFromScratch = ( ) => {
21
+ const { createSnapshot, feedSource} = this . props
22
+ createSnapshot ( feedSource , 'Blank' )
23
+ }
24
+
25
+ _onClickLoad = ( ) => {
26
+ const { feedSource, loadFeedVersionForEditing} = this . props
27
+ const { latestVersionId : feedVersionId , id : feedSourceId } = feedSource
28
+ loadFeedVersionForEditing ( { feedSourceId, feedVersionId} )
29
+ }
30
+
31
+ _onClickReload = ( ) => {
32
+ this . props . onComponentMount ( { } )
33
+ this . close ( )
34
+ }
35
+
16
36
close = ( ) => {
17
37
if ( this . state . hideTutorial !== this . props . hideTutorial ) {
18
38
this . props . setTutorialHidden ( ! this . props . hideTutorial )
@@ -25,21 +45,61 @@ export default class EditorHelpModal extends Component {
25
45
}
26
46
27
47
render ( ) {
28
- if ( ! this . props . show ) {
48
+ const { feedSource, isNewFeed, show, status} = this . props
49
+ if ( ! show ) {
29
50
return null
30
51
}
31
52
const { Body, Footer, Header, Title} = Modal
32
- const { Caption, Item} = Carousel
33
53
return (
34
54
< Modal
35
55
show = { this . state . showModal }
36
56
onHide = { this . close }
37
- bsSize = 'large' >
38
- < Header closeButton >
57
+ // Prevent closure of modal if there is no snapshot yet
58
+ backdrop = { isNewFeed ? 'static' : undefined }
59
+ >
60
+ < Header closeButton = { ! isNewFeed } >
39
61
< Title > Welcome to the GTFS Editor</ Title >
40
62
</ Header >
41
63
< Body >
42
- < Carousel >
64
+ { isNewFeed
65
+ ? < div >
66
+ < p > There is no feed loaded in the editor. To begin editing you can either
67
+ start from scratch or import an existing version (if a version exists).</ p >
68
+ { status . snapshotFinished
69
+ ? < Button
70
+ bsStyle = 'primary'
71
+ bsSize = 'large'
72
+ block
73
+ onClick = { this . _onClickReload } >
74
+ < Icon type = 'check' /> Begin editing
75
+ </ Button >
76
+ : < ButtonToolbar >
77
+ < Button
78
+ bsSize = 'large'
79
+ block
80
+ onClick = { this . _buildFromScratch }
81
+ disabled = { status . creatingSnapshot } >
82
+ < Icon type = 'file' /> Start from scratch
83
+ </ Button >
84
+ < Button
85
+ bsSize = 'large'
86
+ block
87
+ onClick = { this . _onClickLoad }
88
+ disabled = { ! feedSource . latestVersionId || status . creatingSnapshot } >
89
+ < Icon type = 'upload' /> Import latest version
90
+ </ Button >
91
+ </ ButtonToolbar >
92
+ }
93
+ </ div >
94
+ : < p > For instructions on using the editor, view the{ ' ' }
95
+ < a
96
+ target = '_blank'
97
+ href = { `${ getConfigProperty ( 'application.docs_url' ) } /en/latest/user/editor/introduction/` } >
98
+ documentation
99
+ </ a > .
100
+ </ p >
101
+ }
102
+ { /* <Carousel>
43
103
<Item>
44
104
<img width={900} height={500} alt='900x500' src='https://react-bootstrap.github.io/assets/carousel.png' />
45
105
<Caption>
@@ -61,17 +121,22 @@ export default class EditorHelpModal extends Component {
61
121
<p>Praesent commodo cursus magna, vel scelerisque nisl consectetur.</p>
62
122
</Caption>
63
123
</Item>
64
- </ Carousel >
124
+ </Carousel> */ }
65
125
</ Body >
66
126
< Footer >
67
- < small className = 'pull-left' >
127
+ { ! isNewFeed && < small className = 'pull-left' >
68
128
< Checkbox
69
129
checked = { this . state . hideTutorial }
70
130
onChange = { this . _onToggleTutorial } >
71
131
Do not show when editor opens
72
132
</ Checkbox >
73
- </ small >
74
- < Button onClick = { this . close } > Close</ Button >
133
+ </ small > }
134
+ { isNewFeed
135
+ ? < LinkContainer to = { feedSource ? `/feed/${ feedSource . id } ` : `/home` } >
136
+ < Button > < Icon type = 'chevron-left' /> Back to feed source</ Button >
137
+ </ LinkContainer >
138
+ : < Button onClick = { this . close } > Close</ Button >
139
+ }
75
140
</ Footer >
76
141
</ Modal >
77
142
)
0 commit comments