mirror of
				https://github.com/scm-manager/scm-manager.git
				synced 2025-10-31 10:35:56 +01:00 
			
		
		
		
	implemented global configuration for subversion
This commit is contained in:
		
							
								
								
									
										107
									
								
								scm-plugins/scm-svn-plugin/src/main/js/SvnConfigurationForm.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										107
									
								
								scm-plugins/scm-svn-plugin/src/main/js/SvnConfigurationForm.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,107 @@ | ||||
| //@flow | ||||
| import React from "react"; | ||||
| import type { Links } from "@scm-manager/ui-types"; | ||||
| import { translate } from "react-i18next"; | ||||
| import { InputField, Checkbox, Select } from "@scm-manager/ui-components"; | ||||
|  | ||||
| type Configuration = { | ||||
|   repositoryDirectory: string, | ||||
|   compatibility: string, | ||||
|   enabledGZip: boolean, | ||||
|   disabled: boolean, | ||||
|   _links: Links | ||||
| }; | ||||
|  | ||||
| type Props = { | ||||
|   initialConfiguration: Configuration, | ||||
|   readOnly: boolean, | ||||
|  | ||||
|   onConfigurationChange: (Configuration, boolean) => void, | ||||
|  | ||||
|   // context props | ||||
|   t: (string) => string | ||||
| } | ||||
|  | ||||
| type State = Configuration; | ||||
|  | ||||
| class HgConfigurationForm extends React.Component<Props, State> { | ||||
|  | ||||
|   constructor(props: Props) { | ||||
|     super(props); | ||||
|     this.state = { ...props.initialConfiguration, validationErrors: [] }; | ||||
|   } | ||||
|  | ||||
|   isValid = () => { | ||||
|     return !!this.state.repositoryDirectory; | ||||
|   }; | ||||
|  | ||||
|   handleChange = (value: any, name: string) => { | ||||
|     this.setState({ | ||||
|       [name]: value | ||||
|     }, () => this.props.onConfigurationChange(this.state, this.isValid())); | ||||
|   }; | ||||
|  | ||||
|   compatibilityOptions = (values: string[]) => { | ||||
|     const options = []; | ||||
|     for (let value of values) { | ||||
|       options.push( this.compatibilityOption(value) ); | ||||
|     } | ||||
|     return options; | ||||
|   }; | ||||
|  | ||||
|   compatibilityOption = (value: string) => { | ||||
|     return { | ||||
|       value, | ||||
|       label: this.props.t("scm-svn-plugin.config.compatibility-values." + value.toLowerCase()) | ||||
|     }; | ||||
|   }; | ||||
|  | ||||
|   render() { | ||||
|     const { readOnly, t } = this.props; | ||||
|     const compatibilityOptions = this.compatibilityOptions([ | ||||
|       "NONE", "PRE14", "PRE15", "PRE16", "PRE17", "WITH17" | ||||
|     ]); | ||||
|  | ||||
|     return ( | ||||
|       <> | ||||
|         <InputField | ||||
|           name="repositoryDirectory" | ||||
|           label={t("scm-svn-plugin.config.directory")} | ||||
|           helpText={t("scm-svn-plugin.config.directoryHelpText")} | ||||
|           value={this.state.repositoryDirectory} | ||||
|           errorMessage={t("scm-svn-plugin.config.required")} | ||||
|           validationError={!this.state.repositoryDirectory} | ||||
|           onChange={this.handleChange} | ||||
|           disabled={readOnly} | ||||
|         /> | ||||
|         <Select | ||||
|           name="compatibility" | ||||
|           label={t("scm-svn-plugin.config.compatibility")} | ||||
|           helpText={t("scm-svn-plugin.config.compatibilityHelpText")} | ||||
|           value={this.state.compatibility} | ||||
|           options={compatibilityOptions} | ||||
|           onChange={this.handleChange} | ||||
|         /> | ||||
|         <Checkbox | ||||
|           name="enabledGZip" | ||||
|           label={t("scm-svn-plugin.config.enabledGZip")} | ||||
|           helpText={t("scm-svn-plugin.config.enabledGZipHelpText")} | ||||
|           checked={this.state.enabledGZip} | ||||
|           onChange={this.handleChange} | ||||
|           disabled={readOnly} | ||||
|         /> | ||||
|         <Checkbox | ||||
|           name="disabled" | ||||
|           label={t("scm-svn-plugin.config.disabled")} | ||||
|           helpText={t("scm-svn-plugin.config.disabledHelpText")} | ||||
|           checked={this.state.disabled} | ||||
|           onChange={this.handleChange} | ||||
|           disabled={readOnly} | ||||
|         /> | ||||
|       </> | ||||
|     ); | ||||
|   } | ||||
|  | ||||
| } | ||||
|  | ||||
| export default translate("plugins")(HgConfigurationForm); | ||||
| @@ -0,0 +1,28 @@ | ||||
| //@flow | ||||
| import React from "react"; | ||||
| import { translate } from "react-i18next"; | ||||
| import { Title, GlobalConfiguration } from "@scm-manager/ui-components"; | ||||
| import SvnConfigurationForm from "./SvnConfigurationForm"; | ||||
|  | ||||
| type Props = { | ||||
|   link: string, | ||||
|  | ||||
|   // context props | ||||
|   t: (string) => string | ||||
| } | ||||
|  | ||||
| class SvnGlobalConfiguration extends React.Component<Props> { | ||||
|  | ||||
|   render() { | ||||
|     const  { link, t } = this.props; | ||||
|     return ( | ||||
|       <div> | ||||
|         <Title title={t("scm-svn-plugin.config.title")}/> | ||||
|         <GlobalConfiguration link={link} render={props => <SvnConfigurationForm {...props} />}/> | ||||
|       </div> | ||||
|     ); | ||||
|   } | ||||
|  | ||||
| } | ||||
|  | ||||
| export default translate("plugins")(SvnGlobalConfiguration); | ||||
| @@ -1,7 +1,9 @@ | ||||
| // @flow | ||||
| import { binder } from "@scm-manager/ui-extensions"; | ||||
| import { ConfigurationBinder as cfgBinder } from "@scm-manager/ui-components"; | ||||
| import ProtocolInformation from "./ProtocolInformation"; | ||||
| import SvnAvatar from "./SvnAvatar"; | ||||
| import SvnGlobalConfiguration from "./SvnGlobalConfiguration"; | ||||
|  | ||||
| const svnPredicate = (props: Object) => { | ||||
|   return props.repository && props.repository.type === "svn"; | ||||
| @@ -9,3 +11,7 @@ const svnPredicate = (props: Object) => { | ||||
|  | ||||
| binder.bind("repos.repository-details.information", ProtocolInformation, svnPredicate); | ||||
| binder.bind("repos.repository-avatar", SvnAvatar, svnPredicate); | ||||
|  | ||||
| // bind global configuration | ||||
|  | ||||
| cfgBinder.bindGlobal("/svn", "scm-svn-plugin.config.link", "svnConfig", SvnGlobalConfiguration); | ||||
|   | ||||
| @@ -2,6 +2,27 @@ | ||||
|   "scm-svn-plugin": { | ||||
|     "information": { | ||||
|       "checkout" : "Checkout repository" | ||||
|     }, | ||||
|     "config": { | ||||
|       "link": "Subversion", | ||||
|       "title": "Subversion Configuration", | ||||
|       "directory": "Repository Directory", | ||||
|       "directoryHelpText": "Location of Subversion repositories.", | ||||
|       "compatibility": "Version Compatibility", | ||||
|       "compatibilityHelpText": "Specifies with which subversion version repositories are compatible.", | ||||
|       "compatibility-values": { | ||||
|         "none": "No compatibility", | ||||
|         "pre14": "Pre 1.4 Compatible", | ||||
|         "pre15": "Pre 1.5 Compatible", | ||||
|         "pre16": "Pre 1.6 Compatible", | ||||
|         "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 Git plugin", | ||||
|       "required": "This configuration value is required" | ||||
|     } | ||||
|   } | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user