3 * Copyright (C) 2009-2023 SonarSource SA
4 * mailto:info AT sonarsource DOT com
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 3 of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with this program; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 import * as React from 'react';
21 import { translate } from '../../../../helpers/l10n';
22 import { getBaseUrl } from '../../../../helpers/system';
23 import { BitbucketCloudRepository } from '../../../../types/alm-integration';
24 import { AlmKeys, AlmSettingsInstance } from '../../../../types/alm-settings';
25 import AlmSettingsInstanceDropdown from '../components/AlmSettingsInstanceDropdown';
26 import CreateProjectPageHeader from '../components/CreateProjectPageHeader';
27 import PersonalAccessTokenForm from '../components/PersonalAccessTokenForm';
28 import WrongBindingCountAlert from '../components/WrongBindingCountAlert';
29 import BitbucketCloudSearchForm from './BitbucketCloudSearchForm';
31 export interface BitbucketCloudProjectCreateRendererProps {
32 importingSlug?: string;
37 onImport: (repositorySlug: string) => void;
38 onLoadMore: () => void;
39 onPersonalAccessTokenCreated: () => void;
40 onSearch: (searchQuery: string) => void;
41 onSelectedAlmInstanceChange: (instance: AlmSettingsInstance) => void;
42 repositories?: BitbucketCloudRepository[];
46 showPersonalAccessTokenForm: boolean;
47 almInstances: AlmSettingsInstance[];
48 selectedAlmInstance?: AlmSettingsInstance;
51 export default function BitbucketCloudProjectCreateRenderer(
52 props: BitbucketCloudProjectCreateRendererProps
66 showPersonalAccessTokenForm,
71 <CreateProjectPageHeader
73 <span className="text-middle">
75 alt="" // Should be ignored by screen readers
76 className="spacer-right"
78 src={`${getBaseUrl()}/images/alm/bitbucket.svg`}
80 {translate('onboarding.create_project.bitbucketcloud.title')}
85 <AlmSettingsInstanceDropdown
86 almKey={AlmKeys.BitbucketCloud}
87 almInstances={almInstances}
88 selectedAlmInstance={selectedAlmInstance}
89 onChangeConfig={props.onSelectedAlmInstanceChange}
92 {loading && <i className="spinner" />}
94 {!loading && !selectedAlmInstance && (
95 <WrongBindingCountAlert alm={AlmKeys.BitbucketCloud} canAdmin={!!canAdmin} />
99 selectedAlmInstance &&
100 (showPersonalAccessTokenForm ? (
101 <PersonalAccessTokenForm
102 almSetting={selectedAlmInstance}
104 onPersonalAccessTokenCreated={props.onPersonalAccessTokenCreated}
107 <BitbucketCloudSearchForm
108 importingSlug={importingSlug}
109 isLastPage={isLastPage}
110 loadingMore={loadingMore}
111 searchQuery={searchQuery}
112 searching={searching}
113 onImport={props.onImport}
114 onSearch={props.onSearch}
115 onLoadMore={props.onLoadMore}
116 repositories={repositories}