@@ -30,7 +30,6 @@ export const configBlock = createComponent<
30
30
componentId : 'configure' ,
31
31
initialState : ( props ) => {
32
32
return {
33
- withConnectGitLab : props . spaceInstallation . configuration ?. accessToken !== undefined ,
34
33
accessToken : props . spaceInstallation . configuration ?. accessToken ,
35
34
withCustomInstanceUrl : Boolean (
36
35
props . spaceInstallation . configuration ?. customInstanceUrl &&
@@ -55,15 +54,6 @@ export const configBlock = createComponent<
55
54
} ,
56
55
action : async ( element , action , context ) => {
57
56
switch ( action . action ) {
58
- case 'connect.gitlab' : {
59
- return {
60
- ...element ,
61
- state : {
62
- ...element . state ,
63
- withConnectGitLab : action . withConnectGitLab ,
64
- } ,
65
- } ;
66
- }
67
57
case 'save.token' : {
68
58
const spaceInstallation = context . environment . spaceInstallation ;
69
59
assertIsDefined ( spaceInstallation , { label : 'spaceInstallation' } ) ;
@@ -72,6 +62,7 @@ export const configBlock = createComponent<
72
62
...spaceInstallation . configuration ,
73
63
key : crypto . randomUUID ( ) ,
74
64
accessToken : action . token ,
65
+ customInstanceUrl : action . customInstanceUrl ,
75
66
} ;
76
67
77
68
const glUser = await getCurrentUser ( updatedConfig ) ;
@@ -182,85 +173,80 @@ export const configBlock = createComponent<
182
173
183
174
return (
184
175
< block >
185
- < input
186
- label = "Connect your GitLab account"
187
- hint = {
188
- < text >
189
- The access token requires the{ ' ' }
190
- < text style = "bold" > api, read_repository, write_repository</ text > scope
191
- for the integration to work. You can create one at{ ' ' }
192
- < link
193
- target = { {
194
- url : 'https://gitlab.com/-/profile/personal_access_tokens' ,
195
- } }
196
- >
197
- User Settings → Access Tokens.
198
- </ link >
199
- </ text >
200
- }
201
- element = {
202
- < button
203
- label = "Connect"
204
- icon = { ContentKitIcon . Gitlab }
205
- disabled = { element . state . withConnectGitLab }
206
- tooltip = "Connect your GitLab account"
207
- onPress = { {
208
- action : 'connect.gitlab' ,
209
- withConnectGitLab : true ,
210
- } }
211
- />
212
- }
213
- />
214
-
215
- { element . state . withConnectGitLab ? (
216
- < hstack >
176
+ < card >
177
+ < vstack >
217
178
< box grow = { 1 } >
218
- < textinput
219
- state = "accessToken"
220
- placeholder = "Enter your GitLab access token"
221
- />
222
- </ box >
223
- < button
224
- style = "secondary"
225
- tooltip = "Save access token"
226
- label = "Save"
227
- onPress = { {
228
- action : 'save.token' ,
229
- token : element . dynamicState ( 'accessToken' ) ,
230
- } }
231
- />
232
- </ hstack >
233
- ) : null }
234
-
235
- { accessToken ? (
236
- < >
237
- < divider size = "medium" />
238
-
239
- < vstack >
240
179
< input
241
- label = "Custom GitLab URL"
242
- hint = "If your GitLab instance is self-hosted, enter its publicly accessible URL"
180
+ label = "GitLab access token"
181
+ hint = {
182
+ < text >
183
+ The access token requires the{ ' ' }
184
+ < text style = "bold" >
185
+ api, read_repository, write_repository
186
+ </ text > { ' ' }
187
+ scope for the integration to work. You can create one at{ ' ' }
188
+ < link
189
+ target = { {
190
+ url : 'https://gitlab.com/-/profile/personal_access_tokens' ,
191
+ } }
192
+ >
193
+ User Settings → Access Tokens.
194
+ </ link >
195
+ </ text >
196
+ }
243
197
element = {
244
- < switch
245
- state = "withCustomInstanceUrl"
246
- onValueChange = { {
247
- action : 'toggle.customInstanceUrl' ,
248
- withCustomInstanceUrl :
249
- element . dynamicState ( 'withCustomInstanceUrl' ) ,
250
- } }
198
+ < textinput
199
+ state = "accessToken"
200
+ placeholder = "xxxxxxxxxxxxxxxxxxxx"
251
201
/>
252
202
}
253
203
/>
254
- { element . state . withCustomInstanceUrl ? (
255
- < box grow = { 1 } >
256
- < textinput
257
- state = "customInstanceUrl"
258
- placeholder = "https://gitlab.mycompany.com"
259
- />
260
- </ box >
261
- ) : null }
262
- </ vstack >
204
+ </ box >
205
+
206
+ < input
207
+ label = "Custom GitLab URL"
208
+ hint = "If your GitLab instance is self-hosted, enter its publicly accessible URL"
209
+ element = {
210
+ < switch
211
+ state = "withCustomInstanceUrl"
212
+ onValueChange = { {
213
+ action : 'toggle.customInstanceUrl' ,
214
+ withCustomInstanceUrl :
215
+ element . dynamicState ( 'withCustomInstanceUrl' ) ,
216
+ } }
217
+ />
218
+ }
219
+ />
220
+ { element . state . withCustomInstanceUrl ? (
221
+ < box grow = { 1 } >
222
+ < textinput
223
+ state = "customInstanceUrl"
224
+ placeholder = "https://gitlab.mycompany.com"
225
+ />
226
+ </ box >
227
+ ) : null }
263
228
229
+ < box grow = { 1 } >
230
+ < hstack align = "end" >
231
+ < button
232
+ style = "secondary"
233
+ icon = { ContentKitIcon . Gitlab }
234
+ tooltip = "Authenticate with GitLab"
235
+ label = "Authenticate"
236
+ onPress = { {
237
+ action : 'save.token' ,
238
+ token : element . dynamicState ( 'accessToken' ) ,
239
+ customInstanceUrl :
240
+ element . dynamicState ( 'customInstanceUrl' ) ,
241
+ } }
242
+ />
243
+ </ hstack >
244
+ </ box >
245
+ </ vstack >
246
+ </ card >
247
+
248
+ { accessToken ? (
249
+ < >
264
250
< divider size = "medium" />
265
251
266
252
< markdown content = "### Project" />
@@ -472,8 +458,8 @@ export const configBlock = createComponent<
472
458
! element . state . project ||
473
459
! element . state . branch
474
460
}
475
- label = "Configure "
476
- tooltip = "Save configuration "
461
+ label = "Sync "
462
+ tooltip = "Start the initial synchronization "
477
463
onPress = { { action : 'save.configuration' } }
478
464
/>
479
465
}
0 commit comments