Skip to content

Commit 89f8b9f

Browse files
committed
gitops refactorig
1 parent d764432 commit 89f8b9f

File tree

1 file changed

+21
-46
lines changed

1 file changed

+21
-46
lines changed

src/components/gitOps/GitOpsConfiguration.tsx

Lines changed: 21 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -487,51 +487,12 @@ class GitOpsConfiguration extends Component<GitOpsProps, GitOpsState> {
487487
)
488488
}
489489

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) => {
526491
return (
527492
<div className="flex">
528-
<span className="dc__required-field">{getInputFieldlabelAndlink(inputName).label}</span>&nbsp;
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>&nbsp;
494+
<a target="_blank" href={link} className="cursor fs-13 onlink ml-4">
495+
{linkText}
535496
</a>
536497
</div>
537498
)
@@ -677,7 +638,11 @@ class GitOpsConfiguration extends Component<GitOpsProps, GitOpsState> {
677638
{this.state.providerTab === GitProvider.BITBUCKET_CLOUD && (
678639
<CustomInput
679640
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+
)}
681646
value={this.state.form.bitBucketWorkspaceId}
682647
onChange={(event) => this.handleChange(event, 'bitBucketWorkspaceId')}
683648
error={this.state.isError.bitBucketWorkspaceId}
@@ -691,7 +656,11 @@ class GitOpsConfiguration extends Component<GitOpsProps, GitOpsState> {
691656
<div className="mt-16">
692657
<CustomInput
693658
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+
)}
695664
value={this.state.form[key]}
696665
tabIndex={2}
697666
error={this.state.isError[key]}
@@ -758,7 +727,13 @@ class GitOpsConfiguration extends Component<GitOpsProps, GitOpsState> {
758727
<div>
759728
<CustomInput
760729
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+
)}
762737
value={this.state.form.token}
763738
onChange={(event) => this.handleChange(event, 'token')}
764739
tabIndex={4}

0 commit comments

Comments
 (0)