Skip to content
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
Binary file removed client/src/assets/share.png
Binary file not shown.
62 changes: 17 additions & 45 deletions client/src/components/Share.jsx
Original file line number Diff line number Diff line change
@@ -1,74 +1,46 @@
import React from 'react';
import { Input, Modal, ModalHeader, ModalBody, ModalFooter, Button } from 'reactstrap';
import css from '../styles/Share.css';
import shareIcon from '../assets/share.png';
import Helmet from 'react-helmet';
import { Col, Button } from 'reactstrap';
import $ from 'jquery';

class Share extends React.Component {
constructor(props) {
super(props);

this.state = {
email: ''
};

this.handleClick = this.handleClick.bind(this);
this.toggle = this.toggle.bind(this);
this.handleEmailChange = this.handleEmailChange.bind(this);
}

handleClick() {
const data = {
email: this.state.email,
file: this.props.file
};

// change file acl to public
$.ajax({
type: 'POST',
type: 'GET',
url: '/share',
data: JSON.stringify(data),
data: this.props.file,
contentType: 'application/json; charset=utf-8',
})
.done(() => {
this.toggle();
FB.ui({
method: 'share',
display: 'popup',
href: 'https://s3-us-west-1.amazonaws.com/ablebox/' + this.props.file.s3_objectId
}, function(response){});
})
.fail((err) => {
.fail(() => {
alert('failed to share');
});
}

handleEmailChange(e) {
e.preventDefault();
this.setState({
email: e.target.value
});
}

toggle() {
this.setState({
modal: !this.state.modal,
});
}

render () {
return (
<React.Fragment>
<Button className="btn-sm btn-link shadow-sm" onClick={this.toggle} type="download">
<img width="30px" background="transparent" src={shareIcon} alt="share"/>
</Button>
<Modal isOpen={this.state.modal} toggle={this.toggle} className={this.props.className}>
<ModalHeader toggle={this.toggle}>Email</ModalHeader>
<ModalBody>
<Input onChange={this.handleEmailChange}/>
</ModalBody>
<ModalFooter>
<Button color="primary" disabled={!this.state.email.length} onClick={this.handleClick}>Share</Button>
<Button color="secondary" onClick={this.toggle}>Cancel</Button>
</ModalFooter>
</Modal>
<Helmet>
<meta property="og:url" content={'"https://s3-us-west-1.amazonaws.com/ablebox/' + this.props.file.s3_objectId + '"'}/>
<meta property="og:title" content={'"' + this.props.file.name + '"'} />
</Helmet>
<Button className="btn btn-sm btn-outline-success" onClick={this.handleClick}>Share</Button>
</React.Fragment>
);
}
}

export default Share;
export default Share;
Loading