feat(plus): disable Shareable URL if song is private

This commit is contained in:
Phan An 2024-01-23 00:27:31 +01:00
parent 44fa2d0179
commit 84ce42da08
2 changed files with 18 additions and 2 deletions

View file

@ -262,11 +262,25 @@ new class extends UnitTestCase {
expect(screen.queryByText('Edit…')).toBeNull()
})
it('has an option to copy shareable URL', async () => {
it('has an option to copy shareable URL in Community edition', async () => {
await this.renderComponent(factory<Song>('song'))
screen.getByText('Copy Shareable URL')
})
it('has an option to copy shareable URL if song is public in Plus edition', async () => {
this.enablePlusEdition()
await this.renderComponent(factory<Song>('song', { is_public: true }))
screen.getByText('Copy Shareable URL')
})
it('does not have an option to share if song is private in Plus edition', async () => {
this.enablePlusEdition()
await this.renderComponent(factory<Song>('song', { is_public: false }))
expect(screen.queryByText('Copy Shareable URL')).toBeNull()
})
it('deletes song', async () => {
const confirmMock = this.mock(DialogBoxStub.value, 'confirm', true)
const toasterMock = this.mock(MessageToasterStub.value, 'success')

View file

@ -50,7 +50,7 @@
<li v-if="canModify" @click="openEditForm">Edit</li>
<li v-if="allowsDownload" @click="download">Download</li>
<li v-if="onlyOneSongSelected" @click="copyUrl">Copy Shareable URL</li>
<li v-if="onlyOneSongSelected && canBeShared" @click="copyUrl">Copy Shareable URL</li>
<template v-if="canBeRemovedFromPlaylist">
<li class="separator" />
@ -123,6 +123,8 @@ const makePrivate = () => trigger(async () => {
toastSuccess(`Removed public access to ${pluralize(songs.value, 'song')}.`)
})
const canBeShared = computed(() => !isPlus.value || songs.value[0].is_public)
const visibilityActions = computed(() => {
if (!isPlus.value) return []