* Added cancel button in the delete category modal * fix lint error * fix eslint issues * migrated from class to functional component * updateCode * used react.memo * updateSnapshots --------- Co-authored-by: Mattermost Build <build@mattermost.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
5c061a6f75
Коммит
cd8796bf0b
@@ -288,7 +288,7 @@ exports[`components/MessageExportSettings should match snapshot, disabled, globa
|
|||||||
<SettingsGroup
|
<SettingsGroup
|
||||||
id="globalRelaySettings"
|
id="globalRelaySettings"
|
||||||
>
|
>
|
||||||
<RadioSetting
|
<Memo(RadioSetting)
|
||||||
disabled={true}
|
disabled={true}
|
||||||
helpText={
|
helpText={
|
||||||
<Memo(MemoizedFormattedMessage)
|
<Memo(MemoizedFormattedMessage)
|
||||||
@@ -733,7 +733,7 @@ exports[`components/MessageExportSettings should match snapshot, enabled, global
|
|||||||
<SettingsGroup
|
<SettingsGroup
|
||||||
id="globalRelaySettings"
|
id="globalRelaySettings"
|
||||||
>
|
>
|
||||||
<RadioSetting
|
<Memo(RadioSetting)
|
||||||
disabled={false}
|
disabled={false}
|
||||||
helpText={
|
helpText={
|
||||||
<Memo(MemoizedFormattedMessage)
|
<Memo(MemoizedFormattedMessage)
|
||||||
|
|||||||
@@ -143,7 +143,7 @@ exports[`components/admin_console/SchemaAdminSettings should match snapshot with
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
<RadioSetting
|
<Memo(RadioSetting)
|
||||||
disabled={false}
|
disabled={false}
|
||||||
helpText={
|
helpText={
|
||||||
<SchemaText
|
<SchemaText
|
||||||
|
|||||||
@@ -107,7 +107,7 @@ exports[`components/admin_console/CustomPluginSettings should match snapshot wit
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
<RadioSetting
|
<Memo(RadioSetting)
|
||||||
disabled={false}
|
disabled={false}
|
||||||
helpText={
|
helpText={
|
||||||
<SchemaText
|
<SchemaText
|
||||||
@@ -417,7 +417,7 @@ exports[`components/admin_console/CustomPluginSettings should match snapshot wit
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
<RadioSetting
|
<Memo(RadioSetting)
|
||||||
disabled={false}
|
disabled={false}
|
||||||
helpText={
|
helpText={
|
||||||
<SchemaText
|
<SchemaText
|
||||||
|
|||||||
@@ -15,47 +15,49 @@ interface Props {
|
|||||||
helpText?: React.ReactNode;
|
helpText?: React.ReactNode;
|
||||||
onChange(id: string, value: any): void;
|
onChange(id: string, value: any): void;
|
||||||
}
|
}
|
||||||
export default class RadioSetting extends React.PureComponent<Props> {
|
const RadioSetting = ({
|
||||||
public static defaultProps: Partial<Props> = {
|
id,
|
||||||
disabled: false,
|
label,
|
||||||
|
values,
|
||||||
|
value,
|
||||||
|
setByEnv,
|
||||||
|
disabled = false,
|
||||||
|
helpText,
|
||||||
|
onChange,
|
||||||
|
}: Props) => {
|
||||||
|
const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
||||||
|
onChange(id, e.target.value);
|
||||||
};
|
};
|
||||||
|
|
||||||
private handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
const options = values.map(({value: optionValue, text}) => (
|
||||||
this.props.onChange(this.props.id, e.target.value);
|
<div
|
||||||
};
|
className='radio'
|
||||||
|
key={optionValue}
|
||||||
|
>
|
||||||
|
<label>
|
||||||
|
<input
|
||||||
|
type='radio'
|
||||||
|
value={optionValue}
|
||||||
|
name={id}
|
||||||
|
checked={optionValue === value}
|
||||||
|
onChange={handleChange}
|
||||||
|
disabled={disabled || setByEnv}
|
||||||
|
/>
|
||||||
|
{text}
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
));
|
||||||
|
|
||||||
render(): JSX.Element {
|
return (
|
||||||
const options = [];
|
<Setting
|
||||||
for (const {value, text} of this.props.values) {
|
label={label}
|
||||||
options.push(
|
inputId={id}
|
||||||
<div
|
helpText={helpText}
|
||||||
className='radio'
|
setByEnv={setByEnv}
|
||||||
key={value}
|
>
|
||||||
>
|
{options}
|
||||||
<label>
|
</Setting>
|
||||||
<input
|
);
|
||||||
type='radio'
|
};
|
||||||
value={value}
|
|
||||||
name={this.props.id}
|
|
||||||
checked={value === this.props.value}
|
|
||||||
onChange={this.handleChange}
|
|
||||||
disabled={this.props.disabled || this.props.setByEnv}
|
|
||||||
/>
|
|
||||||
{text}
|
|
||||||
</label>
|
|
||||||
</div>,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
export default React.memo(RadioSetting);
|
||||||
<Setting
|
|
||||||
label={this.props.label}
|
|
||||||
inputId={this.props.id}
|
|
||||||
helpText={this.props.helpText}
|
|
||||||
setByEnv={this.props.setByEnv}
|
|
||||||
>
|
|
||||||
{options}
|
|
||||||
</Setting>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user