| 
									
										
										
										
											2020-03-23 15:35:58 +01:00
										 |  |  | /* | 
					
						
							| 
									
										
										
										
											2024-09-24 09:42:07 +02:00
										 |  |  |  * Copyright (c) 2020 - present Cloudogu GmbH | 
					
						
							| 
									
										
										
										
											2020-03-23 15:35:58 +01:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2024-09-24 09:42:07 +02:00
										 |  |  |  * This program is free software: you can redistribute it and/or modify it under | 
					
						
							|  |  |  |  * the terms of the GNU Affero General Public License as published by the Free | 
					
						
							|  |  |  |  * Software Foundation, version 3. | 
					
						
							| 
									
										
										
										
											2020-03-23 15:35:58 +01:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2024-09-24 09:42:07 +02:00
										 |  |  |  * 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 Affero General Public License for more | 
					
						
							|  |  |  |  * details. | 
					
						
							| 
									
										
										
										
											2020-03-23 15:35:58 +01:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2024-09-24 09:42:07 +02:00
										 |  |  |  * You should have received a copy of the GNU Affero General Public License | 
					
						
							|  |  |  |  * along with this program. If not, see https://www.gnu.org/licenses/.
 | 
					
						
							| 
									
										
										
										
											2020-03-23 15:35:58 +01:00
										 |  |  |  */ | 
					
						
							| 
									
										
										
										
											2024-09-24 09:42:07 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-02-24 08:17:40 +01:00
										 |  |  | import React, { FC } from "react"; | 
					
						
							| 
									
										
										
										
											2021-05-14 09:15:35 +02:00
										 |  |  | import { ErrorNotification } from "@scm-manager/ui-components"; | 
					
						
							| 
									
										
										
										
											2019-10-23 15:47:08 +02:00
										 |  |  | import RepositoryForm from "../components/form"; | 
					
						
							| 
									
										
										
										
											2021-02-24 08:17:40 +01:00
										 |  |  | import { Redirect } from "react-router-dom"; | 
					
						
							| 
									
										
										
										
											2021-05-14 09:15:35 +02:00
										 |  |  | import { useCreateRepository } from "@scm-manager/ui-api"; | 
					
						
							|  |  |  | import { CreatorComponentProps } from "../types"; | 
					
						
							| 
									
										
										
										
											2018-08-02 16:09:58 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-05-14 09:15:35 +02:00
										 |  |  | const CreateRepository: FC<CreatorComponentProps> = ({ repositoryTypes, namespaceStrategies, index }) => { | 
					
						
							| 
									
										
										
										
											2021-02-24 08:17:40 +01:00
										 |  |  |   const { isLoading, error, repository, create } = useCreateRepository(); | 
					
						
							| 
									
										
										
										
											2018-08-03 08:52:02 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-02-24 08:17:40 +01:00
										 |  |  |   if (repository) { | 
					
						
							| 
									
										
										
										
											2021-07-28 15:04:00 +02:00
										 |  |  |     return <Redirect to={`/repo/${repository.namespace}/${repository.name}/info`} />; | 
					
						
							| 
									
										
										
										
											2021-02-24 08:17:40 +01:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2018-08-02 16:09:58 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-02-24 08:17:40 +01:00
										 |  |  |   return ( | 
					
						
							| 
									
										
										
										
											2021-05-14 09:15:35 +02:00
										 |  |  |     <> | 
					
						
							|  |  |  |       <ErrorNotification error={error} /> | 
					
						
							|  |  |  |       <RepositoryForm | 
					
						
							|  |  |  |         repositoryTypes={repositoryTypes._embedded.repositoryTypes} | 
					
						
							|  |  |  |         loading={isLoading} | 
					
						
							|  |  |  |         namespaceStrategy={namespaceStrategies.current} | 
					
						
							|  |  |  |         createRepository={create} | 
					
						
							|  |  |  |         indexResources={index} | 
					
						
							|  |  |  |       /> | 
					
						
							|  |  |  |     </> | 
					
						
							| 
									
										
										
										
											2021-02-24 08:17:40 +01:00
										 |  |  |   ); | 
					
						
							| 
									
										
										
										
											2018-08-02 16:09:58 +02:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-02-24 08:17:40 +01:00
										 |  |  | export default CreateRepository; |