import React, { Component } from 'react';
import { Dropdown, Icon, Tooltip } from 'antd';
import "./branch.css";

class CloneAddress extends Component {
  // 点击按钮复制功能
  jsCopy = () => {
    var e = document.getElementById("copy_rep_content");
    e.select();
    document.execCommand("Copy");
  }

  render() {
    const { http_url, downloadUrl } = this.props;
    return (
      <div className="gitAddressClone">
        {
          http_url && <span>HTTP</span>
        }
        <input type="text" id="copy_rep_content" value={http_url} />
        <Tooltip title="复制链接">
          <span onClick={() => this.jsCopy()}><i className="iconfont icon-fuzhi"></i></span>
        </Tooltip>
        {
          downloadUrl &&
          <span>
            <Dropdown overlay={downloadUrl} trigger={['click']} placement="bottomRight">
              <a className="ant-dropdown-link">
                <Icon type="cloud-download" className="font-18 fl" />
              </a>
            </Dropdown>
          </span>
        }
      </div>
    )
  }
}
export default CloneAddress;