import "choerodon-ui/pro/lib/text-area/style";
import _TextArea from "choerodon-ui/pro/lib/text-area";
import "choerodon-ui/pro/lib/tooltip/style";
import _Tooltip from "choerodon-ui/pro/lib/tooltip";
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/password/style";
import _Password from "choerodon-ui/pro/lib/password";
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/modal/style";
import _Modal from "choerodon-ui/pro/lib/modal";
import "choerodon-ui/lib/icon/style";
import _Icon from "choerodon-ui/lib/icon";
import "choerodon-ui/lib/spin/style";
import _Spin from "@hzero-front-ui/c7n-ui/lib/Spin";
import "choerodon-ui/pro/lib/select/style";
import _Select from "choerodon-ui/pro/lib/select";

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); }); }; }

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 _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }

function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }

function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }

function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }

function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }

function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }

function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }

function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }

function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }

function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }

/* eslint-disable jsx-a11y/no-static-element-interactions */

/* eslint-disable no-param-reassign */

/* eslint-disable no-template-curly-in-string */
import React, { useEffect, useState, useCallback } from 'react';
import { NewTips } from '@choerodon/components';
import { axios, Choerodon } from '@choerodon/boot';
import { Base64 } from 'js-base64';
import { CopyToClipboard } from 'react-copy-to-clipboard';
import { observer } from 'mobx-react-lite';
import DeployConfig from "../../../../../../components/deploy-config";
import JSONbig from 'json-bigint';
import { get } from 'lodash';
import addCDTaskDataSetMap from "./stores/addCDTaskDataSetMap";
import { useAddCDTaskStore } from "./stores";
import YamlEditor from "../../../../../../components/yamlEditor";
import Tips from "../../../../../../components/new-tips";
import "./index.less";
var currentSize = 10;
var originBranchs = [{
  value: 'master',
  name: 'master'
}, {
  value: 'feature',
  name: 'feature'
}, {
  value: 'bugfix',
  name: 'bugfix'
}, {
  value: 'hotfix',
  name: 'hotfix'
}, {
  value: 'release',
  name: 'release'
}, {
  value: 'tag',
  name: 'tag'
}];
var Option = _Select.Option;
export default observer(function () {
  var _ADDCDTaskDataSet$cur2, _ADDCDTaskDataSet$cur3, _ADDCDTaskDataSet$cur8, _ADDCDTaskDataSet$cur9, _ADDCDTaskDataSet$cur10, _ADDCDTaskDataSet$cur11, _ADDCDTaskDataSet$cur16, _ADDCDTaskDataSet$cur17, _ADDCDTaskDataSet$cur18, _ADDCDTaskDataSet$cur19, _ADDCDTaskDataSet$cur20;

  var _useAddCDTaskStore = useAddCDTaskStore(),
      ADDCDTaskDataSet = _useAddCDTaskStore.ADDCDTaskDataSet,
      appServiceId = _useAddCDTaskStore.appServiceId,
      PipelineCreateFormDataSet = _useAddCDTaskStore.PipelineCreateFormDataSet,
      AppState = _useAddCDTaskStore.AppState,
      projectId = _useAddCDTaskStore.AppState.currentMenuType.projectId,
      modal = _useAddCDTaskStore.modal,
      ADDCDTaskUseStore = _useAddCDTaskStore.ADDCDTaskUseStore,
      handleOk = _useAddCDTaskStore.handleOk,
      jobDetail = _useAddCDTaskStore.jobDetail,
      pipelineStageMainSource = _useAddCDTaskStore.pipelineStageMainSource,
      columnIndex = _useAddCDTaskStore.columnIndex,
      witchColumnJobIndex = _useAddCDTaskStore.witchColumnJobIndex,
      taskIndex = _useAddCDTaskStore.index;

  var _useState = useState([]),
      _useState2 = _slicedToArray(_useState, 2),
      branchsList = _useState2[0],
      setBranchsList = _useState2[1];

  var _useState3 = useState(''),
      _useState4 = _slicedToArray(_useState3, 2),
      valueIdValues = _useState4[0],
      setValueIdValues = _useState4[1];

  var _useState5 = useState('# 自定义ssh指令\n# 比如部署镜像\n# 需要包括部署镜像指令以及二次触发部署的停用删除逻辑\ndocker stop mynginx & docker rm mynginx & docker run --name mynginx -d nginx:latest'),
      _useState6 = _slicedToArray(_useState5, 2),
      customValues = _useState6[0],
      setCustomValues = _useState6[1];

  var _useState7 = useState('# docker run指令\n# 不可删除${containerName}和${imageName}占位符\n# 不可删除 -d: 后台运行容器\n# 其余参数可参考可根据需要添加\ndocker run --name=${containerName} -d ${imageName}'),
      _useState8 = _slicedToArray(_useState7, 2),
      imageDeployValues = _useState8[0],
      setImageDeployValues = _useState8[1];

  var _useState9 = useState('# java -jar指令\n' + '# 不可删除${jar}\n' + '# java -jar 后台运行参数会自动添加 不需要在重复添加\n' + '# 其余参数可参考可根据需要添加\n' + 'java -jar ${jar}\n' + '# 默认工作目录，当前工作目录(./)，jar包下载存放目录为：./temp-jar/xxx.jar 日志存放目录为：./temp-log/xxx.log\n' + '# 填写工作目录，jar包下载存放目录为：工作目录/temp-jar/xxx.jar 日志存放目录为：工作目录/temp-jar/xxx.log\n' + '# 请确保用户有该目录操作权限'),
      _useState10 = _slicedToArray(_useState9, 2),
      jarValues = _useState10[0],
      setJarValues = _useState10[1];

  var _useState11 = useState(''),
      _useState12 = _slicedToArray(_useState11, 2),
      testStatus = _useState12[0],
      setTestStatus = _useState12[1];

  var _useState13 = useState(''),
      _useState14 = _slicedToArray(_useState13, 2),
      accountKeyValue = _useState14[0],
      setAccountKeyValue = _useState14[1];

  var _useState15 = useState([]),
      _useState16 = _slicedToArray(_useState15, 2),
      relatedJobOpts = _useState16[0],
      setRelatedJobOpts = _useState16[1];

  var _useState17 = useState(false),
      _useState18 = _slicedToArray(_useState17, 2),
      isProjectOwner = _useState18[0],
      setIsProjectOwner = _useState18[1];

  var _useState19 = useState(undefined),
      _useState20 = _slicedToArray(_useState19, 2),
      pipelineCallbackAddress = _useState20[0],
      setPipelineCallbackAddress = _useState20[1];

  useEffect(function () {
    ADDCDTaskUseStore.setValueIdRandom(Math.random());
    axios.get("/iam/choerodon/v1/projects/".concat(projectId, "/check_admin_permission")).then(function (res) {
      setIsProjectOwner(res);
    });
    axios.get('/devops/v1/cd_pipeline/external_approval_task/callback_url').then(function (res) {
      setPipelineCallbackAddress(res);
    });
  }, []);
  useEffect(function () {
    var _ADDCDTaskDataSet$cur, _concat;

    var currentHostDeployType = ADDCDTaskDataSet === null || ADDCDTaskDataSet === void 0 ? void 0 : (_ADDCDTaskDataSet$cur = ADDCDTaskDataSet.current) === null || _ADDCDTaskDataSet$cur === void 0 ? void 0 : _ADDCDTaskDataSet$cur.get('hostDeployType');
    var tempArr = pipelineStageMainSource && pipelineStageMainSource.length > 0 && pipelineStageMainSource.map(function (item) {
      return item === null || item === void 0 ? void 0 : item.jobList.slice();
    });
    var jobArr = tempArr ? tempArr.length > 0 && (_concat = [].concat).apply.apply(_concat, _toConsumableArray(tempArr)) : [];
    var filterArr;

    if (jobArr && currentHostDeployType && currentHostDeployType === 'image') {
      filterArr = jobArr.filter(function (x) {
        var _x$configJobTypes;

        return ((_x$configJobTypes = x.configJobTypes) === null || _x$configJobTypes === void 0 ? void 0 : _x$configJobTypes.includes('docker')) && x.type === 'build';
      });
    } else if (currentHostDeployType === 'jar') {
      filterArr = jobArr.filter(function (x) {
        var _x$configJobTypes2, _x$configJobTypes3;

        return (((_x$configJobTypes2 = x.configJobTypes) === null || _x$configJobTypes2 === void 0 ? void 0 : _x$configJobTypes2.includes('maven_deploy')) || ((_x$configJobTypes3 = x.configJobTypes) === null || _x$configJobTypes3 === void 0 ? void 0 : _x$configJobTypes3.includes('upload_jar'))) && x.type === 'build';
      });
    }

    if (filterArr && filterArr.length === 1) {
      if (typeof filterArr[0] === 'object') {
        ADDCDTaskDataSet.current.set('pipelineTask', filterArr[0].name);
      }
    }

    if (filterArr && filterArr.length > 0) {
      setRelatedJobOpts(filterArr);
    } else {
      setRelatedJobOpts([]);
    }
  }, [ADDCDTaskDataSet === null || ADDCDTaskDataSet === void 0 ? void 0 : (_ADDCDTaskDataSet$cur2 = ADDCDTaskDataSet.current) === null || _ADDCDTaskDataSet$cur2 === void 0 ? void 0 : _ADDCDTaskDataSet$cur2.get('hostDeployType'), pipelineStageMainSource]);
  useEffect(function () {
    if (relatedJobOpts && relatedJobOpts.length === 1) {
      ADDCDTaskDataSet.current.set('pipelineTask', relatedJobOpts[0].name);
    } else {
      ADDCDTaskDataSet.current.init('pipelineTask');
    }
  }, [relatedJobOpts, ADDCDTaskDataSet === null || ADDCDTaskDataSet === void 0 ? void 0 : (_ADDCDTaskDataSet$cur3 = ADDCDTaskDataSet.current) === null || _ADDCDTaskDataSet$cur3 === void 0 ? void 0 : _ADDCDTaskDataSet$cur3.get('hostDeployType')]);
  /**
   * 这里是如果有关联构建任务 则默认选中该关联任务的匹配类型和触发分支
   * 并且将匹配类型禁用 然后设置触发分支可选项只能为该关联任务的触发分支
   */

  useEffect(function () {
    var _ADDCDTaskDataSet$cur4, _ADDCDTaskDataSet$cur5, _ADDCDTaskDataSet$cur6, _ADDCDTaskDataSet$cur7;

    var pipelineTask = ADDCDTaskDataSet === null || ADDCDTaskDataSet === void 0 ? void 0 : (_ADDCDTaskDataSet$cur4 = ADDCDTaskDataSet.current) === null || _ADDCDTaskDataSet$cur4 === void 0 ? void 0 : _ADDCDTaskDataSet$cur4.get('pipelineTask');
    var hostDeployType = ADDCDTaskDataSet === null || ADDCDTaskDataSet === void 0 ? void 0 : (_ADDCDTaskDataSet$cur5 = ADDCDTaskDataSet.current) === null || _ADDCDTaskDataSet$cur5 === void 0 ? void 0 : _ADDCDTaskDataSet$cur5.get('hostDeployType');
    var deploySource = ADDCDTaskDataSet === null || ADDCDTaskDataSet === void 0 ? void 0 : (_ADDCDTaskDataSet$cur6 = ADDCDTaskDataSet.current) === null || _ADDCDTaskDataSet$cur6 === void 0 ? void 0 : _ADDCDTaskDataSet$cur6.get('deploySource');
    var type = ADDCDTaskDataSet === null || ADDCDTaskDataSet === void 0 ? void 0 : (_ADDCDTaskDataSet$cur7 = ADDCDTaskDataSet.current) === null || _ADDCDTaskDataSet$cur7 === void 0 ? void 0 : _ADDCDTaskDataSet$cur7.get('type'); // 如果是主机部署并且部署模式是镜像部署或者jar包部署并且部署来源是流水线制品

    if (type === 'cdHost' && ['image', 'jar'].includes(hostDeployType) && deploySource === 'pipelineDeploy' && pipelineTask && relatedJobOpts && relatedJobOpts.length > 0) {
      var _relatedJobOpts$find = relatedJobOpts.find(function (i) {
        return i.name === pipelineTask;
      }),
          triggerType = _relatedJobOpts$find.triggerType,
          triggerValue = _relatedJobOpts$find.triggerValue;

      ADDCDTaskDataSet.current.set('triggerType', triggerType);
      ADDCDTaskDataSet.getField('triggerType').set('disabled', true);
      ADDCDTaskDataSet.current.set('triggerValue', triggerValue === null || triggerValue === void 0 ? void 0 : triggerValue.split(','));
      setBranchsList(triggerValue === null || triggerValue === void 0 ? void 0 : triggerValue.split(',').map(function (i) {
        return {
          value: i,
          name: i
        };
      }));
    } else {
      ADDCDTaskDataSet.getField('triggerType').set('disabled', false);
      setBranchsList(originBranchs); // ADDCDTaskDataSet.getField('triggerValue').set('disabled', false);
    }
  }, [ADDCDTaskDataSet === null || ADDCDTaskDataSet === void 0 ? void 0 : (_ADDCDTaskDataSet$cur8 = ADDCDTaskDataSet.current) === null || _ADDCDTaskDataSet$cur8 === void 0 ? void 0 : _ADDCDTaskDataSet$cur8.get('pipelineTask'), ADDCDTaskDataSet === null || ADDCDTaskDataSet === void 0 ? void 0 : (_ADDCDTaskDataSet$cur9 = ADDCDTaskDataSet.current) === null || _ADDCDTaskDataSet$cur9 === void 0 ? void 0 : _ADDCDTaskDataSet$cur9.get('type'), ADDCDTaskDataSet === null || ADDCDTaskDataSet === void 0 ? void 0 : (_ADDCDTaskDataSet$cur10 = ADDCDTaskDataSet.current) === null || _ADDCDTaskDataSet$cur10 === void 0 ? void 0 : _ADDCDTaskDataSet$cur10.get('hostDeployType'), ADDCDTaskDataSet === null || ADDCDTaskDataSet === void 0 ? void 0 : (_ADDCDTaskDataSet$cur11 = ADDCDTaskDataSet.current) === null || _ADDCDTaskDataSet$cur11 === void 0 ? void 0 : _ADDCDTaskDataSet$cur11.get('deploySource')]);

  function getMetadata(ds) {
    if (ds.type === 'cdDeploy') {
      ds.value = Base64.encode(valueIdValues); // 如果部署模式是新建 则删掉多余的实例id

      if (ds.deployType && ds.deployType === 'create') {
        delete ds.instanceId;
      } else {
        var _ADDCDTaskUseStore$ge, _ADDCDTaskUseStore$ge2;

        // 如果是替换 则除了传id 还需要传对应的name
        var instanceName = (_ADDCDTaskUseStore$ge = ADDCDTaskUseStore.getInstanceList) === null || _ADDCDTaskUseStore$ge === void 0 ? void 0 : (_ADDCDTaskUseStore$ge2 = _ADDCDTaskUseStore$ge.find(function (i) {
          return i.id === ds.instanceId;
        })) === null || _ADDCDTaskUseStore$ge2 === void 0 ? void 0 : _ADDCDTaskUseStore$ge2.code;
        ds.instanceName = instanceName;
      }
    }

    if (ds.type === addCDTaskDataSetMap.apiTest) {
      var _ds$warningSettingVO;

      ds.apiTestTaskName = ADDCDTaskUseStore.getApiTestArray.find(function (i) {
        return i.id == ADDCDTaskDataSet.current.get(addCDTaskDataSetMap.apiTestMission);
      }).name;
      ds[addCDTaskDataSetMap.relativeMission] = ADDCDTaskDataSet.current.get(addCDTaskDataSetMap.relativeMission);
      ds.warningSettingVO = (_ds$warningSettingVO = {}, _defineProperty(_ds$warningSettingVO, addCDTaskDataSetMap.whetherBlock, ds[addCDTaskDataSetMap.whetherBlock]), _defineProperty(_ds$warningSettingVO, addCDTaskDataSetMap.alarm, ds[addCDTaskDataSetMap.alarm]), _defineProperty(_ds$warningSettingVO, addCDTaskDataSetMap.threshold, ds[addCDTaskDataSetMap.threshold]), _defineProperty(_ds$warningSettingVO, addCDTaskDataSetMap.notifyObject, ds[addCDTaskDataSetMap.notifyObject]), _ds$warningSettingVO);

      if (ds[addCDTaskDataSetMap.notifyWay]) {
        ds[addCDTaskDataSetMap.notifyWay].split(',').forEach(function (item) {
          ds.warningSettingVO[item] = true;
        });
      }
    }

    if (ds.type === 'cdHost') {
      var _ds$hostConnectionVO;

      ds.hostConnectionVO = (_ds$hostConnectionVO = {}, _defineProperty(_ds$hostConnectionVO, addCDTaskDataSetMap.hostSource, ds[addCDTaskDataSetMap.hostSource]), _defineProperty(_ds$hostConnectionVO, addCDTaskDataSetMap.host, ds[addCDTaskDataSetMap.host]), _defineProperty(_ds$hostConnectionVO, "hostIp", ds.hostIp), _defineProperty(_ds$hostConnectionVO, "hostPort", ds.hostPort), _defineProperty(_ds$hostConnectionVO, "authType", ds.authType), _defineProperty(_ds$hostConnectionVO, "username", ds.username), _defineProperty(_ds$hostConnectionVO, "password", ds.authType === 'accountPassword' ? ds.password : accountKeyValue && Base64.encode(accountKeyValue)), _ds$hostConnectionVO);
      var currentObj = {
        deploySource: ds.deploySource
      };

      if (ds.hostDeployType === 'customize') {
        ds.customize = {
          values: Base64.encode(customValues)
        };
      } else if (ds.hostDeployType === 'image') {
        if (ds.deploySource === 'matchDeploy') {
          var _ADDCDTaskUseStore$ge3, _ADDCDTaskUseStore$ge4;

          var repo = (_ADDCDTaskUseStore$ge3 = ADDCDTaskUseStore.getRepoList) === null || _ADDCDTaskUseStore$ge3 === void 0 ? void 0 : _ADDCDTaskUseStore$ge3.find(function (i) {
            return String(i.repoId) === String(ds.repoId);
          });
          var img = (_ADDCDTaskUseStore$ge4 = ADDCDTaskUseStore.getImageList) === null || _ADDCDTaskUseStore$ge4 === void 0 ? void 0 : _ADDCDTaskUseStore$ge4.find(function (i) {
            return String(i.imageId) === String(ds.imageId);
          });
          ds.imageDeploy = _objectSpread(_objectSpread({}, currentObj), {}, {
            repoId: ds.repoId,
            repoName: repo === null || repo === void 0 ? void 0 : repo.repoName,
            repoType: repo === null || repo === void 0 ? void 0 : repo.repoType,
            imageId: ds.imageId,
            imageName: img === null || img === void 0 ? void 0 : img.imageName,
            matchType: ds.matchType,
            matchContent: ds.matchContent,
            containerName: ds.containerName,
            value: Base64.encode(imageDeployValues)
          });
        } else if (ds.deploySource === 'pipelineDeploy') {
          ds.imageDeploy = _objectSpread(_objectSpread({}, currentObj), {}, {
            pipelineTask: ds.pipelineTask,
            containerName: ds.containerName,
            value: Base64.encode(imageDeployValues)
          });
        }
      } else if (ds.hostDeployType === 'jar') {
        if (ds.deploySource === 'matchDeploy') {
          ds.jarDeploy = _objectSpread(_objectSpread({}, currentObj), {}, {
            serverName: ds.serverName,
            repositoryId: ds.repositoryId,
            groupId: ds.groupId,
            artifactId: ds.artifactId,
            versionRegular: ds.versionRegular,
            value: Base64.encode(jarValues)
          });
        } else if (ds.deploySource === 'pipelineDeploy') {
          ds.jarDeploy = _objectSpread(_objectSpread({}, currentObj), {}, {
            pipelineTask: ds.pipelineTask,
            value: Base64.encode(jarValues)
          });
        }

        ds.jarDeploy.workingPath = ds.workingPath;
      }
    }

    ds.appServiceId = PipelineCreateFormDataSet.current.get('appServiceId');
    return JSON.stringify(ds).replace(/"/g, "'");
  }

  var handleAdd = /*#__PURE__*/function () {
    var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
      var result, _ds$triggerValue, ds, cdAuditUserIds, data;

      return regeneratorRuntime.wrap(function _callee$(_context) {
        while (1) {
          switch (_context.prev = _context.next) {
            case 0:
              _context.next = 2;
              return ADDCDTaskDataSet.current.validate(true);

            case 2:
              result = _context.sent;

              if (!result) {
                _context.next = 15;
                break;
              }

              ds = JSON.parse(JSON.stringify(ADDCDTaskDataSet.toData()[0]));

              if (!(ds.type === 'cdHost')) {
                _context.next = 10;
                break;
              }

              _context.next = 8;
              return handleTestConnect();

            case 8:
              if (_context.sent) {
                _context.next = 10;
                break;
              }

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

            case 10:
              cdAuditUserIds = ds.cdAuditUserIds.map(function (x) {
                return typeof x === 'object' ? x.id : x;
              });
              data = _objectSpread(_objectSpread({}, ds), {}, {
                cdAuditUserIds: cdAuditUserIds,
                triggerValue: typeof ds.triggerValue === 'object' ? (_ds$triggerValue = ds.triggerValue) === null || _ds$triggerValue === void 0 ? void 0 : _ds$triggerValue.join(',') : ds.triggerValue
              });

              if (ds.type !== 'cdAudit') {
                data.metadata = getMetadata(ds);
              }

              handleOk(data);
              return _context.abrupt("return", true);

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

            case 16:
            case "end":
              return _context.stop();
          }
        }
      }, _callee);
    }));

    return function handleAdd() {
      return _ref.apply(this, arguments);
    };
  }();

  modal.handleOk(handleAdd);
  useEffect(function () {
    if (jobDetail) {
      var _jobDetail$triggerVal;

      var newCdAuditUserIds = jobDetail === null || jobDetail === void 0 ? void 0 : jobDetail.cdAuditUserIds;
      var extra = {};

      if (jobDetail.type === 'cdDeploy') {
        var _JSON$parse = JSON.parse(jobDetail.metadata.replace(/'/g, '"')),
            value = _JSON$parse.value;

        value && setValueIdValues(Base64.decode(value));
      } else if (jobDetail.type === addCDTaskDataSetMap.apiTest) {
        if (jobDetail.metadata) {
          var metadata = JSONbig.parse(jobDetail.metadata.replace(/'/g, '"'));
          extra[addCDTaskDataSetMap.relativeMission] = metadata[addCDTaskDataSetMap.relativeMission];

          if (metadata.warningSettingVO) {
            Object.keys(metadata.warningSettingVO).forEach(function (item) {
              extra[item] = metadata.warningSettingVO[item];
            });
            extra[addCDTaskDataSetMap.notifyWay] = [];

            if (metadata.warningSettingVO.sendEmail) {
              extra[addCDTaskDataSetMap.notifyWay].push('sendEmail');
            }

            if (metadata.warningSettingVO.sendSiteMessage) {
              extra[addCDTaskDataSetMap.notifyWay].push('sendSiteMessage');
            }

            extra[addCDTaskDataSetMap.notifyWay] = extra[addCDTaskDataSetMap.notifyWay].join(',');
          }
        }
      } else if (jobDetail.type === 'cdHost') {
        var _extra;

        var _metadata = JSONbig.parse(jobDetail.metadata.replace(/'/g, '"'));

        extra = _objectSpread(_objectSpread(_objectSpread({}, _metadata === null || _metadata === void 0 ? void 0 : _metadata.hostConnectionVO), _metadata === null || _metadata === void 0 ? void 0 : _metadata.jarDeploy), _metadata === null || _metadata === void 0 ? void 0 : _metadata.imageDeploy); // 如果初始值没有主机来源值 说明是老数据 前端默认将主机来源设置成自定义

        if (!extra[addCDTaskDataSetMap.hostSource]) {
          extra[addCDTaskDataSetMap.hostSource] = addCDTaskDataSetMap.customhost;
        }

        if (((_extra = extra) === null || _extra === void 0 ? void 0 : _extra.authType) === 'accountKey') {
          setAccountKeyValue(Base64.decode(extra.password));
        }

        var hostDeployType = _metadata.hostDeployType;

        if (hostDeployType === 'customize') {
          var _metadata$customize;

          setCustomValues(Base64.decode((_metadata$customize = _metadata.customize) === null || _metadata$customize === void 0 ? void 0 : _metadata$customize.values));
        } else if (hostDeployType === 'image') {
          setImageDeployValues(Base64.decode(_metadata.imageDeploy.value));
        } else if (hostDeployType === 'jar') {
          setJarValues(Base64.decode(_metadata.jarDeploy.value));
        }
      } else if (jobDetail.type === 'cdAudit') {
        if (jobDetail.metadata) {
          var _JSON$parse2 = JSON.parse(jobDetail.metadata.replace(/'/g, '"')),
              cdAuditUserIds = _JSON$parse2.cdAuditUserIds;

          newCdAuditUserIds = cdAuditUserIds && _toConsumableArray(cdAuditUserIds);
        }
      }

      var newJobDetail = _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, jobDetail), extra), jobDetail.metadata ? JSONbig.parse(jobDetail.metadata.replace(/'/g, '"')) : {}), {}, {
        cdAuditUserIds: newCdAuditUserIds && _toConsumableArray(newCdAuditUserIds),
        triggerValue: jobDetail.triggerType === 'regex' ? jobDetail.triggerValue : (_jobDetail$triggerVal = jobDetail.triggerValue) === null || _jobDetail$triggerVal === void 0 ? void 0 : _jobDetail$triggerVal.split(',')
      });

      delete newJobDetail.metadata;
      ADDCDTaskDataSet.loadData([newJobDetail]);
    }

    ADDCDTaskDataSet.current.set('glyyfw', appServiceId || PipelineCreateFormDataSet.getField('appServiceId').getText(PipelineCreateFormDataSet.current.get('appServiceId')));
    handleClickMore();
  }, [ADDCDTaskDataSet, PipelineCreateFormDataSet, appServiceId, jobDetail]);
  useEffect(function () {
    function initBranchs() {
      return _initBranchs.apply(this, arguments);
    }

    function _initBranchs() {
      _initBranchs = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {
        var value;
        return regeneratorRuntime.wrap(function _callee2$(_context2) {
          while (1) {
            switch (_context2.prev = _context2.next) {
              case 0:
                value = ADDCDTaskDataSet.current.get('triggerType');

                if (value && !value.includes('exact')) {
                  setBranchsList(originBranchs);
                } else {
                  getBranchsList();
                }

              case 2:
              case "end":
                return _context2.stop();
            }
          }
        }, _callee2);
      }));
      return _initBranchs.apply(this, arguments);
    }

    initBranchs();
  }, [currentSize, ADDCDTaskDataSet.current.get('triggerType')]);

  var getTestDom = function getTestDom() {
    var res = {
      loading: /*#__PURE__*/React.createElement("div", {
        className: "testConnectCD"
      }, "\u6B63\u5728\u8FDB\u884C\u8FDE\u63A5\u6D4B\u8BD5", /*#__PURE__*/React.createElement(_Spin, null)),
      success: /*#__PURE__*/React.createElement("div", {
        style: {
          background: 'rgba(0,191,165,0.04)',
          borderColor: 'rgba(0,191,165,1)'
        },
        className: "testConnectCD"
      }, /*#__PURE__*/React.createElement("span", {
        style: {
          color: '#3A345F'
        }
      }, "\u6D4B\u8BD5\u8FDE\u63A5\uFF1A"), /*#__PURE__*/React.createElement("span", {
        style: {
          color: '#00BFA5'
        }
      }, /*#__PURE__*/React.createElement(_Icon, {
        style: {
          border: '1px solid rgb(0, 191, 165)',
          borderRadius: '50%',
          marginRight: 2,
          fontSize: '9px'
        },
        type: "done"
      }), "\u6210\u529F")),
      error: /*#__PURE__*/React.createElement("div", {
        style: {
          background: 'rgba(247,122,112,0.04)',
          borderColor: 'rgba(247,122,112,1)'
        },
        className: "testConnectCD"
      }, /*#__PURE__*/React.createElement("span", {
        style: {
          color: '#3A345F'
        }
      }, "\u6D4B\u8BD5\u8FDE\u63A5\uFF1A"), /*#__PURE__*/React.createElement("span", {
        style: {
          color: '#F77A70'
        }
      }, /*#__PURE__*/React.createElement(_Icon, {
        style: {
          border: '1px solid #F77A70',
          borderRadius: '50%',
          marginRight: 2,
          fontSize: '9px'
        },
        type: "close"
      }), "\u5931\u8D25"))
    };
    return res[testStatus];
  };

  var handleTestConnect = /*#__PURE__*/function () {
    var _ref2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3() {
      return regeneratorRuntime.wrap(function _callee3$(_context3) {
        while (1) {
          switch (_context3.prev = _context3.next) {
            case 0:
              return _context3.abrupt("return", new Promise(function (resolve) {
                var _ADDCDTaskDataSet$toD = ADDCDTaskDataSet.toData()[0],
                    hostIp = _ADDCDTaskDataSet$toD.hostIp,
                    hostPort = _ADDCDTaskDataSet$toD.hostPort,
                    username = _ADDCDTaskDataSet$toD.username,
                    password = _ADDCDTaskDataSet$toD.password,
                    authType = _ADDCDTaskDataSet$toD.authType,
                    host = _ADDCDTaskDataSet$toD[addCDTaskDataSetMap.host];
                axios.post(ADDCDTaskDataSet.current.get(addCDTaskDataSetMap.hostSource) === addCDTaskDataSetMap.alreadyhost ? "/devops/v1/projects/".concat(projectId, "/hosts/connection_test_by_id?host_id=").concat(host) : "/devops/v1/projects/".concat(projectId, "/cicd_pipelines/test_connection"), {
                  hostIp: hostIp,
                  hostPort: hostPort,
                  username: username,
                  password: authType === 'accountPassword' ? password : accountKeyValue && Base64.encode(accountKeyValue),
                  authType: authType
                }).then(function (res) {
                  setTestStatus(res ? 'success' : 'error');
                  resolve(res);
                })["catch"](function () {
                  setTestStatus('error');
                  resolve(false);
                });
              }));

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

    return function handleTestConnect() {
      return _ref2.apply(this, arguments);
    };
  }(); // const renderRelatedJobOpts = () => {
  //   const currentHostDeployType = ADDCDTaskDataSet?.current?.get(
  //     'hostDeployType'
  //   );
  //   const tempArr = pipelineStageMainSource
  //     && pipelineStageMainSource.length > 0
  //     && pipelineStageMainSource.map((item) => item?.jobList.slice());
  //   const jobArr = tempArr
  //     ? tempArr.length > 0 && [].concat.apply(...tempArr)
  //     : [];
  //   let filterArr;
  //   if (jobArr && currentHostDeployType && currentHostDeployType === 'image') {
  //     filterArr = jobArr.filter(
  //       (x) => x.configJobTypes?.includes('docker') && x.type === 'build',
  //     );
  //   } else if (currentHostDeployType === 'jar') {
  //     filterArr = jobArr.filter(
  //       (x) => (x.configJobTypes?.includes('maven_deploy')
  //           || x.configJobTypes?.includes('upload_jar'))
  //         && x.type === 'build',
  //     );
  //   }
  //   if (filterArr && filterArr.length > 0) {
  //     if (typeof filterArr[0] === 'object') {
  //       ADDCDTaskDataSet.current.set('pipelineTask', filterArr[0].name);
  //     }
  //   }
  //   return (
  //     filterArr
  //     && filterArr.length > 0
  //     && filterArr.map((item) => <Option value={item.name}>{item.name}</Option>)
  //   );
  // };


  function searchMatcher(_ref3) {
    var _record$get;

    var record = _ref3.record,
        text = _ref3.text;
    return ((_record$get = record.get('pipelineTask')) === null || _record$get === void 0 ? void 0 : _record$get.indexOf(text)) !== -1;
  }

  var handleClickCreateValue = function handleClickCreateValue(e) {
    e.preventDefault();
    e.stopPropagation();

    _Modal.open({
      key: _Modal.key(),
      drawer: true,
      style: {
        width: '740px'
      },
      children: /*#__PURE__*/React.createElement(DeployConfig, {
        envId: ADDCDTaskDataSet.current.get('envId'),
        appServiceId: PipelineCreateFormDataSet.current.get('appServiceId'),
        appServiceName: appServiceId,
        refresh: function refresh(_ref4) {
          var valueId = _ref4.valueId,
              value = _ref4.value;
          ADDCDTaskUseStore.setValueIdRandom(Math.random());
          ADDCDTaskDataSet.current.set('valueId', valueId); // const origin = ADDCDTaskUseStore.getValueIdList;

          setValueIdValues(value);
        }
      }),
      title: '创建部署配置'
    });
  };

  var rendererValueId = function rendererValueId(_ref5) {
    var value = _ref5.value,
        text = _ref5.text,
        record = _ref5.record;
    return text === '创建部署配置' ? /*#__PURE__*/React.createElement("a", {
      style: {
        width: 'calc(100% + 0.24rem)',
        display: 'inline-block',
        position: 'relative',
        right: '0.12rem'
      },
      role: "none",
      onClick: function onClick(e) {
        return handleClickCreateValue(e);
      }
    }, /*#__PURE__*/React.createElement("span", {
      style: {
        marginLeft: '0.12rem'
      }
    }, text)) : text;
  };

  var optionRenderValueId = function optionRenderValueId(_ref6) {
    var value = _ref6.value,
        text = _ref6.text,
        record = _ref6.record;
    return rendererValueId({
      text: text
    });
  };

  var renderHostSetting = function renderHostSetting() {
    var _ADDCDTaskDataSet$cur12;

    var value = ADDCDTaskDataSet.current.get(addCDTaskDataSetMap.hostSource);

    if (value === addCDTaskDataSetMap.alreadyhost) {
      return [/*#__PURE__*/React.createElement("div", {
        colSpan: 2,
        style: {
          display: 'flex',
          alignItems: 'flex-start',
          justifyContent: 'space-between',
          position: 'relative'
        },
        newLine: true
      }, /*#__PURE__*/React.createElement(_Select, {
        style: {
          flex: 1
        },
        name: addCDTaskDataSetMap.host,
        onChange: function onChange(value2) {
          var item = ADDCDTaskUseStore.getHostList.find(function (i) {
            return i.id == value2;
          });
          ADDCDTaskDataSet.current.set('hostIp', item.hostIp);
          ADDCDTaskDataSet.current.set('hostPort', item.sshPort);
        }
      }), /*#__PURE__*/React.createElement("div", {
        style: {
          flex: 1,
          marginLeft: 16
        }
      }, /*#__PURE__*/React.createElement(_TextField, {
        style: {
          width: '100%'
        },
        name: "hostIp"
      })), /*#__PURE__*/React.createElement("div", {
        style: {
          flex: 1,
          marginLeft: 16
        }
      }, /*#__PURE__*/React.createElement(_TextField, {
        style: {
          width: '100%'
        },
        name: "hostPort"
      })))];
    }

    return [/*#__PURE__*/React.createElement(_TextField, {
      newLine: true,
      colSpan: 1,
      name: "hostIp"
    }), /*#__PURE__*/React.createElement(_TextField, {
      colSpan: 1,
      name: "hostPort"
    }), /*#__PURE__*/React.createElement(_SelectBox, {
      colSpan: 1,
      name: "authType",
      className: "addcdTask-mode"
    }, /*#__PURE__*/React.createElement(Option, {
      value: "accountPassword"
    }, "\u7528\u6237\u540D\u4E0E\u5BC6\u7801"), /*#__PURE__*/React.createElement(Option, {
      value: "accountKey"
    }, "\u7528\u6237\u540D\u4E0E\u5BC6\u94A5")), /*#__PURE__*/React.createElement(_TextField, {
      colSpan: 1,
      newLine: true,
      name: "username"
    }), (ADDCDTaskDataSet === null || ADDCDTaskDataSet === void 0 ? void 0 : (_ADDCDTaskDataSet$cur12 = ADDCDTaskDataSet.current) === null || _ADDCDTaskDataSet$cur12 === void 0 ? void 0 : _ADDCDTaskDataSet$cur12.get('authType')) === 'accountPassword' ? /*#__PURE__*/React.createElement(_Password, {
      colSpan: 1,
      name: "password"
    }) : [/*#__PURE__*/React.createElement("p", {
      newLine: true,
      colSpan: 1,
      className: "addcdTask-accountKeyP"
    }, "\u5BC6\u94A5"), /*#__PURE__*/React.createElement(YamlEditor, {
      colSpan: 2,
      newLine: true,
      readOnly: false,
      value: accountKeyValue,
      modeChange: false,
      onValueChange: function onValueChange(data) {
        return setAccountKeyValue(data);
      }
    })]];
  };
  /**
   * 修改配置信息事件
   */


  var handleChangeValueIdValues = function handleChangeValueIdValues() {
    var tempValues = valueIdValues;
    var item = ADDCDTaskUseStore.getValueIdList.find(function (i) {
      return String(i.id) === String(ADDCDTaskDataSet.current.get('valueId'));
    });

    _Modal.open({
      key: _Modal.key(),
      drawer: true,
      title: "\u4FEE\u6539\u90E8\u7F72\u914D\u7F6E\"".concat((item === null || item === void 0 ? void 0 : item.name) || '', "\"\u7684\u914D\u7F6E\u4FE1\u606F"),
      children: /*#__PURE__*/React.createElement("div", {
        style: {
          maxHeight: 500
        }
      }, /*#__PURE__*/React.createElement(YamlEditor, {
        colSpan: 3,
        newLine: true,
        readOnly: false,
        className: "addcdTask-yamleditor",
        onValueChange: function onValueChange(data) {
          tempValues = data;
        },
        value: tempValues
      })),
      style: {
        width: '740px'
      },
      okText: '修改',
      onOk: function () {
        var _onOk = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee4() {
          return regeneratorRuntime.wrap(function _callee4$(_context4) {
            while (1) {
              switch (_context4.prev = _context4.next) {
                case 0:
                  _context4.next = 2;
                  return axios.post("/devops/v1/projects/".concat(projectId, "/deploy_value"), _objectSpread(_objectSpread({}, ADDCDTaskUseStore.getValueIdList.find(function (i) {
                    return String(i.id) === String(ADDCDTaskDataSet.current.get('valueId'));
                  })), {}, {
                    value: tempValues
                  }));

                case 2:
                  ADDCDTaskUseStore.setValueIdRandom(Math.random());
                  setValueIdValues(tempValues);

                case 4:
                case "end":
                  return _context4.stop();
              }
            }
          }, _callee4);
        }));

        function onOk() {
          return _onOk.apply(this, arguments);
        }

        return onOk;
      }(),
      onCancel: function onCancel() {}
    });
  };

  var getOtherConfig = function getOtherConfig() {
    var _ADDCDTaskDataSet$cur15;

    function getModeDom() {
      var _ADDCDTaskDataSet$cur13, _ADDCDTaskDataSet$cur14;

      var currentDepoySource = ADDCDTaskDataSet === null || ADDCDTaskDataSet === void 0 ? void 0 : (_ADDCDTaskDataSet$cur13 = ADDCDTaskDataSet.current) === null || _ADDCDTaskDataSet$cur13 === void 0 ? void 0 : _ADDCDTaskDataSet$cur13.get('deploySource');
      var result = {
        customize: /*#__PURE__*/React.createElement(YamlEditor, {
          colSpan: 6,
          newLine: true,
          className: "addcdTask-yamleditor",
          readOnly: false,
          value: customValues,
          onValueChange: function onValueChange(data) {
            return setCustomValues(data);
          }
        }),
        image: [/*#__PURE__*/React.createElement(_Select, {
          newLine: true,
          colSpan: 3,
          name: "deploySource",
          clearButton: false,
          addonAfter: /*#__PURE__*/React.createElement(Tips, {
            helpText: "\u6D41\u6C34\u7EBF\u5236\u54C1\u90E8\u7F72\u8868\u793A\u76F4\u63A5\u4F7F\u7528\u6240\u9009\u5173\u8054\u6784\u5EFA\u4EFB\u52A1\u4E2D\u4EA7\u751F\u7684\u955C\u50CF\u8FDB\u884C\u90E8\u7F72\uFF1B\u5339\u914D\u5236\u54C1\u90E8\u7F72\u5219\u8868\u793A\u53EF\u81EA\u4E3B\u9009\u62E9\u9879\u76EE\u955C\u50CF\u4ED3\u5E93\u4E2D\u7684\u955C\u50CF\uFF0C\u5E76\u914D\u7F6E\u955C\u50CF\u7248\u672C\u7684\u5339\u914D\u89C4\u5219\uFF0C\u540E\u7EED\u90E8\u7F72\u7684\u955C\u50CF\u7248\u672C\u4FBF\u4F1A\u9075\u5FAA\u6B64\u89C4\u5219\u3002"
          })
        }, /*#__PURE__*/React.createElement(Option, {
          value: "pipelineDeploy"
        }, "\u6D41\u6C34\u7EBF\u5236\u54C1\u90E8\u7F72"), /*#__PURE__*/React.createElement(Option, {
          value: "matchDeploy"
        }, "\u5339\u914D\u5236\u54C1\u90E8\u7F72")), currentDepoySource === 'pipelineDeploy' && /*#__PURE__*/React.createElement(_Select, {
          colSpan: 3,
          name: "pipelineTask",
          searchable: true,
          addonAfter: /*#__PURE__*/React.createElement(Tips, {
            helpText: "\u6B64\u5904\u7684\u5173\u8054\u6784\u5EFA\u4EFB\u52A1\uFF0C\u4EC5\u4F1A\u67E5\u8BE2\u51FA\u8BE5\u6761\u6D41\u6C34\u7EBF\u4E2D\u5B58\u5728'Docker\u6784\u5EFA'\u6B65\u9AA4\u7684\u201C\u6784\u5EFA\u7C7B\u578B\u201D\u4EFB\u52A1\u3002\u82E5\u6240\u9009\u4EFB\u52A1\u4E2D\u5B58\u5728\u591A\u4E2A\u201CDocker\u6784\u5EFA\u201D\u6B65\u9AA4\uFF0C\u5219\u53EA\u4F1A\u90E8\u7F72\u7B2C\u4E00\u4E2A\u201CDocker\u6784\u5EFA\u201D\u6B65\u9AA4\u4EA7\u751F\u7684\u955C\u50CF"
          }),
          searchMatcher: searchMatcher
        }, relatedJobOpts.map(function (item) {
          return /*#__PURE__*/React.createElement(Option, {
            value: item.name
          }, item.name);
        })), currentDepoySource === 'matchDeploy' && /*#__PURE__*/React.createElement(_Select, {
          colSpan: 3,
          name: "repoId"
        }), currentDepoySource === 'matchDeploy' && /*#__PURE__*/React.createElement(_Select, {
          colSpan: 3,
          name: "imageId"
        }), currentDepoySource === 'matchDeploy' && /*#__PURE__*/React.createElement(_Select, {
          colSpan: 3,
          name: "matchType"
        }, /*#__PURE__*/React.createElement(Option, {
          value: "refs"
        }, "\u6A21\u7CCA\u5339\u914D"), /*#__PURE__*/React.createElement(Option, {
          value: "regex"
        }, "\u6B63\u5219\u5339\u914D"), /*#__PURE__*/React.createElement(Option, {
          value: "exact_match"
        }, "\u7CBE\u786E\u5339\u914D"), /*#__PURE__*/React.createElement(Option, {
          value: "exact_exclude"
        }, "\u7CBE\u786E\u6392\u9664")), currentDepoySource === 'matchDeploy' && /*#__PURE__*/React.createElement(_TextField, {
          colSpan: 3,
          name: "matchContent"
        }), /*#__PURE__*/React.createElement(_TextField, {
          colSpan: 3,
          name: "containerName"
        }), /*#__PURE__*/React.createElement(YamlEditor, {
          colSpan: 6,
          className: "addcdTask-yamleditor",
          newLine: true,
          readOnly: false,
          value: imageDeployValues,
          onValueChange: function onValueChange(data) {
            return setImageDeployValues(data);
          }
        })],
        jar: [/*#__PURE__*/React.createElement(_Select, {
          newLine: true,
          colSpan: 3,
          name: "deploySource",
          clearButton: false,
          addonAfter: /*#__PURE__*/React.createElement(Tips, {
            helpText: "\u6D41\u6C34\u7EBF\u5236\u54C1\u90E8\u7F72\u8868\u793A\u76F4\u63A5\u4F7F\u7528\u6240\u9009\u5173\u8054\u6784\u5EFA\u4EFB\u52A1\u4E2D\u751F\u6210\u7684jar\u5305\u8FDB\u884C\u90E8\u7F72\uFF1B\u5339\u914D\u5236\u54C1\u90E8\u7F72\u5219\u8868\u793A\u53EF\u81EA\u4E3B\u9009\u62E9\u9879\u76EE\u4E0B\u5236\u54C1\u5E93\u4E2D\u7684jar\u5305\uFF0C\u5E76\u9700\u914D\u7F6Ejar\u5305\u7248\u672C\u7684\u6B63\u5219\u5339\u914D\u89C4\u5219\uFF0C\u540E\u7EED\u90E8\u7F72\u7684jar\u5305\u7248\u672C\u4FBF\u4F1A\u9075\u5FAA\u6B64\u89C4\u5219\u3002"
          })
        }, /*#__PURE__*/React.createElement(Option, {
          value: "pipelineDeploy"
        }, "\u6D41\u6C34\u7EBF\u5236\u54C1\u90E8\u7F72"), /*#__PURE__*/React.createElement(Option, {
          value: "matchDeploy"
        }, "\u5339\u914D\u5236\u54C1\u90E8\u7F72")), currentDepoySource === 'pipelineDeploy' && /*#__PURE__*/React.createElement(_Select, {
          colSpan: 3,
          name: "pipelineTask",
          searchable: true,
          addonAfter: /*#__PURE__*/React.createElement(Tips, {
            helpText: "\u6B64\u5904\u7684\u5173\u8054\u6784\u5EFA\u4EFB\u52A1\uFF0C\u4EC5\u4F1A\u67E5\u8BE2\u51FA\u8BE5\u6761\u6D41\u6C34\u7EBF\u4E2D\u5B58\u5728'\u4E0A\u4F20jar\u5305\u81F3\u5236\u54C1\u5E93'\u6216\u201CMaven\u53D1\u5E03\u201D\u6B65\u9AA4\u7684\u201C\u6784\u5EFA\u7C7B\u578B\u201D\u4EFB\u52A1\u3002\u82E5\u6240\u9009\u4EFB\u52A1\u4E2D\u5B58\u5728\u591A\u4E2A\u6EE1\u8DB3\u6761\u4EF6\u7684\u6B65\u9AA4\uFF0C\u5219\u53EA\u4F1A\u90E8\u7F72\u6240\u9009\u4EFB\u52A1\u4E2D\u7B2C\u4E00\u4E2A\u6EE1\u8DB3\u6761\u4EF6\u7684\u6B65\u9AA4\u4EA7\u751F\u7684jar\u5305\uFF1B"
          }),
          searchMatcher: searchMatcher
        }, relatedJobOpts.map(function (item) {
          return /*#__PURE__*/React.createElement(Option, {
            value: item.name
          }, item.name);
        })), currentDepoySource === 'matchDeploy' && /*#__PURE__*/React.createElement(_Select, {
          colSpan: 3,
          name: "serverName"
        }), currentDepoySource === 'matchDeploy' && /*#__PURE__*/React.createElement(_Select, {
          colSpan: 3,
          name: "repositoryId"
        }), currentDepoySource === 'matchDeploy' && /*#__PURE__*/React.createElement(_Select, {
          colSpan: 3,
          name: "groupId"
        }), currentDepoySource === 'matchDeploy' && /*#__PURE__*/React.createElement(_Select, {
          colSpan: 3,
          name: "artifactId"
        }), currentDepoySource === 'matchDeploy' && /*#__PURE__*/React.createElement(_TextField, {
          colSpan: 6,
          name: "versionRegular",
          addonAfter: /*#__PURE__*/React.createElement(Tips, {
            helpText: "\u6B63\u5219\u8868\u8FBE\u5F0F\u5339\u914D\u7248\u672C\u540D\uFF0C\u9ED8\u8BA4\u503C^*master*$\uFF0C\u53C2\u8003demo\u5982\u4E0B\uFF1A^*master*$:\u6A21\u7CCA\u5339\u914D\u7248\u672C\u540D\u5305\u542Bmaster\uFF0C^hotfix-0.21.1$\uFF1A\u7CBE\u786E\u5339\u914D\u7248\u672C\u540D\u4E3Ahotfix-0.21.1"
          })
        }), /*#__PURE__*/React.createElement(_TextField, {
          addonAfter: /*#__PURE__*/React.createElement(Tips, {
            helpText: /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("p", {
              style: {
                margin: 0
              }
            }, "\u9ED8\u8BA4\u5DE5\u4F5C\u76EE\u5F55\uFF0C\u5F53\u524D\u5DE5\u4F5C\u76EE\u5F55(./)\uFF0Cjar\u5305\u4E0B\u8F7D\u5B58\u653E\u76EE\u5F55\u4E3A\uFF1A./temp-jar/xxx.jar \u65E5\u5FD7\u5B58\u653E\u76EE\u5F55\u4E3A\uFF1A./temp-log/xxx.log"), /*#__PURE__*/React.createElement("p", {
              style: {
                margin: 0
              }
            }, "\u586B\u5199\u5DE5\u4F5C\u76EE\u5F55\uFF0Cjar\u5305\u4E0B\u8F7D\u5B58\u653E\u76EE\u5F55\u4E3A\uFF1A\u5DE5\u4F5C\u76EE\u5F55/temp-jar/xxx.jar \u65E5\u5FD7\u5B58\u653E\u76EE\u5F55\u4E3A\uFF1A\u5DE5\u4F5C\u76EE\u5F55/temp-jar/xxx.log"))
          }),
          colSpan: 3,
          name: "workingPath"
        }), /*#__PURE__*/React.createElement(YamlEditor, {
          colSpan: 6,
          newLine: true,
          className: "addcdTask-yamleditor",
          readOnly: false,
          value: jarValues,
          onValueChange: function onValueChange(data) {
            return setJarValues(data);
          }
        })]
      };
      return result[ADDCDTaskDataSet === null || ADDCDTaskDataSet === void 0 ? void 0 : (_ADDCDTaskDataSet$cur14 = ADDCDTaskDataSet.current) === null || _ADDCDTaskDataSet$cur14 === void 0 ? void 0 : _ADDCDTaskDataSet$cur14.get('hostDeployType')];
    }

    var obj = _defineProperty({
      cdDeploy: [/*#__PURE__*/React.createElement("div", {
        className: "addcdTask-divided"
      }), /*#__PURE__*/React.createElement("p", {
        className: "addcdTask-title"
      }, "\u914D\u7F6E\u4FE1\u606F"), /*#__PURE__*/React.createElement(_Form, {
        className: "addcdTask-form2",
        columns: 3,
        dataSet: ADDCDTaskDataSet
      }, /*#__PURE__*/React.createElement(_Select, {
        colSpan: 2,
        name: "valueId",
        onChange: function onChange(data) {
          var origin = ADDCDTaskUseStore.getValueIdList;
          setValueIdValues(origin.find(function (i) {
            return i.id === data;
          }).value);
        },
        optionRenderer: optionRenderValueId,
        renderer: rendererValueId,
        className: "addCdTask-form2-valueId"
      }), /*#__PURE__*/React.createElement("div", {
        newLine: true,
        colSpan: 3
      }, /*#__PURE__*/React.createElement(_Icon, {
        style: {
          color: 'rgb(244, 67, 54)'
        },
        type: "error"
      }), /*#__PURE__*/React.createElement("span", {
        style: {
          fontSize: '12px',
          fontFamily: 'PingFangSC-Regular, PingFang SC',
          fontWeight: 400,
          color: 'var(--text-color3)',
          lineHeight: '20px'
        }
      }, "\u4FEE\u6539\u914D\u7F6E\u4FE1\u606F\u540E\uFF0C\u6240\u9009\u7684\u90E8\u7F72\u914D\u7F6E\u4E2D\u7684\u914D\u7F6E\u4FE1\u606F\u4E5F\u5C06\u968F\u4E4B\u6539\u52A8\u3002"), /*#__PURE__*/React.createElement(_Button, {
        funcType: "flat",
        color: "blue",
        icon: "edit-o",
        onClick: handleChangeValueIdValues,
        disabled: !ADDCDTaskDataSet.current.get('valueId')
      }, "\u4FEE\u6539\u914D\u7F6E\u4FE1\u606F")), /*#__PURE__*/React.createElement(YamlEditor, {
        colSpan: 3,
        newLine: true,
        readOnly: true,
        className: "addcdTask-yamleditor" // onValueChange={(data) => {
        //   setValueIdValues(data);
        // }}
        ,
        value: valueIdValues
      }))],
      cdHost: [/*#__PURE__*/React.createElement("div", {
        className: "addcdTask-divided"
      }), /*#__PURE__*/React.createElement("p", {
        className: "addcdTask-title"
      }, "\u4E3B\u673A\u8BBE\u7F6E"), /*#__PURE__*/React.createElement(_Form, {
        className: "addcdTask-cdHost",
        columns: 2,
        dataSet: ADDCDTaskDataSet
      }, /*#__PURE__*/React.createElement(_SelectBox, {
        style: {
          top: '16px'
        },
        colSpan: 1,
        name: addCDTaskDataSetMap.hostSource,
        onChange: function onChange() {
          ADDCDTaskDataSet.current.set(addCDTaskDataSetMap.host, undefined);
          ADDCDTaskDataSet.current.set('hostIp', undefined);
          ADDCDTaskDataSet.current.set('hostPort', undefined);
        }
      }, /*#__PURE__*/React.createElement(Option, {
        value: addCDTaskDataSetMap.alreadyhost
      }, "\u5DF2\u6709\u4E3B\u673A"), /*#__PURE__*/React.createElement(Option, {
        value: addCDTaskDataSetMap.customhost
      }, "\u81EA\u5B9A\u4E49\u4E3B\u673A")), renderHostSetting(), /*#__PURE__*/React.createElement("div", {
        newLine: true,
        colSpan: 2,
        style: {
          display: 'flex',
          alignItems: 'center'
        }
      }, /*#__PURE__*/React.createElement(_Button, {
        disabled: ADDCDTaskDataSet.current.get(addCDTaskDataSetMap.hostSource) === addCDTaskDataSetMap.customhost ? !ADDCDTaskDataSet.current.get('hostIp') || !ADDCDTaskDataSet.current.get('hostPort') || !ADDCDTaskDataSet.current.get('username') : !ADDCDTaskDataSet.current.get(addCDTaskDataSetMap.host),
        onClick: handleTestConnect,
        style: {
          marginRight: 20
        },
        color: "primary",
        funcType: "raised"
      }, "\u6D4B\u8BD5\u8FDE\u63A5"), getTestDom())), /*#__PURE__*/React.createElement("div", {
        className: "addcdTask-divided"
      }), /*#__PURE__*/React.createElement("p", {
        className: "addcdTask-title"
      }, "\u4E3B\u673A\u90E8\u7F72"), /*#__PURE__*/React.createElement(_Form, {
        style: {
          marginTop: 20
        },
        columns: 6,
        dataSet: ADDCDTaskDataSet
      }, /*#__PURE__*/React.createElement(_SelectBox, {
        className: "addcdTask-mainMode",
        colSpan: 5,
        name: "hostDeployType",
        onChange: function onChange(data) {
          ADDCDTaskDataSet.current.set('hostDeployType', data);

          if (data !== 'customize') {
            ADDCDTaskDataSet.current.set('deploySource', 'pipelineDeploy'); // console.log(ADDCDTaskDataSet.getField('pipelineTask'));
            // ADDCDTaskDataSet.current.set('pipelineTask', '123');
          }
        }
      }, /*#__PURE__*/React.createElement(Option, {
        value: "image"
      }, "\u955C\u50CF\u90E8\u7F72"), /*#__PURE__*/React.createElement(Option, {
        value: "jar"
      }, "jar\u5305\u90E8\u7F72"), /*#__PURE__*/React.createElement(Option, {
        value: "customize"
      }, "\u81EA\u5B9A\u4E49\u547D\u4EE4")), ",", getModeDom())]
    }, addCDTaskDataSetMap.apiTest, [
    /*#__PURE__*/
    // <div className="addcdTask-divided" />,
    // <p className="addcdTask-title">执行设置</p>,
    // <Form style={{ marginTop: 20 }} columns={2} dataSet={ADDCDTaskDataSet}>
    //   <div className="addcdTask-whetherBlock" style={{ position: 'relative' }}>
    //     <SelectBox name={addCDTaskDataSetMap.whetherBlock}>
    //       <Option value>是</Option>
    //       <Option value={false}>否</Option>
    //     </SelectBox>
    //     <Tooltip title={(
    //       <>
    //         <p>若选择为是，则表示API测试任务在执行的过程中，后续的阶段与任务将不会执行</p>
    //         <p>若选择为否，则表示在执行API测试任务的同时，会同步执行接下来的任务或阶段</p>
    //       </>
    //     )}
    //     >
    //       <Icon
    //         style={{
    //           position: 'absolute',
    //           top: '-18px',
    //           left: '136px',
    //           color: 'rgba(0, 0, 0, 0.36)',
    //         }}
    //         type="help"
    //       />
    //     </Tooltip>
    //   </div>
    // </Form>,
    React.createElement("div", {
      className: "addcdTask-divided"
    }), /*#__PURE__*/React.createElement("p", {
      className: "addcdTask-title"
    }, "\u544A\u8B66\u8BBE\u7F6E", /*#__PURE__*/React.createElement(_Tooltip, {
      title: "\u542F\u7528\u544A\u8B66\u8BBE\u7F6E\u540E\uFF0C\u82E5\u8BE5API\u6D4B\u8BD5\u4EFB\u52A1\u7684\u6267\u884C\u7387\u4F4E\u4E8E\u67D0\u4E2A\u8BBE\u5B9A\u503C\uFF0C\u4FBF\u4F1A\u901A\u8FC7\u90AE\u4EF6\u6216\u7AD9\u5185\u4FE1\u901A\u77E5\u5230\u6307\u5B9A\u7684\u901A\u77E5\u5BF9\u8C61\u3002"
    }, /*#__PURE__*/React.createElement(_Icon, {
      style: {
        position: 'relative',
        bottom: '2px',
        marginLeft: '5px',
        color: 'rgba(0, 0, 0, 0.36)'
      },
      type: "help"
    }))), /*#__PURE__*/React.createElement(_Form, {
      style: {
        marginTop: 20
      },
      columns: 2,
      dataSet: ADDCDTaskDataSet
    }, /*#__PURE__*/React.createElement("div", {
      className: "addcdTask-whetherBlock",
      style: {
        position: 'relative'
      }
    }, /*#__PURE__*/React.createElement(_SelectBox, {
      name: addCDTaskDataSetMap.alarm
    }, /*#__PURE__*/React.createElement(Option, {
      value: true
    }, "\u662F"), /*#__PURE__*/React.createElement(Option, {
      value: false
    }, "\u5426"))), ADDCDTaskDataSet.current.get(addCDTaskDataSetMap.alarm) && [/*#__PURE__*/React.createElement(_TextField, {
      name: addCDTaskDataSetMap.threshold,
      newLine: true,
      suffix: "%",
      restrict: "0-9|.",
      min: 0,
      max: 100,
      addonAfter: /*#__PURE__*/React.createElement(Tips, {
        helpText: "\u5373\u6307\u5B9A\u4E00\u4E2A\u6267\u884C\u6210\u529F\u7387\u7684\u6807\u51C6\u503C\uFF0C\u82E5\u540E\u7EED\u5728\u6D41\u6C34\u7EBF\u4E2D\u6267\u884C\u8BE5API\u6D4B\u8BD5\u4EFB\u52A1\u540E\u6210\u529F\u7387\u4F4E\u4E8E\u8BBE\u5B9A\u503C\uFF0C\u4FBF\u4F1A\u544A\u8B66\u901A\u77E5\u5230\u6307\u5B9A\u4EBA\u5458\u3002\u4EC5\u80FD\u586B\u51650-100\u3002"
      }),
      onChange: function onChange(value) {
        if (Number(value) > 100) {
          ADDCDTaskDataSet.current.set(addCDTaskDataSetMap.threshold, '100');
        } else if (Number(value) < 0) {
          ADDCDTaskDataSet.current.set(addCDTaskDataSetMap.threshold, '0');
        }
      }
    }), /*#__PURE__*/React.createElement(_Select, {
      searchable: true,
      searchMatcher: "param",
      newLine: true,
      name: addCDTaskDataSetMap.notifyObject,
      addonAfter: /*#__PURE__*/React.createElement(Tips, {
        helpText: "\u53EF\u9009\u62E9\u9879\u76EE\u4E0B\u4EFB\u610F\u4EBA\u5458\u4F5C\u4E3A\u901A\u77E5\u5BF9\u8C61\u3002"
      })
    }), /*#__PURE__*/React.createElement(_SelectBox, {
      newLine: true,
      name: addCDTaskDataSetMap.notifyWay
    }, /*#__PURE__*/React.createElement(Option, {
      value: "sendEmail"
    }, "\u90AE\u4EF6"), /*#__PURE__*/React.createElement(Option, {
      value: "sendSiteMessage"
    }, "\u7AD9\u5185\u4FE1")), /*#__PURE__*/React.createElement("div", {
      className: "addcdTask-whetherBlock",
      style: {
        position: 'relative'
      }
    }, /*#__PURE__*/React.createElement(_SelectBox, {
      name: addCDTaskDataSetMap.whetherBlock
    }, /*#__PURE__*/React.createElement(Option, {
      value: true
    }, "\u662F"), /*#__PURE__*/React.createElement(Option, {
      value: false
    }, "\u5426")), /*#__PURE__*/React.createElement(_Tooltip, {
      title: /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("p", null, "\u82E5\u9009\u62E9\u4E3A\u662F\uFF0C\u5219\u8868\u793AAPI\u6D4B\u8BD5\u4EFB\u52A1\u6267\u884C\u6210\u529F\u7387\u4F4E\u4E8E\u8BBE\u5B9A\u503C\u540E\uFF0C\u540E\u7EED\u7684\u9636\u6BB5\u4E0E\u4EFB\u52A1\u5C06\u88AB\u963B\u585E\uFF0C\u4E0D\u4F1A\u6267\u884C\u3002"), /*#__PURE__*/React.createElement("p", null, "\u82E5\u9009\u62E9\u4E3A\u5426\uFF0C\u5219\u8868\u793A\u65E0\u8BBA\u6267\u884C\u6210\u529F\u7387\u5982\u4F55\uFF0C\u6B64\u4EFB\u52A1\u6267\u884C\u5B8C\u6210\u540E\uFF0C\u5747\u4F1A\u7EE7\u7EED\u6267\u884C\u63A5\u4E0B\u6765\u7684\u9636\u6BB5\u6216\u4EFB\u52A1\u3002"))
    }, /*#__PURE__*/React.createElement(_Icon, {
      style: {
        position: 'absolute',
        top: '5px',
        right: '150px',
        color: 'rgba(0, 0, 0, 0.36)'
      },
      type: "help"
    })))])]);

    return obj[ADDCDTaskDataSet === null || ADDCDTaskDataSet === void 0 ? void 0 : (_ADDCDTaskDataSet$cur15 = ADDCDTaskDataSet.current) === null || _ADDCDTaskDataSet$cur15 === void 0 ? void 0 : _ADDCDTaskDataSet$cur15.get('type')];
  };

  function handleClickMore(_x, _x2) {
    return _handleClickMore.apply(this, arguments);
  }

  function _handleClickMore() {
    _handleClickMore = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee6(e, realName) {
      var pageSize, url, cdAuditsUserIds, res;
      return regeneratorRuntime.wrap(function _callee6$(_context6) {
        while (1) {
          switch (_context6.prev = _context6.next) {
            case 0:
              if (!ADDCDTaskDataSet.current.get('pageSize')) {
                ADDCDTaskDataSet.current.set('pageSize', 20);
              }

              e && e.stopPropagation();
              pageSize = !e ? ADDCDTaskDataSet.current.get('pageSize') : ADDCDTaskDataSet.current.get('pageSize') + 20;
              url = "/devops/v1/projects/".concat(projectId, "/users/app_services/").concat(PipelineCreateFormDataSet.current.get('appServiceId'), "?page=0&size=").concat(pageSize);
              cdAuditsUserIds = [];
              (jobDetail === null || jobDetail === void 0 ? void 0 : jobDetail.cdAuditUserIds) && jobDetail.cdAuditUserIds.forEach(function (obj) {
                if (typeof obj === 'string') {
                  cdAuditsUserIds.push(obj);
                } else if (typeof obj === 'object') {
                  cdAuditsUserIds.push(obj === null || obj === void 0 ? void 0 : obj.id);
                }
              });
              _context6.next = 8;
              return axios.post(url, {
                userName: realName || '',
                ids: cdAuditsUserIds || []
              });

            case 8:
              res = _context6.sent;

              if (res.content.length % 20 === 0 && res.content.length !== 0) {
                res.content.push({
                  realName: '加载更多',
                  id: 'more'
                });
              }

              ADDCDTaskDataSet.current.set('pageSize', pageSize);

              if (realName) {
                ADDCDTaskDataSet.getField('cdAuditUserIds').props.lookup = [].concat(_toConsumableArray(res.content), _toConsumableArray(ADDCDTaskDataSet.getField('cdAuditUserIds').props.lookup));
              } else {
                ADDCDTaskDataSet.getField('cdAuditUserIds').props.lookup = res.content;
              }

            case 12:
            case "end":
              return _context6.stop();
          }
        }
      }, _callee6);
    }));
    return _handleClickMore.apply(this, arguments);
  }

  var renderderAuditUsersList = function renderderAuditUsersList(_ref7) {
    var text = _ref7.text,
        record = _ref7.record;
    var ldap = record.get('ldap');

    if (text === '加载更多') {
      return /*#__PURE__*/React.createElement("a", {
        style: {
          display: 'block',
          width: '100%',
          height: '100%'
        },
        onClick: handleClickMore,
        role: "none"
      }, text);
    }

    return ldap ? "".concat(text, "(").concat(record.get('loginName'), ")") : "".concat(text, "(").concat(record.get('email'), ")");
  };
  /**
   * 外部卡点回调地址的复制事件
   */


  var handleCopy = function handleCopy() {
    Choerodon.prompt('复制成功');
  };

  var getBranchsList = useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee5() {
    var url, res;
    return regeneratorRuntime.wrap(function _callee5$(_context5) {
      while (1) {
        switch (_context5.prev = _context5.next) {
          case 0:
            url = "devops/v1/projects/".concat(projectId, "/app_service/").concat(PipelineCreateFormDataSet.current.get('appServiceId'), "/git/page_branch_by_options?page=1&size=").concat(currentSize);
            _context5.next = 3;
            return axios.post(url);

          case 3:
            res = _context5.sent;

            if (res.content.length % 10 === 0 && res.content.length !== 0) {
              res.content.push({
                name: '加载更多',
                value: 'more'
              });
            }

            setBranchsList(res.content.map(function (c) {
              if (c.branchName) {
                c.name = c.branchName;
                c.value = c.branchName;
              }

              return c;
            }));

          case 6:
          case "end":
            return _context5.stop();
        }
      }
    }, _callee5);
  })), [PipelineCreateFormDataSet, projectId]);

  var renderderBranchs = function renderderBranchs(_ref9) {
    var text = _ref9.text;
    return text === '加载更多' ?
    /*#__PURE__*/
    // eslint-disable-next-line jsx-a11y/click-events-have-key-events
    React.createElement("a", {
      style: {
        width: '100%',
        height: '100%',
        display: 'block'
      },
      onClick: function onClick(e) {
        e.preventDefault();
        e.stopPropagation();
        currentSize += 10;
        getBranchsList();
      }
    }, text) : text;
  };

  function renderTriggerTypeTips() {
    var type = ADDCDTaskDataSet.current.get('triggerType');

    switch (type) {
      case 'refs':
        return '您可在此选择或输入触发该任务的分支类型；支持多填多选；若不填写，则默认为所有分支和tag';

      case 'exact_match':
        return '您可在此精确选择或输入触发该任务的具体分支名称；支持多填多选；若不填写，则默认为所有分支和tag';

      default:
        return '您可在此选择或输入某几个具体的分支名称以此来精确排除；此处支持多填多选；若不填写，则默认为没有需要排除的分支或tag';
    }
  }

  var renderer = function renderer(_ref10) {
    var record = _ref10.record,
        text = _ref10.text;
    return /*#__PURE__*/React.createElement("span", null, text && /*#__PURE__*/React.createElement("i", {
      style: {
        display: 'inline-block',
        marginRight: 3,
        width: '0.08rem',
        height: '0.08rem',
        borderRadius: '50%',
        backgroundColor: record.get('connected') ? 'rgb(0, 191, 165)' : '#ff9915'
      }
    }), text);
  };

  var optionRenderer = function optionRenderer(_ref11) {
    var record = _ref11.record,
        text = _ref11.text,
        value = _ref11.value;
    return /*#__PURE__*/React.createElement(_Tooltip, {
      title: !record.get('connected') && '未连接'
    }, renderer({
      record: record,
      text: text,
      value: value
    }));
  };
  /**
   * 渲染关联部署任务options
   */


  var renderRelatedMission = function renderRelatedMission() {
    var lists = [];
    JSON.parse(JSON.stringify(pipelineStageMainSource)).forEach(function (i, iIndex) {
      // 是cd阶段
      if (i.type === 'CD') {
        // 如果遍历列小于当前列 则直接存入joblist
        if (iIndex < columnIndex - 1) {
          lists = [].concat(_toConsumableArray(lists), _toConsumableArray(i.jobList));
        } else {
          //  如果遍历列是当切列
          lists = [].concat(_toConsumableArray(lists), _toConsumableArray(i.jobList.splice(0, taskIndex)));
        }
      }
    }); // 返回任务是部署任务的options

    return lists.filter(function (l) {
      return l.type === 'cdDeploy';
    }).map(function (i) {
      return /*#__PURE__*/React.createElement(Option, {
        value: i.name
      }, i.name);
    });
  };

  return /*#__PURE__*/React.createElement("div", {
    className: "addcdTask"
  }, /*#__PURE__*/React.createElement(_Form, {
    columns: 3,
    dataSet: ADDCDTaskDataSet
  }, /*#__PURE__*/React.createElement(_Select, {
    onChange: function onChange(data) {
      var _newData;

      var newData = (_newData = {
        type: data,
        glyyfw: appServiceId || PipelineCreateFormDataSet.getField('appServiceId').getText(PipelineCreateFormDataSet.current.get('appServiceId')),
        triggerType: 'refs',
        deployType: 'create',
        authType: 'accountPassword',
        hostDeployType: 'image',
        deploySource: 'pipelineDeploy'
      }, _defineProperty(_newData, addCDTaskDataSetMap.hostSource, addCDTaskDataSetMap.alreadyhost), _defineProperty(_newData, "workingPath", './'), _defineProperty(_newData, "name", ADDCDTaskDataSet.current.get('name') || undefined), _defineProperty(_newData, addCDTaskDataSetMap.alarm, false), _defineProperty(_newData, addCDTaskDataSetMap.whetherBlock, true), _newData);

      if (data === 'cdHost' && relatedJobOpts && relatedJobOpts.length === 1) {
        newData.pipelineTask = relatedJobOpts[0].name;
      }

      ADDCDTaskDataSet.loadData([newData]);
    },
    colSpan: 1,
    name: "type"
  }, /*#__PURE__*/React.createElement(Option, {
    value: "cdDeploy"
  }, "\u90E8\u7F72"), /*#__PURE__*/React.createElement(Option, {
    value: "cdHost"
  }, "\u4E3B\u673A\u90E8\u7F72"), /*#__PURE__*/React.createElement(Option, {
    value: "cdAudit"
  }, "\u4EBA\u5DE5\u5361\u70B9"), /*#__PURE__*/React.createElement(Option, {
    value: addCDTaskDataSetMap.apiTest
  }, "API\u6D4B\u8BD5"), /*#__PURE__*/React.createElement(Option, {
    value: addCDTaskDataSetMap.externalStuck
  }, "\u5916\u90E8\u5361\u70B9")), /*#__PURE__*/React.createElement(_TextField, {
    colSpan: 2,
    name: "name"
  }), /*#__PURE__*/React.createElement(_TextField, {
    colSpan: 1,
    name: "glyyfw"
  }), /*#__PURE__*/React.createElement("div", {
    className: "addcdTask-wrap",
    colSpan: 2
  }, /*#__PURE__*/React.createElement(_Select, {
    name: "triggerType",
    className: "addcdTask-triggerType",
    onChange: function onChange() {
      return ADDCDTaskDataSet.current.set('triggerValue', undefined);
    },
    colSpan: 1,
    clearButton: false
  }, /*#__PURE__*/React.createElement(Option, {
    value: "refs"
  }, "\u5206\u652F\u7C7B\u578B\u5339\u914D"), /*#__PURE__*/React.createElement(Option, {
    value: "regex"
  }, "\u6B63\u5219\u5339\u914D"), /*#__PURE__*/React.createElement(Option, {
    value: "exact_match"
  }, "\u7CBE\u786E\u5339\u914D"), /*#__PURE__*/React.createElement(Option, {
    value: "exact_exclude"
  }, "\u7CBE\u786E\u6392\u9664")), ADDCDTaskDataSet.current.get('triggerType') === 'regex' ? /*#__PURE__*/React.createElement(_TextField, {
    className: "addcdTask-triggerValue",
    name: "triggerValue",
    addonAfter: /*#__PURE__*/React.createElement(NewTips, {
      helpText: "\u60A8\u53EF\u5728\u6B64\u8F93\u5165\u6B63\u5219\u8868\u8FBE\u5F0F\u6765\u914D\u7F6E\u89E6\u53D1\u5206\u652F\uFF1B\u4F8B\uFF1A\u82E5\u60F3\u5339\u914D\u4EE5 feature \u5F00\u5934\u7684\u5206\u652F\uFF0C\u53EF\u4EE5\u8F93\u5165 ^feature.*\u3002\u66F4\u591A\u8868\u8FBE\u5F0F\uFF0C\u8BE6\u89C1\u7528\u6237\u624B\u518C\u3002\u82E5\u4E0D\u586B\u5199\uFF0C\u5219\u9ED8\u8BA4\u4E3A\u6240\u6709\u5206\u652F\u548Ctag"
    })
  }) : /*#__PURE__*/React.createElement(_Select, {
    combo: true,
    searchable: true,
    multiple: true,
    className: "addcdTask-triggerValue",
    name: "triggerValue",
    addonAfter: /*#__PURE__*/React.createElement(Tips, {
      helpText: renderTriggerTypeTips()
    }),
    searchMatcher: "branchName",
    optionRenderer: function optionRenderer(_ref12) {
      var text = _ref12.text;
      return renderderBranchs({
        text: text
      });
    },
    maxTagCount: 3,
    maxTagPlaceholder: function maxTagPlaceholder(omittedValues) {
      return /*#__PURE__*/React.createElement(_Tooltip, {
        title: omittedValues.join(',')
      }, "+".concat(omittedValues.length));
    },
    renderer: renderderBranchs,
    colSpan: 2
  }, branchsList === null || branchsList === void 0 ? void 0 : branchsList.map(function (b) {
    return /*#__PURE__*/React.createElement(Option, {
      value: b.value
    }, b.name);
  }))), ADDCDTaskDataSet.current.get('type') === addCDTaskDataSetMap.apiTest && [/*#__PURE__*/React.createElement(_Select, {
    newLine: true,
    colSpan: 1,
    name: addCDTaskDataSetMap.apiTestMission,
    addonAfter: /*#__PURE__*/React.createElement(Tips, {
      helpText: "\u6B64\u5904\u4EC5\u80FD\u4ECE\u9879\u76EE\u4E0B\u5DF2\u6709\u7684API\u6D4B\u8BD5\u4EFB\u52A1\u4E2D\u8FDB\u884C\u9009\u62E9"
    })
  }), /*#__PURE__*/React.createElement(_Select, {
    colSpan: 2,
    name: addCDTaskDataSetMap.relativeMission,
    addonAfter: /*#__PURE__*/React.createElement(Tips, {
      helpText: /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("p", null, "1. \u6B64\u5904\u4E3A\u975E\u5FC5\u9009\uFF0C\u82E5\u4E0D\u9009\u5173\u8054\u90E8\u7F72\u4EFB\u52A1\uFF0C\u5219\u4EE3\u8868\uFF0CAPI\u6D4B\u8BD5\u4EFB\u52A1\u5728\u6267\u884C\u524D\u4E0D\u4F1A\u505A\u4EFB\u4F55\u5224\u65AD"), /*#__PURE__*/React.createElement("p", null, "2. \u6B64\u5904\u4EC5\u652F\u6301\u9009\u62E9\u8BE5\u4EFB\u52A1\u4E4B\u524D\u7684\u4EFB\u4E00\u90E8\u7F72\u4EFB\u52A1\uFF1B \u9009\u62E9\u540E\uFF0C\u5728\u6267\u884C\u6B64API\u6D4B\u8BD5\u4EFB\u52A1\u524D\u4FBF\u4F1A\u6821\u9A8C\uFF1A\u5173\u8054\u7684\u90E8\u7F72\u4EFB\u52A1\u4E2D\u5BF9\u5E94\u7684\u65B0\u7248\u672C\u662F\u5426\u5DF2\u90E8\u7F72\u6210\u529F\u3002\u53EA\u6709\u8BE5\u7248\u672C\u5BF9\u5E94\u7684pod\u72B6\u6001\u4E3A\u53EF\u7528\u65F6\uFF0C\u6D4B\u8BD5\u4EFB\u52A1\u624D\u4F1A\u6267\u884C"))
    })
  }, renderRelatedMission())], (ADDCDTaskDataSet === null || ADDCDTaskDataSet === void 0 ? void 0 : (_ADDCDTaskDataSet$cur16 = ADDCDTaskDataSet.current) === null || _ADDCDTaskDataSet$cur16 === void 0 ? void 0 : _ADDCDTaskDataSet$cur16.get('type')) === 'cdDeploy' && [/*#__PURE__*/React.createElement(_Select, {
    colSpan: 1,
    name: "envId",
    optionRenderer: optionRenderer // renderer={renderer}
    ,
    onOption: function onOption(_ref13) {
      var record = _ref13.record;
      return {
        disabled: !record.get('connected')
      };
    }
  }), isProjectOwner && /*#__PURE__*/React.createElement("div", {
    className: "addcdTask-whetherBlock addcdTask-triggersTasks",
    style: {
      position: 'relative'
    },
    colSpan: 2
  }, /*#__PURE__*/React.createElement(_SelectBox, {
    name: addCDTaskDataSetMap.triggersTasks.name
  }, /*#__PURE__*/React.createElement(Option, {
    value: addCDTaskDataSetMap.triggersTasks.values[0]
  }, "\u662F"), /*#__PURE__*/React.createElement(Option, {
    value: addCDTaskDataSetMap.triggersTasks.values[1]
  }, "\u5426")), /*#__PURE__*/React.createElement(NewTips, {
    helpText: "\u6B64\u5904\u4EC5\u9879\u76EE\u6240\u6709\u8005\u53EF\u4EE5\u8BBE\u7F6E\uFF1B\u9ED8\u8BA4\u4E3A\u662F\uFF0C\u5373\u89E6\u53D1\u7528\u6237\u5728\u6CA1\u6709\u8BE5\u90E8\u7F72\u4EFB\u52A1\u7684\u73AF\u5883\u6743\u9650\u65F6\uFF0C\u5C06\u4F1A\u76F4\u63A5\u4F7F\u7528\u7BA1\u7406\u5458\u8D26\u6237\u89E6\u53D1\u90E8\u7F72\uFF1B\u82E5\u9009\u62E9\u4E3A\u5426\uFF0C\u89E6\u53D1\u6210\u5458\u5728\u6CA1\u6709\u73AF\u5883\u6743\u9650\u65F6\uFF0C\u5C06\u4F1A\u76F4\u63A5\u8DF3\u8FC7\u6B64\u90E8\u7F72\u4EFB\u52A1\u3002",
    style: {
      position: 'absolute',
      top: '7px',
      left: '195px'
    }
  })), /*#__PURE__*/React.createElement(_SelectBox, {
    className: "addcdTask-mode",
    newLine: true,
    colSpan: 1,
    name: "deployType"
  }, /*#__PURE__*/React.createElement(Option, {
    value: "create"
  }, "\u65B0\u5EFA\u5B9E\u4F8B"), /*#__PURE__*/React.createElement(Option, {
    value: "update"
  }, "\u66FF\u6362\u5B9E\u4F8B")), /*#__PURE__*/React.createElement("p", {
    className: "addcdTask-text",
    colSpan: 2
  }, /*#__PURE__*/React.createElement(_Icon, {
    style: {
      color: '#F44336',
      position: 'relative',
      bottom: '2px'
    },
    type: "error"
  }), "\u66FF\u6362\u5B9E\u4F8B\u4F1A\u66F4\u65B0\u8BE5\u5B9E\u4F8B\u7684\u955C\u50CF\u53CA\u914D\u7F6E\u4FE1\u606F\uFF0C\u8BF7\u786E\u8BA4\u8981\u66FF\u6362\u7684\u5B9E\u4F8B\u9009\u62E9\u65E0\u8BEF\u3002"), (ADDCDTaskDataSet === null || ADDCDTaskDataSet === void 0 ? void 0 : (_ADDCDTaskDataSet$cur17 = ADDCDTaskDataSet.current) === null || _ADDCDTaskDataSet$cur17 === void 0 ? void 0 : _ADDCDTaskDataSet$cur17.get('deployType')) === 'create' ? /*#__PURE__*/React.createElement(_TextField, {
    newLine: true,
    colSpan: 2,
    name: "instanceName"
  }) : /*#__PURE__*/React.createElement(_Select, {
    newLine: true,
    colSpan: 2,
    name: "instanceId"
  })], (ADDCDTaskDataSet === null || ADDCDTaskDataSet === void 0 ? void 0 : (_ADDCDTaskDataSet$cur18 = ADDCDTaskDataSet.current) === null || _ADDCDTaskDataSet$cur18 === void 0 ? void 0 : _ADDCDTaskDataSet$cur18.get('type')) === 'cdAudit' && /*#__PURE__*/React.createElement("div", {
    colSpan: 3,
    style: {
      display: 'flex'
    }
  }, /*#__PURE__*/React.createElement("div", {
    style: {
      width: '47.5%',
      marginRight: 8
    },
    colSpan: 2
  }, /*#__PURE__*/React.createElement(_Select, {
    popupCls: "addcdTask-auditUsers",
    searchable: true,
    style: {
      width: '100%'
    },
    name: "cdAuditUserIds",
    maxTagCount: 3,
    searchMatcher: "realName",
    onOption: function onOption(_ref14) {
      var record = _ref14.record;
      return {
        disabled: record.get('id') === 'more'
      };
    },
    onChange: function onChange() {
      handleClickMore(null);
    },
    maxTagPlaceholder: function maxTagPlaceholder(omittedValues) {
      var tempArr = omittedValues.map(function (item) {
        var tempId = typeof item === 'string' ? item : item === null || item === void 0 ? void 0 : item.id;
        return ADDCDTaskDataSet.getField('cdAuditUserIds').getText(tempId);
      });
      return /*#__PURE__*/React.createElement(_Tooltip, {
        title: tempArr && tempArr.join('，')
      }, /*#__PURE__*/React.createElement("span", {
        style: {
          width: '31px',
          display: 'block'
        }
      }, "+".concat(omittedValues.length), "..."));
    },
    optionRenderer: renderderAuditUsersList,
    renderer: function renderer(_ref15) {
      var text = _ref15.text,
          value = _ref15.value;

      if (typeof value === 'object') {
        var isLdap = get(value, 'ldap');
        return /*#__PURE__*/React.createElement(_Tooltip, {
          title: isLdap ? "".concat(value.realName, "(").concat(value.loginName, ")") : "".concat(value.realName, "(").concat(value.email, ")")
        }, value.realName);
      }

      return /*#__PURE__*/React.createElement(_Tooltip, {
        title: text
      }, text);
    }
  })), (ADDCDTaskDataSet === null || ADDCDTaskDataSet === void 0 ? void 0 : (_ADDCDTaskDataSet$cur19 = ADDCDTaskDataSet.current) === null || _ADDCDTaskDataSet$cur19 === void 0 ? void 0 : (_ADDCDTaskDataSet$cur20 = _ADDCDTaskDataSet$cur19.get('cdAuditUserIds')) === null || _ADDCDTaskDataSet$cur20 === void 0 ? void 0 : _ADDCDTaskDataSet$cur20.length) > 1 && /*#__PURE__*/React.createElement("div", {
    style: {
      width: 'calc(100% - 47.5% - 8px)'
    },
    colSpan: 1
  }, /*#__PURE__*/React.createElement(_Select, {
    style: {
      width: '100%'
    },
    name: "countersigned",
    addonAfter: /*#__PURE__*/React.createElement(Tips, {
      helpText: "\u4F1A\u7B7E\u6A21\u5F0F\u4E2D\uFF0C\u9700\u8981\u6240\u6709\u5BA1\u6838\u4EBA\u5458\u90FD\u5BA1\u6838\u901A\u8FC7\u624D\u80FD\u901A\u8FC7\uFF0C\u5BA1\u6838\u4EBA\u5458\u4E2D\u4EFB\u4E00\u4EBA\u70B9\u51FB\u7EC8\u6B62\uFF0C\u5219\u6D41\u6C34\u7EBF\u7EC8\u6B62\uFF1B\u6216\u7B7E\u6A21\u5F0F\u4E2D\uFF0C\u4EC5\u9700\u4EFB\u4E00\u5BA1\u6838\u4EBA\u5458\u5BA1\u6838\u5373\u53EF\uFF0C\u5373\u7B2C\u4E00\u4E2A\u5BA1\u6838\u7684\u4EBA\u70B9\u51FB\u901A\u8FC7\u5219\u901A\u8FC7\uFF0C\u70B9\u51FB\u7EC8\u6B62\u5219\u7EC8\u6B62"
    })
  }, /*#__PURE__*/React.createElement(Option, {
    value: 1
  }, "\u4F1A\u7B7E"), /*#__PURE__*/React.createElement(Option, {
    value: 0
  }, "\u6216\u7B7E")))), ADDCDTaskDataSet.current.get('type') === addCDTaskDataSetMap.externalStuck && [/*#__PURE__*/React.createElement("div", {
    colSpan: 3,
    className: "addcdTask-missionDes"
  }, /*#__PURE__*/React.createElement("span", {
    style: {
      fontWeight: 500
    }
  }, "\u4EFB\u52A1\u8BF4\u660E\uFF1A"), /*#__PURE__*/React.createElement("span", {
    style: {
      display: 'inline-block'
    }
  }, "- \u5916\u90E8\u5361\u70B9\u4EFB\u52A1\u7528\u4E8E\u5BF9\u63A5Choerodon\u5E73\u53F0\u5916\u7684\u5DE5\u4F5C\u6D41\u6216\u7CFB\u7EDF\u3002\u6B64\u4EFB\u52A1\u89E6\u53D1\u65F6\uFF0C \u4F1A\u9ED8\u8BA4\u5C06projectId\u3001pipelineRecordId\u3001stageRecordId \u3001jobRecordId\u3001callback_token\u3001 currentCdJob\u4EE5\u53CApipelineRecordDetails\u53D1\u9001\u81F3\u5916\u90E8\u5730\u5740\u3002"), /*#__PURE__*/React.createElement("span", {
    style: {
      display: 'inline-block'
    }
  }, "- \u5916\u90E8\u7CFB\u7EDF\u6267\u884C\u7ED3\u675F\u540E\uFF0C\u4F1A\u5F80", ' ', /*#__PURE__*/React.createElement("span", {
    className: "addcdTask-missionDes-focus"
  }, "\u6D41\u6C34\u7EBF\u56DE\u8C03\u5730\u5740"), ' ', "\u53D1\u9001\u4E00\u4E2A\u72B6\u6001\u6765\u4F5C\u4E3A\u5916\u90E8\u5361\u70B9\u7684\u4EFB\u52A1\u72B6\u6001\u3002\u6210\u529F\u540E\u4F1A\u63A5\u7740\u6267\u884C\u540E\u7EED\u4EFB\u52A1\uFF0C\u5931\u8D25\u5219\u505C\u7559\u5728\u6B64\u4EFB\u52A1\u3002"), /*#__PURE__*/React.createElement("br", null), /*#__PURE__*/React.createElement("span", {
    style: {
      display: 'block',
      marginTop: 10,
      fontWeight: 500
    }
  }, "\u6D41\u6C34\u7EBF\u56DE\u8C03\u5730\u5740\u53C2\u6570\u8BF4\u660E\uFF1A"), /*#__PURE__*/React.createElement("span", {
    style: {
      display: 'block'
    }
  }, "- pipelineRecordId\uFF1A \u6D41\u6C34\u7EBF\u8BB0\u5F55id"), /*#__PURE__*/React.createElement("span", {
    style: {
      display: 'block'
    }
  }, "- stageRecordId: \u6D41\u6C34\u7EBF\u9636\u6BB5\u8BB0\u5F55id"), /*#__PURE__*/React.createElement("span", {
    style: {
      display: 'block'
    }
  }, "- jobRecordId: \u6D41\u6C34\u7EBF\u4EFB\u52A1\u8BB0\u5F55id"), /*#__PURE__*/React.createElement("span", {
    style: {
      display: 'block'
    }
  }, "- callback_token: \u56DE\u8C03\u65F6\u7684\u8BA4\u8BC1token"), /*#__PURE__*/React.createElement("span", {
    style: {
      display: 'block'
    }
  }, "- approval_status\uFF1A \u4EFB\u52A1\u6267\u884C\u72B6\u6001\uFF08true/false ,\u4EE3\u8868\u5916\u90E8\u5361\u70B9\u4EFB\u52A1\u6267\u884C\u6210\u529F\u6216\u5931\u8D25\uFF09")), /*#__PURE__*/React.createElement(_TextField, {
    label: "\u6D41\u6C34\u7EBF\u56DE\u8C03\u5730\u5740",
    colSpan: 3,
    addonAfter: /*#__PURE__*/React.createElement(CopyToClipboard, {
      text: pipelineCallbackAddress,
      onCopy: handleCopy
    }, /*#__PURE__*/React.createElement(_Icon, {
      style: {
        cursor: 'pointer'
      },
      type: "content_copy"
    })),
    disabled: true,
    required: true,
    value: pipelineCallbackAddress
  }), /*#__PURE__*/React.createElement(_TextArea, {
    name: addCDTaskDataSetMap.externalAddress,
    colSpan: 3
  }), /*#__PURE__*/React.createElement(_TextArea, {
    name: addCDTaskDataSetMap.externalToken,
    colSpan: 3
  }), /*#__PURE__*/React.createElement(_TextArea, {
    name: addCDTaskDataSetMap.missionDes,
    colSpan: 3
  })]), getOtherConfig());
});