mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-08 06:25: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.",
|
||||
"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."
|
||||
"descriptionHelpText": "Eine kurze Beschreibung des Repository.",
|
||||
"initializeRepository": "Erstellt einen ersten Branch und committet eine README.md."
|
||||
},
|
||||
"repositoryRoot": {
|
||||
"errorTitle": "Fehler",
|
||||
@@ -97,7 +98,8 @@
|
||||
},
|
||||
"repositoryForm": {
|
||||
"subtitle": "Repository bearbeiten",
|
||||
"submit": "Speichern"
|
||||
"submit": "Speichern",
|
||||
"initializeRepository": "Repository initiieren"
|
||||
},
|
||||
"sources": {
|
||||
"file-tree": {
|
||||
|
||||
@@ -21,7 +21,8 @@
|
||||
"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."
|
||||
"descriptionHelpText": "A short description of the repository.",
|
||||
"initializeRepository": "Creates a initial branch and commit a basic README.md."
|
||||
},
|
||||
"repositoryRoot": {
|
||||
"errorTitle": "Error",
|
||||
@@ -97,7 +98,8 @@
|
||||
},
|
||||
"repositoryForm": {
|
||||
"subtitle": "Edit Repository",
|
||||
"submit": "Save"
|
||||
"submit": "Save",
|
||||
"initializeRepository": "Initialize repository"
|
||||
},
|
||||
"sources": {
|
||||
"file-tree": {
|
||||
|
||||
@@ -21,7 +21,8 @@
|
||||
"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."
|
||||
"descriptionHelpText": "Breve descripción del repositorio.",
|
||||
"initializeRepository": "Creates a initial branch and commit a basic README.md."
|
||||
},
|
||||
"repositoryRoot": {
|
||||
"errorTitle": "Error",
|
||||
@@ -97,7 +98,8 @@
|
||||
},
|
||||
"repositoryForm": {
|
||||
"subtitle": "Editar repositorio",
|
||||
"submit": "Guardar"
|
||||
"submit": "Guardar",
|
||||
"initializeRepository": "Initialize repository"
|
||||
},
|
||||
"sources": {
|
||||
"file-tree": {
|
||||
|
||||
@@ -1,12 +1,27 @@
|
||||
import React from "react";
|
||||
import styled from "styled-components";
|
||||
import { WithTranslation, withTranslation } from "react-i18next";
|
||||
import { ExtensionPoint } from "@scm-manager/ui-extensions";
|
||||
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";
|
||||
|
||||
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 & {
|
||||
submitForm: (p: Repository) => void;
|
||||
submitForm: (repo: Repository, shouldInit: boolean) => void;
|
||||
repository?: Repository;
|
||||
repositoryTypes?: RepositoryType[];
|
||||
namespaceStrategy?: string;
|
||||
@@ -15,6 +30,7 @@ type Props = WithTranslation & {
|
||||
|
||||
type State = {
|
||||
repository: Repository;
|
||||
initRepository: boolean;
|
||||
namespaceValidationError: boolean;
|
||||
nameValidationError: boolean;
|
||||
contactValidationError: boolean;
|
||||
@@ -35,6 +51,7 @@ class RepositoryForm extends React.Component<Props, State> {
|
||||
description: "",
|
||||
_links: {}
|
||||
},
|
||||
initRepository: false,
|
||||
namespaceValidationError: false,
|
||||
nameValidationError: false,
|
||||
contactValidationError: false
|
||||
@@ -71,7 +88,7 @@ class RepositoryForm extends React.Component<Props, State> {
|
||||
submit = (event: Event) => {
|
||||
event.preventDefault();
|
||||
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;
|
||||
};
|
||||
|
||||
toggleInitCheckbox = () => {
|
||||
this.setState({
|
||||
initRepository: !this.state.initRepository
|
||||
});
|
||||
};
|
||||
|
||||
render() {
|
||||
const { loading, t } = this.props;
|
||||
const repository = this.state.repository;
|
||||
@@ -175,6 +198,8 @@ class RepositoryForm extends React.Component<Props, State> {
|
||||
errorMessage={t("validation.name-invalid")}
|
||||
helpText={t("help.nameHelpText")}
|
||||
/>
|
||||
<SpaceBetween>
|
||||
<SelectWrapper>
|
||||
<Select
|
||||
label={t("repository.type")}
|
||||
onChange={this.handleTypeChange}
|
||||
@@ -182,6 +207,16 @@ class RepositoryForm extends React.Component<Props, State> {
|
||||
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
|
||||
fetchNamespaceStrategiesIfNeeded: () => 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;
|
||||
|
||||
// context props
|
||||
@@ -67,8 +67,8 @@ class Create extends React.Component<Props> {
|
||||
repositoryTypes={repositoryTypes}
|
||||
loading={createLoading}
|
||||
namespaceStrategy={namespaceStrategies.current}
|
||||
submitForm={repo => {
|
||||
createRepo(repoLink, repo, (repo: Repository) => this.repoCreated(repo));
|
||||
submitForm={(repo, initRepository) => {
|
||||
createRepo(repoLink, repo, initRepository, (repo: Repository) => this.repoCreated(repo));
|
||||
}}
|
||||
/>
|
||||
</Page>
|
||||
@@ -102,8 +102,8 @@ const mapDispatchToProps = (dispatch: any) => {
|
||||
fetchNamespaceStrategiesIfNeeded: () => {
|
||||
dispatch(fetchNamespaceStrategiesIfNeeded());
|
||||
},
|
||||
createRepo: (link: string, repository: Repository, callback: () => void) => {
|
||||
dispatch(createRepo(link, repository, callback));
|
||||
createRepo: (link: string, repository: Repository, initRepository: boolean, callback: () => void) => {
|
||||
dispatch(createRepo(link, repository, initRepository, callback));
|
||||
},
|
||||
resetForm: () => {
|
||||
dispatch(createRepoReset());
|
||||
|
||||
@@ -155,11 +155,12 @@ export function fetchRepoFailure(namespace: string, name: string, error: Error):
|
||||
|
||||
// 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) {
|
||||
dispatch(createRepoPending());
|
||||
const repoLink = initRepository ? link + "?initRepository=true" : link;
|
||||
return apiClient
|
||||
.post(link, repository, CONTENT_TYPE)
|
||||
.post(repoLink, repository, CONTENT_TYPE)
|
||||
.then(response => {
|
||||
const location = response.headers.get("Location");
|
||||
dispatch(createRepoSuccess());
|
||||
|
||||
Reference in New Issue
Block a user