External-internal links (UX/UI) #1660

Merged
btzr-io merged 2 commits from links into master 2018-06-23 06:38:20 +02:00
19 changed files with 113 additions and 55 deletions

View file

@ -56,6 +56,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/).
* URI and outpoint not being passed properly to API ([#1494](https://github.com/lbryio/lbry-app/issues/1494))
* Incorrect markdown preview on url with parentheses ([#1570](https://github.com/lbryio/lbry-app/issues/1570))
* Fix Linux upgrade path and add manual installation note ([#1606](https://github.com/lbryio/lbry-app/issues/1606))
* Fix can type in unfocused fields while publishing without selecting file ([#1456](https://github.com/lbryio/lbry-app/issues/1456))
* Fix navigation button resulting incorrect page designation ([#1502](https://github.com/lbryio/lbry-app/issues/1502))
* Fix shouldn't allow to open multiple export and choose file dialogs ([#1175](https://github.com/lbryio/lbry-app/issues/1175))

View file

@ -2,7 +2,6 @@
import fs from 'fs';
import path from 'path';
import React from 'react';
import PropTypes from 'prop-types';
import Button from 'component/button';
import parseData from 'util/parseData';
import * as icons from 'constants/icons';
@ -56,16 +55,20 @@ class FileExporter extends React.PureComponent<Props> {
],
};
remote.dialog.showSaveDialog(options, filename => {
// User hit cancel so do nothing:
if (!filename) return;
// Get extension and remove initial dot
const format = path.extname(filename).replace(/\./g, '');
// Parse data to string with the chosen format
const parsed = parseData(data, format, filters);
// Write file
parsed && this.handleFileCreation(filename, parsed);
});
remote.dialog.showSaveDialog(
remote.getCurrentWindow(),
options,
filename => {
// User hit cancel so do nothing:
if (!filename) return;
// Get extension and remove initial dot
const format = path.extname(filename).replace(/\./g, '');
// Parse data to string with the chosen format
const parsed = parseData(data, format, filters);
// Write file
parsed && this.handleFileCreation(filename, parsed);
}
);
}
render() {

View file

@ -25,6 +25,7 @@ class FileSelector extends React.PureComponent<Props> {
handleButtonClick() {
remote.dialog.showOpenDialog(
remote.getCurrentWindow(),
{
properties:
this.props.type === 'file' ? ['openFile'] : ['openDirectory', 'createDirectory'],

View file

@ -82,6 +82,7 @@ export class FormField extends React.PureComponent<Props> {
<div
className={classnames('form-field', {
'form-field--stretch': stretch || type === 'markdown',
'form-field--disabled': inputProps.disabled,
})}
>
{(label || errorMessage) && (

View file

@ -1,6 +1,7 @@
// @flow
import * as React from 'react';
import { MODALS, isURIValid } from 'lbry-redux';
import * as icons from 'constants/icons';
import Button from 'component/button';
type Props = {
@ -32,12 +33,12 @@ class ExternalLink extends React.PureComponent<Props> {
element = (
<Button
button="link"
iconRight={icons.EXTERNAL_LINK}
title={title || href}
label={children}
className="btn--external-link"
onClick={() => openModal({ id: MODALS.CONFIRM_EXTERNAL_LINK }, { uri: href })}
>
{children}
</Button>
/>
);
}
@ -47,10 +48,9 @@ class ExternalLink extends React.PureComponent<Props> {
<Button
button="link"
title={title || href}
label={children}
onClick={() => navigate('/show', { uri: href })}
>
{children}
</Button>
/>
);
}

View file

@ -11,6 +11,7 @@ type Props = {
isSearching: boolean,
uris: ?Array<string>,
downloadUris: ?Array<string>,
resultCount: number,
};
class FileListSearch extends React.PureComponent<Props> {

View file

@ -7,6 +7,8 @@ import {
doBlurSearchInput,
doSearch,
} from 'lbry-redux';
import { makeSelectClientSetting } from 'redux/selectors/settings';
import * as settings from 'constants/settings';
import { doNavigate } from 'redux/actions/navigation';
import Wunderbar from './view';
@ -21,12 +23,13 @@ const select = state => {
return {
...searchState,
wunderbarValue,
resultCount: makeSelectClientSetting(settings.RESULT_COUNT)(state),
};
};
const perform = dispatch => ({
onSearch: query => {
dispatch(doSearch(query, 30)); // Hard coding this for now until https://github.com/lbryio/lbry-app/pull/1639 is merged
onSearch: (query, size) => {
dispatch(doSearch(query, size));
dispatch(doNavigate(`/search`, { query }));
},
onSubmit: (uri, extraParams) => dispatch(doNavigate('/show', { uri, ...extraParams })),

View file

@ -15,6 +15,7 @@ type Props = {
suggestions: Array<string>,
doFocus: () => void,
doBlur: () => void,
resultCount: number,
};
class WunderBar extends React.PureComponent<Props> {
@ -45,7 +46,7 @@ class WunderBar extends React.PureComponent<Props> {
}
handleSubmit(value: string, suggestion?: { value: string, type: string }) {
const { onSubmit, onSearch } = this.props;
const { onSubmit, onSearch, resultCount } = this.props;
const query = value.trim();
const getParams = () => {
const parts = query.split('?');
@ -61,7 +62,7 @@ class WunderBar extends React.PureComponent<Props> {
// User selected a suggestion
if (suggestion) {
if (suggestion.type === 'search') {
onSearch(query);
onSearch(query, resultCount);
} else {
const params = getParams();
const uri = normalizeURI(query);
@ -78,7 +79,7 @@ class WunderBar extends React.PureComponent<Props> {
const params = getParams();
onSubmit(uri, params);
} catch (e) {
onSearch(query);
onSearch(query, resultCount);
}
}

View file

@ -26,3 +26,4 @@ export const HEART = 'Heart';
export const UNLOCK = 'Unlock';
export const CHECK_SIMPLE = 'Check';
export const GLOBE = 'Globe';
export const EXTERNAL_LINK = 'ExternalLink';

View file

@ -13,3 +13,4 @@ export const THEME = 'theme';
export const THEMES = 'themes';
export const AUTOMATIC_DARK_MODE_ENABLED = 'automaticDarkModeEnabled';
export const AUTOPLAY = 'autoplay';
export const RESULT_COUNT = 'resultCount';

View file

@ -66,7 +66,7 @@ class ChannelPage extends React.PureComponent<Props> {
render() {
const { fetching, claimsInChannel, claim, page, totalPages } = this.props;
const { name, permanent_url: permanentUrl, claim_id: claimId } = claim;
const currentPage = parseInt((page || 1) - 1, 10);
let contentList;
if (fetching) {
contentList = <BusyIndicator message={__('Fetching content')} />;
@ -104,7 +104,8 @@ class ChannelPage extends React.PureComponent<Props> {
breakClassName="pagination__item pagination__item--break"
marginPagesDisplayed={2}
onPageChange={e => this.changePage(e.selected + 1)}
initialPage={parseInt(page - 1, 10)}
forcePage={currentPage}
initialPage={currentPage}
containerClassName="pagination"
/>

View file

@ -1,16 +1,22 @@
import { connect } from 'react-redux';
import { selectIsSearching, doUpdateSearchQuery, makeSelectCurrentParam } from 'lbry-redux';
import * as settings from 'constants/settings';
import { selectIsSearching, makeSelectCurrentParam, doUpdateSearchQuery } from 'lbry-redux';
import { doSetClientSetting } from 'redux/actions/settings';
import { doNavigate } from 'redux/actions/navigation';
import { makeSelectClientSetting } from 'redux/selectors/settings';
import SearchPage from './view';
const select = state => ({
isSearching: selectIsSearching(state),
query: makeSelectCurrentParam('query')(state),
showUnavailable: makeSelectClientSetting(settings.SHOW_UNAVAILABLE)(state),
resultCount: makeSelectClientSetting(settings.RESULT_COUNT)(state),
});
const perform = dispatch => ({
navigate: path => dispatch(doNavigate(path)),
updateSearchQuery: query => dispatch(doUpdateSearchQuery(query)),
setClientSetting: (key, value) => dispatch(doSetClientSetting(key, value)),
});
export default connect(

View file

@ -1,6 +1,8 @@
// @flow
import * as React from 'react';
import * as settings from 'constants/settings';
import { isURIValid, normalizeURI } from 'lbry-redux';
import { FormField, FormRow } from 'component/common/form';
import FileTile from 'component/fileTile';
import FileListSearch from 'component/fileListSearch';
import ToolTip from 'component/common/tooltip';
@ -10,13 +12,52 @@ import * as icons from 'constants/icons';
type Props = {
query: ?string,
showUnavailable: boolean,
resultCount: number,
setClientSetting: (string, number | boolean) => void,
};
class SearchPage extends React.PureComponent<Props> {
constructor() {
super();
(this: any).onShowUnavailableChange = this.onShowUnavailableChange.bind(this);
(this: any).onSearchResultCountChange = this.onSearchResultCountChange.bind(this);
}
onSearchResultCountChange(event: SyntheticInputEvent<*>) {
const count = Number(event.target.value);
this.props.setClientSetting(settings.RESULT_COUNT, count);
}
onShowUnavailableChange(event: SyntheticInputEvent<*>) {
this.props.setClientSetting(settings.SHOW_UNAVAILABLE, event.target.checked);
}
render() {
const { query } = this.props;
const { query, resultCount, showUnavailable } = this.props;
return (
<Page>
<React.Fragment>
<FormRow alignRight>
<FormField
type="number"
name="result_count"
min={10}
max={1000}
value={resultCount}
onChange={this.onSearchResultCountChange}
postfix={__('returned results')}
/>
<FormField
type="checkbox"
name="show_unavailable"
onChange={this.onShowUnavailableChange}
checked={showUnavailable}
postfix={__('Include unavailable content')}
/>
</FormRow>
</React.Fragment>
{isURIValid(query) && (
<React.Fragment>
<div className="file-list__header">

View file

@ -18,7 +18,6 @@ import SettingsPage from './view';
const select = state => ({
daemonSettings: selectDaemonSettings(state),
showNsfw: makeSelectClientSetting(settings.SHOW_NSFW)(state),
showUnavailable: makeSelectClientSetting(settings.SHOW_UNAVAILABLE)(state),
instantPurchaseEnabled: makeSelectClientSetting(settings.INSTANT_PURCHASE_ENABLED)(state),
instantPurchaseMax: makeSelectClientSetting(settings.INSTANT_PURCHASE_MAX)(state),
currentTheme: makeSelectClientSetting(settings.THEME)(state),
@ -37,4 +36,7 @@ const perform = dispatch => ({
changeLanguage: newLanguage => dispatch(doChangeLanguage(newLanguage)),
});
export default connect(select, perform)(SettingsPage);
export default connect(
select,
perform
)(SettingsPage);

View file

@ -20,14 +20,13 @@ type DaemonSettings = {
type Props = {
setDaemonSetting: (string, boolean | string | Price) => void,
setClientSetting: (string, boolean | string | Price) => void,
setClientSetting: (string, boolean | string | number | Price) => void,
clearCache: () => Promise<any>,
getThemes: () => void,
daemonSettings: DaemonSettings,
showNsfw: boolean,
instantPurchaseEnabled: boolean,
instantPurchaseMax: Price,
showUnavailable: boolean,
currentTheme: string,
themes: Array<string>,
automaticDarkModeEnabled: boolean,
@ -50,7 +49,6 @@ class SettingsPage extends React.PureComponent<Props, State> {
(this: any).onKeyFeeChange = this.onKeyFeeChange.bind(this);
(this: any).onInstantPurchaseMaxChange = this.onInstantPurchaseMaxChange.bind(this);
(this: any).onShowNsfwChange = this.onShowNsfwChange.bind(this);
(this: any).onShowUnavailableChange = this.onShowUnavailableChange.bind(this);
(this: any).onShareDataChange = this.onShareDataChange.bind(this);
(this: any).onThemeChange = this.onThemeChange.bind(this);
(this: any).onAutomaticDarkModeChange = this.onAutomaticDarkModeChange.bind(this);
@ -113,10 +111,6 @@ class SettingsPage extends React.PureComponent<Props, State> {
this.props.setClientSetting(settings.SHOW_NSFW, event.target.checked);
}
onShowUnavailableChange(event: SyntheticInputEvent<*>) {
this.props.setClientSetting(settings.SHOW_UNAVAILABLE, event.target.checked);
}
setDaemonSetting(name: string, value: boolean | string | Price) {
this.props.setDaemonSetting(name, value);
}
@ -140,7 +134,6 @@ class SettingsPage extends React.PureComponent<Props, State> {
showNsfw,
instantPurchaseEnabled,
instantPurchaseMax,
showUnavailable,
currentTheme,
themes,
automaticDarkModeEnabled,
@ -253,13 +246,6 @@ class SettingsPage extends React.PureComponent<Props, State> {
checked={autoplay}
postfix={__('Autoplay media files')}
/>
<FormField
type="checkbox"
name="show_unavailable"
onChange={this.onShowUnavailableChange}
checked={showUnavailable}
postfix={__('Show unavailable content in search results')}
/>
<FormField
type="checkbox"
name="show_nsfw"

View file

@ -25,6 +25,7 @@ const defaultState = {
themes: getLocalStorageSetting(SETTINGS.THEMES, []),
automaticDarkModeEnabled: getLocalStorageSetting(SETTINGS.AUTOMATIC_DARK_MODE_ENABLED, false),
autoplay: getLocalStorageSetting(SETTINGS.AUTOPLAY, false),
resultCount: Number(getLocalStorageSetting(SETTINGS.RESULT_COUNT, 50)),
},
isNight: false,
languages: {},

View file

@ -66,6 +66,7 @@
.card--disabled {
opacity: 0.3;
pointer-events: none;
}
.card__media {

View file

@ -41,6 +41,11 @@
}
}
.form-field.form-field--disabled {
opacity: 0.4;
pointer-events: none;
}
.form-field--SimpleMDE {
display: block;
width: 100%;

View file

@ -9,12 +9,12 @@
line-height: $spacing-vertical * 1.5;
height: $spacing-vertical * 1.5;
border-radius: 2px;
&:not(.pagination__item--selected):hover {
&:not(.pagination__item--selected):not(.pagination__item--break):not(.disabled):hover {
background: rgba(0, 0, 0, 0.2);
> a {
cursor: hand;
}
cursor: pointer;
}
> a {
display: inline-block;
padding: 0 $spacing-vertical * 2 / 3;