/* * SonarQube * Copyright (C) 2009-2023 SonarSource SA * mailto:info AT sonarsource DOT com * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import * as React from 'react'; import { rawSizes } from '../../../app/theme'; import { Button } from '../../../components/controls/buttons'; import ChevronRightIcon from '../../../components/icons/ChevronRightIcon'; import { translate } from '../../../helpers/l10n'; import { AlmKeys, AlmSettingsInstance, ProjectAlmBindingResponse, } from '../../../types/alm-settings'; import CodeSnippet from '../../common/CodeSnippet'; import LabelActionPair from '../components/LabelActionPair'; import LabelValuePair from '../components/LabelValuePair'; import SentenceWithHighlights from '../components/SentenceWithHighlights'; import Step from '../components/Step'; import { buildGithubLink } from '../utils'; export interface MultiBranchPipelineStepProps { alm: AlmKeys; almBinding?: AlmSettingsInstance; finished: boolean; onDone: () => void; onOpen: () => void; open: boolean; projectBinding?: ProjectAlmBindingResponse; } /* Capture [workspaceID] from this pattern: https://bitbucket.org/[workspaceId]/ */ const bitbucketcloudUrlRegex = new RegExp('https:\\/\\/bitbucket.org\\/(.+)\\/'); function extractBitbucketCloudWorkspaceId(almBinding?: AlmSettingsInstance): string | undefined { if (almBinding?.url) { const result = almBinding.url.match(bitbucketcloudUrlRegex); return result ? result[1] : undefined; } } export default function MultiBranchPipelineStep(props: MultiBranchPipelineStepProps) { const { alm, almBinding, finished, open, projectBinding } = props; const workspaceId = extractBitbucketCloudWorkspaceId(almBinding); const isGitLab = alm === AlmKeys.GitLab; const isBitbucketServer = alm === AlmKeys.BitbucketServer; const isBitbucketCloud = alm === AlmKeys.BitbucketCloud; const isGitHub = alm === AlmKeys.GitHub; const renderForm = React.useCallback( () => (

{translate('onboarding.tutorial.with.jenkins.multi_branch_pipeline.intro')}

    • {isBitbucketServer && ( <>
    • {projectBinding?.repository ? ( ) : ( )}
    • {projectBinding?.slug ? ( ) : ( )}
    • )} {isBitbucketCloud && ( <>
    • {workspaceId ? ( ) : ( )}
    • {projectBinding?.repository ? ( ) : ( )}
    • )} {isGitHub && ( <>
    • {almBinding !== undefined && projectBinding !== undefined && buildGithubLink(almBinding, projectBinding) !== null ? ( ) : ( )}
    • )} {isGitLab && ( <>
    • )}
    • {translate( 'onboarding.tutorial.with.jenkins.multi_branch_pipeline.step2.behaviors.label' )} :
      1. {translate( 'onboarding.tutorial.with.jenkins.multi_branch_pipeline.step2.behaviors.ref_specs.label' )} :

    {translate( 'onboarding.tutorial.with.jenkins.multi_branch_pipeline.step2.leave_defaults' )}

), [ isBitbucketCloud, isBitbucketServer, isGitHub, isGitLab, workspaceId, alm, projectBinding, almBinding, props.onDone, ] ); return ( ); }