mirror of
https://github.com/Readarr/Readarr.git
synced 2026-04-21 22:04:31 -04:00
Renames in Frontend
This commit is contained in:
+3
-3
@@ -34,14 +34,14 @@
|
||||
flex-grow: 1;
|
||||
}
|
||||
|
||||
.artistContainer {
|
||||
.authorContainer {
|
||||
@add-mixin scrollbar;
|
||||
@add-mixin scrollbarTrack;
|
||||
@add-mixin scrollbarThumb;
|
||||
}
|
||||
|
||||
.containerOpen {
|
||||
.artistContainer {
|
||||
.authorContainer {
|
||||
position: absolute;
|
||||
top: 42px;
|
||||
z-index: 1;
|
||||
@@ -78,7 +78,7 @@
|
||||
color: $disabledColor;
|
||||
}
|
||||
|
||||
.addNewArtistSuggestion {
|
||||
.addNewAuthorSuggestion {
|
||||
padding: 0 3px;
|
||||
cursor: pointer;
|
||||
}
|
||||
+24
-24
@@ -5,16 +5,16 @@ import Autosuggest from 'react-autosuggest';
|
||||
import { icons } from 'Helpers/Props';
|
||||
import Icon from 'Components/Icon';
|
||||
import keyboardShortcuts, { shortcuts } from 'Components/keyboardShortcuts';
|
||||
import ArtistSearchResult from './ArtistSearchResult';
|
||||
import AuthorSearchResult from './AuthorSearchResult';
|
||||
import LoadingIndicator from 'Components/Loading/LoadingIndicator';
|
||||
import FuseWorker from './fuse.worker';
|
||||
import styles from './ArtistSearchInput.css';
|
||||
import styles from './AuthorSearchInput.css';
|
||||
|
||||
const LOADING_TYPE = 'suggestionsLoading';
|
||||
const ADD_NEW_TYPE = 'addNew';
|
||||
const workerInstance = new FuseWorker();
|
||||
|
||||
class ArtistSearchInput extends Component {
|
||||
class AuthorSearchInput extends Component {
|
||||
|
||||
//
|
||||
// Lifecycle
|
||||
@@ -31,7 +31,7 @@ class ArtistSearchInput extends Component {
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
this.props.bindShortcut(shortcuts.ARTIST_SEARCH_INPUT.key, this.focusInput);
|
||||
this.props.bindShortcut(shortcuts.AUTHOR_SEARCH_INPUT.key, this.focusInput);
|
||||
workerInstance.addEventListener('message', this.onSuggestionsReceived, false);
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ class ArtistSearchInput extends Component {
|
||||
renderSuggestion(item, { query }) {
|
||||
if (item.type === ADD_NEW_TYPE) {
|
||||
return (
|
||||
<div className={styles.addNewArtistSuggestion}>
|
||||
<div className={styles.addNewAuthorSuggestion}>
|
||||
Search for {query}
|
||||
</div>
|
||||
);
|
||||
@@ -79,16 +79,16 @@ class ArtistSearchInput extends Component {
|
||||
}
|
||||
|
||||
return (
|
||||
<ArtistSearchResult
|
||||
<AuthorSearchResult
|
||||
{...item.item}
|
||||
match={item.matches[0]}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
goToArtist(item) {
|
||||
goToAuthor(item) {
|
||||
this.setState({ value: '' });
|
||||
this.props.onGoToArtist(item.item.titleSlug);
|
||||
this.props.onGoToAuthor(item.item.titleSlug);
|
||||
}
|
||||
|
||||
reset() {
|
||||
@@ -125,20 +125,20 @@ class ArtistSearchInput extends Component {
|
||||
} = this._autosuggest.state;
|
||||
|
||||
if (!suggestions.length || suggestions[0].type === LOADING_TYPE || highlightedSectionIndex) {
|
||||
this.props.onGoToAddNewArtist(value);
|
||||
this.props.onGoToAddNewAuthor(value);
|
||||
this._autosuggest.input.blur();
|
||||
this.reset();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// If an suggestion is not selected go to the first artist,
|
||||
// otherwise go to the selected artist.
|
||||
// If an suggestion is not selected go to the first author,
|
||||
// otherwise go to the selected author.
|
||||
|
||||
if (highlightedSuggestionIndex == null) {
|
||||
this.goToArtist(suggestions[0]);
|
||||
this.goToAuthor(suggestions[0]);
|
||||
} else {
|
||||
this.goToArtist(suggestions[highlightedSuggestionIndex]);
|
||||
this.goToAuthor(suggestions[highlightedSuggestionIndex]);
|
||||
}
|
||||
|
||||
this._autosuggest.input.blur();
|
||||
@@ -164,7 +164,7 @@ class ArtistSearchInput extends Component {
|
||||
requestSuggestions = _.debounce((value) => {
|
||||
const payload = {
|
||||
value,
|
||||
artists: this.props.artists
|
||||
authors: this.props.authors
|
||||
};
|
||||
|
||||
workerInstance.postMessage(payload);
|
||||
@@ -184,9 +184,9 @@ class ArtistSearchInput extends Component {
|
||||
|
||||
onSuggestionSelected = (event, { suggestion }) => {
|
||||
if (suggestion.type === ADD_NEW_TYPE) {
|
||||
this.props.onGoToAddNewArtist(this.state.value);
|
||||
this.props.onGoToAddNewAuthor(this.state.value);
|
||||
} else {
|
||||
this.goToArtist(suggestion);
|
||||
this.goToAuthor(suggestion);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -203,7 +203,7 @@ class ArtistSearchInput extends Component {
|
||||
|
||||
if (suggestions.length) {
|
||||
suggestionGroups.push({
|
||||
title: 'Existing Artist',
|
||||
title: 'Existing Author',
|
||||
suggestions
|
||||
});
|
||||
}
|
||||
@@ -221,7 +221,7 @@ class ArtistSearchInput extends Component {
|
||||
const inputProps = {
|
||||
ref: this.setInputRef,
|
||||
className: styles.input,
|
||||
name: 'artistSearch',
|
||||
name: 'authorSearch',
|
||||
value,
|
||||
placeholder: 'Search',
|
||||
autoComplete: 'off',
|
||||
@@ -235,7 +235,7 @@ class ArtistSearchInput extends Component {
|
||||
const theme = {
|
||||
container: styles.container,
|
||||
containerOpen: styles.containerOpen,
|
||||
suggestionsContainer: styles.artistContainer,
|
||||
suggestionsContainer: styles.authorContainer,
|
||||
suggestionsList: styles.list,
|
||||
suggestion: styles.listItem,
|
||||
suggestionHighlighted: styles.highlighted
|
||||
@@ -266,11 +266,11 @@ class ArtistSearchInput extends Component {
|
||||
}
|
||||
}
|
||||
|
||||
ArtistSearchInput.propTypes = {
|
||||
artists: PropTypes.arrayOf(PropTypes.object).isRequired,
|
||||
onGoToArtist: PropTypes.func.isRequired,
|
||||
onGoToAddNewArtist: PropTypes.func.isRequired,
|
||||
AuthorSearchInput.propTypes = {
|
||||
authors: PropTypes.arrayOf(PropTypes.object).isRequired,
|
||||
onGoToAuthor: PropTypes.func.isRequired,
|
||||
onGoToAddNewAuthor: PropTypes.func.isRequired,
|
||||
bindShortcut: PropTypes.func.isRequired
|
||||
};
|
||||
|
||||
export default keyboardShortcuts(ArtistSearchInput);
|
||||
export default keyboardShortcuts(AuthorSearchInput);
|
||||
+15
-15
@@ -1,27 +1,27 @@
|
||||
import { connect } from 'react-redux';
|
||||
import { push } from 'connected-react-router';
|
||||
import { createSelector } from 'reselect';
|
||||
import createAllArtistSelector from 'Store/Selectors/createAllArtistSelector';
|
||||
import createAllAuthorSelector from 'Store/Selectors/createAllAuthorsSelector';
|
||||
import createDeepEqualSelector from 'Store/Selectors/createDeepEqualSelector';
|
||||
import createTagsSelector from 'Store/Selectors/createTagsSelector';
|
||||
import ArtistSearchInput from './ArtistSearchInput';
|
||||
import AuthorSearchInput from './AuthorSearchInput';
|
||||
|
||||
function createCleanArtistSelector() {
|
||||
function createCleanAuthorSelector() {
|
||||
return createSelector(
|
||||
createAllArtistSelector(),
|
||||
createAllAuthorSelector(),
|
||||
createTagsSelector(),
|
||||
(allArtists, allTags) => {
|
||||
return allArtists.map((artist) => {
|
||||
(allAuthors, allTags) => {
|
||||
return allAuthors.map((author) => {
|
||||
const {
|
||||
artistName,
|
||||
authorName,
|
||||
sortName,
|
||||
images,
|
||||
titleSlug,
|
||||
tags = []
|
||||
} = artist;
|
||||
} = author;
|
||||
|
||||
return {
|
||||
artistName,
|
||||
authorName,
|
||||
sortName,
|
||||
titleSlug,
|
||||
images,
|
||||
@@ -42,10 +42,10 @@ function createCleanArtistSelector() {
|
||||
|
||||
function createMapStateToProps() {
|
||||
return createDeepEqualSelector(
|
||||
createCleanArtistSelector(),
|
||||
(artists) => {
|
||||
createCleanAuthorSelector(),
|
||||
(authors) => {
|
||||
return {
|
||||
artists
|
||||
authors
|
||||
};
|
||||
}
|
||||
);
|
||||
@@ -53,14 +53,14 @@ function createMapStateToProps() {
|
||||
|
||||
function createMapDispatchToProps(dispatch, props) {
|
||||
return {
|
||||
onGoToArtist(titleSlug) {
|
||||
onGoToAuthor(titleSlug) {
|
||||
dispatch(push(`${window.Readarr.urlBase}/author/${titleSlug}`));
|
||||
},
|
||||
|
||||
onGoToAddNewArtist(query) {
|
||||
onGoToAddNewAuthor(query) {
|
||||
dispatch(push(`${window.Readarr.urlBase}/add/search?term=${encodeURIComponent(query)}`));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
export default connect(createMapStateToProps, createMapDispatchToProps)(ArtistSearchInput);
|
||||
export default connect(createMapStateToProps, createMapDispatchToProps)(AuthorSearchInput);
|
||||
+9
-9
@@ -2,13 +2,13 @@ import PropTypes from 'prop-types';
|
||||
import React from 'react';
|
||||
import { kinds } from 'Helpers/Props';
|
||||
import Label from 'Components/Label';
|
||||
import ArtistPoster from 'Artist/ArtistPoster';
|
||||
import styles from './ArtistSearchResult.css';
|
||||
import AuthorPoster from 'Author/AuthorPoster';
|
||||
import styles from './AuthorSearchResult.css';
|
||||
|
||||
function ArtistSearchResult(props) {
|
||||
function AuthorSearchResult(props) {
|
||||
const {
|
||||
match,
|
||||
artistName,
|
||||
authorName,
|
||||
images,
|
||||
tags
|
||||
} = props;
|
||||
@@ -21,7 +21,7 @@ function ArtistSearchResult(props) {
|
||||
|
||||
return (
|
||||
<div className={styles.result}>
|
||||
<ArtistPoster
|
||||
<AuthorPoster
|
||||
className={styles.poster}
|
||||
images={images}
|
||||
size={250}
|
||||
@@ -31,7 +31,7 @@ function ArtistSearchResult(props) {
|
||||
|
||||
<div className={styles.titles}>
|
||||
<div className={styles.title}>
|
||||
{artistName}
|
||||
{authorName}
|
||||
</div>
|
||||
|
||||
{
|
||||
@@ -51,11 +51,11 @@ function ArtistSearchResult(props) {
|
||||
);
|
||||
}
|
||||
|
||||
ArtistSearchResult.propTypes = {
|
||||
artistName: PropTypes.string.isRequired,
|
||||
AuthorSearchResult.propTypes = {
|
||||
authorName: PropTypes.string.isRequired,
|
||||
images: PropTypes.arrayOf(PropTypes.object).isRequired,
|
||||
tags: PropTypes.arrayOf(PropTypes.object).isRequired,
|
||||
match: PropTypes.object.isRequired
|
||||
};
|
||||
|
||||
export default ArtistSearchResult;
|
||||
export default AuthorSearchResult;
|
||||
@@ -4,7 +4,7 @@ import { icons } from 'Helpers/Props';
|
||||
import keyboardShortcuts, { shortcuts } from 'Components/keyboardShortcuts';
|
||||
import IconButton from 'Components/Link/IconButton';
|
||||
import Link from 'Components/Link/Link';
|
||||
import ArtistSearchInputConnector from './ArtistSearchInputConnector';
|
||||
import AuthorSearchInputConnector from './AuthorSearchInputConnector';
|
||||
import PageHeaderActionsMenuConnector from './PageHeaderActionsMenuConnector';
|
||||
import KeyboardShortcutsModal from './KeyboardShortcutsModal';
|
||||
import styles from './PageHeader.css';
|
||||
@@ -70,7 +70,7 @@ class PageHeader extends Component {
|
||||
/>
|
||||
</div>
|
||||
|
||||
<ArtistSearchInputConnector />
|
||||
<AuthorSearchInputConnector />
|
||||
|
||||
<div className={styles.right}>
|
||||
<IconButton
|
||||
|
||||
@@ -9,21 +9,21 @@ const fuseOptions = {
|
||||
maxPatternLength: 32,
|
||||
minMatchCharLength: 1,
|
||||
keys: [
|
||||
'artistName',
|
||||
'authorName',
|
||||
'tags.label'
|
||||
]
|
||||
};
|
||||
|
||||
function getSuggestions(artists, value) {
|
||||
function getSuggestions(authors, value) {
|
||||
const limit = 10;
|
||||
let suggestions = [];
|
||||
|
||||
if (value.length === 1) {
|
||||
for (let i = 0; i < artists.length; i++) {
|
||||
const s = artists[i];
|
||||
for (let i = 0; i < authors.length; i++) {
|
||||
const s = authors[i];
|
||||
if (s.firstCharacter === value.toLowerCase()) {
|
||||
suggestions.push({
|
||||
item: artists[i],
|
||||
item: authors[i],
|
||||
indices: [
|
||||
[0, 0]
|
||||
],
|
||||
@@ -41,7 +41,7 @@ function getSuggestions(artists, value) {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
const fuse = new Fuse(artists, fuseOptions);
|
||||
const fuse = new Fuse(authors, fuseOptions);
|
||||
suggestions = fuse.search(value, { limit });
|
||||
}
|
||||
|
||||
@@ -54,9 +54,9 @@ self.addEventListener('message', (e) => {
|
||||
}
|
||||
|
||||
const {
|
||||
artists,
|
||||
authors,
|
||||
value
|
||||
} = e.data;
|
||||
|
||||
self.postMessage(getSuggestions(artists, value));
|
||||
self.postMessage(getSuggestions(authors, value));
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user