import "choerodon-ui/pro/lib/modal/style";
import _Modal from "choerodon-ui/pro/lib/modal";
import React, { useMemo } from 'react';
import { observer } from 'mobx-react-lite';
import { HeaderButtons } from '@choerodon/master';
import GroupForm from "../../modals/GroupForm";
import { useEnvironmentStore } from "../../../stores";
import { useMainStore } from "../../stores";

var groupKey = _Modal.key();

var EmptyPage = observer(function () {
  var modalStyle = useMemo(function () {
    return {
      width: 380
    };
  }, []);

  var _useEnvironmentStore = useEnvironmentStore(),
      intlPrefix = _useEnvironmentStore.intlPrefix,
      formatMessage = _useEnvironmentStore.intl.formatMessage,
      treeDs = _useEnvironmentStore.treeDs;

  var _useMainStore = useMainStore(),
      groupFormDs = _useMainStore.groupFormDs;

  function openGroupModal() {
    _Modal.open({
      key: groupKey,
      title: formatMessage({
        id: "".concat(intlPrefix, ".group.create")
      }),
      children: /*#__PURE__*/React.createElement(GroupForm, {
        dataSet: groupFormDs,
        treeDs: treeDs
      }),
      drawer: true,
      style: modalStyle,
      afterClose: function afterClose() {
        groupFormDs.current.reset();
      }
    });
  }

  function getButtons() {
    return [{
      permissions: ['choerodon.code.project.deploy.environment.ps.group-create'],
      name: formatMessage({
        id: "".concat(intlPrefix, ".group.create")
      }),
      icon: 'playlist_add',
      handler: openGroupModal,
      display: true
    }];
  }

  return /*#__PURE__*/React.createElement(HeaderButtons, {
    items: getButtons(),
    showClassName: true
  });
});
export default EmptyPage;