mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-07 22:15:45 +01:00
add help to checkbox
This commit is contained in:
@@ -1,11 +1,13 @@
|
|||||||
//@flow
|
//@flow
|
||||||
import React from "react";
|
import React from "react";
|
||||||
|
import {Help} from "../index";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
label?: string,
|
label?: string,
|
||||||
checked: boolean,
|
checked: boolean,
|
||||||
onChange?: boolean => void,
|
onChange?: boolean => void,
|
||||||
disabled?: boolean
|
disabled?: boolean,
|
||||||
|
helpText?: string
|
||||||
};
|
};
|
||||||
class Checkbox extends React.Component<Props> {
|
class Checkbox extends React.Component<Props> {
|
||||||
onCheckboxChange = (event: SyntheticInputEvent<HTMLInputElement>) => {
|
onCheckboxChange = (event: SyntheticInputEvent<HTMLInputElement>) => {
|
||||||
@@ -14,10 +16,22 @@ class Checkbox extends React.Component<Props> {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
renderHelp = () => {
|
||||||
|
const helpText = this.props.helpText;
|
||||||
|
if(helpText){
|
||||||
|
return (
|
||||||
|
<div className="control columns is-vcentered">
|
||||||
|
<Help message={helpText} />
|
||||||
|
</div>);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return null;
|
||||||
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
<div className="field">
|
<div className="field is-grouped">
|
||||||
<div className="control">
|
<div className="control is-expanded">
|
||||||
<label className="checkbox" disabled={this.props.disabled}>
|
<label className="checkbox" disabled={this.props.disabled}>
|
||||||
<input
|
<input
|
||||||
type="checkbox"
|
type="checkbox"
|
||||||
@@ -28,6 +42,7 @@ class Checkbox extends React.Component<Props> {
|
|||||||
{this.props.label}
|
{this.props.label}
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
|
{this.renderHelp()}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ class InputField extends React.Component<Props> {
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
return null;
|
return null;
|
||||||
}
|
};
|
||||||
|
|
||||||
handleKeyPress = (event: SyntheticKeyboardEvent<HTMLInputElement>) => {
|
handleKeyPress = (event: SyntheticKeyboardEvent<HTMLInputElement>) => {
|
||||||
const onReturnPressed = this.props.onReturnPressed;
|
const onReturnPressed = this.props.onReturnPressed;
|
||||||
|
|||||||
@@ -66,6 +66,7 @@ class GeneralSettings extends React.Component<Props> {
|
|||||||
label={t("general-settings.enabled-xsrf-protection")}
|
label={t("general-settings.enabled-xsrf-protection")}
|
||||||
onChange={this.handleEnabledXsrfProtectionChange}
|
onChange={this.handleEnabledXsrfProtectionChange}
|
||||||
disabled={!hasUpdatePermission}
|
disabled={!hasUpdatePermission}
|
||||||
|
helpText={"hey"}
|
||||||
/>
|
/>
|
||||||
<Checkbox
|
<Checkbox
|
||||||
checked={enableRepositoryArchive}
|
checked={enableRepositoryArchive}
|
||||||
|
|||||||
Reference in New Issue
Block a user