import "choerodon-ui/lib/button/style";
import _Button from "choerodon-ui/lib/button";
import "choerodon-ui/lib/collapse/style";
import _Collapse from "choerodon-ui/lib/collapse";
import "choerodon-ui/lib/modal/style";
import _Modal from "choerodon-ui/lib/modal";

var _class, _class2, _temp;

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 _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 _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 _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 _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }

function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }

function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }

function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }

function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }

function _possibleConstructorReturn(self, call) { if (call && (typeof call === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }

function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }

function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }

function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }

import React, { Component, Fragment } from 'react';
import { FormattedMessage } from 'react-intl';
import { observer } from 'mobx-react';
import _ from 'lodash';
import Store from "../../stores";
import SimpleTable from "./SimpleTable";
import YamlEditor from "../../../../../../../components/yamlEditor";
import "./index.less";
var Sidebar = _Modal.Sidebar;
var Panel = _Collapse.Panel;
var PANEL_TYPE = ['ports', 'volume', 'health', 'security', 'label', 'variables'];

var ContainerLabel = function ContainerLabel() {
  return /*#__PURE__*/React.createElement("span", {
    className: "c7ncd-deploy-container-label"
  }, /*#__PURE__*/React.createElement(FormattedMessage, {
    id: "ist.deploy.container"
  }));
};

