import "choerodon-ui/lib/popover/style";
import _Popover from "choerodon-ui/lib/popover";
import "choerodon-ui/pro/lib/tooltip/style";
import _Tooltip from "choerodon-ui/pro/lib/tooltip";
import "choerodon-ui/pro/lib/icon/style";
import _Icon from "choerodon-ui/pro/lib/icon";
import "choerodon-ui/pro/lib/button/style";
import _Button from "choerodon-ui/pro/lib/button";
import "choerodon-ui/pro/lib/modal/style";
import _Modal from "choerodon-ui/pro/lib/modal";
import "choerodon-ui/pro/lib/table/style";
import _Table from "@hzero-front-ui/c7n-ui/lib/TablePro";

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 _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 */
import React, { Fragment, useEffect, useState } from 'react';
import { Page, Permission, stores, Action } from '@choerodon/boot';
import classNames from 'classnames';
import map from 'lodash/map';
import forEach from 'lodash/forEach';
import isEmpty from 'lodash/isEmpty';
import some from 'lodash/some';
import { injectIntl, FormattedMessage } from 'react-intl';
import { SagaDetails } from '@choerodon/master';
import { observer } from 'mobx-react-lite';
import BranchCreate from "./branch-create/index";
import BranchEdit from "./branch-edit";
import IssueDetail from "./issue-detail";
import MouserOverWrapper from "../../../../components/MouseOverWrapper";
import UserInfo from "../../../../components/userInfo";
import TimePopover from "../../../../components/timePopover";
import Loading from "../../../../components/loading";
import StatusIcon from "../../../../components/StatusIcon/StatusIcon";
import handleMapStore from "../../main-view/store/handleMapStore";
import { useTableStore } from "./stores";
import EmptyPage from "../../components/empty-page";
import "../../../main.less";
import "./Branch.less";
import "./index.less";
import "./theme4.less";
var Column = _Table.Column;

var branchCreateModalKey = _Modal.key();

var branchEditModalKey = _Modal.key();

var issueDetailModalKey = _Modal.key();

var branchCreateModalStyle = {
  width: 740
};
var issueDetailModalStyle = {
  width: 1020
};

