mirror of
https://github.com/scm-manager/scm-manager.git
synced 2026-03-02 02:10:53 +01:00
Fix selection of undefined type in import repository dialog
Squash commits of branch bugfix/repo_type: - Fix selection of undefined type in import repository dialog - Remove required marker, add i18n genitive - Select first available repositoryType as default
This commit is contained in:
2
gradle/changelog/repo_type.yaml
Normal file
2
gradle/changelog/repo_type.yaml
Normal file
@@ -0,0 +1,2 @@
|
||||
- type: fixed
|
||||
description: Selection of undefined type in import repository dialog
|
||||
@@ -2,7 +2,7 @@
|
||||
"repository": {
|
||||
"namespace": "Namespace",
|
||||
"name": "Name",
|
||||
"type": "Typ",
|
||||
"type": "Typ des Repositorys",
|
||||
"contact": "Kontakt",
|
||||
"description": "Beschreibung",
|
||||
"creationDate": "Erstellt",
|
||||
@@ -24,7 +24,6 @@
|
||||
"help": {
|
||||
"namespaceHelpText": "Der Namespace des Repository. Dieser wird Teil der URL des Repository sein.",
|
||||
"nameHelpText": "Der Name des Repository. Dieser wird Teil der URL des Repository sein.",
|
||||
"typeHelpText": "Der Typ des Repository (Mercurial, Git oder Subversion).",
|
||||
"contactHelpText": "E-Mail Adresse der Person, die für das Repository verantwortlich ist.",
|
||||
"descriptionHelpText": "Eine kurze Beschreibung des Repository.",
|
||||
"initializeRepository": "Erstellt einen ersten Branch und committet eine README.md.",
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"repository": {
|
||||
"namespace": "Namespace",
|
||||
"name": "Name",
|
||||
"type": "Type",
|
||||
"type": "Type of repository",
|
||||
"contact": "Contact",
|
||||
"description": "Description",
|
||||
"creationDate": "Creation Date",
|
||||
@@ -24,7 +24,6 @@
|
||||
"help": {
|
||||
"namespaceHelpText": "The namespace of the repository. This name will be part of the repository url.",
|
||||
"nameHelpText": "The name of the repository. This name will be part of the repository url.",
|
||||
"typeHelpText": "The type of the repository (e.g. Mercurial, Git or Subversion).",
|
||||
"contactHelpText": "Email address of the person who is responsible for this repository.",
|
||||
"descriptionHelpText": "A short description of the repository.",
|
||||
"initializeRepository": "Creates an initial branch and commits a basic README.md.",
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"repository": {
|
||||
"namespace": "Espacio de nombres",
|
||||
"name": "Nombre",
|
||||
"type": "Tipo",
|
||||
"type": "Tipo del repositorio",
|
||||
"contact": "Contacto",
|
||||
"description": "Descripción",
|
||||
"creationDate": "Fecha de creación",
|
||||
@@ -19,7 +19,6 @@
|
||||
"help": {
|
||||
"namespaceHelpText": "El espacio de nombres del repositorio. Este nombre formará parte de la URL del repositorio.",
|
||||
"nameHelpText": "El nombre del repositorio. Este nombre formará parte de la URL del repositorio.",
|
||||
"typeHelpText": "El tipo del repositorio (Mercurial, Git or Subversion).",
|
||||
"contactHelpText": "Dirección del correo electrónico de la persona responsable del repositorio.",
|
||||
"descriptionHelpText": "Breve descripción del repositorio.",
|
||||
"initializeRepository": "Creates an initial branch and commits a basic README.md."
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
import React, { FC } from "react";
|
||||
import { RepositoryType } from "@scm-manager/ui-types";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Select } from "@scm-manager/ui-components";
|
||||
import { Label, Loading, Select } from "@scm-manager/ui-core";
|
||||
|
||||
type Props = {
|
||||
repositoryTypes: RepositoryType[];
|
||||
@@ -30,32 +30,36 @@ const ImportRepositoryTypeSelect: FC<Props> = ({ repositoryTypes, repositoryType
|
||||
const [t] = useTranslation("repos");
|
||||
|
||||
const createSelectOptions = () => {
|
||||
const options = repositoryTypes
|
||||
.filter(repoType => !!repoType._links.import)
|
||||
.map(repositoryType => {
|
||||
return repositoryTypes
|
||||
.filter((repoType) => !!repoType._links.import)
|
||||
.map((repositoryType) => {
|
||||
return {
|
||||
label: repositoryType.displayName,
|
||||
value: repositoryType.name
|
||||
value: repositoryType.name,
|
||||
};
|
||||
});
|
||||
options.unshift({ label: "", value: "" });
|
||||
return options;
|
||||
};
|
||||
|
||||
const onChangeType = (type: string) => {
|
||||
const repositoryType = repositoryTypes.filter(t => t.name === type)[0];
|
||||
const onChangeType = (event: React.ChangeEvent<HTMLSelectElement>) => {
|
||||
const type = event.target.value;
|
||||
const repositoryType = repositoryTypes.filter((t) => t.name === type)[0];
|
||||
setRepositoryType(repositoryType);
|
||||
};
|
||||
|
||||
if (!repositoryType) {
|
||||
return <Loading />;
|
||||
}
|
||||
|
||||
return (
|
||||
<Select
|
||||
label={t("repository.type")}
|
||||
onChange={onChangeType}
|
||||
value={repositoryType ? repositoryType.name : ""}
|
||||
options={createSelectOptions()}
|
||||
helpText={t("help.typeHelpText")}
|
||||
disabled={disabled}
|
||||
/>
|
||||
<Label className="is-flex is-align-items-baseline">
|
||||
<span className="mr-2">{t("repository.type")}</span>
|
||||
<Select
|
||||
onChange={onChangeType}
|
||||
options={createSelectOptions()}
|
||||
disabled={disabled}
|
||||
defaultValue={repositoryType.name}
|
||||
/>
|
||||
</Label>
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
@@ -45,11 +45,13 @@ const ImportPendingLoading = ({ importPending }: { importPending: boolean }) =>
|
||||
const ImportRepository: extensionPoints.RepositoryCreatorExtension["component"] = ({
|
||||
repositoryTypes,
|
||||
nameForm,
|
||||
informationForm
|
||||
informationForm,
|
||||
}) => {
|
||||
const [importPending, setImportPending] = useState(false);
|
||||
const [importedRepository, setImportedRepository] = useState<Repository>();
|
||||
const [repositoryType, setRepositoryType] = useState<RepositoryType | undefined>();
|
||||
const [repositoryType, setRepositoryType] = useState<RepositoryType | undefined>(
|
||||
repositoryTypes?._embedded?.repositoryTypes?.[0]
|
||||
);
|
||||
const [importType, setImportType] = useState("");
|
||||
const [t] = useTranslation("repos");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user