var DetailsSidebar = observer(_class = (_temp = _class2 = /*#__PURE__*/function (_Component) {
  _inherits(DetailsSidebar, _Component);

  var _super = _createSuper(DetailsSidebar);

  function DetailsSidebar() {
    var _this;

    _classCallCheck(this, DetailsSidebar);

    for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
      args[_key] = arguments[_key];
    }

    _this = _super.call.apply(_super, [this].concat(args));
    _this.state = {
      activeKey: [],
      isJson: true
    };

    _this.handlePanelChange = function (key) {
      var isExpand = key.length === PANEL_TYPE.length;

      _this.setState({
        activeKey: key,
        isExpand: isExpand
      });
    };

    _this.handleExpandAll = function () {
      _this.setState(function (prev) {
        return {
          isExpand: !prev.isExpand,
          activeKey: !prev.isExpand ? PANEL_TYPE : []
        };
      });
    };

    _this.handleChangeType = function () {
      _this.setState(function (prev) {
        return {
          isJson: !prev.isJson
        };
      });
    };

    _this.renderHealth = function (containers) {
      var healthContent = null;

      if (containers && containers.length) {
        healthContent = _.map(containers, function (item) {
          var name = item.name;
          var readinessProbe = item.readinessProbe || {};
          var livenessProbe = item.livenessProbe || {};
          var readDom = returnHealthDom('readiness', readinessProbe);
          var liveDom = returnHealthDom('liveness', livenessProbe);
          return /*#__PURE__*/React.createElement("div", {
            key: name,
            className: "c7ncd-deploy-health-wrap"
          }, /*#__PURE__*/React.createElement("div", {
            className: "c7ncd-deploy-container-title"
          }, /*#__PURE__*/React.createElement("span", {
            className: "c7ncd-deploy-container-name"
          }, name), /*#__PURE__*/React.createElement(ContainerLabel, null)), /*#__PURE__*/React.createElement("div", {
            className: "c7ncd-deploy-health-content"
          }, readDom, liveDom));
        });
      } else {
        healthContent = /*#__PURE__*/React.createElement("div", {
          className: "c7ncd-deploy-detail-empty"
        }, /*#__PURE__*/React.createElement("p", null, /*#__PURE__*/React.createElement(FormattedMessage, {
          id: "ist.deploy.health.readiness"
        })), /*#__PURE__*/React.createElement(FormattedMessage, {
          id: "ist.deploy.volume.type"
        }), /*#__PURE__*/React.createElement("span", {
          className: "c7ncd-deploy-health-empty"
        }, /*#__PURE__*/React.createElement(FormattedMessage, {
          id: "ist.deploy.none"
        })));
      }

      return healthContent;
    };

    _this.renderVar = function (containers) {
      var columns = [{
        width: '50%',
        title: /*#__PURE__*/React.createElement(FormattedMessage, {
          id: "ist.deploy.variables.key"
        }),
        key: 'name',
        dataIndex: 'name'
      }, {
        width: '50%',
        title: /*#__PURE__*/React.createElement(FormattedMessage, {
          id: "ist.deploy.variables.value"
        }),
        key: 'value',
        dataIndex: 'value'
      }];
      var hasEnv = false;

      var envContent = _.map(containers, function (_ref) {
        var name = _ref.name,
            env = _ref.env;

        if (env && env.length) {
          hasEnv = true;
        }

        return /*#__PURE__*/React.createElement(Fragment, {
          key: name
        }, /*#__PURE__*/React.createElement("div", {
          className: "c7ncd-deploy-container-title"
        }, /*#__PURE__*/React.createElement("span", {
          className: "c7ncd-deploy-container-name"
        }, name), /*#__PURE__*/React.createElement(ContainerLabel, null)), /*#__PURE__*/React.createElement("div", {
          className: "c7ncd-deploy-container-table"
        }, /*#__PURE__*/React.createElement(SimpleTable, {
          columns: columns,
          data: env && env.slice()
        })));
      });

      if (!hasEnv) {
        envContent = /*#__PURE__*/React.createElement("div", {
          className: "c7ncd-deploy-empty-table"
        }, /*#__PURE__*/React.createElement(SimpleTable, {
          columns: columns,
          data: []
        }));
      }

      return envContent;
    };

    _this.renderLabel = function (labels, annotations) {
      /**
       * 表格数据
       * @param {object} obj
       * @param {array} col
       */
      function format(obj, col) {
        var arr = []; // eslint-disable-next-line no-restricted-syntax

        for (var key in obj) {
          // eslint-disable-next-line no-prototype-builtins
          if (obj.hasOwnProperty(key)) {
            var value = obj[key];
            arr.push({
              key: key,
              value: value
            });
          }
        }

        return /*#__PURE__*/React.createElement("div", {
          className: "c7ncd-deploy-container-table"
        }, /*#__PURE__*/React.createElement(SimpleTable, {
          columns: columns,
          data: arr
        }));
      }

      var columns = [{
        width: '50%',
        title: /*#__PURE__*/React.createElement(FormattedMessage, {
          id: "ist.deploy.key"
        }),
        key: 'key',
        dataIndex: 'key'
      }, {
        width: '50%',
        title: /*#__PURE__*/React.createElement(FormattedMessage, {
          id: "ist.deploy.value"
        }),
        key: 'value',
        dataIndex: 'value'
      }];
      var labelContent = format(labels, columns);
      var annoContent = format(annotations, columns);
      return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement("div", {
        className: "c7ncd-deploy-label"
      }, "Labels"), labelContent, /*#__PURE__*/React.createElement("div", {
        className: "c7ncd-deploy-label"
      }, "Annotations"), annoContent);
    };

    _this.renderVolume = function (containers, volumes) {
      var volumeContent = null;

      var volumeType = function volumeType(vol, mounts) {
        var vDom = volumesTemplate(vol);
        var columnsItem = ['mountPath', 'subPath', 'readOnly'];

        var columns = _.map(columnsItem, function (item) {
          return {
            title: /*#__PURE__*/React.createElement(FormattedMessage, {
              id: "ist.deploy.volume.".concat(item)
            }),
            key: item,
            dataIndex: item,
            width: item === 'readOnly' ? '16%' : '42%',
            render: function render(text) {
              return _.isBoolean(text) ? text.toString() : text;
            }
          };
        });

        return /*#__PURE__*/React.createElement("div", {
          key: vol.name,
          className: "c7ncd-deploy-volume-wrap"
        }, vDom, /*#__PURE__*/React.createElement(SimpleTable, {
          columns: columns,
          data: mounts,
          rowKey: function rowKey(record) {
            return record.key;
          }
        }));
      };

      if (volumes && volumes.length) {
        volumeContent = _.map(volumes, function (vol) {
          var name = vol.name;
          var mounts = [];

          _.forEach(containers, function (item) {
            var volumeMounts = item.volumeMounts;

            var filterVol = _.filter(volumeMounts, function (m) {
              return m.name === name;
            });

            mounts.push.apply(mounts, _toConsumableArray(filterVol));
          });

          return volumeType(vol, mounts);
        });
      } else {
        volumeContent = /*#__PURE__*/React.createElement("div", {
          className: "c7ncd-deploy-detail-empty"
        }, /*#__PURE__*/React.createElement(FormattedMessage, {
          id: "ist.deploy.volume"
        }), /*#__PURE__*/React.createElement(FormattedMessage, {
          id: "ist.deploy.volume.empty"
        }));
      }

      return volumeContent;
    };

    _this.renderSecurity = function (containers, hostIPC, hostNetwork) {
      var containerArr = containers.length ? containers : [{}];

      var securityCtx = _.map(containerArr, function (item) {
        var imagePullPolicy = item.imagePullPolicy,
            name = item.name;
        var securityContext = item.securityContext || {};
        var privileged = securityContext.privileged,
            allowPrivilegeEscalation = securityContext.allowPrivilegeEscalation,
            readOnlyRootFilesystem = securityContext.readOnlyRootFilesystem,
            runAsNonRoot = securityContext.runAsNonRoot,
            capabilities = securityContext.capabilities;
        var capAdd = [];
        var capDrop = [];

        if (!_.isEmpty(capabilities)) {
          capAdd = capabilities.add;
          capDrop = capabilities.drop;
        }

        var addArr = capAdd.length ? _.map(capAdd, function (text) {
          return /*#__PURE__*/React.createElement("p", {
            className: "c7ncd-deploy-detail-text"
          }, text);
        }) : /*#__PURE__*/React.createElement(FormattedMessage, {
          id: "ist.deploy.none"
        });
        var dropArr = capDrop.length ? _.map(capDrop, function (text) {
          return /*#__PURE__*/React.createElement("p", {
            className: "c7ncd-deploy-detail-text"
          }, text);
        }) : /*#__PURE__*/React.createElement(FormattedMessage, {
          id: "ist.deploy.none"
        });
        return /*#__PURE__*/React.createElement(Fragment, {
          key: name
        }, /*#__PURE__*/React.createElement("div", {
          className: "c7ncd-deploy-container-title"
        }, /*#__PURE__*/React.createElement("span", {
          className: "c7ncd-deploy-container-name"
        }, name), /*#__PURE__*/React.createElement(ContainerLabel, null)), /*#__PURE__*/React.createElement("div", {
          className: "c7ncd-deploy-security-block"
        }, securityItem('imagePullPolicy', imagePullPolicy, '_flex'), securityItem('privileged', privileged, '_flex'), securityItem('allowPrivilegeEscalation', allowPrivilegeEscalation, '_flex')), /*#__PURE__*/React.createElement("div", {
          className: "c7ncd-deploy-security-block"
        }, securityItem('runAsNonRoot', runAsNonRoot), securityItem('readOnlyRootFilesystem', readOnlyRootFilesystem)), /*#__PURE__*/React.createElement("div", {
          className: "c7ncd-deploy-security-block"
        }, securityItem('capabilities.add', addArr), securityItem('capabilities.drop', dropArr)));
      });

      return /*#__PURE__*/React.createElement("div", {
        className: "c7ncd-deploy-security-wrap"
      }, /*#__PURE__*/React.createElement("div", {
        className: "c7ncd-deploy-security-block"
      }, securityItem('hostIPC', hostIPC), securityItem('hostNetwork', hostNetwork)), securityCtx);
    };

    return _this;
  }

  _createClass(DetailsSidebar, [{
    key: "renderPorts",
    value: function renderPorts(containers) {
      var _this2 = this;

      var portsContent = null;
      var hasPorts = false;

      if (containers && containers.length) {
        var colItems = ['name', 'containerPort', 'protocol', 'hostPort'];

        var columns = _.map(colItems, function (item) {
          return {
            title: /*#__PURE__*/React.createElement(FormattedMessage, {
              id: "ist.deploy.ports.".concat(item)
            }),
            key: item,
            dataIndex: item,
            render: textOrNA
          };
        });

        portsContent = _.map(containers, function (item) {
          var name = item.name,
              ports = item.ports;

          if (ports && ports.length) {
            hasPorts = true;
          }

          return /*#__PURE__*/React.createElement(Fragment, {
            key: name
          }, /*#__PURE__*/React.createElement("div", {
            className: "c7ncd-deploy-container-title"
          }, /*#__PURE__*/React.createElement("span", {
            className: "c7ncd-deploy-container-name"
          }, name), _this2.containerLabel), /*#__PURE__*/React.createElement("div", {
            className: "c7ncd-deploy-container-table"
          }, /*#__PURE__*/React.createElement(SimpleTable, {
            columns: columns,
            data: ports && ports.slice()
          })));
        });
      } else {
        portsContent = /*#__PURE__*/React.createElement("div", {
          className: "c7ncd-deploy-detail-empty"
        }, /*#__PURE__*/React.createElement(FormattedMessage, {
          id: "ist.deploy.ports.map"
        }), /*#__PURE__*/React.createElement(FormattedMessage, {
          id: "ist.deploy.ports.empty"
        }));
      }

      if (!hasPorts) {
        portsContent = /*#__PURE__*/React.createElement("div", {
          className: "c7ncd-deploy-detail-empty"
        }, /*#__PURE__*/React.createElement(FormattedMessage, {
          id: "ist.deploy.ports.map"
        }), /*#__PURE__*/React.createElement(FormattedMessage, {
          id: "ist.deploy.ports.empty"
        }));
      }

      return portsContent;
    }
  }, {
    key: "render",
    value: function render() {
      var _this3 = this;

      var _this$context = this.context,
          detailsStore = _this$context.detailsStore,
          formatMessage = _this$context.intl.formatMessage;
      var _this$props = this.props,
          visible = _this$props.visible,
          onClose = _this$props.onClose;
      var _this$state = this.state,
          activeKey = _this$state.activeKey,
          isExpand = _this$state.isExpand,
          isJson = _this$state.isJson;
      var detail = detailsStore.getDeployments.detail,
          getDeploymentsYaml = detailsStore.getDeploymentsYaml;
      var containers = [];
      var volumes = [];
      var hostIPC = null;
      var hostNetwork = null;
      var labels = [];
      var annotations = [];

      if (detail) {
        if (detail.metadata) {
          labels = detail.metadata.labels;
          annotations = detail.metadata.annotations;
        }

        if (detail.spec && detail.spec.template && detail.spec.template.spec) {
          var spec = detail.spec.template.spec;
          containers = spec.containers;
          volumes = spec.volumes;
          hostIPC = spec.hostIPC;
          hostNetwork = spec.hostNetwork;
        }
      }

      var renderFun = {
        ports: function ports() {
          return _this3.renderPorts(containers);
        },
        volume: function volume() {
          return _this3.renderVolume(containers, volumes);
        },
        health: function health() {
          return _this3.renderHealth(containers);
        },
        variables: function variables() {
          return _this3.renderVar(containers);
        },
        security: function security() {
          return _this3.renderSecurity(containers, hostIPC, hostNetwork);
        },
        label: function label() {
          return _this3.renderLabel(labels, annotations);
        }
      };
      return /*#__PURE__*/React.createElement(Sidebar, {
        destroyOnClose: true,
        visible: true,
        footer: [/*#__PURE__*/React.createElement(_Button, {
          type: "primary",
          funcType: "raised",
          key: "close",
          onClick: onClose
        }, /*#__PURE__*/React.createElement(FormattedMessage, {
          id: "close"
        }))],
        title: formatMessage({
          id: "ist.deploy.".concat(detail ? detail.kind : 'Deployment', ".detail")
        })
      }, /*#__PURE__*/React.createElement("div", {
        className: "c7ncd-expand-btn-wrap"
      }, /*#__PURE__*/React.createElement(_Button, {
        className: "c7ncd-deploy-detail-type-btn",
        onClick: this.handleChangeType
      }, /*#__PURE__*/React.createElement(FormattedMessage, {
        id: "ist.deploy.type.".concat(isJson ? 'yaml' : 'json')
      })), isJson && /*#__PURE__*/React.createElement(_Button, {
        className: "c7ncd-expand-btn",
        onClick: this.handleExpandAll
      }, /*#__PURE__*/React.createElement(FormattedMessage, {
        id: isExpand ? 'collapseAll' : 'expandAll'
      }))), isJson ? /*#__PURE__*/React.createElement(_Collapse, {
        bordered: false,
        activeKey: activeKey,
        onChange: this.handlePanelChange
      }, _.map(PANEL_TYPE, function (item) {
        return /*#__PURE__*/React.createElement(Panel, {
          key: item,
          header: /*#__PURE__*/React.createElement("div", {
            className: "c7ncd-deploy-panel-header"
          }, /*#__PURE__*/React.createElement("div", {
            className: "c7ncd-deploy-panel-title"
          }, /*#__PURE__*/React.createElement(FormattedMessage, {
            id: "ist.deploy.".concat(item)
          })), /*#__PURE__*/React.createElement("div", {
            className: "c7ncd-deploy-panel-text"
          }, /*#__PURE__*/React.createElement(FormattedMessage, {
            id: "ist.deploy.".concat(item, ".describe")
          }))),
          className: "c7ncd-deploy-panel"
        }, visible && renderFun[item]());
      })) : /*#__PURE__*/React.createElement(YamlEditor, {
        value: getDeploymentsYaml,
        originValue: getDeploymentsYaml,
        readOnly: true
      }));
    }
  }]);

  return DetailsSidebar;
}(Component), _class2.contextType = Store, _temp)) || _class;