function Branch(props) {
  var _useTableStore = useTableStore(),
      tableDs = _useTableStore.tableDs,
      intl = _useTableStore.intl,
      _useTableStore$AppSta = _useTableStore.AppState.currentMenuType,
      organizationId = _useTableStore$AppSta.organizationId,
      projectId = _useTableStore$AppSta.projectId,
      currentProjectName = _useTableStore$AppSta.name,
      categories = _useTableStore$AppSta.categories,
      appServiceDs = _useTableStore.appServiceDs,
      appServiceId = _useTableStore.appServiceId,
      formatMessage = _useTableStore.formatMessage,
      branchStore = _useTableStore.branchStore,
      prefixCls = _useTableStore.prefixCls;

  var styles = props.styles,
      columnsRender = props.columnsRender;

  var _useState = useState(false),
      _useState2 = _slicedToArray(_useState, 2),
      isOPERATIONS = _useState2[0],
      setIsOPERATIONS = _useState2[1];

  useEffect(function () {
    setIsOPERATIONS(!some(categories || [], ['code', 'N_AGILE']));
  }, [categories]);
  useEffect(function () {
    handleMapStore.setCodeManagerBranch({
      refresh: handleRefresh,
      getSelfToolBar: getSelfToolBar,
      getSelfToolBarObj: getSelfToolBarObj
    });
  }, [projectId, appServiceId]);

  var getSelfToolBarObj = function getSelfToolBarObj() {
    if (!appServiceId) {
      return {};
    } else {
      return {
        name: /*#__PURE__*/React.createElement(FormattedMessage, {
          id: "branch.create"
        }),
        icon: 'playlist_add',
        display: true,
        permissions: ['choerodon.code.project.develop.code-management.ps.branch.create'],
        disabled: !(appServiceId && renderEmpty()),
        handler: openCreateBranchModal
      };
    }
  };
  /**
   * 生成特殊的自定义tool-bar
   * 未选择应用那么就不显示 创建分支按钮
   * 如果是空仓库显示不可用的创建分支按钮
   * 如果是使用了过滤条 导致没有数据，那么仍然可以看到创建分支按钮
   */


  var getSelfToolBar = function getSelfToolBar() {
    return !appServiceId ? null : /*#__PURE__*/React.createElement(Permission, {
      service: ['choerodon.code.project.develop.code-management.ps.branch.create']
    }, /*#__PURE__*/React.createElement(_Button, {
      onClick: openCreateBranchModal,
      icon: "playlist_add",
      disabled: !(appServiceId && renderEmpty())
    }, /*#__PURE__*/React.createElement(FormattedMessage, {
      id: "branch.create"
    })));
  };

  function renderEmpty() {
    var _select$;

    var appServiceData = appServiceDs.toData();

    if (!appServiceData) {
      return false;
    }

    var appArr = appServiceDs.current && appServiceData;
    var select = appArr.filter(function (item) {
      return (item === null || item === void 0 ? void 0 : item.id) === appServiceId;
    });
    return !((_select$ = select[0]) === null || _select$ === void 0 ? void 0 : _select$.emptyRepository);
  } // 打开创建分支模态框


  function openCreateBranchModal() {
    return _openCreateBranchModal.apply(this, arguments);
  }
  /**
   * 刷新
   */


  function _openCreateBranchModal() {
    _openCreateBranchModal = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
      return regeneratorRuntime.wrap(function _callee$(_context) {
        while (1) {
          switch (_context.prev = _context.next) {
            case 0:
              _context.prev = 0;
              _context.next = 3;
              return branchStore.checkCreate(projectId, appServiceId);

            case 3:
              _Modal.open({
                key: branchCreateModalKey,
                title: /*#__PURE__*/React.createElement(FormattedMessage, {
                  id: "branch.create"
                }),
                drawer: true,
                children: /*#__PURE__*/React.createElement(BranchCreate, {
                  intl: intl,
                  appServiceId: appServiceId,
                  handleRefresh: handleRefresh
                }),
                style: branchCreateModalStyle,
                okText: /*#__PURE__*/React.createElement(FormattedMessage, {
                  id: "create"
                }),
                cancelText: /*#__PURE__*/React.createElement(FormattedMessage, {
                  id: "cancel"
                })
              });

              _context.next = 8;
              break;

            case 6:
              _context.prev = 6;
              _context.t0 = _context["catch"](0);

            case 8:
            case "end":
              return _context.stop();
          }
        }
      }, _callee, null, [[0, 6]]);
    }));
    return _openCreateBranchModal.apply(this, arguments);
  }

  var handleRefresh = function handleRefresh() {
    appServiceId && tableDs.query();
  };
  /**
   * 获取列表的icon
   * @param name 分支名称
   * @returns {*}
   */


  var getIcon = function getIcon(name) {
    var nameArr = ['feature', 'release', 'bugfix', 'hotfix'];
    var type = '';

    if (name.includes('-') && nameArr.includes(name.split('-')[0])) {
      type = name.split('-')[0];
    } else if (name === 'master') {
      type = name;
    } else {
      type = 'custom';
    }

    return /*#__PURE__*/React.createElement("span", {
      style: {
        marginLeft: 10
      },
      className: "c7n-branch-icon icon-".concat(type)
    }, type.slice(0, 1).toUpperCase());
  }; // 打开修改问题模态框


  function openEditIssueModal(recordData) {
    var _ref = recordData || {},
        objectVersionNumber = _ref.objectVersionNumber,
        branchName = _ref.branchName,
        issueInfoList = _ref.issueInfoList;

    var initIssues = [];
    forEach(issueInfoList || [], function (issue) {
      var _ref2 = issue || {},
          issueId = _ref2.issueId,
          issueCode = _ref2.issueCode,
          issueName = _ref2.issueName,
          issueProjectId = _ref2.issueProjectId,
          projectName = _ref2.projectName,
          typeCode = _ref2.typeCode;

      if (issueId && issueCode && issueName) {
        initIssues.push({
          issue: {
            issueId: issueId,
            issueNum: issueCode,
            summary: issueName,
            typeCode: typeCode
          },
          project: {
            id: issueProjectId,
            name: String(issueProjectId) === String(projectId) ? currentProjectName : projectName
          }
        });
      }
    });

    _Modal.open({
      key: branchEditModalKey,
      title: /*#__PURE__*/React.createElement(FormattedMessage, {
        id: "branch.edit"
      }),
      drawer: true,
      children: /*#__PURE__*/React.createElement(BranchEdit, {
        intl: intl,
        appServiceId: appServiceId,
        objectVersionNumber: objectVersionNumber,
        branchName: branchName,
        handleRefresh: handleRefresh,
        initIssues: initIssues
      }),
      style: branchCreateModalStyle,
      okText: /*#__PURE__*/React.createElement(FormattedMessage, {
        id: "save"
      }),
      cancelText: /*#__PURE__*/React.createElement(FormattedMessage, {
        id: "cancel"
      })
    });
  }

  function handleMergeRequest(_x) {
    return _handleMergeRequest.apply(this, arguments);
  }

  function _handleMergeRequest() {
    _handleMergeRequest = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(record) {
      return regeneratorRuntime.wrap(function _callee2$(_context2) {
        while (1) {
          switch (_context2.prev = _context2.next) {
            case 0:
              _context2.prev = 0;
              _context2.next = 3;
              return branchStore.checkCreate(projectId, appServiceId, 'MERGE_REQUEST_CREATE');

            case 3:
              window.open("".concat(record.get('commitUrl').split('/commit')[0], "/merge_requests/new?change_branches=true&merge_request[source_branch]=").concat(record.get('branchName'), "&merge_request[target_branch]=master"));
              _context2.next = 8;
              break;

            case 6:
              _context2.prev = 6;
              _context2.t0 = _context2["catch"](0);

            case 8:
            case "end":
              return _context2.stop();
          }
        }
      }, _callee2, null, [[0, 6]]);
    }));
    return _handleMergeRequest.apply(this, arguments);
  }

  function openSagaDetails(id) {
    _Modal.open({
      title: formatMessage({
        id: 'global.saga-instance.detail'
      }),
      key: _Modal.key(),
      children: /*#__PURE__*/React.createElement(SagaDetails, {
        sagaInstanceId: id,
        instance: true
      }),
      drawer: true,
      okCancel: false,
      okText: formatMessage({
        id: 'close'
      }),
      style: {
        width: 'calc(100% - 3.5rem)'
      }
    });
  } // 分支名称渲染函数


  function branchNameRenderer(_ref3) {
    var record = _ref3.record,
        text = _ref3.text;
    var status = record.get('status');
    var errorMessage = record.get('errorMessage');
    return /*#__PURE__*/React.createElement("div", {
      style: {
        display: 'flex',
        alignItems: 'center'
      }
    }, getIcon(text), /*#__PURE__*/React.createElement(StatusIcon, {
      status: status,
      error: errorMessage,
      name: text,
      width: 0.17,
      clickAble: status !== 'operating' && !isOPERATIONS,
      onClick: function onClick() {
        return openEditIssueModal(record.toData());
      },
      record: text,
      permissionCode: ['choerodon.code.project.develop.code-management.ps.branch.update']
    }), record.get('sagaInstanceId') ? /*#__PURE__*/React.createElement(_Icon, {
      className: "c7n-branch-table-dashBoard",
      type: "developer_board",
      onClick: function onClick() {
        return openSagaDetails(record.get('sagaInstanceId'));
      }
    }) : '');
  } // 操作符渲染函数


  function actionRender(_ref4) {
    var record = _ref4.record;
    var action = [{
      service: ['choerodon.code.project.develop.code-management.ps.default'],
      text: formatMessage({
        id: 'branch.request'
      }),
      action: function action() {
        return handleMergeRequest(record);
      }
    }, {
      service: ['choerodon.code.project.develop.code-management.ps.branch.delete'],
      text: formatMessage({
        id: 'delete'
      }),
      action: function action() {
        return openRemove(record.get('branchName'));
      }
    }];
    var editAction = {
      service: ['choerodon.code.project.develop.code-management.ps.branch.update'],
      text: formatMessage({
        id: 'edit'
      }),
      action: function action() {
        return openEditIssueModal(record.toData());
      }
    };

    if (!isOPERATIONS) {
      action.unshift(editAction);
    } // 分支如果是master  禁止创建合并请求 否则会造成跳转到 gitlab，gailab页面报错的问题


    if (record.get('status') === 'operating' || record.get('branchName') === 'master' && isOPERATIONS) {
      return /*#__PURE__*/React.createElement("div", {
        style: {
          width: 24
        }
      });
    }

    return /*#__PURE__*/React.createElement(Action, {
      data: record.get('branchName') === 'master' ? [editAction] : action,
      className: "".concat(prefixCls, "-item-action")
    });
  } // 打开删除框


  var openRemove = function openRemove(name) {
    var record = tableDs.current;
    var deleteModal = {
      title: formatMessage({
        id: 'branch.action.delete.title'
      }, {
        name: name
      }),
      children: formatMessage({
        id: 'branch.delete.tooltip'
      }),
      okText: formatMessage({
        id: 'delete'
      }),
      okProps: {
        color: 'red'
      },
      cancelProps: {
        color: 'dark'
      }
    };
    tableDs["delete"](record, deleteModal);
  }; // 最新提交渲染函数


  function updateCommitRender(_ref5) {
    var record = _ref5.record,
        text = _ref5.text;
    return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("i", {
      className: "icon icon-point branch-column-icon"
    }), /*#__PURE__*/React.createElement("a", {
      href: record.get('commitUrl'),
      target: "_blank",
      rel: "nofollow me noopener noreferrer"
    }, /*#__PURE__*/React.createElement("span", null, record.get('sha') && record.get('sha').slice(0, 8))), /*#__PURE__*/React.createElement("i", {
      className: "icon icon-schedule branch-col-icon branch-column-icon",
      style: {
        paddingLeft: 16,
        fontSize: 16,
        marginBottom: 2
      }
    }), /*#__PURE__*/React.createElement(TimePopover, {
      content: record.get('commitDate'),
      style: {
        display: 'inline-block',
        color: 'var(--text-color3)'
      }
    })), record.get('commitUserUrl') && record.get('commitUserName') ? /*#__PURE__*/React.createElement(_Tooltip, {
      title: "".concat(record.get('commitUserName')).concat(record.get('commitUserRealName') ? " (".concat(record.get('commitUserRealName'), ")") : '')
    }, /*#__PURE__*/React.createElement("div", {
      className: "branch-user-img",
      style: {
        backgroundImage: "url(".concat(record.get('commitUserUrl'), ")")
      }
    })) : /*#__PURE__*/React.createElement(_Tooltip, {
      title: record.get('commitUserName') ? "".concat(record.get('commitUserName')).concat(record.get('commitUserRealName') ? " (".concat(record.get('commitUserRealName'), ")") : '') : ''
    }, /*#__PURE__*/React.createElement("div", {
      className: "branch-user-img"
    }, record.get('commitUserName') && record.get('commitUserName').slice(0, 1))), /*#__PURE__*/React.createElement(MouserOverWrapper, {
      text: text,
      width: 0.2,
      className: "branch-col-icon"
    }, text));
  } // 创建者渲染函数


  function createUserRender(_ref6) {
    var record = _ref6.record,
        text = _ref6.text;
    return /*#__PURE__*/React.createElement(UserInfo, {
      name: text || '',
      avatar: record.get('createUserUrl'),
      id: record.get('createUserName')
    });
  } // 问题名称渲染函数


  function issueNameRender(_ref7) {
    var record = _ref7.record,
        text = _ref7.text;
    var issueContent = map(record.get('issueInfoList') || [], function (issueItem, index) {
      var _ref8 = issueItem || {},
          typeCode = _ref8.typeCode,
          issueId = _ref8.issueId,
          issueProjectId = _ref8.issueProjectId,
          issueCode = _ref8.issueCode,
          projectName = _ref8.projectName,
          issueName = _ref8.issueName;

      return /*#__PURE__*/React.createElement("div", {
        className: "".concat(prefixCls, "-issue-item")
      }, /*#__PURE__*/React.createElement("div", {
        className: "".concat(prefixCls, "-issue-item-title")
      }, typeCode ? getOptionContent(typeCode) : null, /*#__PURE__*/React.createElement("a", {
        onClick: function onClick() {
          return openIssueDetail(issueId, record.get('branchName'), issueProjectId);
        },
        role: "none",
        className: "".concat(prefixCls, "-issue-item-title-name")
      }, /*#__PURE__*/React.createElement(_Tooltip, {
        title: "".concat(issueCode, " ").concat(issueName)
      }, "".concat(issueCode, " ").concat(issueName)))), /*#__PURE__*/React.createElement("div", {
        className: "".concat(prefixCls, "-issue-item-project")
      }, /*#__PURE__*/React.createElement(_Icon, {
        type: "project_line",
        className: "".concat(prefixCls, "-issue-item-project-icon")
      }), /*#__PURE__*/React.createElement("span", null, projectName)));
    });
    return /*#__PURE__*/React.createElement("div", {
      className: "".concat(prefixCls, "-issue")
    }, /*#__PURE__*/React.createElement("span", {
      className: "".concat(prefixCls, "-issue-label")
    }, "\u5173\u8054\uFF1A"), issueContent ? issueContent[0] : null, (issueContent === null || issueContent === void 0 ? void 0 : issueContent.length) > 1 ? /*#__PURE__*/React.createElement(_Popover, {
      placement: "bottom",
      content: issueContent,
      overlayClassName: "".concat(prefixCls, "-issue-popover"),
      arrowPointAtCenter: true
    }, /*#__PURE__*/React.createElement(_Icon, {
      type: "expand_more",
      className: "".concat(prefixCls, "-issue-expand")
    })) : null);
  }
  /**
   * 获取issue的options
   * @param s
   * @returns {*}
   */


  var getOptionContent = function getOptionContent(typeCode) {
    var mes = '';
    var icon = '';
    var color = '';

    switch (typeCode) {
      case 'story':
        mes = formatMessage({
          id: 'branch.issue.story'
        });
        icon = 'agile_story';
        color = '#00bfa5';
        break;

      case 'bug':
        mes = formatMessage({
          id: 'branch.issue.bug'
        });
        icon = 'agile_fault';
        color = '#f44336';
        break;

      case 'issue_epic':
        mes = formatMessage({
          id: 'branch.issue.epic'
        });
        icon = 'agile_epic';
        color = '#743be7';
        break;

      case 'sub_task':
        mes = formatMessage({
          id: 'branch.issue.subtask'
        });
        icon = 'agile_subtask';
        color = '#4d90fe';
        break;

      default:
        mes = formatMessage({
          id: 'branch.issue.task'
        });
        icon = 'agile_task';
        color = '#4d90fe';
    }

    return /*#__PURE__*/React.createElement(_Tooltip, {
      title: mes
    }, /*#__PURE__*/React.createElement("div", {
      style: {
        color: color
      },
      className: "branch-issue"
    }, /*#__PURE__*/React.createElement("i", {
      className: "icon icon-".concat(icon)
    })));
  };

  function openIssueDetail(id, name, issueProjectId) {
    var newProjectId = issueProjectId || projectId;

    _Modal.open({
      key: issueDetailModalKey,
      title: /*#__PURE__*/React.createElement(FormattedMessage, {
        id: "branch.detailHead",
        values: {
          name: name
        }
      }),
      drawer: true,
      children: /*#__PURE__*/React.createElement(IssueDetail, {
        intl: intl,
        projectId: newProjectId,
        issueId: id,
        orgId: organizationId
      }),
      style: issueDetailModalStyle,
      okCancel: false,
      okText: /*#__PURE__*/React.createElement(FormattedMessage, {
        id: "envPl.close"
      })
    });
  }
  /**
   * theme4主题 table column渲染
   */


  function theme4RenderColumn(_ref9) {
    var _record$get;

    var record = _ref9.record,
        text = _ref9.text;
    var status = record.get('status');
    var errorMessage = record.get('errorMessage');
    return /*#__PURE__*/React.createElement("div", {
      className: styles === null || styles === void 0 ? void 0 : styles['c7n-branch-theme4-table-column']
    }, /*#__PURE__*/React.createElement("div", {
      className: styles === null || styles === void 0 ? void 0 : styles['c7n-branch-theme4-table-column-side'],
      style: {
        width: '600px',
        display: 'flex',
        alignItems: 'center',
        overflow: 'hidden',
        flexShrink: 0
      }
    }, /*#__PURE__*/React.createElement("div", {
      style: {
        marginRight: 30
      }
    }, /*#__PURE__*/React.createElement("div", {
      className: styles === null || styles === void 0 ? void 0 : styles['c7n-branch-theme4-table-column-side-line']
    }, /*#__PURE__*/React.createElement(_Icon, {
      type: "branch"
    }), getIcon(record.get('branchName')), /*#__PURE__*/React.createElement(StatusIcon, {
      status: status,
      error: errorMessage,
      name: record.get('branchName'),
      width: 0.17,
      record: record.get('branchName'),
      className: "".concat(prefixCls, "-item-branchName")
    })), /*#__PURE__*/React.createElement("div", {
      className: styles === null || styles === void 0 ? void 0 : styles['c7n-branch-theme4-table-column-side-line']
    }, /*#__PURE__*/React.createElement(_Icon, {
      type: "point"
    }), /*#__PURE__*/React.createElement("a", {
      href: record.get('commitUrl')
    }, (_record$get = record.get('sha')) === null || _record$get === void 0 ? void 0 : _record$get.substring(0, 8)), record.get('commitUserRealName') && /*#__PURE__*/React.createElement(UserInfo, {
      name: record.get('commitUserRealName'),
      id: record.get('commitUserName'),
      avatar: record.get('commitUserUrl'),
      showName: false
    }), /*#__PURE__*/React.createElement("span", {
      className: styles === null || styles === void 0 ? void 0 : styles['c7n-branch-theme4-table-column-side-line-commitContent']
    }, record.get('commitContent'), "\xA0\xB7\xA0"), /*#__PURE__*/React.createElement(UserInfo, {
      name: record.get('createUserRealName'),
      id: record.get('createUserName'),
      avatar: record.get('createUserUrl'),
      showName: false
    }), /*#__PURE__*/React.createElement("span", null, "\u521B\u5EFA\u4E8E"), /*#__PURE__*/React.createElement(TimePopover, {
      content: record.get('creationDate')
    })))), actionRender({
      record: record
    }), !isEmpty(record.get('issueInfoList')) && issueNameRender({
      record: record,
      text: text
    }));
  } // 获取分支正文列表


  function tableBranch() {
    if (branchStore.getIsEmpty) {
      return /*#__PURE__*/React.createElement(EmptyPage, {
        title: formatMessage({
          id: 'empty.title.prohibited'
        }),
        describe: formatMessage({
          id: 'empty.title.code'
        }),
        btnText: formatMessage({
          id: 'empty.link.code'
        }),
        pathname: "/rducm/code-lib-management/apply"
      });
    }

    return /*#__PURE__*/React.createElement("div", {
      className: "c7ncd-tab-table"
    }, /*#__PURE__*/React.createElement(_Table, {
      className: classNames('c7n-branch-main-table', styles === null || styles === void 0 ? void 0 : styles['c7n-branch-theme4-table']),
      queryBar: "bar",
      dataSet: tableDs
    }, columnsRender({
      branchNameRenderer: branchNameRenderer,
      actionRender: actionRender,
      updateCommitRender: updateCommitRender,
      createUserRender: createUserRender,
      isOPERATIONS: isOPERATIONS,
      issueNameRender: issueNameRender,
      theme4RenderColumn: theme4RenderColumn
    })));
  }

  return /*#__PURE__*/React.createElement(Page, {
    className: classNames('c7n-region c7n-branch', styles === null || styles === void 0 ? void 0 : styles['c7n-branch-theme4-page']),
    service: ['choerodon.code.project.develop.code-management.ps.branch.create']
  }, !appServiceId || appServiceDs.status !== 'ready' ? /*#__PURE__*/React.createElement(Loading, {
    display: true
  }) : tableBranch());
}

export default injectIntl(observer(Branch));