2022-04-15 14:24:30 +00:00
|
|
|
<template>
|
2022-04-24 08:29:14 +00:00
|
|
|
<ContextMenuBase extra-class="artist-menu" ref="base" data-testid="artist-context-menu">
|
2022-04-15 14:24:30 +00:00
|
|
|
<template v-if="artist">
|
|
|
|
<li data-test="play" @click="play">Play All</li>
|
|
|
|
<li data-test="shuffle" @click="shuffle">Shuffle All</li>
|
|
|
|
<template v-if="isStandardArtist">
|
|
|
|
<li class="separator"></li>
|
|
|
|
<li data-test="view-artist" @click="viewArtistDetails">Go to Artist</li>
|
|
|
|
</template>
|
2022-04-25 16:13:18 +00:00
|
|
|
<template v-if="isStandardArtist && allowDownload">
|
2022-04-15 14:24:30 +00:00
|
|
|
<li class="separator"></li>
|
|
|
|
<li data-test="download" @click="download">Download</li>
|
|
|
|
</template>
|
|
|
|
</template>
|
2022-04-24 08:29:14 +00:00
|
|
|
</ContextMenuBase>
|
2022-04-15 14:24:30 +00:00
|
|
|
</template>
|
|
|
|
|
2022-04-15 17:00:08 +00:00
|
|
|
<script lang="ts" setup>
|
2022-04-25 16:13:18 +00:00
|
|
|
import { computed, Ref, toRef } from 'vue'
|
2022-04-24 08:50:45 +00:00
|
|
|
import { artistStore, commonStore } from '@/stores'
|
|
|
|
import { downloadService, playbackService } from '@/services'
|
2022-04-15 17:00:08 +00:00
|
|
|
import { useContextMenu } from '@/composables'
|
2022-04-15 14:24:30 +00:00
|
|
|
import router from '@/router'
|
|
|
|
|
2022-04-24 08:29:14 +00:00
|
|
|
const { context, base, ContextMenuBase, open, close } = useContextMenu()
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-04-20 10:27:10 +00:00
|
|
|
const artist = toRef(context, 'artist') as Ref<Artist>
|
2022-04-25 16:13:18 +00:00
|
|
|
const allowDownload = toRef(commonStore.state, 'allowDownload')
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-04-15 17:00:08 +00:00
|
|
|
const isStandardArtist = computed(() =>
|
|
|
|
!artistStore.isUnknownArtist(artist.value)
|
|
|
|
&& !artistStore.isVariousArtists(artist.value)
|
|
|
|
)
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-04-24 08:50:45 +00:00
|
|
|
const play = () => playbackService.playAllByArtist(artist.value)
|
|
|
|
const shuffle = () => playbackService.playAllByArtist(artist.value, true /* shuffled */)
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-04-15 17:00:08 +00:00
|
|
|
const viewArtistDetails = () => {
|
|
|
|
router.go(`artist/${artist.value.id}`)
|
|
|
|
close()
|
|
|
|
}
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-04-15 17:00:08 +00:00
|
|
|
const download = () => {
|
|
|
|
downloadService.fromArtist(artist.value)
|
|
|
|
close()
|
|
|
|
}
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-04-15 17:00:08 +00:00
|
|
|
defineExpose({ open, close })
|
2022-04-15 14:24:30 +00:00
|
|
|
</script>
|