mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-12-22 16:29:51 +01:00
Restructure global configuration forms for each repository type
Squash commits of branch feature/repository-type-configuration: - Refactor hg configuration form - Add support of description text for checkbox and input fields - Refactor git configuration form - Refactor svn configuration form - Add aria-describedby for checkbox and input fields - Change hgBinary can also be null - Fix naming of test - Fix spelling - Change logic of successfull notification to only be shown if the config rest api returns without an error Reviewed-by: Philipp Ahrendt <philipp.ahrendt@cloudogu.com>, Till-André Diegeler <till-andre.diegeler@cloudogu.com> Reviewed-by: Philipp Ahrendt <philipp.ahrendt@cloudogu.com>
This commit is contained in:
@@ -14,13 +14,11 @@
|
||||
* along with this program. If not, see https://www.gnu.org/licenses/.
|
||||
*/
|
||||
|
||||
import React, { FC, useEffect } from "react";
|
||||
import { useForm } from "react-hook-form";
|
||||
import React, { FC } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { useConfigLink } from "@scm-manager/ui-api";
|
||||
import { ConfigurationForm, InputField, Checkbox, validation } from "@scm-manager/ui-components";
|
||||
import { Title, useDocumentTitle } from "@scm-manager/ui-core";
|
||||
import { ConfigurationForm, Form, Title, useDocumentTitle } from "@scm-manager/ui-core";
|
||||
import { HalRepresentation } from "@scm-manager/ui-types";
|
||||
import { validation } from "@scm-manager/ui-components";
|
||||
|
||||
type Props = {
|
||||
link: string;
|
||||
@@ -40,62 +38,41 @@ const GitGlobalConfiguration: FC<Props> = ({ link }) => {
|
||||
const [t] = useTranslation("plugins");
|
||||
useDocumentTitle(t("scm-git-plugin.config.title"));
|
||||
|
||||
const { initialConfiguration, isReadOnly, update, ...formProps } = useConfigLink<Configuration>(link);
|
||||
const { formState, handleSubmit, register, reset } = useForm<Configuration>({ mode: "onChange" });
|
||||
|
||||
useEffect(() => {
|
||||
if (initialConfiguration) {
|
||||
reset(initialConfiguration);
|
||||
}
|
||||
}, [initialConfiguration, reset]);
|
||||
|
||||
const isValidDefaultBranch = (value: string) => {
|
||||
return validation.isBranchValid(value);
|
||||
const validateLfsWriteAuthorization = (value: string) => {
|
||||
const authorizationTime = parseInt(value);
|
||||
return Number.isInteger(authorizationTime) && authorizationTime > 0;
|
||||
};
|
||||
|
||||
return (
|
||||
<ConfigurationForm
|
||||
isValid={formState.isValid}
|
||||
isReadOnly={isReadOnly}
|
||||
onSubmit={handleSubmit(update)}
|
||||
{...formProps}
|
||||
>
|
||||
<Title>{t("scm-git-plugin.config.title")}</Title>
|
||||
<InputField
|
||||
label={t("scm-git-plugin.config.gcExpression")}
|
||||
helpText={t("scm-git-plugin.config.gcExpressionHelpText")}
|
||||
disabled={isReadOnly}
|
||||
{...register("gcExpression")}
|
||||
/>
|
||||
<Checkbox
|
||||
label={t("scm-git-plugin.config.nonFastForwardDisallowed")}
|
||||
helpText={t("scm-git-plugin.config.nonFastForwardDisallowedHelpText")}
|
||||
disabled={isReadOnly}
|
||||
{...register("nonFastForwardDisallowed")}
|
||||
/>
|
||||
<InputField
|
||||
label={t("scm-git-plugin.config.defaultBranch")}
|
||||
helpText={t("scm-git-plugin.config.defaultBranchHelpText")}
|
||||
disabled={isReadOnly}
|
||||
validationError={!!formState.errors.defaultBranch}
|
||||
errorMessage={t("scm-git-plugin.config.defaultBranchValidationError")}
|
||||
{...register("defaultBranch", { validate: isValidDefaultBranch })}
|
||||
/>
|
||||
<InputField
|
||||
type="number"
|
||||
label={t("scm-git-plugin.config.lfsWriteAuthorizationExpirationInMinutes")}
|
||||
helpText={t("scm-git-plugin.config.lfsWriteAuthorizationExpirationInMinutesHelpText")}
|
||||
disabled={isReadOnly}
|
||||
validationError={!!formState.errors.lfsWriteAuthorizationExpirationInMinutes}
|
||||
errorMessage={t("scm-git-plugin.config.lfsWriteAuthorizationExpirationInMinutesValidationError")}
|
||||
{...register("lfsWriteAuthorizationExpirationInMinutes", { min: 1, required: true })}
|
||||
/>
|
||||
<Checkbox
|
||||
label={t("scm-git-plugin.config.disabled")}
|
||||
helpText={t("scm-git-plugin.config.disabledHelpText")}
|
||||
disabled={isReadOnly || !initialConfiguration?.allowDisable}
|
||||
{...register("disabled")}
|
||||
/>
|
||||
<ConfigurationForm<Configuration> link={link} translationPath={["plugins", "scm-git-plugin.config"]}>
|
||||
{({ watch }) => (
|
||||
<>
|
||||
<Title>{t("scm-git-plugin.config.title")}</Title>
|
||||
<Form.Row>
|
||||
<Form.Checkbox name="disabled" readOnly={!watch("allowDisable")} />
|
||||
</Form.Row>
|
||||
{!watch("disabled") ? (
|
||||
<>
|
||||
<Form.Row>
|
||||
<Form.Input name="gcExpression" />
|
||||
</Form.Row>
|
||||
<Form.Row>
|
||||
<Form.Checkbox name="nonFastForwardDisallowed" />
|
||||
</Form.Row>
|
||||
<Form.Row>
|
||||
<Form.Input name="defaultBranch" rules={{ required: true, validate: validation.isBranchValid }} />
|
||||
</Form.Row>
|
||||
<Form.Row>
|
||||
<Form.Input
|
||||
name="lfsWriteAuthorizationExpirationInMinutes"
|
||||
type="number"
|
||||
rules={{ required: true, validate: validateLfsWriteAuthorization }}
|
||||
/>
|
||||
</Form.Row>
|
||||
</>
|
||||
) : null}
|
||||
</>
|
||||
)}
|
||||
</ConfigurationForm>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -21,18 +21,24 @@
|
||||
"config": {
|
||||
"link": "Git",
|
||||
"title": "Git Konfiguration",
|
||||
"gcExpression": "GC Cron Ausdruck",
|
||||
"gcExpressionHelpText": "Benutze Quartz Cron Ausdrücke (SECOND MINUTE HOUR DAYOFMONTH MONTH DAYOFWEEK), um git GC regelmäßig auszuführen.",
|
||||
"nonFastForwardDisallowed": "Deaktiviere \"Non Fast-Forward\"",
|
||||
"nonFastForwardDisallowedHelpText": "Git Pushes ablehnen, die nicht \"fast-forward\" sind, wie \"--force\".",
|
||||
"defaultBranch": "Default Branch",
|
||||
"defaultBranchHelpText": "Dieser Name wird bei der Initialisierung neuer Git Repositories genutzt. Er hat keine weiteren Auswirkungen (insbesondere hat er keinen Einfluss auf den Branchnamen bei leeren Repositories).",
|
||||
"defaultBranchValidationError": "Dies ist kein valider Branchname",
|
||||
"lfsWriteAuthorizationExpirationInMinutes": "Ablaufzeit für LFS Autorisierung",
|
||||
"lfsWriteAuthorizationExpirationInMinutesHelpText": "Ablaufzeit für den Autorisierungstoken in Minuten, der für LFS Speicheranfragen ausgestellt wird. Wenn der SCM-Manager hinter einem Reverse-Proxy mit Zwischenspeicherung (z. B. Nginx) betrieben wird, sollte dieser Wert auf die Zeit gesetzt werden, die ein LFS-Upload maximal benötigen kann.",
|
||||
"lfsWriteAuthorizationExpirationInMinutesValidationError": "Has to be at least 1 minute",
|
||||
"disabled": "Deaktiviert",
|
||||
"disabledHelpText": "Aktiviere oder deaktiviere das Git Plugin. Nur erlaubt, wenn keine Git Repositories existieren.",
|
||||
"gcExpression": {
|
||||
"label": "GC Cron Ausdruck",
|
||||
"descriptionText": "Benutze Quartz Cron Ausdrücke (SECOND MINUTE HOUR DAYOFMONTH MONTH DAYOFWEEK), um git GC regelmäßig auszuführen."
|
||||
},
|
||||
"nonFastForwardDisallowed": {
|
||||
"label": "Deaktiviere \"Non Fast-Forward\"",
|
||||
"descriptionText": "Git Pushes ablehnen, die nicht \"fast-forward\" sind, wie \"--force\"."
|
||||
},
|
||||
"defaultBranch": {
|
||||
"label": "Default Branch für neu initialisierte Repositorys"
|
||||
},
|
||||
"lfsWriteAuthorizationExpirationInMinutes": {
|
||||
"label": "Ablaufzeit für LFS Autorisierung",
|
||||
"descriptionText": "Ablaufzeit für den Autorisierungstoken in Minuten, der für LFS Speicheranfragen ausgestellt wird. Wenn der SCM-Manager hinter einem Reverse-Proxy mit Zwischenspeicherung (z. B. Nginx) betrieben wird, sollte dieser Wert auf die Zeit gesetzt werden, die ein LFS-Upload maximal benötigen kann."
|
||||
},
|
||||
"disabled": {
|
||||
"label": "Deaktiviere das Git Plugin. Nur erlaubt, wenn keine Git Repositories existieren."
|
||||
},
|
||||
"submit": "Speichern"
|
||||
},
|
||||
"repoConfig": {
|
||||
|
||||
@@ -21,18 +21,24 @@
|
||||
"config": {
|
||||
"link": "Git",
|
||||
"title": "Git Configuration",
|
||||
"gcExpression": "GC Cron Expression",
|
||||
"gcExpressionHelpText": "Use Quartz Cron Expressions (SECOND MINUTE HOUR DAYOFMONTH MONTH DAYOFWEEK) to run git gc in intervals.",
|
||||
"nonFastForwardDisallowed": "Disallow Non Fast-Forward",
|
||||
"nonFastForwardDisallowedHelpText": "Reject git pushes which are non fast-forward such as --force.",
|
||||
"defaultBranch": "Default Branch",
|
||||
"defaultBranchHelpText": "This name will be used for the initialization of new git repositories. It has no effect otherwise (especially this cannot change the initial branch name for empty repositories).",
|
||||
"defaultBranchValidationError": "This is not a valid branch name",
|
||||
"lfsWriteAuthorizationExpirationInMinutes": "LFS authorization expiration",
|
||||
"lfsWriteAuthorizationExpirationInMinutesHelpText": "Expiration time of the authorization token generated for LFS put requests in minutes. If SCM-Manager is run behind a reverse proxy that buffers http requests (eg. Nginx), this should set up to the time, an LFS upload may take at maximum.",
|
||||
"lfsWriteAuthorizationExpirationInMinutesValidationError": "Has to be at least 1 minute",
|
||||
"disabled": "Disabled",
|
||||
"disabledHelpText": "Enable or disable the Git plugin. Only allowed if no Git Repositories exist.",
|
||||
"gcExpression": {
|
||||
"label": "GC Cron Expression",
|
||||
"descriptionText": "Use Quartz Cron Expressions (SECOND MINUTE HOUR DAYOFMONTH MONTH DAYOFWEEK) to run git gc in intervals."
|
||||
},
|
||||
"nonFastForwardDisallowed": {
|
||||
"label": "Disallow Non Fast-Forward",
|
||||
"descriptionText": "Reject git pushes which are non fast-forward such as --force."
|
||||
},
|
||||
"defaultBranch": {
|
||||
"label": "Default branch for newly initialized repositories"
|
||||
},
|
||||
"lfsWriteAuthorizationExpirationInMinutes": {
|
||||
"label": "LFS authorization expiration",
|
||||
"descriptionText": "Expiration time of the authorization token generated for LFS put requests in minutes. If SCM-Manager is run behind a reverse proxy that buffers http requests (eg. Nginx), this should set up to the time, an LFS upload may take at maximum."
|
||||
},
|
||||
"disabled": {
|
||||
"label": "Disable the Git plugin. Only allowed if no Git Repositories exist."
|
||||
},
|
||||
"submit": "Submit"
|
||||
},
|
||||
"repoConfig": {
|
||||
|
||||
Reference in New Issue
Block a user