export { DetailsSidebar as default };
/**
 * 内容为空时返回 n/a
 */

function textOrNA(text) {
  if (!text && !_.isBoolean(text)) {
    return 'n/a';
  }

  return String(text);
}
/**
 * 返回健康检查的DOM
 * @param {string} name
 * @param {obj} data
 */


function returnHealthDom(name, data) {
  var items = ['failureThreshold', 'initialDelaySeconds', 'periodSeconds', 'successThreshold', 'timeoutSeconds'];
  return /*#__PURE__*/React.createElement("div", {
    className: "c7ncd-deploy-health-block"
  }, /*#__PURE__*/React.createElement("div", {
    className: "c7ncd-deploy-health-title"
  }, /*#__PURE__*/React.createElement(FormattedMessage, {
    id: "ist.deploy.health.".concat(name)
  })), /*#__PURE__*/React.createElement("div", {
    className: "c7ncd-deploy-health-main"
  }, _.map(items, function (item) {
    return /*#__PURE__*/React.createElement("div", {
      className: "c7ncd-deploy-health-item"
    }, /*#__PURE__*/React.createElement("p", {
      className: "c7ncd-deploy-detail-label"
    }, /*#__PURE__*/React.createElement(FormattedMessage, {
      id: "ist.deploy.health.".concat(item)
    })), /*#__PURE__*/React.createElement("p", {
      className: "c7ncd-deploy-detail-text"
    }, textOrNA(data[item])));
  })));
}
/**
 * 返回数据卷的项目 DOM
 * @param name
 * @param data
 * @param isBool
 * @returns {*}
 */


