@@ -9,7 +9,7 @@ namespace GitHub.Unity
9
9
{
10
10
class PublishView : Subview
11
11
{
12
- private static readonly Vector2 viewSize = new Vector2 ( 300 , 250 ) ;
12
+ private static readonly Vector2 viewSize = new Vector2 ( 400 , 350 ) ;
13
13
14
14
private const string WindowTitle = "Publish" ;
15
15
private const string Header = "Publish this repository to GitHub" ;
@@ -20,7 +20,9 @@ class PublishView : Subview
20
20
private const string SelectedOwnerLabel = "Owner" ;
21
21
private const string RepositoryNameLabel = "Repository Name" ;
22
22
private const string DescriptionLabel = "Description" ;
23
- private const string CreatePrivateRepositoryLabel = "Create as a private repository" ;
23
+ private const string CreatePrivateRepositoryLabel = "Make repository private" ;
24
+ private const string PublishLimitPrivateRepositoriesError = "You are currently at your limit of private repositories" ;
25
+ private const string PublishToGithubLabel = "Publish to GitHub" ;
24
26
25
27
[ SerializeField ] private string username ;
26
28
[ SerializeField ] private string [ ] owners = { OwnersDefaultText } ;
@@ -139,81 +141,18 @@ private void LoadOrganizations()
139
141
140
142
public override void OnGUI ( )
141
143
{
142
- GUILayout . BeginHorizontal ( Styles . AuthHeaderBoxStyle ) ;
143
- {
144
- GUILayout . BeginVertical ( GUILayout . Width ( 16 ) ) ;
145
- {
146
- GUILayout . Space ( 9 ) ;
147
- GUILayout . Label ( Styles . BigLogo , GUILayout . Height ( 20 ) , GUILayout . Width ( 20 ) ) ;
148
- }
149
- GUILayout . EndVertical ( ) ;
150
-
151
- GUILayout . BeginVertical ( ) ;
152
- {
153
- GUILayout . Space ( 11 ) ;
154
- GUILayout . Label ( Title , EditorStyles . boldLabel ) ;
155
- }
156
- GUILayout . EndVertical ( ) ;
157
- }
158
- GUILayout . EndHorizontal ( ) ;
159
-
160
- GUILayout . Space ( Styles . PublishViewSpacingHeight ) ;
144
+ GUILayout . Label ( PublishToGithubLabel , EditorStyles . boldLabel ) ;
161
145
162
146
EditorGUI . BeginDisabledGroup ( isBusy ) ;
163
147
{
164
- GUILayout . BeginHorizontal ( ) ;
165
- {
166
- GUILayout . BeginVertical ( ) ;
167
- {
168
- GUILayout . Label ( SelectedOwnerLabel ) ;
169
- selectedOwner = EditorGUILayout . Popup ( selectedOwner , owners ) ;
170
- }
171
- GUILayout . EndVertical ( ) ;
172
-
173
- GUILayout . BeginVertical ( GUILayout . Width ( 8 ) ) ;
174
- {
175
- GUILayout . Space ( 20 ) ;
176
- GUILayout . Label ( "/" ) ;
177
- }
178
- GUILayout . EndVertical ( ) ;
179
-
180
- GUILayout . BeginVertical ( ) ;
181
- {
182
- GUILayout . Label ( RepositoryNameLabel ) ;
183
- repoName = EditorGUILayout . TextField ( repoName ) ;
184
- }
185
- GUILayout . EndVertical ( ) ;
186
- }
187
- GUILayout . EndHorizontal ( ) ;
188
-
189
- GUILayout . Label ( DescriptionLabel ) ;
190
- repoDescription = EditorGUILayout . TextField ( repoDescription ) ;
191
- GUILayout . Space ( Styles . PublishViewSpacingHeight ) ;
192
-
193
- GUILayout . BeginVertical ( ) ;
194
- {
195
- GUILayout . BeginHorizontal ( ) ;
196
- {
197
- togglePrivate = GUILayout . Toggle ( togglePrivate , CreatePrivateRepositoryLabel ) ;
198
- }
199
- GUILayout . EndHorizontal ( ) ;
148
+ selectedOwner = EditorGUILayout . Popup ( SelectedOwnerLabel , selectedOwner , owners ) ;
149
+ repoName = EditorGUILayout . TextField ( RepositoryNameLabel , repoName ) ;
150
+ repoDescription = EditorGUILayout . TextField ( DescriptionLabel , repoDescription ) ;
200
151
201
- GUILayout . BeginHorizontal ( ) ;
202
- {
203
- GUILayout . Space ( Styles . PublishViewSpacingHeight ) ;
204
- var repoPrivacyExplanation = togglePrivate ? PrivateRepoMessage : PublicRepoMessage ;
205
- GUILayout . Label ( repoPrivacyExplanation , Styles . LongMessageStyle ) ;
206
- }
207
- GUILayout . EndHorizontal ( ) ;
208
- }
209
- GUILayout . EndVertical ( ) ;
152
+ togglePrivate = EditorGUILayout . Toggle ( CreatePrivateRepositoryLabel , togglePrivate ) ;
210
153
211
- GUILayout . Space ( Styles . PublishViewSpacingHeight ) ;
212
-
213
- if ( error != null )
214
- GUILayout . Label ( error , Styles . ErrorLabel ) ;
215
-
216
- GUILayout . FlexibleSpace ( ) ;
154
+ var repoPrivacyExplanation = togglePrivate ? PrivateRepoMessage : PublicRepoMessage ;
155
+ EditorGUILayout . HelpBox ( repoPrivacyExplanation , MessageType . None ) ;
217
156
218
157
GUILayout . BeginHorizontal ( ) ;
219
158
{
@@ -235,11 +174,11 @@ public override void OnGUI()
235
174
Description = cleanRepoDescription
236
175
} , ( repository , ex ) =>
237
176
{
238
- Logger . Trace ( "Create Repository Callback" ) ;
239
-
240
177
if ( ex != null )
241
178
{
242
- error = ex . Message ;
179
+ Logger . Error ( ex , "Repository Create Error Type:{0}" , ex . GetType ( ) . ToString ( ) ) ;
180
+
181
+ error = GetPublishErrorMessage ( ex ) ;
243
182
isBusy = false ;
244
183
return ;
245
184
}
@@ -251,6 +190,8 @@ public override void OnGUI()
251
190
return ;
252
191
}
253
192
193
+ Logger . Trace ( "Repository Created" ) ;
194
+
254
195
GitClient . RemoteAdd ( "origin" , repository . CloneUrl )
255
196
. Then ( GitClient . Push ( "origin" , Repository . CurrentBranch . Value . Name ) )
256
197
. ThenInUI ( Finish )
@@ -261,10 +202,25 @@ public override void OnGUI()
261
202
}
262
203
GUILayout . EndHorizontal ( ) ;
263
204
GUILayout . Space ( 10 ) ;
205
+
206
+ if ( error != null )
207
+ EditorGUILayout . HelpBox ( error , MessageType . Error ) ;
208
+
209
+ GUILayout . FlexibleSpace ( ) ;
264
210
}
265
211
EditorGUI . EndDisabledGroup ( ) ;
266
212
}
267
213
214
+ private string GetPublishErrorMessage ( Exception ex )
215
+ {
216
+ if ( ex . Message . StartsWith ( PublishLimitPrivateRepositoriesError ) )
217
+ {
218
+ return PublishLimitPrivateRepositoriesError ;
219
+ }
220
+
221
+ return ex . Message ;
222
+ }
223
+
268
224
public override bool IsBusy
269
225
{
270
226
get { return isBusy ; }
0 commit comments