forked from atom/github
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreate-dialog-view.js
157 lines (143 loc) · 5.11 KB
/
create-dialog-view.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
import React from 'react';
import PropTypes from 'prop-types';
import DialogView from './dialog-view';
import RepositoryHomeSelectionView from './repository-home-selection-view';
import DirectorySelect from './directory-select';
import RemoteConfigurationView from './remote-configuration-view';
import TabGroup from '../tab-group';
import {TabbableInput} from './tabbable';
import Octicon from '../atom/octicon';
const DIALOG_TEXT = {
create: {
heading: 'Create GitHub repository',
hostPath: 'Destination path:',
progressMessage: 'Creating repository...',
acceptText: 'Create',
},
publish: {
heading: 'Publish GitHub repository',
hostPath: 'Local path:',
progressMessage: 'Publishing repository...',
acceptText: 'Publish',
},
};
export default class CreateDialogView extends React.Component {
static propTypes = {
// Relay
user: PropTypes.object,
// Model
request: PropTypes.shape({
identifier: PropTypes.oneOf(['create', 'publish']).isRequired,
getParams: PropTypes.func.isRequired,
cancel: PropTypes.func.isRequired,
}).isRequired,
error: PropTypes.instanceOf(Error),
isLoading: PropTypes.bool.isRequired,
inProgress: PropTypes.bool.isRequired,
selectedOwnerID: PropTypes.string.isRequired,
repoName: PropTypes.object.isRequired,
selectedVisibility: PropTypes.oneOf(['PUBLIC', 'PRIVATE']).isRequired,
localPath: PropTypes.object.isRequired,
sourceRemoteName: PropTypes.object.isRequired,
selectedProtocol: PropTypes.oneOf(['https', 'ssh']).isRequired,
acceptEnabled: PropTypes.bool.isRequired,
// Change callbacks
didChangeOwnerID: PropTypes.func.isRequired,
didChangeVisibility: PropTypes.func.isRequired,
didChangeProtocol: PropTypes.func.isRequired,
accept: PropTypes.func.isRequired,
// Atom environment
currentWindow: PropTypes.object.isRequired,
workspace: PropTypes.object.isRequired,
commands: PropTypes.object.isRequired,
config: PropTypes.object.isRequired,
}
constructor(props) {
super(props);
this.tabGroup = new TabGroup();
}
render() {
const text = DIALOG_TEXT[this.props.request.identifier];
return (
<DialogView
progressMessage={text.progressMessage}
acceptEnabled={this.props.acceptEnabled}
acceptText={text.acceptText}
accept={this.props.accept}
cancel={this.props.request.cancel}
tabGroup={this.tabGroup}
inProgress={this.props.inProgress}
error={this.props.error}
workspace={this.props.workspace}
commands={this.props.commands}>
<h1 className="github-Create-header">
<Octicon icon="globe" />
{text.heading}
</h1>
<div className="github-Create-repo block">
<RepositoryHomeSelectionView
tabGroup={this.tabGroup}
commands={this.props.commands}
autofocusName
user={this.props.user}
nameBuffer={this.props.repoName}
selectedOwnerID={this.props.selectedOwnerID}
didChangeOwnerID={this.props.didChangeOwnerID}
isLoading={this.props.isLoading}
/>
</div>
<div className="github-Create-visibility block">
<span className="github-Create-visibilityHeading">Visibility:</span>
<label className="github-Create-visibilityOption input-label">
<TabbableInput
tabGroup={this.tabGroup}
commands={this.props.commands}
className="input-radio"
type="radio"
name="visibility"
value="PUBLIC"
checked={this.props.selectedVisibility === 'PUBLIC'}
onChange={this.didChangeVisibility}
/>
<Octicon icon="globe" />
Public
</label>
<label className="github-Create-visibilityOption input-label">
<TabbableInput
tabGroup={this.tabGroup}
commands={this.props.commands}
className="input-radio"
type="radio"
name="visibility"
value="PRIVATE"
checked={this.props.selectedVisibility === 'PRIVATE'}
onChange={this.didChangeVisibility}
/>
<Octicon icon="mirror-private" />
Private
</label>
</div>
<div className="github-Create-localPath">
<DirectorySelect
tabGroup={this.tabGroup}
commands={this.props.commands}
currentWindow={this.props.currentWindow}
buffer={this.props.localPath}
disabled={this.props.request.identifier === 'publish'}
/>
</div>
<RemoteConfigurationView
tabGroup={this.tabGroup}
commands={this.props.commands}
currentProtocol={this.props.selectedProtocol}
didChangeProtocol={this.props.didChangeProtocol}
sourceRemoteBuffer={this.props.sourceRemoteName}
/>
</DialogView>
);
}
componentDidMount() {
this.tabGroup.autofocus();
}
didChangeVisibility = event => this.props.didChangeVisibility(event.target.value);
}