Add list type to album list view title
This commit is contained in:
@@ -47,7 +47,7 @@
|
|||||||
"shuffle": "Aleatório"
|
"shuffle": "Aleatório"
|
||||||
},
|
},
|
||||||
"lists": {
|
"lists": {
|
||||||
"default": "Todos",
|
"all": "Todos",
|
||||||
"random": "Aleatório",
|
"random": "Aleatório",
|
||||||
"recentlyAdded": "Recém-adicionados",
|
"recentlyAdded": "Recém-adicionados",
|
||||||
"recentlyPlayed": "Recém-tocados",
|
"recentlyPlayed": "Recém-tocados",
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import {
|
|||||||
useTranslate,
|
useTranslate,
|
||||||
useListParams,
|
useListParams,
|
||||||
} from 'react-admin'
|
} from 'react-admin'
|
||||||
import { List, useAlbumsPerPage } from '../common'
|
import { List, Title, useAlbumsPerPage } from '../common'
|
||||||
import { withWidth } from '@material-ui/core'
|
import { withWidth } from '@material-ui/core'
|
||||||
import AlbumListActions from './AlbumListActions'
|
import AlbumListActions from './AlbumListActions'
|
||||||
import AlbumListView from './AlbumListView'
|
import AlbumListView from './AlbumListView'
|
||||||
@@ -41,6 +41,18 @@ const AlbumFilter = (props) => {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const AlbumListTitle = ({ albumListType }) => {
|
||||||
|
const translate = useTranslate()
|
||||||
|
let title = translate('resources.album.name', { smart_count: 2 })
|
||||||
|
if (albumListType) {
|
||||||
|
let listTitle = translate(`resources.album.lists.${albumListType}`, {
|
||||||
|
smart_count: 2,
|
||||||
|
})
|
||||||
|
title = `${title} - ${listTitle}`
|
||||||
|
}
|
||||||
|
return <Title subTitle={title} args={{ smart_count: 2 }} />
|
||||||
|
}
|
||||||
|
|
||||||
const AlbumList = (props) => {
|
const AlbumList = (props) => {
|
||||||
const { width, resource } = props
|
const { width, resource } = props
|
||||||
const albumView = useSelector((state) => state.albumView)
|
const albumView = useSelector((state) => state.albumView)
|
||||||
@@ -54,12 +66,14 @@ const AlbumList = (props) => {
|
|||||||
})
|
})
|
||||||
const isArtistView = !!(query.filter && query.filter.artist_id)
|
const isArtistView = !!(query.filter && query.filter.artist_id)
|
||||||
|
|
||||||
|
const albumListType = location.pathname
|
||||||
|
.replace(/^\/album/, '')
|
||||||
|
.replace(/^\//, '')
|
||||||
|
|
||||||
// If it does not have filter/sort params (usually coming from Menu),
|
// If it does not have filter/sort params (usually coming from Menu),
|
||||||
// reload with correct filter/sort params
|
// reload with correct filter/sort params
|
||||||
if (!location.search) {
|
if (!location.search) {
|
||||||
let type =
|
const type = albumListType || 'all'
|
||||||
location.pathname.replace(/^\/album/, '').replace(/^\//, '') || 'all'
|
|
||||||
|
|
||||||
const listParams = albumLists[type]
|
const listParams = albumLists[type]
|
||||||
if (listParams) {
|
if (listParams) {
|
||||||
return <Redirect to={`/album/${type}?${listParams.params}`} />
|
return <Redirect to={`/album/${type}?${listParams.params}`} />
|
||||||
@@ -76,6 +90,7 @@ const AlbumList = (props) => {
|
|||||||
filters={<AlbumFilter />}
|
filters={<AlbumFilter />}
|
||||||
perPage={perPage}
|
perPage={perPage}
|
||||||
pagination={<Pagination rowsPerPageOptions={perPageOptions} />}
|
pagination={<Pagination rowsPerPageOptions={perPageOptions} />}
|
||||||
|
title={<AlbumListTitle albumListType={albumListType} />}
|
||||||
>
|
>
|
||||||
{albumView.mode === ALBUM_MODE_LIST ? (
|
{albumView.mode === ALBUM_MODE_LIST ? (
|
||||||
<AlbumListView {...props} />
|
<AlbumListView {...props} />
|
||||||
|
|||||||
+1
-1
@@ -48,7 +48,7 @@
|
|||||||
"shuffle": "Shuffle"
|
"shuffle": "Shuffle"
|
||||||
},
|
},
|
||||||
"lists": {
|
"lists": {
|
||||||
"default": "All",
|
"all": "All",
|
||||||
"random": "Random",
|
"random": "Random",
|
||||||
"recentlyAdded": "Recently Added",
|
"recentlyAdded": "Recently Added",
|
||||||
"recentlyPlayed": "Recently Played",
|
"recentlyPlayed": "Recently Played",
|
||||||
|
|||||||
Reference in New Issue
Block a user