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">
        {/* <p className="addressTips"><span>版本库地址已变更，请基于新地址提交代码</span></p> */}
        {
          http_url && <span>HTTP</span>
        }
        <input type="text" id="copy_rep_content" value={http_url} />
        <Tooltip title="复制链接">
          <span className="color-blue" 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 color-blue" />
              </a>
            </Dropdown>
          </span>
        }
      </div>
    )
  }
}
export default CloneAddress;