Make "Remove from LBRY" and "Delete file" options work

This commit is contained in:
Alex Liebowitz 2016-05-30 08:54:08 -04:00
parent 9aabfc171c
commit 142c0dad9e
2 changed files with 30 additions and 13 deletions

View file

@ -119,8 +119,15 @@ lbry.stopFile = function(name, callback) {
lbry.call('stop_lbry_file', { name: name }, callback);
}
lbry.deleteFile = function(name, callback) {
lbry.call('delete_lbry_file', { name: name }, callback)
lbry.deleteFile = function(name, deleteTargetFile=true, callback) {
lbry.call('delete_lbry_file', {
name: name,
delete_target_file: deleteTargetFile,
}, callback);
}
lbry.revealFile = function(path, callback) {
lbry.call('reveal', { path: path }, callback);
}
lbry.getVersionInfo = function(callback) {

View file

@ -1,12 +1,18 @@
var myFilesRowMoreMenuStyle = {
var moreMenuStyle = {
position: 'absolute',
display: 'block',
top: '26px',
left: '-13px',
};
var MyFilesRowMoreMenu = React.createClass({
onRevealClicked: function() {
lbry.revealFile(this.props.path);
},
onRemoveClicked: function() {
lbry.deleteFile(this.props.lbryUri, false);
},
onDeleteClicked: function() {
var alertText = 'Are you sure you\'d like to remove "' + this.props.title + '?" This will ' +
var alertText = 'Are you sure you\'d like to delete "' + this.props.title + '?" This will ' +
(this.completed ? ' stop the download and ' : '') +
'permanently remove the file from your system.';
@ -16,10 +22,10 @@ var MyFilesRowMoreMenu = React.createClass({
},
render: function() {
return (
<div style={myFilesRowMoreMenuStyle}>
<div style={moreMenuStyle}>
<Menu {...this.props}>
<MenuItem onClick={function() { alert('Make me work please!') }} label="Open in Finder" />
<MenuItem onClick={function() { alert('Make me work please!') }} label="Remove from LBRY" />
<MenuItem onClick={this.onRevealClicked} label="Reveal in Finder" />
<MenuItem onClick={this.onRemoveClicked} label="Remove from LBRY" />
<MenuItem onClick={this.onDeleteClicked} label="Remove and delete file" />
</Menu>
</div>
@ -47,7 +53,7 @@ progressBarStyle = {
border: '2px solid #eee',
display: 'inline-block',
},
myFilesRowImgStyle = {
artStyle = {
maxHeight: '100px',
display: 'block',
marginLeft: 'auto',
@ -62,7 +68,9 @@ var MyFilesRow = React.createClass({
}
},
render: function() {
var progressBarWidth = 230; // Move this somewhere better
//@TODO: Convert progress bar to reusable component
var progressBarWidth = 230;
if (this.props.completed) {
var pauseLink = null;
@ -86,7 +94,7 @@ var MyFilesRow = React.createClass({
return (
<div className="row-fluid">
<div className="span3">
<img src={this.props.imgUrl} alt={'Photo for ' + this.props.title} style={myFilesRowImgStyle} />
<img src={this.props.imgUrl} alt={'Photo for ' + this.props.title} style={artStyle} />
</div>
<div className="span6">
<h2>{this.props.title}</h2>
@ -100,7 +108,8 @@ var MyFilesRow = React.createClass({
<div style={moreButtonContainerStyle}>
<Link style={moreButtonStyle} ref="moreButton" icon="icon-ellipsis-h" title="More Options" />
<MyFilesRowMoreMenu toggleButton={this.refs.moreButton} title={this.props.title}
lbryUri={this.props.lbryUri} />
lbryUri={this.props.lbryUri} fileName={this.props.fileName}
path={this.props.path}/>
</div>
</div>
</div>
@ -135,7 +144,8 @@ var MyFilesPage = React.createClass({
} else {
var content = [];
for (let fileInfo of this.state.filesInfo) {
let {completed, written_bytes, total_bytes, lbry_uri, file_name, stopped, metadata} = fileInfo;
let {completed, written_bytes, total_bytes, lbry_uri, file_name, download_path,
stopped, metadata} = fileInfo;
let {name, stream_name, thumbnail} = metadata;
var title = (name || stream_name || ('lbry://' + lbry_uri));
@ -143,7 +153,7 @@ var MyFilesPage = React.createClass({
var showWatchButton = (lbry.getMediaType(file_name) == 'video');
content.push(<MyFilesRow lbryUri={lbry_uri} title={title} completed={completed} stopped={stopped}
ratioLoaded={ratioLoaded} imgUrl={thumbnail}
ratioLoaded={ratioLoaded} imgUrl={thumbnail} path={download_path}
showWatchButton={showWatchButton}/>);
}
}