<commit_before>import _ from 'lodash';
import React from 'react';
import { connect } from 'react-redux';

import {
  AWS_ETCDS,
  EXTERNAL_ETCD_CLIENT,
  ETCD_OPTION,
  ETCD_OPTIONS,
  PLATFORM_TYPE,
} from '../cluster-config';
import { validate } from '../validate';
import { Connect, Input, Radio } from './ui';
import { DefineNode } from './aws-define-nodes';
import { makeNodeForm } from './make-node-form';
import { Field, Form } from '../form';
import { AWS_TF } from '../platforms';

const EtcdForm = 'EtcdForm';
const one2Nine = validate.int({min: 1, max: 9});

const fields = [
  new Field(ETCD_OPTION, {
    default: ETCD_OPTIONS.PROVISIONED,
  }),
  makeNodeForm(AWS_ETCDS, false, value => one2Nine(value) || validate.isOdd(value), {
    dependencies: [ETCD_OPTION],
    ignoreWhen: cc => cc[ETCD_OPTION] !== ETCD_OPTIONS.PROVISIONED,
  }),
  new Field(EXTERNAL_ETCD_CLIENT, {
    default: '',
    validator: validate.hostPort,
    dependencies: [ETCD_OPTION],
    ignoreWhen: cc => cc[ETCD_OPTION] !== ETCD_OPTIONS.EXTERNAL,
  }),
];

const form = new Form(EtcdForm, fields, {
  validator: value => {
    const etcd = value[ETCD_OPTION];
    if (!_.values(ETCD_OPTIONS).includes(etcd)) {
      return 'Please select an option.';
    }
  },
});

export const Etcd = connect(({clusterConfig}) => ({
  etcdOption: clusterConfig[ETCD_OPTION],
  isAWS: clusterConfig[PLATFORM_TYPE] === AWS_TF,
}))(
  ({etcdOption, isAWS}) => <div>
    <div className="row form-group">
      <div className="col-xs-12">
        etcd is the key-value store used by Kubernetes for cluster coordination and state management.<commit_msg>frontend: Use compose() to construct etcd count field validator<commit_after>import _ from 'lodash';
import React from 'react';
import { connect } from 'react-redux';

import {
  AWS_ETCDS,
  EXTERNAL_ETCD_CLIENT,
  ETCD_OPTION,
  ETCD_OPTIONS,
  PLATFORM_TYPE,
} from '../cluster-config';
import { compose, validate } from '../validate';
import { Connect, Input, Radio } from './ui';
import { DefineNode } from './aws-define-nodes';
import { makeNodeForm } from './make-node-form';
import { Field, Form } from '../form';
import { AWS_TF } from '../platforms';

const EtcdForm = 'EtcdForm';

const fields = [
  new Field(ETCD_OPTION, {
    default: ETCD_OPTIONS.PROVISIONED,
  }),
  makeNodeForm(AWS_ETCDS, false, compose(validate.int({min: 1, max: 9}), validate.isOdd), {
    dependencies: [ETCD_OPTION],
    ignoreWhen: cc => cc[ETCD_OPTION] !== ETCD_OPTIONS.PROVISIONED,
  }),
  new Field(EXTERNAL_ETCD_CLIENT, {
    default: '',
    validator: validate.hostPort,
    dependencies: [ETCD_OPTION],
    ignoreWhen: cc => cc[ETCD_OPTION] !== ETCD_OPTIONS.EXTERNAL,
  }),
];

const form = new Form(EtcdForm, fields, {
  validator: value => {
    const etcd = value[ETCD_OPTION];
    if (!_.values(ETCD_OPTIONS).includes(etcd)) {
      return 'Please select an option.';
    }
  },
});

export const Etcd = connect(({clusterConfig}) => ({
  etcdOption: clusterConfig[ETCD_OPTION],
  isAWS: clusterConfig[PLATFORM_TYPE] === AWS_TF,
}))(
  ({etcdOption, isAWS}) => <div>
    <div className="row form-group">
      <div className="col-xs-12">
        etcd is the key-value store used by Kubernetes for cluster coordination and state management.
{'fraction_non_alphanumeric': 0.15113427345187003, 'fraction_numerical': 0.0030656039239730227, 'mean_word_length': 4.090483619344774, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 20, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5145379', 'n_tokens_mistral': 1121, 'n_tokens_neox': 1127, 'n_words': 266}