Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Copy URL button #327

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"data_explorer_service": "file:src/api",
"lodash.debounce": "^4.0.8",
"react": "^16.3.0",
"react-copy-to-clipboard": "5.0.1",
"react-dom": "^16.3.0",
"react-scripts": "^2.0.0",
"react-select": "^2.0.0",
Expand Down
47 changes: 47 additions & 0 deletions ui/src/components/CopyUrlButton.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import React from "react";
import "@clr/icons/clr-icons.css";
import { CopyToClipboard } from "react-copy-to-clipboard";
import { PrimaryButton, TerraTooltip } from "libs/common";
import { withStyles } from "@material-ui/core/styles";

const styles = {
button: {
color: "#7f8fa4",
marginLeft: 16
}
};

class CopyUrlButton extends React.Component {
constructor(props) {
super(props);
this.state = {
buttonText: "Copy URL to clipboard"
};
this.handleButtonClick = this.handleButtonClick.bind(this);
}

handleButtonClick() {
// Just change the button text for a second
this.setState({ buttonText: "Copied!" });
setTimeout(
() => this.setState({ buttonText: "Copy URL to clipboard" }),
1000
);
}

render() {
const { classes } = this.props;

return (
<div onClick={this.handleButtonClick} className={classes.button}>
<TerraTooltip title={this.state.buttonText}>
<CopyToClipboard text={window.location.href}>
<clr-icon shape="copy-to-clipboard" size="16" />
</CopyToClipboard>
</TerraTooltip>
</div>
);
}
}

export default withStyles(styles)(CopyUrlButton);
2 changes: 2 additions & 0 deletions ui/src/components/DeHeader.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import Toolbar from "@material-ui/core/Toolbar";
import { withStyles } from "@material-ui/core/styles";

import colors from "libs/colors";
import CopyUrlButton from "components/CopyUrlButton";
import SaveButton from "components/SaveButton";
import Search from "components/Search";

Expand Down Expand Up @@ -140,6 +141,7 @@ class DeHeader extends React.Component {
facets={this.props.facets}
loadOptions={this.props.handleSearchBoxTyping}
/>
<CopyUrlButton />
<div className={classes.totalCount}>
{this.props.totalCount} Participants
</div>
Expand Down