CopyToModal.tsx 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. import { useState } from "react";
  2. import { Modal } from "antd";
  3. import CopyToStep from "./CopyToStep";
  4. import { IChannel } from "./Channel";
  5. interface IWidget {
  6. trigger: JSX.Element | string;
  7. channel?: IChannel;
  8. }
  9. const Widget = ({ trigger, channel }: IWidget) => {
  10. const [isModalOpen, setIsModalOpen] = useState(false);
  11. const [initStep, setInitStep] = useState(0);
  12. const showModal = () => {
  13. setIsModalOpen(true);
  14. setInitStep(0);
  15. };
  16. const handleOk = () => {
  17. setIsModalOpen(false);
  18. };
  19. const handleCancel = () => {
  20. setIsModalOpen(false);
  21. };
  22. return (
  23. <>
  24. <span onClick={showModal}>{trigger}</span>
  25. <Modal
  26. width={"80%"}
  27. style={{ maxWidth: 1000 }}
  28. title="版本间复制"
  29. open={isModalOpen}
  30. onOk={handleOk}
  31. onCancel={handleCancel}
  32. footer={[]}
  33. >
  34. <CopyToStep
  35. initStep={initStep}
  36. channel={channel}
  37. onClose={() => {
  38. setIsModalOpen(false);
  39. Modal.destroyAll();
  40. }}
  41. />
  42. </Modal>
  43. </>
  44. );
  45. };
  46. export default Widget;