function volumesItem(name, data) {
  var isBool = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  var value = isBool && _.isBoolean(data) ? data.toString() : data;
  return /*#__PURE__*/React.createElement("div", {
    className: "c7ncd-deploy-volume-item"
  }, /*#__PURE__*/React.createElement("p", {
    className: "c7ncd-deploy-detail-label"
  }, /*#__PURE__*/React.createElement(FormattedMessage, {
    id: "ist.deploy.volume.".concat(name)
  })), /*#__PURE__*/React.createElement("p", {
    className: "c7ncd-deploy-detail-text"
  }, value));
}

function volumesTemplate(data) {
  var template = null;
  var VOL_TYPE = ['configMap', 'persistentVolumeClaim', 'cipher', 'hostPath'];
  var vKey = Object.keys(data);
  var name = data.name;

  var type = _.toString(_.filter(VOL_TYPE, function (item) {
    return vKey.includes(item);
  }));

  switch (type) {
    case 'configMap':
    case 'cipher':
      {
        var _data$type = data[type],
            defaultMode = _data$type.defaultMode,
            items = _data$type.items,
            optional = _data$type.optional;
        var itemDom = null;

        if (items && items.length) {
          var columns = [{
            title: /*#__PURE__*/React.createElement(FormattedMessage, {
              id: "ist.deploy.volume.config.key"
            }),
            key: 'key',
            dataIndex: 'key'
          }, {
            title: /*#__PURE__*/React.createElement(FormattedMessage, {
              id: "ist.deploy.volume.config.mode"
            }),
            key: 'mode',
            dataIndex: 'mode'
          }, {
            title: /*#__PURE__*/React.createElement(FormattedMessage, {
              id: "ist.deploy.volume.config.path"
            }),
            key: 'path',
            dataIndex: 'path'
          }];
          itemDom = /*#__PURE__*/React.createElement(SimpleTable, {
            columns: columns,
            data: items
          });
        } else {
          itemDom = /*#__PURE__*/React.createElement("p", {
            className: "c7ncd-deploy-detail-text"
          }, /*#__PURE__*/React.createElement(FormattedMessage, {
            id: "null"
          }));
        }

        template = /*#__PURE__*/React.createElement("div", {
          className: "c7ncd-deploy-volume-main"
        }, volumesItem('defaultMode', defaultMode), volumesItem('optional', optional, true), /*#__PURE__*/React.createElement("div", {
          className: "c7ncd-deploy-volume-item".concat(items ? '_full' : '')
        }, /*#__PURE__*/React.createElement("p", {
          className: "c7ncd-deploy-detail-label"
        }, /*#__PURE__*/React.createElement(FormattedMessage, {
          id: "ist.deploy.volume.item"
        })), itemDom));
        break;
      }

    case 'persistentVolumeClaim':
      {
        var _data$type2 = data[type],
            claimName = _data$type2.claimName,
            readOnly = _data$type2.readOnly;
        template = /*#__PURE__*/React.createElement("div", {
          className: "c7ncd-deploy-volume-main"
        }, volumesItem('claimName', claimName), volumesItem('readOnly', readOnly, true));
        break;
      }

    case 'hostPath':
      {
        var path = data[type].path;
        template = /*#__PURE__*/React.createElement("div", {
          className: "c7ncd-deploy-volume-main"
        }, volumesItem('path', path), volumesItem('type', type));
        break;
      }

    default:
      type = '未知';
      break;
  }

  return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement("div", {
    className: "c7ncd-deploy-volume-main"
  }, volumesItem('name', name), volumesItem('volume.type', type)), template);
}

function securityItem(name, data) {
  var type = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
  var content = _.isArray(data) || _.isObject(data) ? data : /*#__PURE__*/React.createElement("p", {
    className: "c7ncd-deploy-detail-text"
  }, textOrNA(data));
  return /*#__PURE__*/React.createElement("div", {
    className: "c7ncd-deploy-security-item".concat(type)
  }, /*#__PURE__*/React.createElement("p", {
    className: "c7ncd-deploy-detail-label"
  }, /*#__PURE__*/React.createElement(FormattedMessage, {
    id: "ist.deploy.security.".concat(name)
  })), content);
}