Merge pull request #1303 from miikkatu/pre-fill-publish-url

Pre-fill publish URL after clicking "Put something here" link
This commit is contained in:
Sean Yesmunt 2018-04-18 05:30:22 -04:00 committed by GitHub
commit 10b6d64a83
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 4 deletions

View file

@ -11,6 +11,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/).
* Add referral FAQ to Invites screen([#1314](https://github.com/lbryio/lbry-app/pull/1314)) * Add referral FAQ to Invites screen([#1314](https://github.com/lbryio/lbry-app/pull/1314))
* Show exact wallet balance on mouse hover over ([#1305](https://github.com/lbryio/lbry-app/pull/1305)) * Show exact wallet balance on mouse hover over ([#1305](https://github.com/lbryio/lbry-app/pull/1305))
* New dark mode ([#1269](https://github.com/lbryio/lbry-app/pull/1269)) * New dark mode ([#1269](https://github.com/lbryio/lbry-app/pull/1269))
* Pre-fill publish URL after clicking "Put something here" link ([#1303](https://github.com/lbryio/lbry-app/pull/1303))
### Changed ### Changed
* Add flair to snackbar ([#1313](https://github.com/lbryio/lbry-app/pull/1313)) * Add flair to snackbar ([#1313](https://github.com/lbryio/lbry-app/pull/1313))

View file

@ -7,7 +7,7 @@ import {
makeSelectIsUriResolving, makeSelectIsUriResolving,
} from 'lbry-redux'; } from 'lbry-redux';
import { doNavigate } from 'redux/actions/navigation'; import { doNavigate } from 'redux/actions/navigation';
import { selectShowNsfw } from 'redux/selectors/settings'; import { doClearPublish, doUpdatePublishForm } from 'redux/actions/publish';
import { selectRewardContentClaimIds } from 'redux/selectors/content'; import { selectRewardContentClaimIds } from 'redux/selectors/content';
import FileTile from './view'; import FileTile from './view';
@ -20,8 +20,10 @@ const select = (state, props) => ({
}); });
const perform = dispatch => ({ const perform = dispatch => ({
clearPublish: () => dispatch(doClearPublish()),
navigate: (path, params) => dispatch(doNavigate(path, params)), navigate: (path, params) => dispatch(doNavigate(path, params)),
resolveUri: uri => dispatch(doResolveUri(uri)), resolveUri: uri => dispatch(doResolveUri(uri)),
updatePublishForm: value => dispatch(doUpdatePublishForm(value)),
}); });
export default connect(select, perform)(FileTile); export default connect(select, perform)(FileTile);

View file

@ -4,7 +4,6 @@ import * as icons from 'constants/icons';
import { normalizeURI, isURIClaimable, parseURI } from 'lbry-redux'; import { normalizeURI, isURIClaimable, parseURI } from 'lbry-redux';
import CardMedia from 'component/cardMedia'; import CardMedia from 'component/cardMedia';
import TruncatedText from 'component/common/truncated-text'; import TruncatedText from 'component/common/truncated-text';
import FilePrice from 'component/filePrice';
import Icon from 'component/common/icon'; import Icon from 'component/common/icon';
import Button from 'component/button'; import Button from 'component/button';
import classnames from 'classnames'; import classnames from 'classnames';
@ -25,6 +24,8 @@ type Props = {
metadata: {}, metadata: {},
resolveUri: string => void, resolveUri: string => void,
navigate: (string, ?{}) => void, navigate: (string, ?{}) => void,
clearPublish: () => void,
updatePublishForm: () => void,
}; };
class FileTile extends React.PureComponent<Props> { class FileTile extends React.PureComponent<Props> {
@ -55,6 +56,8 @@ class FileTile extends React.PureComponent<Props> {
fullWidth, fullWidth,
showLocal, showLocal,
isDownloaded, isDownloaded,
clearPublish,
updatePublishForm,
} = this.props; } = this.props;
const uri = normalizeURI(this.props.uri); const uri = normalizeURI(this.props.uri);
@ -69,7 +72,7 @@ class FileTile extends React.PureComponent<Props> {
let name; let name;
let channel; let channel;
if (claim) { if (claim) {
name = claim.name; ({ name } = claim);
channel = claim.channel_name; channel = claim.channel_name;
} }
@ -79,6 +82,9 @@ class FileTile extends React.PureComponent<Props> {
'file-tile--fullwidth': fullWidth, 'file-tile--fullwidth': fullWidth,
})} })}
onClick={onClick} onClick={onClick}
onKeyUp={onClick}
role="button"
tabIndex="0"
> >
<CardMedia title={title || name} thumbnail={thumbnail} /> <CardMedia title={title || name} thumbnail={thumbnail} />
<div className="file-tile__info"> <div className="file-tile__info">
@ -101,7 +107,11 @@ class FileTile extends React.PureComponent<Props> {
label={__('Put something here!')} label={__('Put something here!')}
onClick={e => { onClick={e => {
// avoid navigating to /show from clicking on the section // avoid navigating to /show from clicking on the section
e.preventDefault(); e.stopPropagation();
// strip prefix from the Uri and use that as navigation parameter
const nameFromUri = uri.replace(/lbry:\/\//g, '').replace(/-/g, ' ');
clearPublish(); // to remove any existing publish data
updatePublishForm({ name: nameFromUri }); // to populate the name
navigate('/publish'); navigate('/publish');
}} }}
/> />