@@ -222,7 +222,7 @@ class ListWorkflowsComponent extends React.Component<ListWorkflowsProps, State>
222222 </ div >
223223 < div className = "title" > Workflows</ div >
224224 </ div >
225- { Boolean ( this . state . workflowsResponse ?. workflow ?. length || this . state . reposResponse ?. repoUrls ?. length ) && (
225+ { Boolean ( this . state . workflowsResponse ?. workflow ?. length || this . state . reposResponse ?. repos ?. length ) && (
226226 < div className = "buttons create-new-container" >
227227 { isAdmin && < Button onClick = { this . onClickCreate . bind ( this ) } > Link a repository</ Button > }
228228 < OutlinedLinkButton href = "https://docs.buildbuddy.io/docs/workflows-setup" target = "_blank" >
@@ -233,7 +233,7 @@ class ListWorkflowsComponent extends React.Component<ListWorkflowsProps, State>
233233 </ div >
234234 </ div >
235235 < div className = "content" >
236- { ! ( this . state . workflowsResponse ?. workflow ?. length || this . state . reposResponse ?. repoUrls ?. length ) && (
236+ { ! ( this . state . workflowsResponse ?. workflow ?. length || this . state . reposResponse ?. repos ?. length ) && (
237237 < div className = "no-workflows-container" >
238238 < div className = "no-workflows-card" >
239239 < WorkflowsZeroStateAnimation />
@@ -253,17 +253,18 @@ class ListWorkflowsComponent extends React.Component<ListWorkflowsProps, State>
253253 </ div >
254254 </ div >
255255 ) }
256- { Boolean ( this . state . workflowsResponse ?. workflow ?. length || this . state . reposResponse ?. repoUrls ?. length ) && (
256+ { Boolean ( this . state . workflowsResponse ?. workflow ?. length || this . state . reposResponse ?. repos ?. length ) && (
257257 < div className = "workflows-list" >
258258 { /* Render linked repositories */ }
259- { this . state . reposResponse ?. repoUrls . map ( ( repoUrl ) => (
259+ { this . state . reposResponse ?. repos ? .map ( ( repo ) => (
260260 < >
261261 < RepoItem
262262 user = { this . props . user }
263- repoUrl = { repoUrl }
264- onClickUnlinkItem = { ( ) => this . setState ( { repoToUnlink : repoUrl } ) }
265- onClickInvalidateAllItem = { ( ) => this . setState ( { repoToInvalidate : repoUrl } ) }
266- history = { this . renderActionList ( repoUrl ) }
263+ repoUrl = { repo . repoUrl }
264+ useDefaultWorkflowConfig = { repo . useDefaultWorkflowConfig }
265+ onClickUnlinkItem = { ( ) => this . setState ( { repoToUnlink : repo . repoUrl } ) }
266+ onClickInvalidateAllItem = { ( ) => this . setState ( { repoToInvalidate : repo . repoUrl } ) }
267+ history = { this . renderActionList ( repo . repoUrl ) }
267268 />
268269 </ >
269270 ) ) }
@@ -274,6 +275,7 @@ class ListWorkflowsComponent extends React.Component<ListWorkflowsProps, State>
274275 user = { this . props . user }
275276 repoUrl = { workflow . repoUrl }
276277 webhookUrl = { workflow . webhookUrl }
278+ useDefaultWorkflowConfig = { true } /* Default for legacy workflows */
277279 onClickUnlinkItem = { ( ) => this . setState ( { workflowToDelete : workflow } ) }
278280 onClickInvalidateAllItem = { null } /* Not implemented for legacy workflows */
279281 history = { null }
@@ -332,6 +334,7 @@ type RepoItemProps = {
332334 user ?: User ;
333335 repoUrl : string ;
334336 webhookUrl ?: string ;
337+ useDefaultWorkflowConfig : boolean ;
335338 onClickUnlinkItem : ( url : string ) => void ;
336339 onClickInvalidateAllItem : ( ( url : string ) => void ) | null ;
337340 history : React . ReactNode ;
@@ -348,6 +351,7 @@ type RepoItemState = {
348351 isWorkflowRunning : boolean ;
349352 runWorkflowActionStatuses : workflow . ExecuteWorkflowResponse . ActionStatus [ ] | null ;
350353 startTime : Date | null ;
354+ useDefaultWorkflowConfig : boolean ;
351355} ;
352356
353357class RepoItem extends React . Component < RepoItemProps , RepoItemState > {
@@ -361,6 +365,7 @@ class RepoItem extends React.Component<RepoItemProps, RepoItemState> {
361365 isWorkflowRunning : false ,
362366 runWorkflowActionStatuses : null ,
363367 startTime : null ,
368+ useDefaultWorkflowConfig : this . props . useDefaultWorkflowConfig ,
364369 } ;
365370
366371 private onClickMenuButton ( ) {
@@ -376,6 +381,31 @@ class RepoItem extends React.Component<RepoItemProps, RepoItemState> {
376381 alert_service . success ( "Copied webhook URL to clipboard!" ) ;
377382 }
378383
384+ private onClickUpdateDefaultConfig ( updated : boolean ) {
385+ const prev = this . state . useDefaultWorkflowConfig ;
386+ this . setState ( { useDefaultWorkflowConfig : updated } ) ;
387+
388+ const request = new github . UpdateRepoSettingsRequest ( {
389+ repoUrl : this . props . repoUrl ,
390+ useDefaultWorkflowConfig : updated ,
391+ } ) ;
392+
393+ rpcService . service
394+ . updateGitHubRepoSettings ( request )
395+ . then ( ( ) => {
396+ alert_service . success ( `Successfully updated repository settings` ) ;
397+ } )
398+ . catch ( ( e ) => {
399+ this . setState ( { useDefaultWorkflowConfig : prev } ) ;
400+ errorService . handleError ( e ) ;
401+ } ) ;
402+ }
403+
404+ private onClickUpdateDefaultConfigMenuItem ( ) {
405+ this . setState ( { isMenuOpen : false } ) ;
406+ this . onClickUpdateDefaultConfig ( ! this . state . useDefaultWorkflowConfig ) ;
407+ }
408+
379409 private onClickUnlinkMenuItem ( ) {
380410 this . setState ( { isMenuOpen : false } ) ;
381411 this . props . onClickUnlinkItem ( this . props . repoUrl ) ;
@@ -432,6 +462,10 @@ class RepoItem extends React.Component<RepoItemProps, RepoItemState> {
432462 . finally ( ( ) => this . setState ( { isWorkflowRunning : false } ) ) ;
433463 }
434464
465+ isDeprecatedWorkflow ( ) : boolean {
466+ return Boolean ( this . props . webhookUrl ) ;
467+ }
468+
435469 renderWorkflowResults ( ) {
436470 if ( ! this . state . runWorkflowActionStatuses ) return ;
437471 return this . state . runWorkflowActionStatuses . map ( ( actionStatus ) => {
@@ -482,6 +516,12 @@ class RepoItem extends React.Component<RepoItemProps, RepoItemState> {
482516 < MenuItem onClick = { this . onClickInvalidateAllMenuItem . bind ( this ) } > Invalidate all workflow VM snapshots</ MenuItem >
483517 ) ;
484518 }
519+ if ( ! this . isDeprecatedWorkflow ( ) ) {
520+ const configText = this . state . useDefaultWorkflowConfig
521+ ? "Disable default workflow config"
522+ : "Enable default workflow config" ;
523+ menuItems . push ( < MenuItem onClick = { this . onClickUpdateDefaultConfigMenuItem . bind ( this ) } > { configText } </ MenuItem > ) ;
524+ }
485525
486526 return (
487527 < div className = "workflow-item container" >
@@ -493,7 +533,7 @@ class RepoItem extends React.Component<RepoItemProps, RepoItemState> {
493533 < Link href = { router . getWorkflowHistoryUrl ( normalizeRepoURL ( this . props . repoUrl ) ) } className = "repo-url" >
494534 { formatURL ( this . props . repoUrl ) }
495535 </ Link >
496- { capabilities . config . githubAppEnabled && this . props . webhookUrl && (
536+ { capabilities . config . githubAppEnabled && this . isDeprecatedWorkflow ( ) && (
497537 < div className = "upgrade-notice" >
498538 < AlertCircle className = "icon orange" /> This repository uses the legacy GitHub OAuth integration.
499539 Unlink and re-link to use the new GitHub App integration.
@@ -505,7 +545,7 @@ class RepoItem extends React.Component<RepoItemProps, RepoItemState> {
505545 < div className = "workflow-item-column workflow-buttons-container" >
506546 < div className = "workflow-item-row" >
507547 { /* The Run Workflow button is only supported for workflows configured with the Github App, not legacy workflows */ }
508- { ! this . props . webhookUrl && (
548+ { ! this . isDeprecatedWorkflow ( ) && (
509549 < div className = "workflow-button-container" >
510550 < OutlinedButton
511551 className = "run-workflow-button"
0 commit comments