mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-07 22:15:45 +01:00
add "init repository" checkbox to repository form
This commit is contained in:
@@ -21,7 +21,8 @@
|
|||||||
"nameHelpText": "Der Name 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).",
|
"typeHelpText": "Der Typ des Repository (Mercurial, Git oder Subversion).",
|
||||||
"contactHelpText": "E-Mail Adresse der Person, die für das Repository verantwortlich ist.",
|
"contactHelpText": "E-Mail Adresse der Person, die für das Repository verantwortlich ist.",
|
||||||
"descriptionHelpText": "Eine kurze Beschreibung des Repository."
|
"descriptionHelpText": "Eine kurze Beschreibung des Repository.",
|
||||||
|
"initializeRepository": "Erstellt einen ersten Branch und committet eine README.md."
|
||||||
},
|
},
|
||||||
"repositoryRoot": {
|
"repositoryRoot": {
|
||||||
"errorTitle": "Fehler",
|
"errorTitle": "Fehler",
|
||||||
@@ -97,7 +98,8 @@
|
|||||||
},
|
},
|
||||||
"repositoryForm": {
|
"repositoryForm": {
|
||||||
"subtitle": "Repository bearbeiten",
|
"subtitle": "Repository bearbeiten",
|
||||||
"submit": "Speichern"
|
"submit": "Speichern",
|
||||||
|
"initializeRepository": "Repository initiieren"
|
||||||
},
|
},
|
||||||
"sources": {
|
"sources": {
|
||||||
"file-tree": {
|
"file-tree": {
|
||||||
|
|||||||
@@ -21,7 +21,8 @@
|
|||||||
"nameHelpText": "The name 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).",
|
"typeHelpText": "The type of the repository (e.g. Mercurial, Git or Subversion).",
|
||||||
"contactHelpText": "Email address of the person who is responsible for this repository.",
|
"contactHelpText": "Email address of the person who is responsible for this repository.",
|
||||||
"descriptionHelpText": "A short description of the repository."
|
"descriptionHelpText": "A short description of the repository.",
|
||||||
|
"initializeRepository": "Creates a initial branch and commit a basic README.md."
|
||||||
},
|
},
|
||||||
"repositoryRoot": {
|
"repositoryRoot": {
|
||||||
"errorTitle": "Error",
|
"errorTitle": "Error",
|
||||||
@@ -97,7 +98,8 @@
|
|||||||
},
|
},
|
||||||
"repositoryForm": {
|
"repositoryForm": {
|
||||||
"subtitle": "Edit Repository",
|
"subtitle": "Edit Repository",
|
||||||
"submit": "Save"
|
"submit": "Save",
|
||||||
|
"initializeRepository": "Initialize repository"
|
||||||
},
|
},
|
||||||
"sources": {
|
"sources": {
|
||||||
"file-tree": {
|
"file-tree": {
|
||||||
|
|||||||
@@ -21,7 +21,8 @@
|
|||||||
"nameHelpText": "El nombre 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).",
|
"typeHelpText": "El tipo del repositorio (Mercurial, Git or Subversion).",
|
||||||
"contactHelpText": "Dirección del correo electrónico de la persona responsable del repositorio.",
|
"contactHelpText": "Dirección del correo electrónico de la persona responsable del repositorio.",
|
||||||
"descriptionHelpText": "Breve descripción del repositorio."
|
"descriptionHelpText": "Breve descripción del repositorio.",
|
||||||
|
"initializeRepository": "Creates a initial branch and commit a basic README.md."
|
||||||
},
|
},
|
||||||
"repositoryRoot": {
|
"repositoryRoot": {
|
||||||
"errorTitle": "Error",
|
"errorTitle": "Error",
|
||||||
@@ -97,7 +98,8 @@
|
|||||||
},
|
},
|
||||||
"repositoryForm": {
|
"repositoryForm": {
|
||||||
"subtitle": "Editar repositorio",
|
"subtitle": "Editar repositorio",
|
||||||
"submit": "Guardar"
|
"submit": "Guardar",
|
||||||
|
"initializeRepository": "Initialize repository"
|
||||||
},
|
},
|
||||||
"sources": {
|
"sources": {
|
||||||
"file-tree": {
|
"file-tree": {
|
||||||
|
|||||||
@@ -1,12 +1,27 @@
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
|
import styled from "styled-components";
|
||||||
import { WithTranslation, withTranslation } from "react-i18next";
|
import { WithTranslation, withTranslation } from "react-i18next";
|
||||||
import { ExtensionPoint } from "@scm-manager/ui-extensions";
|
import { ExtensionPoint } from "@scm-manager/ui-extensions";
|
||||||
import { Repository, RepositoryType } from "@scm-manager/ui-types";
|
import { Repository, RepositoryType } from "@scm-manager/ui-types";
|
||||||
import { InputField, Level, Select, SubmitButton, Subtitle, Textarea } from "@scm-manager/ui-components";
|
import { Checkbox, Level, InputField, Select, SubmitButton, Subtitle, Textarea } from "@scm-manager/ui-components";
|
||||||
import * as validator from "./repositoryValidation";
|
import * as validator from "./repositoryValidation";
|
||||||
|
|
||||||
|
const CheckboxWrapper = styled.div`
|
||||||
|
margin-top: 2em;
|
||||||
|
flex: 1;
|
||||||
|
`;
|
||||||
|
|
||||||
|
const SelectWrapper = styled.div`
|
||||||
|
flex: 1;
|
||||||
|
`;
|
||||||
|
|
||||||
|
const SpaceBetween = styled.div`
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
`;
|
||||||
|
|
||||||
type Props = WithTranslation & {
|
type Props = WithTranslation & {
|
||||||
submitForm: (p: Repository) => void;
|
submitForm: (repo: Repository, shouldInit: boolean) => void;
|
||||||
repository?: Repository;
|
repository?: Repository;
|
||||||
repositoryTypes?: RepositoryType[];
|
repositoryTypes?: RepositoryType[];
|
||||||
namespaceStrategy?: string;
|
namespaceStrategy?: string;
|
||||||
@@ -15,6 +30,7 @@ type Props = WithTranslation & {
|
|||||||
|
|
||||||
type State = {
|
type State = {
|
||||||
repository: Repository;
|
repository: Repository;
|
||||||
|
initRepository: boolean;
|
||||||
namespaceValidationError: boolean;
|
namespaceValidationError: boolean;
|
||||||
nameValidationError: boolean;
|
nameValidationError: boolean;
|
||||||
contactValidationError: boolean;
|
contactValidationError: boolean;
|
||||||
@@ -35,6 +51,7 @@ class RepositoryForm extends React.Component<Props, State> {
|
|||||||
description: "",
|
description: "",
|
||||||
_links: {}
|
_links: {}
|
||||||
},
|
},
|
||||||
|
initRepository: false,
|
||||||
namespaceValidationError: false,
|
namespaceValidationError: false,
|
||||||
nameValidationError: false,
|
nameValidationError: false,
|
||||||
contactValidationError: false
|
contactValidationError: false
|
||||||
@@ -71,7 +88,7 @@ class RepositoryForm extends React.Component<Props, State> {
|
|||||||
submit = (event: Event) => {
|
submit = (event: Event) => {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
if (this.isValid()) {
|
if (this.isValid()) {
|
||||||
this.props.submitForm(this.state.repository);
|
this.props.submitForm(this.state.repository, this.state.initRepository);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -83,6 +100,12 @@ class RepositoryForm extends React.Component<Props, State> {
|
|||||||
return !!this.props.repository && !!this.props.repository._links.update;
|
return !!this.props.repository && !!this.props.repository._links.update;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
toggleInitCheckbox = () => {
|
||||||
|
this.setState({
|
||||||
|
initRepository: !this.state.initRepository
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { loading, t } = this.props;
|
const { loading, t } = this.props;
|
||||||
const repository = this.state.repository;
|
const repository = this.state.repository;
|
||||||
@@ -175,13 +198,25 @@ class RepositoryForm extends React.Component<Props, State> {
|
|||||||
errorMessage={t("validation.name-invalid")}
|
errorMessage={t("validation.name-invalid")}
|
||||||
helpText={t("help.nameHelpText")}
|
helpText={t("help.nameHelpText")}
|
||||||
/>
|
/>
|
||||||
<Select
|
<SpaceBetween>
|
||||||
label={t("repository.type")}
|
<SelectWrapper>
|
||||||
onChange={this.handleTypeChange}
|
<Select
|
||||||
value={repository ? repository.type : ""}
|
label={t("repository.type")}
|
||||||
options={this.createSelectOptions(repositoryTypes)}
|
onChange={this.handleTypeChange}
|
||||||
helpText={t("help.typeHelpText")}
|
value={repository ? repository.type : ""}
|
||||||
/>
|
options={this.createSelectOptions(repositoryTypes)}
|
||||||
|
helpText={t("help.typeHelpText")}
|
||||||
|
/>
|
||||||
|
</SelectWrapper>
|
||||||
|
<CheckboxWrapper>
|
||||||
|
<Checkbox
|
||||||
|
label={t("repositoryForm.initializeRepository")}
|
||||||
|
checked={this.state.initRepository}
|
||||||
|
onChange={this.toggleInitCheckbox}
|
||||||
|
helpText={t("help.initializeRepository")}
|
||||||
|
/>
|
||||||
|
</CheckboxWrapper>
|
||||||
|
</SpaceBetween>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ type Props = WithTranslation & {
|
|||||||
// dispatch functions
|
// dispatch functions
|
||||||
fetchNamespaceStrategiesIfNeeded: () => void;
|
fetchNamespaceStrategiesIfNeeded: () => void;
|
||||||
fetchRepositoryTypesIfNeeded: () => void;
|
fetchRepositoryTypesIfNeeded: () => void;
|
||||||
createRepo: (link: string, p2: Repository, callback: (repo: Repository) => void) => void;
|
createRepo: (link: string, repository: Repository, initRepository: boolean, callback: (repo: Repository) => void) => void;
|
||||||
resetForm: () => void;
|
resetForm: () => void;
|
||||||
|
|
||||||
// context props
|
// context props
|
||||||
@@ -67,8 +67,8 @@ class Create extends React.Component<Props> {
|
|||||||
repositoryTypes={repositoryTypes}
|
repositoryTypes={repositoryTypes}
|
||||||
loading={createLoading}
|
loading={createLoading}
|
||||||
namespaceStrategy={namespaceStrategies.current}
|
namespaceStrategy={namespaceStrategies.current}
|
||||||
submitForm={repo => {
|
submitForm={(repo, initRepository) => {
|
||||||
createRepo(repoLink, repo, (repo: Repository) => this.repoCreated(repo));
|
createRepo(repoLink, repo, initRepository, (repo: Repository) => this.repoCreated(repo));
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</Page>
|
</Page>
|
||||||
@@ -102,8 +102,8 @@ const mapDispatchToProps = (dispatch: any) => {
|
|||||||
fetchNamespaceStrategiesIfNeeded: () => {
|
fetchNamespaceStrategiesIfNeeded: () => {
|
||||||
dispatch(fetchNamespaceStrategiesIfNeeded());
|
dispatch(fetchNamespaceStrategiesIfNeeded());
|
||||||
},
|
},
|
||||||
createRepo: (link: string, repository: Repository, callback: () => void) => {
|
createRepo: (link: string, repository: Repository, initRepository: boolean, callback: () => void) => {
|
||||||
dispatch(createRepo(link, repository, callback));
|
dispatch(createRepo(link, repository, initRepository, callback));
|
||||||
},
|
},
|
||||||
resetForm: () => {
|
resetForm: () => {
|
||||||
dispatch(createRepoReset());
|
dispatch(createRepoReset());
|
||||||
|
|||||||
@@ -155,11 +155,12 @@ export function fetchRepoFailure(namespace: string, name: string, error: Error):
|
|||||||
|
|
||||||
// create repo
|
// create repo
|
||||||
|
|
||||||
export function createRepo(link: string, repository: Repository, callback?: (repo: Repository) => void) {
|
export function createRepo(link: string, repository: Repository, initRepository: boolean, callback?: (repo: Repository) => void) {
|
||||||
return function(dispatch: any) {
|
return function(dispatch: any) {
|
||||||
dispatch(createRepoPending());
|
dispatch(createRepoPending());
|
||||||
|
const repoLink = initRepository ? link + "?initRepository=true" : link;
|
||||||
return apiClient
|
return apiClient
|
||||||
.post(link, repository, CONTENT_TYPE)
|
.post(repoLink, repository, CONTENT_TYPE)
|
||||||
.then(response => {
|
.then(response => {
|
||||||
const location = response.headers.get("Location");
|
const location = response.headers.get("Location");
|
||||||
dispatch(createRepoSuccess());
|
dispatch(createRepoSuccess());
|
||||||
|
|||||||
Reference in New Issue
Block a user