feat: editors can update album title & description (#31805)
This commit is contained in:
+2
-2
@@ -378,7 +378,7 @@
|
||||
<AlbumTitle
|
||||
id={album.id}
|
||||
albumName={album.albumName}
|
||||
{isOwned}
|
||||
{isEditor}
|
||||
onUpdate={(albumName) => (album = { ...album, albumName })}
|
||||
/>
|
||||
|
||||
@@ -428,7 +428,7 @@
|
||||
{/if}
|
||||
<AlbumDescription
|
||||
id={album.id}
|
||||
{isOwned}
|
||||
{isEditor}
|
||||
bind:description={() => album.description, (description) => (album = { ...album, description })}
|
||||
/>
|
||||
</section>
|
||||
|
||||
+2
-2
@@ -5,13 +5,13 @@ import AlbumDescription from './AlbumDescription.svelte';
|
||||
|
||||
describe('AlbumDescription component', () => {
|
||||
it('shows an AutogrowTextarea component when isOwned is true', () => {
|
||||
render(AlbumDescription, { isOwned: true, id: '', description: '' });
|
||||
render(AlbumDescription, { isEditor: true, id: '', description: '' });
|
||||
const autogrowTextarea = screen.getByTestId('autogrow-textarea');
|
||||
expect(autogrowTextarea).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('does not show an AutogrowTextarea component when isOwned is false', () => {
|
||||
render(AlbumDescription, { isOwned: false, id: '', description: '' });
|
||||
render(AlbumDescription, { isEditor: false, id: '', description: '' });
|
||||
const autogrowTextarea = screen.queryByTestId('autogrow-textarea');
|
||||
expect(autogrowTextarea).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
+3
-3
@@ -10,10 +10,10 @@
|
||||
interface Props {
|
||||
id: string;
|
||||
description: string;
|
||||
isOwned: boolean;
|
||||
isEditor: boolean;
|
||||
}
|
||||
|
||||
let { id, description = $bindable(), isOwned }: Props = $props();
|
||||
let { id, description = $bindable(), isEditor }: Props = $props();
|
||||
|
||||
const handleFocusOut = async () => {
|
||||
try {
|
||||
@@ -30,7 +30,7 @@
|
||||
};
|
||||
</script>
|
||||
|
||||
{#if isOwned}
|
||||
{#if isEditor}
|
||||
<Textarea
|
||||
bind:value={description}
|
||||
variant="ghost"
|
||||
|
||||
+3
-3
@@ -10,11 +10,11 @@
|
||||
type Props = {
|
||||
id: string;
|
||||
albumName: string;
|
||||
isOwned: boolean;
|
||||
isEditor: boolean;
|
||||
onUpdate: (albumName: string) => void;
|
||||
};
|
||||
|
||||
let { id, albumName = $bindable(), isOwned, onUpdate }: Props = $props();
|
||||
let { id, albumName = $bindable(), isEditor, onUpdate }: Props = $props();
|
||||
|
||||
let newAlbumName = $derived(albumName);
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
</script>
|
||||
|
||||
<div class="mb-2">
|
||||
{#if isOwned}
|
||||
{#if isEditor}
|
||||
<Textarea
|
||||
bind:value={newAlbumName}
|
||||
variant="ghost"
|
||||
|
||||
Reference in New Issue
Block a user