import "choerodon-ui/pro/lib/number-field/style";
import _NumberField from "choerodon-ui/pro/lib/number-field";
import "choerodon-ui/pro/lib/password/style";
import _Password from "choerodon-ui/pro/lib/password";
import "choerodon-ui/pro/lib/form/style";
import _Form from "@hzero-front-ui/c7n-ui/lib/FormPro";
import "choerodon-ui/pro/lib/button/style";
import _Button from "choerodon-ui/pro/lib/button";
import "choerodon-ui/pro/lib/tooltip/style";
import _Tooltip from "choerodon-ui/pro/lib/tooltip";
import "choerodon-ui/lib/icon/style";
import _Icon from "choerodon-ui/lib/icon";
import "choerodon-ui/pro/lib/select-box/style";
import _SelectBox from "choerodon-ui/pro/lib/select-box";
import "choerodon-ui/pro/lib/text-field/style";
import _TextField from "choerodon-ui/pro/lib/text-field";
import "choerodon-ui/pro/lib/message/style";
import _message from "choerodon-ui/pro/lib/message";
import "choerodon-ui/pro/lib/table/style";
import _Table from "@hzero-front-ui/c7n-ui/lib/TablePro";
import "choerodon-ui/pro/lib/select/style";
import _Select from "choerodon-ui/pro/lib/select";

function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }

function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }

function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }

function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }

function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }

