Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const mapStateToProps = (state: RootState, ownProps: FilledTextFieldProps & FieldProps) => {
const {
field: { name },
form: { touched, errors, submitCount },
} = ownProps;
const isDisplayDebounceError = getIsDisplayDebounceError(state, name);
const error = getIn(errors, name);
// https://github.com/formium/formik/issues/691#issuecomment-446509600
const _touched = getIn(touched, name) || submitCount > 0;
return {
showError: !!error && (_touched || isDisplayDebounceError),
};
};
useEffect(() => {
resetOtherChaos(formikCtx, 'StressChaos', false)
if (getIn(values, 'target.stress_chaos.stressors.cpu') === null) {
setFieldValue('target.stress_chaos.stressors.cpu', defaultExperimentSchema.target.stress_chaos.stressors.cpu)
}
if (getIn(values, 'target.stress_chaos.stressors.memory') === null) {
setFieldValue(
'target.stress_chaos.stressors.memory',
defaultExperimentSchema.target.stress_chaos.stressors.memory
)
}
// Remove another when choosing a single action
return () => {
if (actionRef.current === 'CPU') {
// Because LabelField will set value when before unmount, it's needed to wrap setFieldValue into setTimeout
setTimeout(() => setFieldValue('target.stress_chaos.stressors.memory', null))
} else if (actionRef.current === 'Memory') {
options,
multiple,
label,
row,
helperText,
FormLabelProps,
FormHelperTextProps,
FormControlLabelProps,
CheckboxProps,
FormGroupProps,
onChange,
className,
classes,
...props
} = this.props;
const message = getIn(touched, field.name) && getIn(errors, field.name);
return (
{label && (
{label}
const LabelField: React.FC = ({ isKV = false, errorText, ...props }) => {
const { values, setFieldValue } = useFormikContext()
const [text, setText] = useState('')
const [error, setError] = useState('')
const name = props.name!
const labels: string[] = getIn(values, name)
const setLabels = (labels: string[]) => setFieldValue(name, labels)
useEffect(() => {
if (errorText) {
setError(errorText)
}
}, [errorText])
const onChange = (_: any, __: any, reason: string) => {
if (reason === 'clear') {
setLabels([])
}
}
const onInputChange = (e: React.ChangeEvent) => {
const val = e.target.value
render={arrayHelpers => {
const selectedApplications: string[] = getIn(arrayHelpers.form.values, name) || [];
const isAppSelected = (app: string) => !selectedApplications.includes(app);
const apps = applications.filter(isAppSelected);
return (
<div>
{selectedApplications.map((app, index) => (
}
actions={ arrayHelpers.remove(index)} />}
touched={true}
/>
))}
</div>
const MinisterIssueBox = ({
issue,
ministerIssueIndex,
activeMinisterIssueIndex,
onMinisterIssueClicked,
namespace,
formik
}) => {
const allPastures = getIn(formik.values, 'pastures') || []
const pasturesOptions = allPastures.map((pasture, index) => ({
value: pasture.id,
text: pasture.name || `Unnamed pasture ${index + 1}`,
key: pasture.id
}))
const types = useReferences()[REFERENCE_KEY.MINISTER_ISSUE_TYPE] || []
const typeOptions = types.map(type => ({
key: type.id,
value: type.id,
text: type.name,
id: type.id
}))
const {
detail,
{({ field, form }: FieldProps) => {
const touched = getIn(form.touched, fieldName);
const error = getIn(form.errors, fieldName);
const invalid = !!(touched && error);
const handleChanges = (ev: {}, { checked }: CheckboxProps) =>
form.setFieldValue(fieldName, checked);
return (
<label>{label}</label>
{invalid && error && (
<label color="red">
{error}
</label>
)}
render={pipelinesArrayHelper => {
const project: IProject = pipelinesArrayHelper.form.values;
const configs: IProjectPipeline[] = getIn(project, Pipelines.pipelineConfigsPath);
const apps: string[] = getIn(project, 'config.applications');
return (
<div>
<div style="{{">
{tableHeader}
{configs.map((config, idx) => {
const pipelinePath = `${Pipelines.pipelineConfigsPath}[${idx}]`;
const application = config && config.application;
const appPipelines = application && appsPipelines[application];
const pipelineOptions = appPipelines && appPipelines.map(p => ({ label: p.name, value: p.id }));
const key = `${application}-${config && config.pipelineConfigId}-${idx}`;
return (<table style="{{">
<thead></thead>
<tbody></tbody></table></div></div>
size,
hint,
required,
} = this.props;
let {
options,
error,
} = this.props;
const {
formik,
} = this.context;
if (formik && name) {
error = getIn(formik.touched, name) && getIn(formik.errors, name);
error = error && error.replace(name, label || name);
}
options = this.makeOptions();
return (
{({
isOpen,
getToggleButtonProps,
getItemProps,