Merge branch 'feat/decoupling-uri-type' into develop
This commit is contained in:
@ -46,7 +46,7 @@ const Button = ({
|
||||
|
||||
let Element = 'button';
|
||||
if (to) Element = Link;
|
||||
if (uri) Element = URILink;
|
||||
if (uri) Element = URILink; // MISSING URI TYPE
|
||||
if (href) Element = 'a';
|
||||
|
||||
const onClick = (e) => {
|
||||
|
||||
@ -118,7 +118,7 @@ class AddSeedField extends React.Component {
|
||||
{type === 'tracks' && (
|
||||
<span className="mid_grey-text">
|
||||
{' '}
|
||||
<LinksSentence items={item.artists} nolinks />
|
||||
<LinksSentence items={item.artists} type="artist" nolinks />
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
|
||||
@ -99,7 +99,7 @@ class AddSeedField extends React.Component {
|
||||
{type == 'tracks' ? (
|
||||
<span className="mid_grey-text">
|
||||
{' '}
|
||||
<LinksSentence items={item.artists} nolinks />
|
||||
<LinksSentence items={item.artists} type="artist" nolinks />
|
||||
</span>
|
||||
) : null}
|
||||
</div>
|
||||
|
||||
@ -84,14 +84,14 @@ class GridItem extends React.Component {
|
||||
case 'album':
|
||||
return (
|
||||
<span className="grid__item__secondary__content">
|
||||
{artists && <LinksSentence nolinks items={artists} />}
|
||||
{artists && <LinksSentence nolinks items={artists} type="artist" />}
|
||||
</span>
|
||||
);
|
||||
|
||||
default:
|
||||
return (
|
||||
<span className="grid__item__secondary__content">
|
||||
{artists && <LinksSentence nolinks items={item.artists} /> }
|
||||
{artists && <LinksSentence nolinks items={item.artists} type="artist" /> }
|
||||
{followers && <I18n path="specs.followers" count={followers.toLocaleString()} />}
|
||||
</span>
|
||||
);
|
||||
|
||||
@ -1,14 +1,13 @@
|
||||
|
||||
import React, { memo } from 'react';
|
||||
import URILink from './URILink';
|
||||
|
||||
export default memo(({ items, className, nolinks }) => {
|
||||
const LinksSentence = memo(({ items, className, nolinks }) => {
|
||||
if (!items) return <span className={`${className} links-sentence`}>-</span>;
|
||||
|
||||
return (
|
||||
<span className={`${className} links-sentence`}>
|
||||
{
|
||||
items.map(({ name, uri }, index) => {
|
||||
items.map(({ name, uri, type }, index) => {
|
||||
if (!name) return <span>-</span>;
|
||||
|
||||
let separator = null;
|
||||
@ -27,6 +26,7 @@ export default memo(({ items, className, nolinks }) => {
|
||||
<URILink
|
||||
className="links-sentence__item links-sentence__item--link"
|
||||
uri={uri}
|
||||
type={type}
|
||||
>
|
||||
{name}
|
||||
</URILink>
|
||||
@ -44,3 +44,5 @@ export default memo(({ items, className, nolinks }) => {
|
||||
</span>
|
||||
);
|
||||
});
|
||||
|
||||
export default LinksSentence;
|
||||
|
||||
@ -107,7 +107,7 @@ export default class ListItem extends React.Component {
|
||||
artists_total: total,
|
||||
artists_uris: array,
|
||||
} = item;
|
||||
if (Array.isArray(value)) return <LinksSentence items={value} />;
|
||||
if (Array.isArray(value)) return <LinksSentence items={value} type="artist" />;
|
||||
if (!total && !array) return null;
|
||||
return <I18n path="specs.artists" count={nice_number(total || array.length)} />;
|
||||
}
|
||||
|
||||
@ -237,7 +237,7 @@ class PlaybackControls extends React.Component {
|
||||
{transition_track.name}
|
||||
</div>
|
||||
<div className="artist">
|
||||
<LinksSentence items={transition_track.artists} nolinks />
|
||||
<LinksSentence items={transition_track.artists} type="artist" nolinks />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -264,7 +264,7 @@ class PlaybackControls extends React.Component {
|
||||
<div className="artist">
|
||||
{
|
||||
(current_track && current_track.artists
|
||||
&& <LinksSentence items={current_track.artists} />)
|
||||
&& <LinksSentence items={current_track.artists} type="artist" />)
|
||||
|| (stream_title && <span className="links-sentence">{stream_title}</span>)
|
||||
|| <LinksSentence />
|
||||
}
|
||||
|
||||
@ -58,7 +58,7 @@ const SearchResults = ({
|
||||
<h4>
|
||||
{!all && (
|
||||
<span>
|
||||
<URILink uri={`iris:search:all:${encodedTerm}`}>
|
||||
<URILink uri={`iris:search:all:${encodedTerm}`} type="search">
|
||||
<I18n path="search.title" />
|
||||
</URILink>
|
||||
{' '}
|
||||
@ -68,7 +68,7 @@ const SearchResults = ({
|
||||
</span>
|
||||
)}
|
||||
{all && (
|
||||
<URILink uri={`iris:search:${type}:${encodedTerm}`}>
|
||||
<URILink uri={`iris:search:${type}:${encodedTerm}`} type="search">
|
||||
<I18n path={`search.${type}.title`} />
|
||||
</URILink>
|
||||
)}
|
||||
|
||||
@ -1,17 +1,10 @@
|
||||
|
||||
import React, { memo, useCallback } from 'react';
|
||||
import React from 'react';
|
||||
import { useStore, useDispatch } from 'react-redux'
|
||||
import { connect } from 'react-redux';
|
||||
import { bindActionCreators } from 'redux';
|
||||
import Link from './Link';
|
||||
import Icon from './Icon';
|
||||
import URILink from './URILink';
|
||||
import TextField from './Fields/TextField';
|
||||
import { indexToArray } from '../util/arrays';
|
||||
import { Button } from './Button';
|
||||
|
||||
import * as uiActions from '../services/ui/actions';
|
||||
import * as coreActions from '../services/core/actions';
|
||||
import * as mopidyActions from '../services/mopidy/actions';
|
||||
import { iconFromKeyword } from '../util/helpers';
|
||||
import { I18n } from '../locale';
|
||||
|
||||
@ -232,7 +232,7 @@ export default class Track extends React.Component {
|
||||
|
||||
case 'browse':
|
||||
var link = (
|
||||
<URILink uri={added_from}>
|
||||
<URILink type={type} uri={added_from}>
|
||||
<I18n path="library.browse.title" />
|
||||
</URILink>
|
||||
);
|
||||
@ -240,7 +240,7 @@ export default class Track extends React.Component {
|
||||
|
||||
case 'search':
|
||||
var link = (
|
||||
<URILink uri={added_from}>
|
||||
<URILink type={type} uri={added_from}>
|
||||
<I18n path="search.title" />
|
||||
</URILink>
|
||||
);
|
||||
@ -312,7 +312,7 @@ export default class Track extends React.Component {
|
||||
if (track.artists) {
|
||||
track_details.push(
|
||||
<li className="details__item details__item--artists" key="artists">
|
||||
{track.artists ? <LinksSentence items={track.artists} /> : '-'}
|
||||
{track.artists ? <LinksSentence items={track.artists} type="artist" /> : '-'}
|
||||
</li>,
|
||||
);
|
||||
} else if (track.playing && stream_title) {
|
||||
|
||||
@ -4,8 +4,8 @@ import { uriType as uriTypeHelper } from '../util/helpers';
|
||||
|
||||
export default memo((props) => {
|
||||
let to = null;
|
||||
let { uri } = props;
|
||||
const uriType = uriTypeHelper(uri);
|
||||
let { uri, type } = props;
|
||||
const uriType = type || uriTypeHelper(uri);
|
||||
if (!props.unencoded) {
|
||||
uri = encodeURIComponent(uri);
|
||||
}
|
||||
|
||||
@ -267,7 +267,7 @@ const CoreMiddleware = (function () {
|
||||
store.dispatch(uiActions.createNotification({
|
||||
content: (
|
||||
<I18n path="actions.added_tracks_to" count={tracks_uris.length} contentAfter>
|
||||
<URILink uri={key}>{asset ? asset.name : 'playlist'}</URILink>
|
||||
<URILink type="playlist" uri={key}>{asset ? asset.name : 'playlist'}</URILink>
|
||||
</I18n>
|
||||
),
|
||||
}));
|
||||
|
||||
@ -387,7 +387,7 @@ export function loveTrack(uri) {
|
||||
userloved: true,
|
||||
}));
|
||||
dispatch(uiActions.createNotification({
|
||||
content: <span>Loved <URILink uri={uri}>{asset ? asset.name : type}</URILink></span>,
|
||||
content: <span>Loved <URILink type="track" uri={uri}>{asset ? asset.name : type}</URILink></span>,
|
||||
}));
|
||||
},
|
||||
);
|
||||
|
||||
@ -779,12 +779,12 @@ export function following(uri, method = 'GET') {
|
||||
if (method === 'DELETE') {
|
||||
dispatch(coreActions.removeFromLibrary(`spotify:library:${type}s`, uri));
|
||||
dispatch(uiActions.createNotification({
|
||||
content: <span>Removed <URILink uri={uri}>{asset ? asset.name : type}</URILink> from library</span>,
|
||||
content: <span>Removed <URILink type={type} uri={uri}>{asset ? asset.name : type}</URILink> from library</span>,
|
||||
}));
|
||||
} else if (method === 'PUT' || method === 'POST') {
|
||||
dispatch(coreActions.addToLibrary(`spotify:library:${type}s`, asset));
|
||||
dispatch(uiActions.createNotification({
|
||||
content: <span>Added <URILink uri={uri}>{asset ? asset.name : type}</URILink> to library</span>,
|
||||
content: <span>Added <URILink type={type} uri={uri}>{asset ? asset.name : type}</URILink> to library</span>,
|
||||
}));
|
||||
}
|
||||
},
|
||||
|
||||
@ -335,7 +335,7 @@ const decodeUri = (rawUri) => {
|
||||
* @return obj
|
||||
* */
|
||||
const formatAlbum = function (data) {
|
||||
const album = {};
|
||||
const album = { type: 'album' };
|
||||
const fields = [
|
||||
'uri',
|
||||
'in_library',
|
||||
@ -412,7 +412,7 @@ const formatAlbum = function (data) {
|
||||
* @return obj
|
||||
* */
|
||||
const formatArtist = function (data) {
|
||||
const artist = {};
|
||||
const artist = { type: 'artist' };
|
||||
const fields = [
|
||||
'uri',
|
||||
'in_library',
|
||||
@ -474,7 +474,7 @@ const formatArtist = function (data) {
|
||||
* @return obj
|
||||
* */
|
||||
const formatPlaylist = function (data) {
|
||||
const playlist = {};
|
||||
const playlist = { type: 'playlist' };
|
||||
const fields = [
|
||||
'uri',
|
||||
'in_library',
|
||||
@ -563,7 +563,7 @@ const formatPlaylist = function (data) {
|
||||
* @return obj
|
||||
* */
|
||||
const formatUser = function (data) {
|
||||
const user = {};
|
||||
const user = { type: 'user' };
|
||||
const fields = [
|
||||
'id',
|
||||
'in_library',
|
||||
@ -619,7 +619,7 @@ const formatUser = function (data) {
|
||||
* @return obj
|
||||
* */
|
||||
const formatTrack = function (data) {
|
||||
const track = {};
|
||||
const track = { type: 'track' };
|
||||
const fields = [
|
||||
'uri',
|
||||
'in_library',
|
||||
@ -734,7 +734,7 @@ const formatTrack = function (data) {
|
||||
* @return obj
|
||||
* */
|
||||
const formatClient = function (data) {
|
||||
const client = {};
|
||||
const client = { type: 'client' };
|
||||
const fields = [
|
||||
'id',
|
||||
'connected',
|
||||
@ -798,7 +798,7 @@ const formatClient = function (data) {
|
||||
* @return obj
|
||||
* */
|
||||
const formatCategory = function (data) {
|
||||
const category = {};
|
||||
const category = { type: 'category' };
|
||||
const fields = [
|
||||
'id',
|
||||
'uri',
|
||||
@ -830,7 +830,7 @@ const formatCategory = function (data) {
|
||||
* @return obj
|
||||
* */
|
||||
const formatGroup = function (data) {
|
||||
const group = {};
|
||||
const group = { type: 'group' };
|
||||
const fields = [
|
||||
'id',
|
||||
'name',
|
||||
|
||||
@ -260,7 +260,7 @@ class Album extends React.Component {
|
||||
) : null}
|
||||
{album.artists && album.artists.length > 0 ? (
|
||||
<li>
|
||||
<LinksSentence items={album.artists} />
|
||||
<LinksSentence items={album.artists} type="artist" />
|
||||
</li>
|
||||
) : null}
|
||||
{album.release_date ? (
|
||||
|
||||
@ -42,7 +42,7 @@ const Artwork = ({
|
||||
<Link to="/kiosk-mode" className="thumbnail__actions__item">
|
||||
<Icon name="expand" type="fontawesome" />
|
||||
</Link>
|
||||
<URILink uri={album_uri} className="thumbnail__actions__item">
|
||||
<URILink type="album" uri={album_uri} className="thumbnail__actions__item">
|
||||
<Icon name="album" />
|
||||
</URILink>
|
||||
</Thumbnail>
|
||||
@ -176,6 +176,7 @@ class Queue extends React.Component {
|
||||
{addedFromItems[0].images && (
|
||||
<URILink
|
||||
uri={addedFromItems[0].uri}
|
||||
type={addedFromItems[0].type}
|
||||
className="current-track__added-from__thumbnail"
|
||||
>
|
||||
<Thumbnail
|
||||
@ -188,7 +189,10 @@ class Queue extends React.Component {
|
||||
)}
|
||||
<div className="current-track__added-from__text">
|
||||
{'Playing from '}
|
||||
<LinksSentence items={addedFromItems} />
|
||||
<LinksSentence
|
||||
items={addedFromItems}
|
||||
type={addedFromItems[0].type}
|
||||
/>
|
||||
{uri_type === 'radio' && (
|
||||
<span className="flag flag--blue">
|
||||
{i18n('now_playing.current_track.radio')}
|
||||
@ -270,15 +274,10 @@ class Queue extends React.Component {
|
||||
{!stream_title && !current_track && (<span>-</span>)}
|
||||
</div>
|
||||
|
||||
{
|
||||
(current_track && current_track.artists && (
|
||||
<LinksSentence
|
||||
className="current-track__artists"
|
||||
items={current_track.artists}
|
||||
/>
|
||||
))
|
||||
|| <LinksSentence className="current-track__artists" />
|
||||
}
|
||||
<LinksSentence
|
||||
className="current-track__artists"
|
||||
items={current_track ? current_track.artists : null}
|
||||
/>
|
||||
|
||||
{this.renderAddedFrom()}
|
||||
|
||||
|
||||
@ -240,7 +240,7 @@ class Track extends React.Component {
|
||||
{track.album && !track.album.uri ? track.album.name : null}
|
||||
{!track.album && <I18n path="track.unknown_album" />}
|
||||
<I18n path="common.by" />
|
||||
{track.artists && <LinksSentence items={track.artists} />}
|
||||
{track.artists && <LinksSentence items={track.artists} type="artist" />}
|
||||
</h2>
|
||||
|
||||
<ul className="details">
|
||||
|
||||
@ -30,7 +30,7 @@ const UriListItem = ({
|
||||
{item ? item.name : <span className="mid_grey-text">{uri}</span>}
|
||||
{item && item.artists && (
|
||||
<I18n path="common.by" contentAfter>
|
||||
<LinksSentence nolinks items={item.artists} />
|
||||
<LinksSentence nolinks items={item.artists} type="artist" />
|
||||
</I18n>
|
||||
)}
|
||||
<span className="mid_grey-text">{` (${type})`}</span>
|
||||
|
||||
@ -210,7 +210,11 @@ class KioskMode extends React.Component {
|
||||
{!stream_title && current_track && <span>{current_track.name}</span>}
|
||||
{!stream_title && !current_track && <span>-</span>}
|
||||
</div>
|
||||
{ current_track ? <LinksSentence nolinks items={current_track.artists} /> : <LinksSentence /> }
|
||||
<LinksSentence
|
||||
items={current_track ? current_track.artists : null}
|
||||
type="artist"
|
||||
nolinks
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user