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 { DeferredSpinner, LightPrimary, Title } from 'design-system';
21 import * as React from 'react';
22 import { translate } from '../../../../helpers/l10n';
23 import { BitbucketCloudRepository } from '../../../../types/alm-integration';
24 import { AlmKeys, AlmSettingsInstance } from '../../../../types/alm-settings';
25 import AlmSettingsInstanceDropdown from '../components/AlmSettingsInstanceDropdown';
26 import PersonalAccessTokenForm from '../components/PersonalAccessTokenForm';
27 import WrongBindingCountAlert from '../components/WrongBindingCountAlert';
28 import BitbucketCloudSearchForm from './BitbucketCloudSearchForm';
30 export interface BitbucketCloudProjectCreateRendererProps {
35 onImport: (repositorySlug: string) => void;
36 onLoadMore: () => void;
37 onPersonalAccessTokenCreated: () => void;
38 onSearch: (searchQuery: string) => void;
39 onSelectedAlmInstanceChange: (instance: AlmSettingsInstance) => void;
40 repositories?: BitbucketCloudRepository[];
44 showPersonalAccessTokenForm: boolean;
45 almInstances: AlmSettingsInstance[];
46 selectedAlmInstance?: AlmSettingsInstance;
49 export default function BitbucketCloudProjectCreateRenderer(
50 props: BitbucketCloudProjectCreateRendererProps
63 showPersonalAccessTokenForm,
68 <header className="sw-mb-10">
69 <Title className="sw-mb-4">
70 {translate('onboarding.create_project.bitbucketcloud.title')}
72 <LightPrimary className="sw-body-sm">
73 {translate('onboarding.create_project.bitbucketcloud.subtitle')}
77 <AlmSettingsInstanceDropdown
78 almKey={AlmKeys.BitbucketCloud}
79 almInstances={almInstances}
80 selectedAlmInstance={selectedAlmInstance}
81 onChangeConfig={props.onSelectedAlmInstanceChange}
84 <DeferredSpinner loading={loading} />
86 {!loading && !selectedAlmInstance && (
87 <WrongBindingCountAlert alm={AlmKeys.BitbucketCloud} canAdmin={!!canAdmin} />
91 selectedAlmInstance &&
92 (showPersonalAccessTokenForm ? (
93 <PersonalAccessTokenForm
94 almSetting={selectedAlmInstance}
96 onPersonalAccessTokenCreated={props.onPersonalAccessTokenCreated}
99 <BitbucketCloudSearchForm
100 isLastPage={isLastPage}
101 loadingMore={loadingMore}
102 searchQuery={searchQuery}
103 searching={searching}
104 onImport={props.onImport}
105 onSearch={props.onSearch}
106 onLoadMore={props.onLoadMore}
107 repositories={repositories}