Add extension point for repository creators (#1657)

Adds an extension point for repository creator such as repository create, repository import or repository mirror.
This commit is contained in:
Sebastian Sdorra
2021-05-14 09:15:35 +02:00
committed by GitHub
parent 640a270e1d
commit 8e16fa11c9
19 changed files with 428 additions and 223 deletions

View File

@@ -30,7 +30,7 @@ type ExtensionRegistration<P, T> = {
extensionName: string;
};
export type ExtensionPointDefinition<N extends string, T, P> = {
export type ExtensionPointDefinition<N extends string, T, P = undefined> = {
name: N;
type: T;
props: P;

View File

@@ -0,0 +1,57 @@
/*
* MIT License
*
* Copyright (c) 2020-present Cloudogu GmbH and Contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
import { ExtensionPointDefinition } from "./binder";
import {
IndexResources,
NamespaceStrategies,
RepositoryCreation,
RepositoryTypeCollection
} from "@scm-manager/ui-types";
type RepositoryCreatorSubFormProps = {
repository: RepositoryCreation;
onChange: (repository: RepositoryCreation) => void;
setValid: (valid: boolean) => void;
disabled?: boolean;
};
export type RepositoryCreatorComponentProps = {
namespaceStrategies: NamespaceStrategies;
repositoryTypes: RepositoryTypeCollection;
index: IndexResources;
nameForm: React.ComponentType<RepositoryCreatorSubFormProps>;
informationForm: React.ComponentType<RepositoryCreatorSubFormProps>;
};
export type RepositoryCreatorExtension = {
subtitle: string;
path: string;
icon: string;
label: string;
component: React.ComponentType<RepositoryCreatorComponentProps>;
};
export type RepositoryCreator = ExtensionPointDefinition<"repos.creator", RepositoryCreatorExtension>;

View File

@@ -25,3 +25,8 @@
export { default as binder, Binder, ExtensionPointDefinition } from "./binder";
export * from "./useBinder";
export { default as ExtensionPoint } from "./ExtensionPoint";
// suppress eslint prettier warning,
// because prettier does not understand "* as"
// eslint-disable-next-line prettier/prettier
export * as extensionPoints from "./extensionPoints";