/* * 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 { FormattedMessage } from 'react-intl'; import Link from '../../../components/common/Link'; import { Button } from '../../../components/controls/buttons'; import SearchBox from '../../../components/controls/SearchBox'; import { Alert } from '../../../components/ui/Alert'; import DeferredSpinner from '../../../components/ui/DeferredSpinner'; import { translate } from '../../../helpers/l10n'; import { getBaseUrl } from '../../../helpers/system'; import { getGlobalSettingsUrl } from '../../../helpers/urls'; import { AzureProject, AzureRepository } from '../../../types/alm-integration'; import { AlmKeys, AlmSettingsInstance } from '../../../types/alm-settings'; import { Dict } from '../../../types/types'; import { ALM_INTEGRATION_CATEGORY } from '../../settings/constants'; import AlmSettingsInstanceDropdown from './AlmSettingsInstanceDropdown'; import AzurePersonalAccessTokenForm from './AzurePersonalAccessTokenForm'; import AzureProjectsList from './AzureProjectsList'; import CreateProjectPageHeader from './CreateProjectPageHeader'; import WrongBindingCountAlert from './WrongBindingCountAlert'; export interface AzureProjectCreateRendererProps { canAdmin?: boolean; importing: boolean; loading: boolean; loadingRepositories: Dict; onImportRepository: () => void; onOpenProject: (key: string) => void; onPersonalAccessTokenCreate: (token: string) => void; onSearch: (query: string) => void; onSelectRepository: (repository: AzureRepository) => void; projects?: AzureProject[]; repositories: Dict; searching?: boolean; searchResults?: AzureRepository[]; searchQuery?: string; selectedRepository?: AzureRepository; almInstances?: AlmSettingsInstance[]; selectedAlmInstance?: AlmSettingsInstance; showPersonalAccessTokenForm?: boolean; submittingToken?: boolean; tokenValidationFailed: boolean; onSelectedAlmInstanceChange: (instance: AlmSettingsInstance) => void; firstConnection?: boolean; } export default function AzureProjectCreateRenderer(props: AzureProjectCreateRendererProps) { const { canAdmin, importing, loading, loadingRepositories, projects, repositories, searching, searchResults, searchQuery, selectedRepository, almInstances, showPersonalAccessTokenForm, submittingToken, tokenValidationFailed, selectedAlmInstance, firstConnection, } = props; const showCountError = !loading && (!almInstances || almInstances?.length === 0); const settingIsValid = selectedAlmInstance && selectedAlmInstance.url; const showUrlError = !loading && selectedAlmInstance && !selectedAlmInstance.url; return ( <> ) } title={ {translate('onboarding.create_project.azure.title')} } /> {loading && } {showUrlError && ( {canAdmin ? ( {translate('settings.page')} ), }} /> ) : ( translate('onboarding.create_project.azure.no_url') )} )} {showCountError && } {!loading && selectedAlmInstance && selectedAlmInstance.url && (showPersonalAccessTokenForm ? (
) : ( <>
))} ); }