Revamp "file not available" message
- Don't fade out tile - Display message in place of buttons with an option to bypass the message - Factor out message into its own FileUnavailableMessage component
This commit is contained in:
parent
42517587ee
commit
e5b4aaf175
3 changed files with 29 additions and 22 deletions
|
@ -2,6 +2,7 @@ import React from 'react';
|
||||||
import lbry from '../lbry.js';
|
import lbry from '../lbry.js';
|
||||||
import {Link} from '../component/link.js';
|
import {Link} from '../component/link.js';
|
||||||
import {Icon} from '../component/common.js';
|
import {Icon} from '../component/common.js';
|
||||||
|
import FileUnavailableMessage from '../component/file-unavailable-message.js';
|
||||||
import Modal from './modal.js';
|
import Modal from './modal.js';
|
||||||
import FormField from './form.js';
|
import FormField from './form.js';
|
||||||
import {DropDownMenu, DropDownMenuItem} from './menu.js';
|
import {DropDownMenu, DropDownMenuItem} from './menu.js';
|
||||||
|
@ -71,6 +72,8 @@ export let FileActions = React.createClass({
|
||||||
deleteChecked: false,
|
deleteChecked: false,
|
||||||
attemptingDownload: false,
|
attemptingDownload: false,
|
||||||
attemptingRemove: false,
|
attemptingRemove: false,
|
||||||
|
available: null,
|
||||||
|
forceShowActions: false,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onFileInfoUpdate: function(fileInfo) {
|
onFileInfoUpdate: function(fileInfo) {
|
||||||
|
@ -136,6 +139,11 @@ export let FileActions = React.createClass({
|
||||||
modal: 'confirmRemove',
|
modal: 'confirmRemove',
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
showActions: function() {
|
||||||
|
this.setState({
|
||||||
|
forceShowActions: true,
|
||||||
|
});
|
||||||
|
},
|
||||||
handleRemoveConfirmed: function() {
|
handleRemoveConfirmed: function() {
|
||||||
if (this.props.streamName) {
|
if (this.props.streamName) {
|
||||||
lbry.removeFile(this.props.sdHash, this.props.streamName, this.state.deleteChecked);
|
lbry.removeFile(this.props.sdHash, this.props.streamName, this.state.deleteChecked);
|
||||||
|
@ -156,6 +164,15 @@ export let FileActions = React.createClass({
|
||||||
componentDidMount: function() {
|
componentDidMount: function() {
|
||||||
this._isMounted = true;
|
this._isMounted = true;
|
||||||
this._fileInfoSubscribeId = lbry.fileInfoSubscribe(this.props.sdHash, this.onFileInfoUpdate);
|
this._fileInfoSubscribeId = lbry.fileInfoSubscribe(this.props.sdHash, this.onFileInfoUpdate);
|
||||||
|
lbry.getPeersForBlobHash(this.props.sdHash, (peers) => {
|
||||||
|
if (!this._isMounted) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.setState({
|
||||||
|
available: peers.length > 0,
|
||||||
|
});
|
||||||
|
});
|
||||||
},
|
},
|
||||||
componentWillUnmount: function() {
|
componentWillUnmount: function() {
|
||||||
this._isMounted = false;
|
this._isMounted = false;
|
||||||
|
@ -168,6 +185,11 @@ export let FileActions = React.createClass({
|
||||||
{
|
{
|
||||||
return <section className="file-actions--stub"></section>;
|
return <section className="file-actions--stub"></section>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.state.available === false && !this.state.forceShowActions) {
|
||||||
|
return <FileUnavailableMessage onShowActionsClicked={this.showActions} />;
|
||||||
|
}
|
||||||
|
|
||||||
const openInFolderMessage = window.navigator.platform.startsWith('Mac') ? 'Open in Finder' : 'Open in Folder',
|
const openInFolderMessage = window.navigator.platform.startsWith('Mac') ? 'Open in Finder' : 'Open in Folder',
|
||||||
showMenu = !!this.state.fileInfo;
|
showMenu = !!this.state.fileInfo;
|
||||||
|
|
||||||
|
@ -180,11 +202,12 @@ export let FileActions = React.createClass({
|
||||||
label = this.state.fileInfo ? progress.toFixed(0) + '% complete' : 'Connecting...',
|
label = this.state.fileInfo ? progress.toFixed(0) + '% complete' : 'Connecting...',
|
||||||
labelWithIcon = <span className="button__content"><Icon icon="icon-download" />{label}</span>;
|
labelWithIcon = <span className="button__content"><Icon icon="icon-download" />{label}</span>;
|
||||||
|
|
||||||
linkBlock =
|
linkBlock = (
|
||||||
<div className="faux-button-block file-actions__download-status-bar">
|
<div className="faux-button-block file-actions__download-status-bar">
|
||||||
<div className="faux-button-block file-actions__download-status-bar-overlay" style={{ width: progress + '%' }}>{labelWithIcon}</div>
|
<div className="faux-button-block file-actions__download-status-bar-overlay" style={{ width: progress + '%' }}>{labelWithIcon}</div>
|
||||||
{labelWithIcon}
|
{labelWithIcon}
|
||||||
</div>;
|
</div>
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
linkBlock = <Link button="text" label="Open" icon="icon-folder-open" onClick={this.onOpenClick} />;
|
linkBlock = <Link button="text" label="Open" icon="icon-folder-open" onClick={this.onOpenClick} />;
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,13 +74,6 @@ export let FileTileStream = React.createClass({
|
||||||
hidePrice: false
|
hidePrice: false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
componentWillMount: function() {
|
|
||||||
lbry.getPeersForBlobHash(this.props.sdHash, (peers) => {
|
|
||||||
this.setState({
|
|
||||||
available: peers.length > 0,
|
|
||||||
});
|
|
||||||
});
|
|
||||||
},
|
|
||||||
componentDidMount: function() {
|
componentDidMount: function() {
|
||||||
this._isMounted = true;
|
this._isMounted = true;
|
||||||
if (this.props.hideOnRemove) {
|
if (this.props.hideOnRemove) {
|
||||||
|
@ -114,26 +107,16 @@ export let FileTileStream = React.createClass({
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
render: function() {
|
render: function() {
|
||||||
const isUnavailable = this.state.available === false;
|
if (this.state.isHidden) {
|
||||||
|
|
||||||
if (this.state.isHidden || (!lbry.getClientSetting('showUnavailable') && isUnavailable)) {
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
const metadata = this.props.metadata || {},
|
const metadata = this.props.metadata || {},
|
||||||
obscureNsfw = this.props.obscureNsfw && metadata.nsfw,
|
obscureNsfw = this.props.obscureNsfw && metadata.nsfw,
|
||||||
title = metadata.title ? metadata.title : ('lbry://' + this.props.name),
|
title = metadata.title ? metadata.title : ('lbry://' + this.props.name);
|
||||||
showAsAvailable = this.state.available !== false,
|
|
||||||
unavailableMessage = ("The content on LBRY is hosted by its users. It appears there are no " +
|
|
||||||
"users connected that have this file at the moment.");
|
|
||||||
return (
|
return (
|
||||||
<section className={ 'file-tile card ' + (obscureNsfw ? 'card-obscured ' : '') } onMouseEnter={this.handleMouseOver} onMouseLeave={this.handleMouseOut}>
|
<section className={ 'file-tile card ' + (obscureNsfw ? 'card-obscured ' : '') } onMouseEnter={this.handleMouseOver} onMouseLeave={this.handleMouseOut}>
|
||||||
{isUnavailable
|
<div className={"row-fluid card-content file-tile__row"}>
|
||||||
? <div className='file-tile__not-available-message'>
|
|
||||||
This file is not currently available. <ToolTipLink label="Why?" tooltip={unavailableMessage} className="not-available-tooltip-link" />
|
|
||||||
</div>
|
|
||||||
: null}
|
|
||||||
<div className={"row-fluid card-content file-tile__row" + (isUnavailable ? ' file-tile__row--unavailable' : '')}>
|
|
||||||
<div className="span3">
|
<div className="span3">
|
||||||
<a href={'/?show=' + this.props.name}><Thumbnail className="file-tile__thumbnail" src={metadata.thumbnail} alt={'Photo for ' + (title || this.props.name)} /></a>
|
<a href={'/?show=' + this.props.name}><Thumbnail className="file-tile__thumbnail" src={metadata.thumbnail} alt={'Photo for ' + (title || this.props.name)} /></a>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
@import "component/_table";
|
@import "component/_table";
|
||||||
@import "component/_file-actions.scss";
|
@import "component/_file-actions.scss";
|
||||||
@import "component/_file-tile.scss";
|
@import "component/_file-tile.scss";
|
||||||
|
@import "component/_file-unavailable-message.scss";
|
||||||
@import "component/_menu.scss";
|
@import "component/_menu.scss";
|
||||||
@import "component/_tooltiplink.scss";
|
@import "component/_tooltiplink.scss";
|
||||||
@import "component/_tooltip.scss";
|
@import "component/_tooltip.scss";
|
||||||
|
|
Loading…
Add table
Reference in a new issue