mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-12-17 13:59:46 +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:
@@ -1,78 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2020 - present Cloudogu GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU Affero General Public License as published by the Free
|
||||
* Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see https://www.gnu.org/licenses/.
|
||||
*/
|
||||
|
||||
import React, { FC, useEffect, useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Links } from "@scm-manager/ui-types";
|
||||
import { Checkbox, Select } from "@scm-manager/ui-components";
|
||||
|
||||
type Configuration = {
|
||||
disabled: boolean;
|
||||
allowDisable: boolean;
|
||||
compatibility: string;
|
||||
enabledGZip: boolean;
|
||||
_links: Links;
|
||||
};
|
||||
|
||||
type Props = {
|
||||
initialConfiguration: Configuration;
|
||||
readOnly: boolean;
|
||||
onConfigurationChange: (p1: Configuration, p2: boolean) => void;
|
||||
};
|
||||
|
||||
const SvnConfigurationForm: FC<Props> = ({ initialConfiguration, readOnly, onConfigurationChange }) => {
|
||||
const [t] = useTranslation("plugins");
|
||||
const [configuration, setConfiguration] = useState(initialConfiguration);
|
||||
|
||||
useEffect(() => setConfiguration(initialConfiguration), [initialConfiguration]);
|
||||
useEffect(() => onConfigurationChange(configuration, true), [configuration]);
|
||||
|
||||
const options = ["NONE", "PRE14", "PRE15", "PRE16", "PRE17", "WITH17"].map((option: string) => ({
|
||||
value: option,
|
||||
label: t("scm-svn-plugin.config.compatibility-values." + option.toLowerCase())
|
||||
}));
|
||||
|
||||
return (
|
||||
<>
|
||||
<Select
|
||||
name="compatibility"
|
||||
label={t("scm-svn-plugin.config.compatibility")}
|
||||
helpText={t("scm-svn-plugin.config.compatibilityHelpText")}
|
||||
value={configuration.compatibility}
|
||||
options={options}
|
||||
onChange={option => setConfiguration({ ...configuration, compatibility: option })}
|
||||
/>
|
||||
<Checkbox
|
||||
name="enabledGZip"
|
||||
label={t("scm-svn-plugin.config.enabledGZip")}
|
||||
helpText={t("scm-svn-plugin.config.enabledGZipHelpText")}
|
||||
checked={configuration.enabledGZip}
|
||||
onChange={value => setConfiguration({ ...configuration, enabledGZip: value })}
|
||||
disabled={readOnly}
|
||||
/>
|
||||
<Checkbox
|
||||
name="disabled"
|
||||
label={t("scm-svn-plugin.config.disabled")}
|
||||
helpText={t("scm-svn-plugin.config.disabledHelpText")}
|
||||
checked={configuration.disabled}
|
||||
onChange={value => setConfiguration({ ...configuration, disabled: value })}
|
||||
disabled={readOnly || !configuration.allowDisable}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default SvnConfigurationForm;
|
||||
@@ -17,22 +17,51 @@
|
||||
import React, { FC } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Configuration } from "@scm-manager/ui-components";
|
||||
import { Title, useDocumentTitle } from "@scm-manager/ui-core";
|
||||
import SvnConfigurationForm from "./SvnConfigurationForm";
|
||||
import { ConfigurationForm, Title, useDocumentTitle, Form } from "@scm-manager/ui-core";
|
||||
import { HalRepresentation } from "@scm-manager/ui-types";
|
||||
|
||||
type Props = {
|
||||
link: string;
|
||||
};
|
||||
|
||||
type Configuration = {
|
||||
disabled: boolean;
|
||||
allowDisable: boolean;
|
||||
compatibility: string;
|
||||
enabledGZip: boolean;
|
||||
} & HalRepresentation;
|
||||
|
||||
const SvnGlobalConfiguration: FC<Props> = ({ link }) => {
|
||||
const [t] = useTranslation("plugins");
|
||||
useDocumentTitle(t("scm-svn-plugin.config.title"));
|
||||
|
||||
const compatibilityOptions = ["NONE", "PRE14", "PRE15", "PRE16", "PRE17", "WITH17"].map((option: string) => (
|
||||
<option value={option} key={`compatibility-${option}`}>
|
||||
{t("scm-svn-plugin.config.compatibility-values." + option.toLowerCase())}
|
||||
</option>
|
||||
));
|
||||
|
||||
return (
|
||||
<div>
|
||||
<Title>{t("scm-svn-plugin.config.title")}</Title>
|
||||
<Configuration link={link} render={(props: any) => <SvnConfigurationForm {...props} />} />
|
||||
</div>
|
||||
<ConfigurationForm<Configuration> link={link} translationPath={["plugins", "scm-svn-plugin.config"]}>
|
||||
{({ watch }) => (
|
||||
<>
|
||||
<Title>{t("scm-svn-plugin.config.title")}</Title>
|
||||
<Form.Row>
|
||||
<Form.Checkbox name="disabled" readOnly={!watch("allowDisable")} />
|
||||
</Form.Row>
|
||||
{!watch("disabled") ? (
|
||||
<>
|
||||
<Form.Row>
|
||||
<Form.Select name="compatibility">{compatibilityOptions}</Form.Select>
|
||||
</Form.Row>
|
||||
<Form.Row>
|
||||
<Form.Checkbox name="enabledGZip" />
|
||||
</Form.Row>
|
||||
</>
|
||||
) : null}
|
||||
</>
|
||||
)}
|
||||
</ConfigurationForm>
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
@@ -6,8 +6,9 @@
|
||||
"config": {
|
||||
"link": "Subversion",
|
||||
"title": "Subversion Konfiguration",
|
||||
"compatibility": "Version Kompatibilität",
|
||||
"compatibilityHelpText": "Gibt an, mit welcher Subversion Version die Repositories kompatibel sind.",
|
||||
"compatibility": {
|
||||
"label": "Versionskompatibilität für jedes Subversion Repository"
|
||||
},
|
||||
"compatibility-values": {
|
||||
"none": "Keine Kompatibilität",
|
||||
"pre14": "Vor 1.4 kompatibel",
|
||||
@@ -16,11 +17,12 @@
|
||||
"pre17": "Vor 1.7 kompatibel",
|
||||
"with17": "Mit 1.7 kompatibel"
|
||||
},
|
||||
"enabledGZip": "GZip Compression aktivieren",
|
||||
"enabledGZipHelpText": "Aktiviert GZip Kompression für SVN Responses",
|
||||
"disabled": "Deaktiviert",
|
||||
"disabledHelpText": "Aktiviert oder deaktiviert das SVN Plugin. Nur erlaubt, wenn keine Subversion Repositories existieren.",
|
||||
"required": "Dieser Konfigurationswert wird benötigt"
|
||||
"enabledGZip": {
|
||||
"label": "Aktiviert GZip Kompression für Subversion Responses"
|
||||
},
|
||||
"disabled": {
|
||||
"label": "Deaktiviert das SVN Plugin. Nur erlaubt, wenn keine Subversion Repositories existieren."
|
||||
}
|
||||
}
|
||||
},
|
||||
"permissions": {
|
||||
|
||||
@@ -6,8 +6,9 @@
|
||||
"config": {
|
||||
"link": "Subversion",
|
||||
"title": "Subversion Configuration",
|
||||
"compatibility": "Version Compatibility",
|
||||
"compatibilityHelpText": "Specifies with which Subversion version repositories are compatible.",
|
||||
"compatibility": {
|
||||
"label": "Version compatibility for each Subversion repository"
|
||||
},
|
||||
"compatibility-values": {
|
||||
"none": "No compatibility",
|
||||
"pre14": "Pre 1.4 Compatible",
|
||||
@@ -16,11 +17,12 @@
|
||||
"pre17": "Pre 1.7 Compatible",
|
||||
"with17": "With 1.7 Compatible"
|
||||
},
|
||||
"enabledGZip": "Enable GZip Compression",
|
||||
"enabledGZipHelpText": "Enable GZip compression for SVN responses.",
|
||||
"disabled": "Disabled",
|
||||
"disabledHelpText": "Enable or disable the SVN plugin. Only allowed if no Subversion repositories exist.",
|
||||
"required": "This configuration value is required"
|
||||
"enabledGZip": {
|
||||
"label": "Enable GZip Compression for Subversion responses"
|
||||
},
|
||||
"disabled": {
|
||||
"label": "Disable the SVN plugin. Only allowed if no Subversion repositories exist."
|
||||
}
|
||||
}
|
||||
},
|
||||
"permissions": {
|
||||
|
||||
Reference in New Issue
Block a user