import React, { useMemo, useEffect, useState } from 'react';
import { observer } from 'mobx-react-lite';
import classNames from 'classnames';
import StatusDot from "../../../../components/status-dot";
import BaseComDeployServices from "./services";
import Tips from "../../../../components/new-tips";
import { NewTips } from '@choerodon/components';
import ResourceSetting from "./components/resource-setting";
import { mapping, deployWayOptionsData, deployModeOptionsData, middleWareData, mapping as baseMapping, mySqlDeployModeOptionsData } from "./stores/baseDeployDataSet";
import { mapping as hostMapping } from "./stores/hostSettingDataSet";
import paramSettingDataSet, { mapping as paramsMapping, mapping as paramMapping } from "./stores/paramSettingDataSet";
import { useBaseComDeployStore } from "./stores";
import redis from "./images/redis.png";
import mysql from "./images/mysql.png";
import "./index.less";
var Option = _Select.Option;
var Column = _Table.Column;
export default observer(function () {
  var _useBaseComDeployStor = useBaseComDeployStore(),
      BaseDeployDataSet = _useBaseComDeployStor.BaseDeployDataSet,
      HostSettingDataSet = _useBaseComDeployStor.HostSettingDataSet,
      ParamSettingDataSet = _useBaseComDeployStor.ParamSettingDataSet,
      PVLabelsDataSet = _useBaseComDeployStor.PVLabelsDataSet,
      modal = _useBaseComDeployStor.modal,
      projectId = _useBaseComDeployStor.AppState.currentMenuType.projectId,
      refresh = _useBaseComDeployStor.refresh,
      deployWay = _useBaseComDeployStor.deployWay,
      middlewareData = _useBaseComDeployStor.middlewareData,
      ServiceVersionDataSet = _useBaseComDeployStor.ServiceVersionDataSet,
      BaseComDeployStore = _useBaseComDeployStor.BaseComDeployStore;

  modal.handleOk( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
    var middleWare, pass, axiosData, flag, setFlagBaseOnParamsSetting, _axiosData, pvlabels, i, baseValid, hostValid, _result, _axiosData2, result, record, flagBase, flagParams, _result2, _objectSpread2, _baseValid, _hostValid, testResult, _result3, _axiosData3;

    return regeneratorRuntime.wrap(function _callee$(_context) {
      while (1) {
        switch (_context.prev = _context.next) {
          case 0:
            setFlagBaseOnParamsSetting = function _setFlagBaseOnParamsS(f) {
              var ad = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
              var isHostInside = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
              var resultData = ad;

              function setFlag(ds) {
                for (var i = 0; i < ds.records.length; i += 1) {
                  var result = handleValidParamsRunningValue(ds.records[i].get(paramMapping.paramsRunnigValue.name), ds.records[i]);

                  if (result !== true) {
                    // eslint-disable-next-line no-param-reassign
                    f = true;
                    break;
                  }
                }
              } // if param's setting is outside of item of hosts


              if (!isHostInside) {
                setFlag(ParamSettingDataSet);
              } else {
                // inside
                for (var i = 0; i < HostSettingDataSet.records.length; i += 1) {
                  var ds = HostSettingDataSet.records[i].getState('params');
                  setFlag(ds);
                }
              }

              if (!f) {
                var configuration = {};

                if (!isHostInside) {
                  ParamSettingDataSet.records.forEach(function (i) {
                    configuration[i.get(paramMapping.params.name)] = i.get(paramMapping.paramsRunnigValue.name);
                  }); // eslint-disable-next-line no-param-reassign

                  resultData = _objectSpread(_objectSpread({}, resultData), {}, {
                    configuration: configuration
                  });
                } else {
                  HostSettingDataSet.records.forEach(function (i) {
                    var item = {};
                    i.getState('params').forEach(function (j) {
                      item[j.get(paramMapping.params.name)] = j.get(paramMapping.paramsRunnigValue.name);
                    });
                    configuration[i.get(hostMapping.hostId.name)] = item;
                  });
                  resultData = configuration;
                }
              }

              return {
                f: f,
                resultData: resultData
              };
            };

            middleWare = BaseDeployDataSet.current.get(mapping.middleware.name);
            axiosData = {};
            flag = false;

            if (!(middleWare === middleWareData[0].value)) {
              _context.next = 83;
              break;
            }

            if (!(BaseDeployDataSet.current.get(mapping.deployWay.name) === deployWayOptionsData[0].value)) {
              _context.next = 44;
              break;
            }

            // const devopsServiceReqVO = await networkRef.current.getDevopsServiceReqVO();
            // const devopsIngressVO = await domainRef.current.getDevopsIngressVO();
            // let resource;
            // if (devopsServiceReqVO && devopsIngressVO) {
            //   if (!devopsServiceReqVO?.devopsServiceReqVO?.name) {
            //     devopsServiceReqVO.devopsServiceReqVO = null;
            //   }
            //   if (!devopsIngressVO?.devopsIngressVO?.name) {
            //     devopsIngressVO.devopsIngressVO = null;
            //   }
            //   resource = {
            //     ...devopsServiceReqVO,
            //     ...devopsIngressVO,
            //   };
            // } else {
            //   return false;
            // }
            // axiosData = {
            //   ...resource,
            // };
            axiosData = (_axiosData = {}, _defineProperty(_axiosData, mapping.serviceVersion.name, BaseDeployDataSet.toData()[0][mapping.serviceVersion.name]), _defineProperty(_axiosData, mapping.deployWay.name, BaseDeployDataSet.toData()[0][mapping.deployWay.name]), _defineProperty(_axiosData, mapping.deployMode.name, BaseDeployDataSet.toData()[0][mapping.deployMode.name]), _defineProperty(_axiosData, mapping.env.name, BaseDeployDataSet.toData()[0][mapping.env.name]), _defineProperty(_axiosData, mapping.instance.name, BaseDeployDataSet.toData()[0][mapping.instance.name]), _defineProperty(_axiosData, mapping.password.name, BaseDeployDataSet.toData()[0][mapping.password.name]), _defineProperty(_axiosData, mapping.sysctlImage.name, BaseDeployDataSet.toData()[0][mapping.sysctlImage.name]), _defineProperty(_axiosData, "type", 'create'), _defineProperty(_axiosData, "isNotChange", false), _axiosData); // 如果是哨兵

            if (!(BaseDeployDataSet.current.get(mapping.deployMode.name) === deployModeOptionsData[1].value)) {
              _context.next = 34;
              break;
            }

            // flag = !await PVLabelsDataSet.validate();
            // if (!flag) {
            //   const pvLength = PVLabelsDataSet.records.filter((i) => !i.isRemoved).length;
            //   const slaveCount = BaseDeployDataSet.current.get(mapping.slaveCount.name);
            //   if (!(pvLength && pvLength >= slaveCount)) {
            //     flag = true;
            //     message.error('pv标签数量应大于等于slaveCount的数量');
            //   }
            // }
            pvlabels = {};
            i = 0;

          case 10:
            if (!(i < PVLabelsDataSet.records.length)) {
              _context.next = 30;
              break;
            }

            if (!(!PVLabelsDataSet.records[i].get('key') && !PVLabelsDataSet.records[i].get('value'))) {
              _context.next = 14;
              break;
            }

            _context.next = 27;
            break;

          case 14:
            if (!(PVLabelsDataSet.records[i].get('key') && PVLabelsDataSet.records[i].get('value'))) {
              _context.next = 24;
              break;
            }

            if (!Object.keys(pvlabels).includes(PVLabelsDataSet.records[i].get('key'))) {
              _context.next = 21;
              break;
            }

            flag = true;

            _message.error('pv标签键值应唯一');

            return _context.abrupt("break", 30);

          case 21:
            pvlabels[PVLabelsDataSet.records[i].get('key')] = PVLabelsDataSet.records[i].get('value');

          case 22:
            _context.next = 27;
            break;

          case 24:
            _message.error('pv标签应配对填写');

            flag = true;
            return _context.abrupt("break", 30);

          case 27:
            i += 1;
            _context.next = 10;
            break;

          case 30:
            axiosData[mapping.slaveCount.name] = BaseDeployDataSet.toData()[0][mapping.slaveCount.name];
            axiosData.pvLabels = pvlabels;
            _context.next = 35;
            break;

          case 34:
            //  如果是单机
            axiosData[mapping.pvc.name] = BaseDeployDataSet.toData()[0][mapping.pvc.name];

          case 35:
            _context.next = 37;
            return BaseDeployDataSet.validate();

          case 37:
            pass = _context.sent;

            if (!(pass && !flag)) {
              _context.next = 41;
              break;
            }

            _context.next = 42;
            break;

          case 41:
            return _context.abrupt("return", false);

          case 42:
            _context.next = 61;
            break;

          case 44:
            _context.next = 46;
            return BaseDeployDataSet.validate();

          case 46:
            baseValid = _context.sent;
            _context.next = 49;
            return HostSettingDataSet.validate();

          case 49:
            hostValid = _context.sent;

            if (!(baseValid && hostValid)) {
              _context.next = 60;
              break;
            }

            if (!HostSettingDataSet.records.some(function (i) {
              return !i.get(hostMapping.status.name) || i.get(hostMapping.status.name) !== 'success';
            })) {
              _context.next = 57;
              break;
            }

            _context.next = 54;
            return handleTestConnect();

          case 54:
            _result = _context.sent;

            if (_result) {
              _context.next = 57;
              break;
            }

            return _context.abrupt("return", false);

          case 57:
            if (!flag) {
              axiosData = (_axiosData2 = {
                hostIds: HostSettingDataSet.records.map(function (i) {
                  return i.get(hostMapping.hostId.name);
                })
              }, _defineProperty(_axiosData2, mapping.deployMode.name, BaseDeployDataSet.current.get(mapping.deployMode.name)), _defineProperty(_axiosData2, "name", BaseDeployDataSet.current.get(mapping.resourceName.name)), _defineProperty(_axiosData2, mapping.serviceVersion.name, BaseDeployDataSet.current.get(mapping.serviceVersion.name)), _defineProperty(_axiosData2, mapping.password.name, BaseDeployDataSet.current.get(mapping.password.name)), _defineProperty(_axiosData2, "type", 'create'), _defineProperty(_axiosData2, "isNotChange", false), _axiosData2);
            }

            _context.next = 61;
            break;

          case 60:
            return _context.abrupt("return", false);

          case 61:
            result = setFlagBaseOnParamsSetting(flag, axiosData);
            flag = result.f;
            axiosData = result.resultData;

            if (flag) {
              _context.next = 81;
              break;
            }

            _context.prev = 65;

            if (!(BaseDeployDataSet.current.get(mapping.deployWay.name) === deployWayOptionsData[0].value)) {
              _context.next = 71;
              break;
            }

            _context.next = 69;
            return BaseComDeployServices.axiosPostDeployMiddleware(projectId, axiosData);

          case 69:
            _context.next = 73;
            break;

          case 71:
            _context.next = 73;
            return BaseComDeployServices.axiosPostDeployHost(projectId, axiosData);

          case 73:
            BaseDeployDataSet.reset();
            refresh();
            return _context.abrupt("return", true);

          case 78:
            _context.prev = 78;
            _context.t0 = _context["catch"](65);
            return _context.abrupt("return", false);

          case 81:
            _context.next = 134;
            break;

          case 83:
            //  mysql
            record = BaseDeployDataSet.current; // 容器部署

            if (!(record.get(mapping.deployWay.name) === deployWayOptionsData[0].value)) {
              _context.next = 107;
              break;
            }

            _context.next = 87;
            return BaseDeployDataSet.validate();

          case 87:
            flagBase = _context.sent;
            flagParams = false;
            _result2 = setFlagBaseOnParamsSetting(flagParams, axiosData);
            flagParams = _result2.f;
            axiosData = _result2.resultData;

            if (!(flagBase && !flagParams)) {
              _context.next = 105;
              break;
            }

            axiosData = _objectSpread(_objectSpread({}, axiosData), {}, (_objectSpread2 = {}, _defineProperty(_objectSpread2, mapping.serviceVersion.name, BaseDeployDataSet.toData()[0][mapping.serviceVersion.name]), _defineProperty(_objectSpread2, mapping.deployWay.name, BaseDeployDataSet.toData()[0][mapping.deployWay.name]), _defineProperty(_objectSpread2, mapping.env.name, BaseDeployDataSet.toData()[0][mapping.env.name]), _defineProperty(_objectSpread2, mapping.instance.name, BaseDeployDataSet.toData()[0][mapping.instance.name]), _defineProperty(_objectSpread2, mapping.password.name, BaseDeployDataSet.toData()[0][mapping.password.name]), _defineProperty(_objectSpread2, mapping.pvc.name, BaseDeployDataSet.toData()[0][mapping.pvc.name]), _objectSpread2));
            _context.prev = 94;
            _context.next = 97;
            return BaseComDeployServices.axiosPostBaseDeployMySqlEnvApi(projectId, axiosData);

          case 97:
            BaseDeployDataSet.reset();
            refresh();
            return _context.abrupt("return", true);

          case 102:
            _context.prev = 102;
            _context.t1 = _context["catch"](94);
            return _context.abrupt("return", false);

          case 105:
            _context.next = 134;
            break;

          case 107:
            _context.next = 109;
            return BaseDeployDataSet.validate();

          case 109:
            _baseValid = _context.sent;
            _context.next = 112;
            return HostSettingDataSet.validate();

          case 112:
            _hostValid = _context.sent;

            if (!(_baseValid && _hostValid)) {
              _context.next = 134;
              break;
            }

            if (!HostSettingDataSet.records.filter(function (i) {
              return !i.isRemoved;
            }).some(function (i) {
              return !i.get('status');
            })) {
              _context.next = 120;
              break;
            }

            _context.next = 117;
            return handleTestConnect();

          case 117:
            testResult = _context.sent;

            if (testResult) {
              _context.next = 120;
              break;
            }

            return _context.abrupt("return", false);

          case 120:
            _result3 = setFlagBaseOnParamsSetting(flag, {}, true);

            if (_result3.f) {
              _context.next = 134;
              break;
            }

            axiosData = (_axiosData3 = {}, _defineProperty(_axiosData3, mapping.serviceVersion.name, BaseDeployDataSet.toData()[0][mapping.serviceVersion.name]), _defineProperty(_axiosData3, mapping.deployWay.name, BaseDeployDataSet.toData()[0][mapping.deployWay.name]), _defineProperty(_axiosData3, mapping.deployMode.name, BaseDeployDataSet.current.get(mapping.deployMode.name)), _defineProperty(_axiosData3, mapping.env.name, BaseDeployDataSet.toData()[0][mapping.env.name]), _defineProperty(_axiosData3, mapping.password.name, BaseDeployDataSet.toData()[0][mapping.password.name]), _defineProperty(_axiosData3, mapping.virtualIp.name, BaseDeployDataSet.toData()[0][mapping.virtualIp.name]), _defineProperty(_axiosData3, "hostIds", HostSettingDataSet.records.map(function (i) {
              return i.get(hostMapping.hostId.name);
            })), _defineProperty(_axiosData3, "configuration", _result3.resultData), _defineProperty(_axiosData3, "name", BaseDeployDataSet.current.get(mapping.resourceName.name)), _axiosData3);
            _context.prev = 123;
            _context.next = 126;
            return BaseComDeployServices.axiosPostBaseDeployMySqlHostApi(projectId, axiosData);

          case 126:
            BaseDeployDataSet.reset();
            refresh();
            return _context.abrupt("return", true);

          case 131:
            _context.prev = 131;
            _context.t2 = _context["catch"](123);
            return _context.abrupt("return", false);

          case 134:
            return _context.abrupt("return", false);

          case 135:
          case "end":
            return _context.stop();
        }
      }
    }, _callee, null, [[65, 78], [94, 102], [123, 131]]);
  })));
  /**
   * 初始化服务版本options
   */

  var getServiceVersionAndSetInit = function getServiceVersionAndSetInit(name) {
    BaseComDeployServices.axiosGetServiceVersion(name).then(function (res) {
      ServiceVersionDataSet.loadData(res);
      BaseDeployDataSet.current.set(mapping.serviceVersion.name, res[0].versionNumber);
    });
  };

  useEffect(function () {
    init();

    function init() {
      return _init.apply(this, arguments);
    }

    function _init() {
      _init = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {
        var result;
        return regeneratorRuntime.wrap(function _callee2$(_context2) {
          while (1) {
            switch (_context2.prev = _context2.next) {
              case 0:
                // 初始化为哨兵模式 初始化三个record
                HostSettingDataSet.create();
                HostSettingDataSet.create();

                if (deployWay) {
                  BaseDeployDataSet.current.set(mapping.deployWay.name, deployWay);
                }

                if (middlewareData) {
                  BaseDeployDataSet.current.set(mapping.middleware.name, middlewareData);
                } // 初始化查询mysql 主机的table params


                _context2.next = 6;
                return BaseComDeployServices.axiosGetParamsSetting('MySQL', 'host', 'master-slave');

              case 6:
                result = _context2.sent;
                result.middlewareConfigVOS.forEach(function (item) {
                  // eslint-disable-next-line no-param-reassign
                  item.paramsRunningValue = item.paramDefaultValue;
                });
                BaseComDeployStore.setMysqlParams(result.middlewareConfigVOS);
                BaseDeployDataSet.current.getField(mapping.deployMode.name).options.loadData(deployModeOptionsData);
                BaseDeployDataSet.current.set(mapping.deployMode.name, deployModeOptionsData[1].value);

              case 11:
              case "end":
                return _context2.stop();
            }
          }
        }, _callee2);
      }));
      return _init.apply(this, arguments);
    }
  }, []);
  useEffect(function () {
    getServiceVersionAndSetInit(BaseDeployDataSet.current.get(mapping.middleware.name));
  }, [BaseDeployDataSet.current.get(mapping.middleware.name)]);
  useEffect(function () {
    var middleware = BaseDeployDataSet.current.get(mapping.middleware.name);
    var deployWary = BaseDeployDataSet.current.get(mapping.deployWay.name);
    var deployMode = BaseDeployDataSet.current.get(mapping.deployMode.name);
    HostSettingDataSet.getField(hostMapping.hostName.name).set('required', deployWary === deployWayOptionsData[1].value); // 如果不是mysql + 主机部署 则要重查paramsetting

    if (!(middleware === middleWareData[1].value && deployWary === deployWayOptionsData[1].value)) {
      // 中间件 部署方式 部署模式改变 重新查询table数据
      ParamSettingDataSet.setQueryParameter('queryParams', {
        middleware: BaseDeployDataSet.current.get(baseMapping.middleware.name),
        deployWay: BaseDeployDataSet.current.get(baseMapping.deployWay.name),
        deployMode: BaseDeployDataSet.current.get(baseMapping.deployMode.name)
      });
      ParamSettingDataSet.query();
    } // 根据选择部署方式不同 修改ip和端口的label字段


    if (middleware === middleWareData[0].value && deployWary === deployWayOptionsData[1].value && deployMode === deployModeOptionsData[0].value) {
      HostSettingDataSet.getField(hostMapping.ip.name).set('label', 'ip');
      HostSettingDataSet.getField(hostMapping.port.name).set('label', '端口');
      HostSettingDataSet.getField(hostMapping.privateIp.name).set('label', '内部IP');
      HostSettingDataSet.getField(hostMapping.privatePort.name).set('label', '内部端口');
    } else {
      HostSettingDataSet.getField(hostMapping.ip.name).set('label', '外部SSH认证IP');
      HostSettingDataSet.getField(hostMapping.port.name).set('label', '外部SSH认证端口');
      HostSettingDataSet.getField(hostMapping.privateIp.name).set('label', '内部SSH认证IP');
      HostSettingDataSet.getField(hostMapping.privatePort.name).set('label', '内部SSH认证端口');
    }
  }, [BaseDeployDataSet.current.get(mapping.middleware.name), BaseDeployDataSet.current.get(mapping.deployWay.name), BaseDeployDataSet.current.get(mapping.deployMode.name)]);
  useEffect(function () {
    // 主机模式 部署模式改变 清空主机设置
    if (BaseDeployDataSet.current.get(mapping.middleware.name) === middleWareData[0].value) {
      if (BaseDeployDataSet.current.get(mapping.deployWay.name) === deployWayOptionsData[1].value) {
        HostSettingDataSet.records.forEach(function (item) {
          Object.keys(hostMapping).forEach(function (key) {
            item.init(key);
          });
        });
      }
    }
  }, [BaseDeployDataSet.current.get(mapping.deployMode.name)]);
  /**
   * 获取主机名称disabled属性
   */

  var getHostNameDisabled = function getHostNameDisabled(data) {
    if (HostSettingDataSet.records.find(function (i) {
      return i.get(hostMapping.hostName.name) === data.record.get('id');
    })) {
      return true;
    }

    if ([deployModeOptionsData[1].value, mySqlDeployModeOptionsData[1].value].includes(BaseDeployDataSet.current.get(mapping.deployMode.name))) {
      //  如果是哨兵模式
      if (data.record.get('privateIp')) {
        return false;
      }

      return true;
    }

    return false;
  };
  /**
   * 点击mysql 下单个主机事件
   */


  var handleClickItemHost = function handleClickItemHost(_ref2) {
    var record = _ref2.record,
        ds = _ref2.ds;

    if (!record.get(hostMapping.checked.name)) {
      ds.records.forEach(function (i) {
        if (i.id === record.id) {
          i.set(hostMapping.checked.name, true);
        } else {
          i.set(hostMapping.checked.name, false);
        }
      });
    }
  };
  /**
   * 添加主机
   */


  var handleAddHost = function handleAddHost() {
    HostSettingDataSet.create();
  };
  /**
   * 添加主机按钮的disabled属性
   */


  var addHostDisabled = function addHostDisabled() {
    var deployMode = BaseDeployDataSet.current.get(mapping.deployMode.name);
    var single = deployModeOptionsData[0].value;
    var multiple = deployModeOptionsData[1].value;
    var length = HostSettingDataSet.records.length;

    if (deployMode === single) {
      if (length === 1) {
        return true;
      }

      return false;
    }

    return false;
  };
  /**
   * 环境option渲染
   * @param envRecord
   * @param text
   * @param value
   * @returns {*}
   */


  function renderEnvOption(_ref3) {
    var envRecord = _ref3.record,
        text = _ref3.text,
        value = _ref3.value;
    return /*#__PURE__*/React.createElement(React.Fragment, null, value && /*#__PURE__*/React.createElement(StatusDot, {
      connect: envRecord.get('connect'),
      synchronize: envRecord.get('synchro'),
      active: envRecord.get('active'),
      size: "small"
    }), /*#__PURE__*/React.createElement("span", null, text));
  }
  /**
   * 环境option属性
   * @param envRecord
   * @returns {{disabled: boolean}}
   */


  function renderOptionProperty(_ref4) {
    var envRecord = _ref4.record;
    var isAvailable = envRecord.get('connect') && envRecord.get('synchro') && envRecord.get('permission');
    return {
      disabled: !isAvailable
    };
  }
  /**
   * 渲染主机部署右侧dom
   */


  var renderHostDeployRight = function renderHostDeployRight() {
    var record = BaseDeployDataSet.current; // redis

    if (record.get(mapping.middleware.name) === middleWareData[0].name) {
      return [/*#__PURE__*/React.createElement(_TextField, {
        style: {
          visibility: 'hidden'
        },
        colSpan: 1
      }), /*#__PURE__*/React.createElement(_SelectBox, {
        colSpan: 1,
        name: mapping.deployMode.name
      }), /*#__PURE__*/React.createElement(_TextField, {
        newLine: true,
        colSpan: 1,
        name: mapping.resourceName.name
      })];
    } //  mysql


    return [/*#__PURE__*/React.createElement(_SelectBox, {
      colSpan: 1,
      name: mapping.deployMode.name
    }), /*#__PURE__*/React.createElement(_TextField, {
      colSpan: 1,
      name: mapping.resourceName.name
    })];
  };

  var renderDomBaseOnDeployWay = useMemo(function () {
    return BaseDeployDataSet.current.get(mapping.deployWay.name) === deployWayOptionsData[1].value ? renderHostDeployRight() : [BaseDeployDataSet.current.get(mapping.middleware.name) === middleWareData[0].value ? /*#__PURE__*/React.createElement(_SelectBox, {
      colSpan: 1,
      name: mapping.deployMode.name
    }) : '', /*#__PURE__*/React.createElement(_Select, {
      newLine: true,
      colSpan: 1,
      name: mapping.env.name,
      optionRenderer: renderEnvOption,
      onOption: renderOptionProperty
    }), /*#__PURE__*/React.createElement(_TextField, {
      colSpan: 1,
      name: mapping.instance.name
    }) // <Select
    //   combo
    //   name={mapping.pvc.name}
    //   colSpan={1}
    // />,
    ];
  }, [BaseDeployDataSet.current.get(mapping.deployWay.name), BaseDeployDataSet.current.get(mapping.middleware.name)]);
  /**
   * 删除host
   */

  var handleDeleteHost = function handleDeleteHost(record) {
    HostSettingDataSet.remove(record); // console.log(HostSettingDataSet);
  };
  /**
   * 测试连接
   */


  var handleTestConnect = /*#__PURE__*/function () {
    var _ref5 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3(id) {
      var result, record, valid, ids, _result4;

      return regeneratorRuntime.wrap(function _callee3$(_context3) {
        while (1) {
          switch (_context3.prev = _context3.next) {
            case 0:
              if (!id) {
                _context3.next = 10;
                break;
              }

              _context3.next = 3;
              return BaseComDeployServices.axiosPostTestHost(projectId, [id]);

            case 3:
              result = _context3.sent;

              if (!result) {
                _context3.next = 9;
                break;
              }

              record = HostSettingDataSet.records.find(function (i) {
                return i.get(hostMapping.hostName.name) === id;
              });

              if (result.includes(record.get(hostMapping.hostId.name))) {
                record.set(hostMapping.status.name, 'failed');
              } else {
                record.set(hostMapping.status.name, 'success');
              }

              if (!(!result || result.length === 0)) {
                _context3.next = 9;
                break;
              }

              return _context3.abrupt("return", true);

            case 9:
              return _context3.abrupt("return", false);

            case 10:
              _context3.next = 12;
              return HostSettingDataSet.validate();

            case 12:
              valid = _context3.sent;

              if (!valid) {
                _context3.next = 23;
                break;
              }

              ids = HostSettingDataSet.records.filter(function (i) {
                return i.get(hostMapping.hostName.name);
              }).map(function (i) {
                return i.get(hostMapping.hostName.name);
              });
              _context3.next = 17;
              return BaseComDeployServices.axiosPostTestHost(projectId, ids);

            case 17:
              _result4 = _context3.sent;

              if (!_result4) {
                _context3.next = 22;
                break;
              }

              HostSettingDataSet.records.forEach(function (record) {
                if (_result4.includes(record.get(hostMapping.hostId.name))) {
                  record.set(hostMapping.status.name, 'failed');
                } else {
                  record.set(hostMapping.status.name, 'success');
                }
              });

              if (!(!_result4 || _result4.length === 0)) {
                _context3.next = 22;
                break;
              }

              return _context3.abrupt("return", true);

            case 22:
              return _context3.abrupt("return", false);

            case 23:
              return _context3.abrupt("return", false);

            case 24:
            case "end":
              return _context3.stop();
          }
        }
      }, _callee3);
    }));

    return function handleTestConnect(_x) {
      return _ref5.apply(this, arguments);
    };
  }();

  var renderItemHostStatus = function renderItemHostStatus(record) {
    if (record && record.get) {
      switch (record === null || record === void 0 ? void 0 : record.get(hostMapping.status.name)) {
        case 'success':
          {
            return /*#__PURE__*/React.createElement("span", {
              className: "c7ncd-baseDeploy-middle-deploySetting-status",
              style: {
                color: '#1FC2BB'
              }
            }, /*#__PURE__*/React.createElement(_Icon, {
              type: "check",
              style: {
                background: 'rgb(31, 194, 187)',
                color: 'white'
              }
            }), "\u6210\u529F");
            break;
          }

        case 'failed':
          {
            return /*#__PURE__*/React.createElement("span", {
              className: "c7ncd-baseDeploy-middle-deploySetting-status",
              style: {
                color: '#f76776'
              }
            }, /*#__PURE__*/React.createElement(_Icon, {
              type: "close",
              style: {
                background: '#F76776',
                color: 'white'
              }
            }), "\u5931\u8D25");
          }

        default:
          return '';
          break;
      }
    }

    return '';
  };
  /**
   * 默认值渲染
   * @param value
   * @returns {*}
   */


  var renderParamsScope = function renderParamsScope(_ref6) {
    var value = _ref6.value;
    return /*#__PURE__*/React.createElement(_Tooltip, {
      placement: "topLeft",
      title: value
    }, value);
  };
  /**
   * 参数运行值 render
   * @param value
   * @param record
   */


  var renderParamsRunningValue = function renderParamsRunningValue(_ref7) {
    var value = _ref7.value,
        record = _ref7.record;
    return /*#__PURE__*/React.createElement(_TextField, {
      required: true,
      value: value,
      onChange: function onChange(text) {
        return record.set(paramMapping.paramsRunnigValue.name, text);
      },
      validator: function validator(values) {
        return handleValidParamsRunningValue(values, record);
      }
    });
  };
  /**
   * table操作列
   */


  var renderOperation = function renderOperation(_ref8) {
    var record = _ref8.record,
        _ref8$isHostInside = _ref8.isHostInside,
        isHostInside = _ref8$isHostInside === void 0 ? true : _ref8$isHostInside;
    return !record.get('id') && /*#__PURE__*/React.createElement(_Button, {
      funcType: "flat",
      onClick: function onClick() {
        if (isHostInside) {
          var ds = HostSettingDataSet.records.find(function (i) {
            return i.get(hostMapping.checked.name);
          }).getState('params');
          ds.remove(record);
          HostSettingDataSet.records.find(function (i) {
            return i.get(hostMapping.checked.name);
          }).setState('params', ds);
        } else {
          ParamSettingDataSet.remove(record);
        }
      },
      icon: "delete"
    });
  };
  /**
   * table 参数render
   * @param value
   * @param record
   * @returns {*}
   */


  var renderParams = function renderParams(_ref9) {
    var value = _ref9.value,
        record = _ref9.record,
        name = _ref9.name;
    return record.get('custom') ? /*#__PURE__*/React.createElement(_TextField, {
      value: value,
      onChange: function onChange(v) {
        return record.set(name, v);
      }
    }) : /*#__PURE__*/React.createElement("span", null, value, record.get(paramMapping.tooltip.name) && /*#__PURE__*/React.createElement(NewTips, {
      helpText: record.get(paramMapping.tooltip.name),
      style: {
        marginLeft: 5,
        position: 'relative',
        bottom: 1
      }
    }));
  };
  /**
   * 测试连接整个结果渲染
   */


  var renderHostResult = function renderHostResult() {
    if (HostSettingDataSet.records.some(function (i) {
      return i.get(hostMapping.status.name);
    })) {
      if (HostSettingDataSet.records.some(function (i) {
        return i.get(hostMapping.status.name) === 'failed';
      })) {
        return /*#__PURE__*/React.createElement("div", {
          className: "c7ncd-baseDeploy-middle-testButton-result c7ncd-baseDeploy-middle-failed"
        }, /*#__PURE__*/React.createElement("span", null, "\u6D4B\u8BD5\u8FDE\u63A5:"), /*#__PURE__*/React.createElement("span", null, /*#__PURE__*/React.createElement(_Icon, {
          type: "close"
        }), "\u5931\u8D25"));
      }

      return /*#__PURE__*/React.createElement("div", {
        className: "c7ncd-baseDeploy-middle-testButton-result c7ncd-baseDeploy-middle-success"
      }, /*#__PURE__*/React.createElement("span", null, "\u6D4B\u8BD5\u8FDE\u63A5:"), /*#__PURE__*/React.createElement("span", null, /*#__PURE__*/React.createElement(_Icon, {
        type: "check"
      }), "\u6210\u529F"));
    }

    return '';
  };

  var handleValidParamsRunningValue = function handleValidParamsRunningValue(values, record) {
    if (!values) {
      _message.error('请输入参数');

      return '该字段为必填';
    }

    var itemScope = record.get(paramMapping.paramsScope.name);
    var middleValue;

    if (itemScope.includes('~') || itemScope.includes('～')) {
      if (itemScope.includes('~')) {
        middleValue = '~';
      }

      if (itemScope.includes('～')) {
        middleValue = '～';
      } //  为区间


      if (parseFloat(values).toString() === 'NaN') {
        _message.error('请输入数字');

        return '请输入数字';
      }

      var scope = itemScope.split(middleValue);
      var newValues = values.replace(/,/gi, '');

      if (newValues <= parseFloat(scope[1].replace(/,/gi, '')) && newValues >= parseFloat(scope[0].replace(/,/gi, ''))) {
        return true;
      }

      _message.error('超出区间范围');

      return '超出区间范围';
    }

    if (itemScope.includes(',')) {
      //  select取值
      if (itemScope.split(',').includes(values)) {
        return true;
      }

      _message.error('超出区间范围');

      return '超出区间范围';
    }

    return true;
  };
  /**
   * 主机部署的主机设置部分
   */


  var rennderHostDeployCotent = function rennderHostDeployCotent() {
    var recordd = BaseDeployDataSet.current; // redis

    if (recordd.get(mapping.middleware.name) === middleWareData[0].value) {
      return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("p", {
        className: "c7ncd-baseDeploy-middle-deploySetting"
      }, "\u4E3B\u673A\u8BBE\u7F6E"), HostSettingDataSet.records.filter(function (i) {
        return !i.isRemoved;
      }).map(function (record) {
        return /*#__PURE__*/React.createElement("div", {
          style: {
            position: 'relative',
            width: '80%'
          }
        }, /*#__PURE__*/React.createElement(_Form, {
          columns: BaseDeployDataSet.current.get(mapping.deployMode.name) === deployModeOptionsData[0].value ? 3 : 5,
          style: {
            width: '100%'
          },
          record: record
        }, /*#__PURE__*/React.createElement(_Select, {
          colSpan: 1,
          name: hostMapping.hostName.name,
          onOption: function onOption(data) {
            return {
              disabled: getHostNameDisabled(data)
            };
          }
        }), /*#__PURE__*/React.createElement(_TextField, {
          colSpan: 1,
          name: hostMapping.ip.name
        }), /*#__PURE__*/React.createElement(_TextField, {
          colSpan: 1,
          name: hostMapping.port.name
        }), BaseDeployDataSet.current.get(mapping.deployMode.name) === deployModeOptionsData[1].value && [/*#__PURE__*/React.createElement(_TextField, {
          colSpan: 1,
          name: hostMapping.privateIp.name
        }), /*#__PURE__*/React.createElement(_TextField, {
          colSpan: 1,
          name: hostMapping.privatePort.name
        })]), /*#__PURE__*/React.createElement(_Button, {
          funcType: "flat",
          disabled: deleteHostDisabled(BaseDeployDataSet, HostSettingDataSet),
          icon: "delete",
          style: {
            position: 'absolute',
            right: '-36px',
            bottom: '30px'
          },
          onClick: function onClick() {
            return handleDeleteHost(record);
          }
        }), renderItemHostStatus(record));
      }), /*#__PURE__*/React.createElement(_Button, {
        icon: "add",
        color: "primary",
        funcType: "flat",
        className: "c7ncd-baseDeploy-middle-flexButton",
        disabled: addHostDisabled(),
        onClick: handleAddHost
      }, "\u6DFB\u52A0\u4E3B\u673A"), /*#__PURE__*/React.createElement("div", {
        className: "c7ncd-baseDeploy-middle-testButton"
      }, /*#__PURE__*/React.createElement(_Button, {
        funcType: "flat",
        disabled: HostSettingDataSet.records.filter(function (i) {
          return !i.isRemoved;
        }).every(function (i) {
          return !i.get(hostMapping.hostName.name);
        }),
        onClick: function onClick() {
          return handleTestConnect();
        }
      }, "\u6D4B\u8BD5\u8FDE\u63A5"), renderHostResult()), /*#__PURE__*/React.createElement("p", {
        style: {
          marginTop: 30
        },
        className: "c7ncd-baseDeploy-middle-deploySetting"
      }, "\u53C2\u6570\u914D\u7F6E"), /*#__PURE__*/React.createElement(_Form, {
        columns: 3,
        style: {
          width: '80%',
          marginTop: 16
        },
        dataSet: BaseDeployDataSet
      }, /*#__PURE__*/React.createElement(_Password, {
        autoComplete: "new-password",
        colSpan: 1,
        name: mapping.password.name,
        addonAfter: /*#__PURE__*/React.createElement(NewTips, {
          helpText: "\u914D\u7F6E\u4E3B\u673A\u7684SSH\u4FE1\u606F\u4EE5\u53CAMySQL\u914D\u7F6E\u4FE1\u606F\u3002\u9ED8\u8BA4\u5BC6\u7801\u4E3AChangeit!123\u3002\u4FEE\u6539\u5BC6\u7801\u9700\u6EE1\u8DB3\u4EE5\u4E0B\u8981\u6C42\uFF1A1\u3001\u957F\u5EA6\u6700\u77ED8\u4F4D 2\u3001\u81F3\u5C11\u5305\u542B\u4E00\u4E2A\u6570\u5B57 3\u3001\u81F3\u5C11\u5305\u542B\u4E00\u4E2A\u5927\u5199\u5B57\u6BCD 4\u3001\u81F3\u5C11\u5305\u542B\u4E00\u4E2A\u5C0F\u5199\u5B57\u6BCD 5\u3001\u81F3\u5C11\u5305\u542B\u4E00\u4E2A\u7279\u6B8A\u7B26\u53F7"
        })
      })));
    } // mysql


    return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("p", {
      className: "c7ncd-baseDeploy-middle-deploySetting"
    }, "\u4E3B\u673A\u8BBE\u7F6E", /*#__PURE__*/React.createElement(NewTips, {
      helpText: "\u914D\u7F6E\u90E8\u7F72MySQL\u670D\u52A1\u7684\u4E3B\u673A\u4FE1\u606F\u4EE5\u53CAMySQL\u7684\u8FD0\u884C\u65F6\u914D\u7F6E\u3002",
      style: {
        marginLeft: 5,
        position: 'relative',
        bottom: 2
      }
    })), /*#__PURE__*/React.createElement(_Form, {
      dataSet: BaseDeployDataSet,
      columns: 3
    }, /*#__PURE__*/React.createElement(_Password, {
      autoComplete: "new-password",
      colSpan: 1,
      name: mapping.password.name,
      addonAfter: /*#__PURE__*/React.createElement(Tips, {
        helpText: "\u914D\u7F6E\u4E3B\u673A\u7684SSH\u4FE1\u606F\u4EE5\u53CAMySQL\u914D\u7F6E\u4FE1\u606F\u3002\u9ED8\u8BA4\u5BC6\u7801\u4E3AChangeit!123\u3002\u4FEE\u6539\u5BC6\u7801\u9700\u6EE1\u8DB3\u4EE5\u4E0B\u8981\u6C42\uFF1A1\u3001\u957F\u5EA6\u6700\u77ED8\u4F4D 2\u3001\u81F3\u5C11\u5305\u542B\u4E00\u4E2A\u6570\u5B57 3\u3001\u81F3\u5C11\u5305\u542B\u4E00\u4E2A\u5927\u5199\u5B57\u6BCD 4\u3001\u81F3\u5C11\u5305\u542B\u4E00\u4E2A\u5C0F\u5199\u5B57\u6BCD 5\u3001\u81F3\u5C11\u5305\u542B\u4E00\u4E2A\u7279\u6B8A\u7B26\u53F7"
      })
    }), BaseDeployDataSet.current.get(mapping.deployMode.name) === mySqlDeployModeOptionsData[1].value && /*#__PURE__*/React.createElement(_TextField, {
      colSpan: 1,
      name: mapping.virtualIp.name,
      addonAfter: /*#__PURE__*/React.createElement(Tips, {
        helpText: "\u5BF9\u5916\u63D0\u4F9BMySQL\u670D\u52A1\u7684ip\u5730\u5740"
      })
    })), /*#__PURE__*/React.createElement("div", {
      className: "c7ncd-baseDeploy-middle-hostList"
    }, /*#__PURE__*/React.createElement("div", {
      className: "c7ncd-baseDeploy-middle-hostList-left"
    }, HostSettingDataSet.records.filter(function (i) {
      return !i.isRemoved;
    }).map(function (i) {
      return /*#__PURE__*/React.createElement(_Form, {
        record: i
      }, /*#__PURE__*/React.createElement("div", {
        role: "none",
        style: {
          cursor: 'pointer',
          padding: '10px 10px 10px 0',
          display: 'flex',
          alignItems: 'center',
          borderTop: i.get(hostMapping.checked.name) ? '1px solid rgba(0, 0, 0, 0.12)' : 'unset',
          borderBottom: i.get(hostMapping.checked.name) ? '1px solid rgba(0, 0, 0, 0.12)' : 'unset',
          position: 'relative',
          bottom: '1px'
        },
        onClick: function onClick() {
          return handleClickItemHost({
            record: i,
            ds: HostSettingDataSet
          });
        }
      }, /*#__PURE__*/React.createElement("div", {
        className: "c7ncd-baseDeploy-middle-hostList-left-checkedLine",
        style: {
          visibility: i.get(hostMapping.checked.name) ? 'visible' : 'hidden'
        }
      }), /*#__PURE__*/React.createElement("div", {
        className: "c7ncd-baseDeploy-middle-hostList-left-whiteline",
        style: {
          visibility: i.get(hostMapping.checked.name) ? 'visible' : 'hidden'
        }
      }), /*#__PURE__*/React.createElement(_Select, {
        onClick: function onClick(e) {
          return e.stopPropagation();
        },
        name: hostMapping.hostName.name,
        onOption: function onOption(data) {
          return {
            disabled: getHostNameDisabled(data)
          };
        }
      })));
    })), /*#__PURE__*/React.createElement("div", {
      className: "c7ncd-baseDeploy-middle-hostList-right"
    }, /*#__PURE__*/React.createElement(_Form, {
      columns: 5,
      record: HostSettingDataSet.records.find(function (i) {
        return i.get(hostMapping.checked.name);
      }),
      style: {
        position: 'relative'
      }
    }, /*#__PURE__*/React.createElement(_TextField, {
      colSpan: 1,
      name: hostMapping.ip.name
    }), /*#__PURE__*/React.createElement(_TextField, {
      colSpan: 1,
      name: hostMapping.port.name
    }), /*#__PURE__*/React.createElement(_TextField, {
      colSpan: 1,
      name: hostMapping.privateIp.name
    }), /*#__PURE__*/React.createElement(_TextField, {
      colSpan: 1,
      name: hostMapping.privatePort.name
    }), renderItemHostStatus(HostSettingDataSet.records.find(function (i) {
      return i.get(hostMapping.checked.name);
    }))), /*#__PURE__*/React.createElement("div", {
      className: "c7ncd-baseDeploy-middle-testButton",
      style: {
        marginTop: 'unset'
      }
    }, /*#__PURE__*/React.createElement(_Button, {
      funcType: "flat",
      color: "blue",
      disabled: !HostSettingDataSet.records.find(function (i) {
        return i.get(hostMapping.checked.name);
      }).get(hostMapping.hostName.name),
      onClick: function onClick() {
        return handleTestConnect(HostSettingDataSet.records.find(function (i) {
          return i.get(hostMapping.checked.name);
        }).get(hostMapping.hostName.name));
      }
    }, "\u6D4B\u8BD5\u8FDE\u63A5")), /*#__PURE__*/React.createElement(_Button, {
      icon: "add",
      color: "primary",
      style: {
        position: 'relative',
        left: 'calc(100% - 100px)'
      },
      onClick: function onClick() {
        return handleAddParams(true);
      }
    }, "\u6DFB\u52A0\u53C2\u6570"), /*#__PURE__*/React.createElement(_Table, {
      editMode: "inline",
      style: {
        marginTop: 20
      },
      queryBar: "none",
      dataSet: HostSettingDataSet.records.find(function (i) {
        return i.get(hostMapping.checked.name);
      }).getState('params'),
      rowHeight: 60
    }, /*#__PURE__*/React.createElement(Column, {
      header: "\u53C2\u6570",
      name: paramMapping.params.name,
      renderer: renderParams
    }), /*#__PURE__*/React.createElement(Column, {
      header: "\u53C2\u6570\u9ED8\u8BA4\u503C",
      name: paramMapping.defaultParams.name
    }), /*#__PURE__*/React.createElement(Column, {
      header: "\u53C2\u6570\u8303\u56F4",
      name: paramMapping.paramsScope.name,
      renderer: renderParamsScope
    }), /*#__PURE__*/React.createElement(Column, {
      name: paramMapping.paramsRunnigValue.name,
      renderer: renderParamsRunningValue,
      header: "\u53C2\u6570\u8FD0\u884C\u503C"
    }), /*#__PURE__*/React.createElement(Column, {
      width: 60,
      renderer: function renderer(_ref10) {
        var record = _ref10.record;
        return renderOperation({
          record: record,
          isHostInside: true
        });
      }
    })))));
  };

  var renderBottomDomBaseOnDeployWay = function renderBottomDomBaseOnDeployWay() {
    return BaseDeployDataSet.current.get(mapping.deployWay.name) === deployWayOptionsData[1].value ? rennderHostDeployCotent() : [/*#__PURE__*/React.createElement("p", {
      className: "c7ncd-baseDeploy-middle-deploySetting"
    }, "\u53C2\u6570\u914D\u7F6E"), /*#__PURE__*/React.createElement(_Form, {
      columns: 3,
      style: {
        width: '80%',
        marginTop: 16
      },
      dataSet: BaseDeployDataSet
    }, BaseDeployDataSet.current.get(mapping.middleware.name) === middleWareData[1].value ? [/*#__PURE__*/React.createElement(_Password, {
      autoComplete: "new-password",
      colSpan: 1,
      name: mapping.password.name,
      addonAfter: /*#__PURE__*/React.createElement(Tips, {
        helpText: "\u8BBF\u95EEMySQL\u670D\u52A1\u7684\u5BC6\u7801\u3002\u9ED8\u8BA4\u5BC6\u7801\u4E3AChangeit!123\u3002\u4FEE\u6539\u5BC6\u7801\u9700\u6EE1\u8DB3\u4EE5\u4E0B\u8981\u6C42\uFF1A1\u3001\u957F\u5EA6\u6700\u77ED8\u4F4D 2\u3001\u81F3\u5C11\u5305\u542B\u4E00\u4E2A\u6570\u5B57 3\u3001\u81F3\u5C11\u5305\u542B\u4E00\u4E2A\u5927\u5199\u5B57\u6BCD 4\u3001\u81F3\u5C11\u5305\u542B\u4E00\u4E2A\u5C0F\u5199\u5B57\u6BCD 5\u3001\u81F3\u5C11\u5305\u542B\u4E00\u4E2A\u7279\u6B8A\u7B26\u53F7\u3002"
      })
    }), /*#__PURE__*/React.createElement(_Select, {
      combo: true,
      colSpan: 1,
      name: mapping.pvc.name,
      addonAfter: /*#__PURE__*/React.createElement(Tips, {
        helpText: "\u6B64\u9879\u586B\u503C\uFF0Credis\u5C06\u4F7F\u7528\u5BF9\u5E94\u7684PVC\u8FDB\u884C\u6570\u636E\u6301\u4E45\u5316"
      })
    })] : [/*#__PURE__*/React.createElement(_Password, {
      autoComplete: "new-password",
      colSpan: 1,
      name: mapping.password.name,
      addonAfter: /*#__PURE__*/React.createElement(Tips, {
        helpText: "\u8BBF\u95EEredis\u670D\u52A1\u7684\u5BC6\u7801\u3002\u9ED8\u8BA4\u5BC6\u7801\u4E3AChangeit!123\u3002\u4FEE\u6539\u5BC6\u7801\u9700\u6EE1\u8DB3\u4EE5\u4E0B\u8981\u6C42\uFF1A1\u3001\u957F\u5EA6\u6700\u77ED8\u4F4D 2\u3001\u81F3\u5C11\u5305\u542B\u4E00\u4E2A\u6570\u5B57 3\u3001\u81F3\u5C11\u5305\u542B\u4E00\u4E2A\u5927\u5199\u5B57\u6BCD 4\u3001\u81F3\u5C11\u5305\u542B\u4E00\u4E2A\u5C0F\u5199\u5B57\u6BCD 5\u3001\u81F3\u5C11\u5305\u542B\u4E00\u4E2A\u7279\u6B8A\u7B26\u53F7\u3002"
      })
    }), /*#__PURE__*/React.createElement(_Select, {
      colSpan: 1,
      name: mapping.sysctlImage.name,
      addonAfter: /*#__PURE__*/React.createElement(Tips, {
        helpText: "\u6B64\u5904\u6307\uFF1A\u662F\u5426\u542F\u7528\u5185\u6838\u53C2\u6570\u4F18\u5316\u3002\u6BD4\u5982\u4F18\u5316redis\u8FDE\u63A5\u6570\u3001\u5185\u5B58\u4F7F\u7528\u7B49\u7B49\u3002"
      })
    }, /*#__PURE__*/React.createElement(Option, {
      value: true
    }, "true"), /*#__PURE__*/React.createElement(Option, {
      value: false
    }, "false")), BaseDeployDataSet.current.get(mapping.deployMode.name) === deployModeOptionsData[0].value ? /*#__PURE__*/React.createElement(_Select, {
      combo: true,
      colSpan: 1,
      name: mapping.pvc.name,
      addonAfter: /*#__PURE__*/React.createElement(Tips, {
        helpText: "\u6B64\u9879\u586B\u503C\uFF0Credis\u5C06\u4F7F\u7528\u5BF9\u5E94\u7684PVC\u8FDB\u884C\u6570\u636E\u6301\u4E45\u5316"
      })
    }) : /*#__PURE__*/React.createElement(_NumberField, {
      colSpan: 1,
      name: mapping.slaveCount.name,
      addonAfter: /*#__PURE__*/React.createElement(Tips, {
        helpText: "\u54E8\u5175\u8282\u70B9\u6570\u91CF\u3002\u6700\u5C0F\u662F3"
      })
    })]), BaseDeployDataSet.current.get(mapping.deployMode.name) === deployModeOptionsData[0].value || BaseDeployDataSet.current.get(mapping.middleware.name) === middleWareData[1].value ? '' : [/*#__PURE__*/React.createElement("p", {
      className: "c7ncd-baseDeploy-middle-deploySetting"
    }, "PV\u6807\u7B7E", /*#__PURE__*/React.createElement(NewTips, {
      helpText: "\u6B64\u5904\u8F93\u5165\u7684PV\u6807\u7B7E\u7528\u4E8E\u5B9A\u4F4D\u5BF9\u5E94\u7684PV\uFF0C\u6B64\u5904\u9700\u4FDD\u8BC1\u5339\u914D\u5F97\u5230\u7684PV\u6570\u91CF\u5E94\u5927\u4E8E\u7B49\u4E8EslaveCount\u7684\u6570\u91CF"
    })), PVLabelsDataSet.records.filter(function (item) {
      return !item.isRemoved;
    }).map(function (item) {
      return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(_Form, {
        style: {
          width: '80%'
        },
        record: item,
        columns: 3
      }, /*#__PURE__*/React.createElement("div", {
        className: "c7ncd-base-pvlabels",
        colSpan: 2
      }, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(_Select, {
        style: {
          width: 219
        },
        combo: true,
        name: "key"
      })), /*#__PURE__*/React.createElement("span", {
        style: {
          margin: '0 6px'
        }
      }, "="), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(_TextField, {
        style: {
          width: 219
        },
        name: "value"
      })), /*#__PURE__*/React.createElement(_Button, {
        funcType: "flat",
        style: {
          flexShrink: 0,
          marginLeft: 10
        },
        icon: "delete",
        onClick: function onClick() {
          return PVLabelsDataSet.remove(item);
        }
      }))));
    }), /*#__PURE__*/React.createElement(_Button, {
      icon: "add",
      color: "primary",
      funcType: "flat",
      style: {
        display: 'block',
        flexShrink: 0,
        flexGrow: 0,
        width: 'max-content'
      },
      onClick: function onClick() {
        return PVLabelsDataSet.create();
      }
    }, "\u6DFB\u52A0PV\u6807\u7B7E")] // <YamlEditor
    //   readOnly={false}
    //   value={BaseDeployDataSet.current.get(mapping.values.name)}
    //   onValueChange={(data) => BaseDeployDataSet.current.set(mapping.values.name, data)}
    // />,
    // <ResourceSetting
    //   networkRef={networkRef}
    //   domainRef={domainRef}
    //   envId={BaseDeployDataSet.current.get(mapping.env.name)}
    //   style={{
    //     marginTop: 30,
    //   }}
    // />,
    ];
  };
  /**
   * 添加table 一行参数
   */


  var handleAddParams = function handleAddParams() {
    var isHostInside = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;

    if (isHostInside) {
      var _ds$create;

      var ds = HostSettingDataSet.records.find(function (i) {
        return i.get(hostMapping.checked.name);
      }).getState('params');
      ds.create((_ds$create = {}, _defineProperty(_ds$create, paramMapping.params.name, ''), _defineProperty(_ds$create, paramMapping.defaultParams.name, '——'), _defineProperty(_ds$create, paramMapping.paramsScope.name, '——'), _defineProperty(_ds$create, paramMapping.paramsRunnigValue.name, ''), _defineProperty(_ds$create, "custom", 'true'), _ds$create), ds.records.length);
      HostSettingDataSet.records.find(function (i) {
        return i.get(hostMapping.checked.name);
      }).setState('params', ds);
    } else {
      var _ParamSettingDataSet$;

      ParamSettingDataSet.create((_ParamSettingDataSet$ = {}, _defineProperty(_ParamSettingDataSet$, paramMapping.params.name, ''), _defineProperty(_ParamSettingDataSet$, paramMapping.defaultParams.name, '——'), _defineProperty(_ParamSettingDataSet$, paramMapping.paramsScope.name, '——'), _defineProperty(_ParamSettingDataSet$, paramMapping.paramsRunnigValue.name, ''), _defineProperty(_ParamSettingDataSet$, "custom", 'true'), _ParamSettingDataSet$), ParamSettingDataSet.records.length);
    }
  };
  /**
   * 删除按钮disabled属性
   */


  var deleteHostDisabled = function deleteHostDisabled(baseDataSet, hostDataSet) {
    var deployMode = baseDataSet.current.get(mapping.deployMode.name); // redis

    if (baseDataSet.current.get(mapping.middleware.name) === middleWareData[0].value) {
      // 哨兵
      if (deployMode === deployModeOptionsData[1].value) {
        if (hostDataSet.records.length <= 3) {
          return true;
        }

        return false;
      } //  单机


      if (hostDataSet.records.length <= 1) {
        return true;
      }
    } else {
      // mysql
      // eslint-disable-next-line no-lonely-if
      if (deployMode === deployModeOptionsData[0].value) {
        // 单机
        return true;
      } // 主备


      if (hostDataSet.records.length <= 2) {
        return true;
      }
    }

    return false;
  };

  return /*#__PURE__*/React.createElement("div", {
    className: "c7ncd-baseDeploy-middle"
  }, /*#__PURE__*/React.createElement("p", {
    className: "c7ncd-baseDeploy-middle-service"
  }, "\u9009\u62E9\u4E2D\u95F4\u4EF6\u670D\u52A1"), /*#__PURE__*/React.createElement("div", {
    className: "c7ncd-baseDeploy-middle-img"
  }, /*#__PURE__*/React.createElement("span", {
    role: "none",
    onClick: function onClick() {
      BaseDeployDataSet.current.set(mapping.middleware.name, middleWareData[0].value);
    }
  }, /*#__PURE__*/React.createElement("img", {
    src: redis,
    alt: "",
    className: classNames({
      'c7ncd-baseDeploy-middle-img-checked': BaseDeployDataSet.current.get(mapping.middleware.name) === middleWareData[0].value
    })
  }), BaseDeployDataSet.current.get(mapping.middleware.name) === middleWareData[0].value && /*#__PURE__*/React.createElement(_Icon, {
    type: "check_circle"
  })), /*#__PURE__*/React.createElement("span", {
    role: "none",
    onClick: function onClick() {
      BaseDeployDataSet.current.set(mapping.middleware.name, middleWareData[1].value);
    }
  }, /*#__PURE__*/React.createElement("img", {
    style: {
      marginLeft: 20
    },
    src: mysql,
    alt: "",
    className: classNames({
      'c7ncd-baseDeploy-middle-img-checked': BaseDeployDataSet.current.get(mapping.middleware.name) === middleWareData[1].value
    })
  }), BaseDeployDataSet.current.get(mapping.middleware.name) === middleWareData[1].value && /*#__PURE__*/React.createElement(_Icon, {
    type: "check_circle"
  }))), /*#__PURE__*/React.createElement(_Form, {
    columns: 2,
    style: {
      width: '80%',
      marginTop: 25
    },
    dataSet: BaseDeployDataSet
  }, /*#__PURE__*/React.createElement(_Select, {
    colSpan: 1,
    name: mapping.serviceVersion.name
  })), /*#__PURE__*/React.createElement("p", {
    className: "c7ncd-baseDeploy-middle-deploySetting"
  }, "\u90E8\u7F72\u8BBE\u7F6E"), /*#__PURE__*/React.createElement(_Form, {
    columns: 3,
    style: {
      width: '80%',
      marginTop: 16
    },
    dataSet: BaseDeployDataSet
  }, /*#__PURE__*/React.createElement(_SelectBox, {
    colSpan: 1,
    name: mapping.deployWay.name
  }), renderDomBaseOnDeployWay), renderBottomDomBaseOnDeployWay(), BaseDeployDataSet.current.get(mapping.middleware.name) === middleWareData[1].value && BaseDeployDataSet.current.get(mapping.deployWay.name) === deployWayOptionsData[1].value ? '' : /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(_Table, {
    style: {
      marginTop: 20
    },
    queryBar: "none",
    dataSet: ParamSettingDataSet,
    rowHeight: 60
  }, /*#__PURE__*/React.createElement(Column, {
    name: paramMapping.params.name,
    renderer: renderParams
  }), /*#__PURE__*/React.createElement(Column, {
    name: paramMapping.defaultParams.name
  }), /*#__PURE__*/React.createElement(Column, {
    name: paramMapping.paramsScope.name,
    renderer: renderParamsScope
  }), /*#__PURE__*/React.createElement(Column, {
    name: paramMapping.paramsRunnigValue.name,
    renderer: renderParamsRunningValue
  }), /*#__PURE__*/React.createElement(Column, {
    width: 60,
    renderer: function renderer(_ref11) {
      var record = _ref11.record;
      return renderOperation({
        record: record,
        isHostInside: false
      });
    }
  })), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(_Button, {
    funcType: "flat",
    icon: "add",
    color: "primary",
    style: {
      margin: '20px 0',
      position: 'relative',
      flexShrink: 0,
      flexGrow: 0,
      width: 'max-content'
    },
    onClick: function onClick() {
      return handleAddParams();
    }
  }, "\u6DFB\u52A0\u53C2\u6570"))));
});