Commit 435767ce authored by Simon Pastor's avatar Simon Pastor
Browse files

checkbox copy clipboard

parent 08e910c2
Loading
Loading
Loading
Loading
+14 −3
Original line number Diff line number Diff line
@@ -23,13 +23,22 @@ class TryIt extends Component {
  constructor(props) {
    super(props);
    this.baseTryIt = HOST_PATH + '/' + this.props.sandboxName + '/';
    this.state = {
      renderUpdate: 0,
      clipboardClicked: false
    };

  }

  copyToClipboard(copyText) {
    /* Copy the text inside the text field */
    navigator.clipboard.writeText(copyText);
    /* Alert the copied text */
    alert('Copied the text: ' + copyText);
    /* setting a local state that will last few render for the icon image to swap */
    this.setState({
      renderUpdate: 0,
      clipboardClicked: true
    });

  }

  render() {
@@ -91,6 +100,8 @@ class TryIt extends Component {

      let runningOn = this.props.edgeAppsMap.edgeApps[index].mepName;
      let appId = (hideApplicationId === true) ? '' : 'application id: ' + this.props.edgeAppsMap.edgeApps[index].id;
      let clipboardIcon = (this.state.clipboardClicked === true && this.state.renderUpdate < 5) ? 'assignment_turned_in' : 'assignment';
      this.state.renderUpdate++;

      return (
        <>
@@ -133,7 +144,7 @@ class TryIt extends Component {
              <GridCell span={2}>
                <IconButton
                  title="Copy to clipboard"
                  icon="content_copy"
                  icon={clipboardIcon}
                  iconOptions={{ size: 'large', id: 'user-icon' }}
                  style={styles.icon}
                  onClick={() => this.copyToClipboard(tryItMecApp)}