mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-12 08:25:44 +01:00
add new extension point for repository initialization
This commit is contained in:
@@ -35,6 +35,10 @@ export type Repository = {
|
|||||||
_links: Links;
|
_links: Links;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export type RepositoryCreation = Repository & {
|
||||||
|
creationContext: { [key: string]: any };
|
||||||
|
};
|
||||||
|
|
||||||
export type RepositoryCollection = PagedCollection & {
|
export type RepositoryCollection = PagedCollection & {
|
||||||
_embedded: {
|
_embedded: {
|
||||||
repositories: Repository[] | string[];
|
repositories: Repository[] | string[];
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ export { Me } from "./Me";
|
|||||||
export { DisplayedUser, User } from "./User";
|
export { DisplayedUser, User } from "./User";
|
||||||
export { Group, Member } from "./Group";
|
export { Group, Member } from "./Group";
|
||||||
|
|
||||||
export { Repository, RepositoryCollection, RepositoryGroup } from "./Repositories";
|
export { Repository, RepositoryCollection, RepositoryGroup, RepositoryCreation } from "./Repositories";
|
||||||
export { RepositoryType, RepositoryTypeCollection } from "./RepositoryTypes";
|
export { RepositoryType, RepositoryTypeCollection } from "./RepositoryTypes";
|
||||||
|
|
||||||
export { Branch, BranchRequest } from "./Branches";
|
export { Branch, BranchRequest } from "./Branches";
|
||||||
|
|||||||
@@ -23,10 +23,10 @@
|
|||||||
*/
|
*/
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import styled from "styled-components";
|
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, RepositoryCreation, RepositoryType} from "@scm-manager/ui-types";
|
||||||
import { Checkbox, InputField, Level, Select, SubmitButton, Subtitle, Textarea } from "@scm-manager/ui-components";
|
import {Checkbox, InputField, Level, Select, SubmitButton, Subtitle, Textarea} from "@scm-manager/ui-components";
|
||||||
import * as validator from "./repositoryValidation";
|
import * as validator from "./repositoryValidation";
|
||||||
import { CUSTOM_NAMESPACE_STRATEGY } from "../../modules/repos";
|
import { CUSTOM_NAMESPACE_STRATEGY } from "../../modules/repos";
|
||||||
|
|
||||||
@@ -45,7 +45,7 @@ const SpaceBetween = styled.div`
|
|||||||
`;
|
`;
|
||||||
|
|
||||||
type Props = WithTranslation & {
|
type Props = WithTranslation & {
|
||||||
submitForm: (repo: Repository, shouldInit: boolean) => void;
|
submitForm: (repo: RepositoryCreation, shouldInit: boolean) => void;
|
||||||
repository?: Repository;
|
repository?: Repository;
|
||||||
repositoryTypes?: RepositoryType[];
|
repositoryTypes?: RepositoryType[];
|
||||||
namespaceStrategy?: string;
|
namespaceStrategy?: string;
|
||||||
@@ -53,7 +53,7 @@ type Props = WithTranslation & {
|
|||||||
};
|
};
|
||||||
|
|
||||||
type State = {
|
type State = {
|
||||||
repository: Repository;
|
repository: RepositoryCreation;
|
||||||
initRepository: boolean;
|
initRepository: boolean;
|
||||||
namespaceValidationError: boolean;
|
namespaceValidationError: boolean;
|
||||||
nameValidationError: boolean;
|
nameValidationError: boolean;
|
||||||
@@ -71,6 +71,7 @@ class RepositoryForm extends React.Component<Props, State> {
|
|||||||
type: "",
|
type: "",
|
||||||
contact: "",
|
contact: "",
|
||||||
description: "",
|
description: "",
|
||||||
|
creationContext: {},
|
||||||
_links: {}
|
_links: {}
|
||||||
},
|
},
|
||||||
initRepository: false,
|
initRepository: false,
|
||||||
@@ -85,7 +86,8 @@ class RepositoryForm extends React.Component<Props, State> {
|
|||||||
if (repository) {
|
if (repository) {
|
||||||
this.setState({
|
this.setState({
|
||||||
repository: {
|
repository: {
|
||||||
...repository
|
...repository,
|
||||||
|
creationContext: {}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -128,6 +130,18 @@ class RepositoryForm extends React.Component<Props, State> {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
setCreationContextEntry = (key: string, value: any) => {
|
||||||
|
this.setState({
|
||||||
|
repository: {
|
||||||
|
...this.state.repository,
|
||||||
|
creationContext: {
|
||||||
|
...this.state.repository.creationContext,
|
||||||
|
[key]: value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { loading, t } = this.props;
|
const { loading, t } = this.props;
|
||||||
const repository = this.state.repository;
|
const repository = this.state.repository;
|
||||||
@@ -209,6 +223,10 @@ class RepositoryForm extends React.Component<Props, State> {
|
|||||||
}
|
}
|
||||||
const { repositoryTypes, t } = this.props;
|
const { repositoryTypes, t } = this.props;
|
||||||
const repository = this.state.repository;
|
const repository = this.state.repository;
|
||||||
|
const extensionProps = {
|
||||||
|
repository,
|
||||||
|
setCreationContextEntry: this.setCreationContextEntry
|
||||||
|
};
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{this.renderNamespaceField()}
|
{this.renderNamespaceField()}
|
||||||
@@ -239,6 +257,9 @@ class RepositoryForm extends React.Component<Props, State> {
|
|||||||
/>
|
/>
|
||||||
</CheckboxWrapper>
|
</CheckboxWrapper>
|
||||||
</SpaceBetween>
|
</SpaceBetween>
|
||||||
|
{this.state.initRepository && (
|
||||||
|
<ExtensionPoint name="repos.create.initialize" props={extensionProps} renderAll={false} />
|
||||||
|
)}
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ import React from "react";
|
|||||||
import { connect } from "react-redux";
|
import { connect } from "react-redux";
|
||||||
import { WithTranslation, withTranslation } from "react-i18next";
|
import { WithTranslation, withTranslation } from "react-i18next";
|
||||||
import { History } from "history";
|
import { History } from "history";
|
||||||
import { NamespaceStrategies, Repository, RepositoryType } from "@scm-manager/ui-types";
|
import { NamespaceStrategies, Repository, RepositoryCreation, RepositoryType } from "@scm-manager/ui-types";
|
||||||
import { Page } from "@scm-manager/ui-components";
|
import { Page } from "@scm-manager/ui-components";
|
||||||
import {
|
import {
|
||||||
fetchRepositoryTypesIfNeeded,
|
fetchRepositoryTypesIfNeeded,
|
||||||
@@ -56,9 +56,10 @@ type Props = WithTranslation & {
|
|||||||
fetchRepositoryTypesIfNeeded: () => void;
|
fetchRepositoryTypesIfNeeded: () => void;
|
||||||
createRepo: (
|
createRepo: (
|
||||||
link: string,
|
link: string,
|
||||||
repository: Repository,
|
repository: RepositoryCreation,
|
||||||
initRepository: boolean,
|
initRepository: boolean,
|
||||||
callback: (repo: Repository) => void
|
callback: (repo: Repository) => void,
|
||||||
|
initRepositoryContext?: any
|
||||||
) => void;
|
) => void;
|
||||||
resetForm: () => void;
|
resetForm: () => void;
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,7 @@
|
|||||||
|
|
||||||
import { apiClient } from "@scm-manager/ui-components";
|
import { apiClient } from "@scm-manager/ui-components";
|
||||||
import * as types from "../../modules/types";
|
import * as types from "../../modules/types";
|
||||||
import { Action, Repository, RepositoryCollection } from "@scm-manager/ui-types";
|
import { Action, Repository, RepositoryCollection, RepositoryCreation } from "@scm-manager/ui-types";
|
||||||
import { isPending } from "../../modules/pending";
|
import { isPending } from "../../modules/pending";
|
||||||
import { getFailure } from "../../modules/failure";
|
import { getFailure } from "../../modules/failure";
|
||||||
|
|
||||||
@@ -183,7 +183,7 @@ export function fetchRepoFailure(namespace: string, name: string, error: Error):
|
|||||||
|
|
||||||
export function createRepo(
|
export function createRepo(
|
||||||
link: string,
|
link: string,
|
||||||
repository: Repository,
|
repository: RepositoryCreation,
|
||||||
initRepository: boolean,
|
initRepository: boolean,
|
||||||
callback?: (repo: Repository) => void
|
callback?: (repo: Repository) => void
|
||||||
) {
|
) {
|
||||||
|
|||||||
Reference in New Issue
Block a user