@@ -487,51 +487,12 @@ class GitOpsConfiguration extends Component<GitOpsProps, GitOpsState> {
487
487
)
488
488
}
489
489
490
- const getInputFieldlabelAndlink = ( inputName ) : { label : string ; link : string ; linkText : string } => {
491
- let fieldLable = {
492
- label : '' ,
493
- link : '' ,
494
- linkText : '' ,
495
- }
496
- switch ( inputName ) {
497
- case 'workspaceID' :
498
- return {
499
- ...fieldLable ,
500
- label : 'Bitbucket Workspace ID' ,
501
- link : GitLink . BITBUCKET_WORKSPACE ,
502
- linkText : '(How to create workspace in bitbucket?)' ,
503
- }
504
- case 'groupID' :
505
- return {
506
- ...fieldLable ,
507
- label : LinkAndLabelSpec [ this . state . providerTab ] [ 'label' ] ,
508
- link : LinkAndLabelSpec [ this . state . providerTab ] [ 'link' ] ,
509
- linkText : LinkAndLabelSpec [ this . state . providerTab ] [ 'linkText' ] ,
510
- }
511
- case 'token' : {
512
- return {
513
- ...fieldLable ,
514
- label :
515
- this . state . providerTab === GitProvider . AZURE_DEVOPS
516
- ? 'Azure DevOps Access Token '
517
- : 'Personal Access Token ' ,
518
- link : DOCUMENTATION . GLOBAL_CONFIG_GIT_ACCESS_LINK ,
519
- linkText : '(Check permissions required for PAT)' ,
520
- }
521
- }
522
- }
523
- }
524
-
525
- const renderInputLabel = ( inputName : string ) => {
490
+ const renderInputLabels = ( label : string , link : string , linkText : string ) => {
526
491
return (
527
492
< div className = "flex" >
528
- < span className = "dc__required-field" > { getInputFieldlabelAndlink ( inputName ) . label } </ span >
529
- < a
530
- target = "_blank"
531
- href = { getInputFieldlabelAndlink ( inputName ) . link }
532
- className = "cursor fs-13 onlink ml-4"
533
- >
534
- { getInputFieldlabelAndlink ( inputName ) . linkText }
493
+ < span className = "dc__required-field" > { label } </ span >
494
+ < a target = "_blank" href = { link } className = "cursor fs-13 onlink ml-4" >
495
+ { linkText }
535
496
</ a >
536
497
</ div >
537
498
)
@@ -677,7 +638,11 @@ class GitOpsConfiguration extends Component<GitOpsProps, GitOpsState> {
677
638
{ this . state . providerTab === GitProvider . BITBUCKET_CLOUD && (
678
639
< CustomInput
679
640
name = "workspaceID"
680
- label = { renderInputLabel . bind ( this , 'workspaceID' ) }
641
+ label = { renderInputLabels (
642
+ 'Bitbucket Workspace ID' ,
643
+ GitLink . BITBUCKET_WORKSPACE ,
644
+ '(How to create workspace in bitbucket?)' ,
645
+ ) }
681
646
value = { this . state . form . bitBucketWorkspaceId }
682
647
onChange = { ( event ) => this . handleChange ( event , 'bitBucketWorkspaceId' ) }
683
648
error = { this . state . isError . bitBucketWorkspaceId }
@@ -691,7 +656,11 @@ class GitOpsConfiguration extends Component<GitOpsProps, GitOpsState> {
691
656
< div className = "mt-16" >
692
657
< CustomInput
693
658
name = "groupID"
694
- label = { renderInputLabel . bind ( this , 'groupID' ) }
659
+ label = { renderInputLabels (
660
+ LinkAndLabelSpec [ this . state . providerTab ] [ 'label' ] ,
661
+ LinkAndLabelSpec [ this . state . providerTab ] [ 'link' ] ,
662
+ LinkAndLabelSpec [ this . state . providerTab ] [ 'linkText' ] ,
663
+ ) }
695
664
value = { this . state . form [ key ] }
696
665
tabIndex = { 2 }
697
666
error = { this . state . isError [ key ] }
@@ -758,7 +727,13 @@ class GitOpsConfiguration extends Component<GitOpsProps, GitOpsState> {
758
727
< div >
759
728
< CustomInput
760
729
name = "token"
761
- label = { renderInputLabel . bind ( this , 'token' ) }
730
+ label = { renderInputLabels (
731
+ this . state . providerTab === GitProvider . AZURE_DEVOPS
732
+ ? 'Azure DevOps Access Token '
733
+ : 'Personal Access Token ' ,
734
+ DOCUMENTATION . GLOBAL_CONFIG_GIT_ACCESS_LINK ,
735
+ '(Check permissions required for PAT)' ,
736
+ ) }
762
737
value = { this . state . form . token }
763
738
onChange = { ( event ) => this . handleChange ( event , 'token' ) }
764
739
tabIndex = { 4 }
0 commit comments