import "choerodon-ui/pro/lib/button/style";
import _Button from "choerodon-ui/pro/lib/button";
import "choerodon-ui/pro/lib/form/style";
import _Form from "@hzero-front-ui/c7n-ui/lib/FormPro";
import "choerodon-ui/pro/lib/password/style";
import _Password from "choerodon-ui/pro/lib/password";
import "choerodon-ui/pro/lib/text-field/style";
import _TextField from "choerodon-ui/pro/lib/text-field";
import "choerodon-ui/pro/lib/url-field/style";
import _UrlField from "choerodon-ui/pro/lib/url-field";
import "choerodon-ui/pro/lib/select-box/style";
import _SelectBox from "choerodon-ui/pro/lib/select-box";
import "choerodon-ui/pro/lib/icon/style";
import _Icon from "choerodon-ui/pro/lib/icon";
import "choerodon-ui/lib/divider/style";
import _Divider from "choerodon-ui/lib/divider";
import "choerodon-ui/pro/lib/select/style";
import _Select from "choerodon-ui/pro/lib/select";
import React, { Fragment } from 'react';
import { injectIntl, FormattedMessage } from 'react-intl';
import { observer } from 'mobx-react-lite';
import Tips from "../../../../components/new-tips";
import { useEditAppServiceStore } from "./stores";
var Option = _Select.Option;
var Settings = injectIntl(observer(function (_ref) {
  var record = _ref.record,
      handleTestChart = _ref.handleTestChart;

  var _useEditAppServiceSto = useEditAppServiceStore(),
      formatMessage = _useEditAppServiceSto.intl.formatMessage,
      intlPrefix = _useEditAppServiceSto.intlPrefix;

  function renderOption(_ref2) {
    var optionRecord = _ref2.record,
        value = _ref2.value,
        text = _ref2.text;

    if (optionRecord.get('type') === 'DEFAULT_REPO') {
      return "".concat(text, " (\u9ED8\u8BA4Docker\u4ED3\u5E93)");
    }

    return text;
  }

  function renderInput(_ref3) {
    var value = _ref3.value,
        text = _ref3.text;

    if (value && value.type === 'DEFAULT_REPO') {
      return "".concat(text, " (\u9ED8\u8BA4Docker\u4ED3\u5E93)");
    }

    return text;
  }

  return /*#__PURE__*/React.createElement("div", {
    className: "content-settings"
  }, /*#__PURE__*/React.createElement(_Divider, {
    className: "c7ncd-form-divider"
  }), /*#__PURE__*/React.createElement("div", {
    className: "content-settings-title"
  }, /*#__PURE__*/React.createElement(Tips, {
    helpText: formatMessage({
      id: "".concat(intlPrefix, ".setting.tips")
    }),
    title: formatMessage({
      id: "".concat(intlPrefix, ".create.settings")
    })
  })), /*#__PURE__*/React.createElement("div", {
    className: "content-settings-tips"
  }, /*#__PURE__*/React.createElement(_Icon, {
    type: "info",
    className: "content-settings-tips-icon"
  }), /*#__PURE__*/React.createElement(FormattedMessage, {
    id: "".concat(intlPrefix, ".create.settings.tips")
  })), /*#__PURE__*/React.createElement(_Form, {
    record: record
  }, /*#__PURE__*/React.createElement(_Select, {
    searchable: true,
    clearButton: false,
    name: "harborRepoConfigDTO",
    optionRenderer: renderOption,
    renderer: renderInput,
    addonAfter: /*#__PURE__*/React.createElement(Tips, {
      helpText: formatMessage({
        id: "".concat(intlPrefix, ".docker.tips")
      })
    })
  }), /*#__PURE__*/React.createElement(_SelectBox, {
    name: "chartType"
  }, /*#__PURE__*/React.createElement(Option, {
    value: "default"
  }, formatMessage({
    id: "".concat(intlPrefix, ".helm.default")
  })), /*#__PURE__*/React.createElement(Option, {
    value: "custom"
  }, formatMessage({
    id: "".concat(intlPrefix, ".helm.custom")
  }))), record.get('chartType') === 'custom' ? [/*#__PURE__*/React.createElement(_UrlField, {
    name: "url"
  }), /*#__PURE__*/React.createElement(_TextField, {
    name: "userName"
  }), /*#__PURE__*/React.createElement(_Password, {
    name: "password"
  })] : null), record.get('chartType') === 'custom' && /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(_Button, {
    onClick: handleTestChart,
    funcType: "raised",
    className: "content-settings-button"
  }, /*#__PURE__*/React.createElement(FormattedMessage, {
    id: "".concat(intlPrefix, ".test")
  })), record.get('chartStatus') && /*#__PURE__*/React.createElement("span", null, /*#__PURE__*/React.createElement(_Icon, {
    type: record.get('chartStatus') === 'success' ? 'check_circle' : 'cancel',
    className: "content-settings-link-".concat(record.get('chartStatus'))
  }), formatMessage({
    id: "".concat(intlPrefix, ".test.").concat(record.get('chartStatus'))
  }))));
}));
export default Settings;