Add config option to globally enable/disable downloads
This commit is contained in:
@@ -15,6 +15,7 @@ import { playNext, addTracks, playTracks, shuffleTracks } from '../actions'
|
||||
import subsonic from '../subsonic'
|
||||
import { formatBytes } from '../common/SizeField'
|
||||
import { useMediaQuery } from '@material-ui/core'
|
||||
import config from '../config'
|
||||
|
||||
const AlbumActions = ({ className, ids, data, record, ...rest }) => {
|
||||
const dispatch = useDispatch()
|
||||
@@ -67,15 +68,17 @@ const AlbumActions = ({ className, ids, data, record, ...rest }) => {
|
||||
>
|
||||
<RiPlayListAddFill />
|
||||
</Button>
|
||||
<Button
|
||||
onClick={handleDownload}
|
||||
label={
|
||||
translate('resources.album.actions.download') +
|
||||
(isDesktop ? ` (${formatBytes(record.size)})` : '')
|
||||
}
|
||||
>
|
||||
<CloudDownloadOutlinedIcon />
|
||||
</Button>
|
||||
{config.enableDownloads && (
|
||||
<Button
|
||||
onClick={handleDownload}
|
||||
label={
|
||||
translate('resources.album.actions.download') +
|
||||
(isDesktop ? ` (${formatBytes(record.size)})` : '')
|
||||
}
|
||||
>
|
||||
<CloudDownloadOutlinedIcon />
|
||||
</Button>
|
||||
)}
|
||||
</TopToolbar>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ import {
|
||||
import subsonic from '../subsonic'
|
||||
import StarButton from './StarButton'
|
||||
import { formatBytes } from './SizeField'
|
||||
import config from '../config'
|
||||
|
||||
const useStyles = makeStyles({
|
||||
noWrap: {
|
||||
@@ -45,31 +46,37 @@ const ContextMenu = ({
|
||||
|
||||
const options = {
|
||||
play: {
|
||||
enabled: true,
|
||||
needData: true,
|
||||
label: translate('resources.album.actions.playAll'),
|
||||
action: (data, ids) => dispatch(playTracks(data, ids)),
|
||||
},
|
||||
playNext: {
|
||||
enabled: true,
|
||||
needData: true,
|
||||
label: translate('resources.album.actions.playNext'),
|
||||
action: (data, ids) => dispatch(playNext(data, ids)),
|
||||
},
|
||||
addToQueue: {
|
||||
enabled: true,
|
||||
needData: true,
|
||||
label: translate('resources.album.actions.addToQueue'),
|
||||
action: (data, ids) => dispatch(addTracks(data, ids)),
|
||||
},
|
||||
shuffle: {
|
||||
enabled: true,
|
||||
needData: true,
|
||||
label: translate('resources.album.actions.shuffle'),
|
||||
action: (data, ids) => dispatch(shuffleTracks(data, ids)),
|
||||
},
|
||||
addToPlaylist: {
|
||||
enabled: true,
|
||||
needData: true,
|
||||
label: translate('resources.album.actions.addToPlaylist'),
|
||||
action: (data, ids) => dispatch(openAddToPlaylist({ selectedIds: ids })),
|
||||
},
|
||||
download: {
|
||||
enabled: config.enableDownloads,
|
||||
needData: false,
|
||||
label: `${translate('resources.album.actions.download')} (${formatBytes(
|
||||
record.size
|
||||
@@ -146,11 +153,14 @@ const ContextMenu = ({
|
||||
open={open}
|
||||
onClose={handleOnClose}
|
||||
>
|
||||
{Object.keys(options).map((key) => (
|
||||
<MenuItem value={key} key={key} onClick={handleItemClick}>
|
||||
{options[key].label}
|
||||
</MenuItem>
|
||||
))}
|
||||
{Object.keys(options).map(
|
||||
(key) =>
|
||||
options[key].enabled && (
|
||||
<MenuItem value={key} key={key} onClick={handleItemClick}>
|
||||
{options[key].label}
|
||||
</MenuItem>
|
||||
)
|
||||
)}
|
||||
</Menu>
|
||||
</span>
|
||||
)
|
||||
|
||||
@@ -9,6 +9,7 @@ import { playNext, addTracks, setTrack, openAddToPlaylist } from '../actions'
|
||||
import subsonic from '../subsonic'
|
||||
import StarButton from './StarButton'
|
||||
import { formatBytes } from './SizeField'
|
||||
import config from '../config'
|
||||
|
||||
const useStyles = makeStyles({
|
||||
noWrap: {
|
||||
@@ -32,18 +33,22 @@ const SongContextMenu = ({
|
||||
const [anchorEl, setAnchorEl] = useState(null)
|
||||
const options = {
|
||||
playNow: {
|
||||
enabled: true,
|
||||
label: translate('resources.song.actions.playNow'),
|
||||
action: (record) => dispatch(setTrack(record)),
|
||||
},
|
||||
playNext: {
|
||||
enabled: true,
|
||||
label: translate('resources.song.actions.playNext'),
|
||||
action: (record) => dispatch(playNext({ [record.id]: record })),
|
||||
},
|
||||
addToQueue: {
|
||||
enabled: true,
|
||||
label: translate('resources.song.actions.addToQueue'),
|
||||
action: (record) => dispatch(addTracks({ [record.id]: record })),
|
||||
},
|
||||
addToPlaylist: {
|
||||
enabled: true,
|
||||
label: translate('resources.song.actions.addToPlaylist'),
|
||||
action: (record) =>
|
||||
dispatch(
|
||||
@@ -54,6 +59,7 @@ const SongContextMenu = ({
|
||||
),
|
||||
},
|
||||
download: {
|
||||
enabled: config.enableDownloads,
|
||||
label: `${translate('resources.song.actions.download')} (${formatBytes(
|
||||
record.size
|
||||
)})`,
|
||||
@@ -95,11 +101,14 @@ const SongContextMenu = ({
|
||||
open={open}
|
||||
onClose={handleClose}
|
||||
>
|
||||
{Object.keys(options).map((key) => (
|
||||
<MenuItem value={key} key={key} onClick={handleItemClick}>
|
||||
{options[key].label}
|
||||
</MenuItem>
|
||||
))}
|
||||
{Object.keys(options).map(
|
||||
(key) =>
|
||||
options[key].enabled && (
|
||||
<MenuItem value={key} key={key} onClick={handleItemClick}>
|
||||
{options[key].label}
|
||||
</MenuItem>
|
||||
)
|
||||
)}
|
||||
</Menu>
|
||||
</span>
|
||||
)
|
||||
|
||||
@@ -7,6 +7,7 @@ const defaultConfig = {
|
||||
baseURL: '',
|
||||
loginBackgroundURL: 'https://source.unsplash.com/random/1600x900?music',
|
||||
enableTranscodingConfig: true,
|
||||
enableDownloads: true,
|
||||
welcomeMessage: '',
|
||||
gaTrackingId: '',
|
||||
devActivityMenu: true,
|
||||
|
||||
@@ -18,6 +18,7 @@ import subsonic from '../subsonic'
|
||||
import PropTypes from 'prop-types'
|
||||
import { formatBytes } from '../common/SizeField'
|
||||
import { useMediaQuery } from '@material-ui/core'
|
||||
import config from '../config'
|
||||
|
||||
const PlaylistActions = ({ className, ids, data, record, ...rest }) => {
|
||||
const dispatch = useDispatch()
|
||||
@@ -88,15 +89,17 @@ const PlaylistActions = ({ className, ids, data, record, ...rest }) => {
|
||||
>
|
||||
<RiPlayListAddFill />
|
||||
</Button>
|
||||
<Button
|
||||
onClick={handleDownload}
|
||||
label={
|
||||
translate('resources.album.actions.download') +
|
||||
(isDesktop ? ` (${formatBytes(record.size)})` : '')
|
||||
}
|
||||
>
|
||||
<CloudDownloadOutlinedIcon />
|
||||
</Button>
|
||||
{config.enableDownloads && (
|
||||
<Button
|
||||
onClick={handleDownload}
|
||||
label={
|
||||
translate('resources.album.actions.download') +
|
||||
(isDesktop ? ` (${formatBytes(record.size)})` : '')
|
||||
}
|
||||
>
|
||||
<CloudDownloadOutlinedIcon />
|
||||
</Button>
|
||||
)}
|
||||
<Button
|
||||
onClick={handleExport}
|
||||
label={translate('resources.playlist.actions.export')}
|
||||
|
||||
Reference in New Issue
Block a user