From 99f0aa868a46ec5db3a86fe1705d22cc50debeb5 Mon Sep 17 00:00:00 2001
From: Michel Heusschen <59014050+michelheusschen@users.noreply.github.com>
Date: Sun, 26 May 2024 14:10:01 +0200
Subject: [PATCH] fix(web): detail panel asset description (#9765)
---
.../asset-viewer/detail-panel.e2e-spec.ts | 14 +++++
.../detail-panel-description.svelte | 62 +++++++++++++++++++
.../asset-viewer/detail-panel.svelte | 61 ++----------------
3 files changed, 80 insertions(+), 57 deletions(-)
create mode 100644 web/src/lib/components/asset-viewer/detail-panel-description.svelte
diff --git a/e2e/src/web/specs/asset-viewer/detail-panel.e2e-spec.ts b/e2e/src/web/specs/asset-viewer/detail-panel.e2e-spec.ts
index ad847dab15..9cfcc4f37b 100644
--- a/e2e/src/web/specs/asset-viewer/detail-panel.e2e-spec.ts
+++ b/e2e/src/web/specs/asset-viewer/detail-panel.e2e-spec.ts
@@ -43,4 +43,18 @@ test.describe('Detail Panel', () => {
await page.keyboard.press('i');
await expect(page.locator('#detail-panel')).toHaveCount(0);
});
+
+ test('description is visible for owner on shared links', async ({ context, page }) => {
+ const sharedLink = await utils.createSharedLink(admin.accessToken, {
+ type: SharedLinkType.Individual,
+ assetIds: [asset.id],
+ });
+ await utils.setAuthCookies(context, admin.accessToken);
+ await page.goto(`/share/${sharedLink.key}/photos/${asset.id}`);
+
+ const textarea = page.getByRole('textbox', { name: 'Add a description' });
+ await page.getByRole('button', { name: 'Info' }).click();
+ await expect(textarea).toBeVisible();
+ await expect(textarea).not.toBeDisabled();
+ });
});
diff --git a/web/src/lib/components/asset-viewer/detail-panel-description.svelte b/web/src/lib/components/asset-viewer/detail-panel-description.svelte
new file mode 100644
index 0000000000..c26eab1a84
--- /dev/null
+++ b/web/src/lib/components/asset-viewer/detail-panel-description.svelte
@@ -0,0 +1,62 @@
+
+
+{#if isOwner}
+
+{:else if description}
+
+{/if}
diff --git a/web/src/lib/components/asset-viewer/detail-panel.svelte b/web/src/lib/components/asset-viewer/detail-panel.svelte
index 0f901d67a3..7f6c00b5f4 100644
--- a/web/src/lib/components/asset-viewer/detail-panel.svelte
+++ b/web/src/lib/components/asset-viewer/detail-panel.svelte
@@ -8,10 +8,8 @@
import { featureFlags } from '$lib/stores/server-config.store';
import { user } from '$lib/stores/user.store';
import { websocketEvents } from '$lib/stores/websocket';
- import { getAssetThumbnailUrl, getPeopleThumbnailUrl, isSharedLink, handlePromiseError } from '$lib/utils';
+ import { getAssetThumbnailUrl, getPeopleThumbnailUrl, handlePromiseError, isSharedLink } from '$lib/utils';
import { delay, isFlipped } from '$lib/utils/asset-utils';
- import { autoGrowHeight } from '$lib/actions/autogrow';
- import { clickOutside } from '$lib/actions/click-outside';
import {
ThumbnailFormat,
getAssetInfo,
@@ -40,9 +38,8 @@
import PersonSidePanel from '../faces-page/person-side-panel.svelte';
import UserAvatar from '../shared-components/user-avatar.svelte';
import LoadingSpinner from '../shared-components/loading-spinner.svelte';
- import { NotificationType, notificationController } from '../shared-components/notification/notification';
- import { shortcut } from '$lib/actions/shortcut';
import AlbumListItemDetails from './album-list-item-details.svelte';
+ import DetailPanelDescription from '$lib/components/asset-viewer/detail-panel-description.svelte';
export let asset: AssetResponseDto;
export let albums: AlbumResponseDto[] = [];
@@ -58,9 +55,6 @@
};
let showAssetPath = false;
- let textArea: HTMLTextAreaElement;
- let description: string;
- let originalDescription: string;
let showEditFaces = false;
let previousId: string;
@@ -77,16 +71,11 @@
$: isOwner = $user?.id === asset.ownerId;
const handleNewAsset = async (newAsset: AssetResponseDto) => {
- description = newAsset?.exifInfo?.description || '';
-
- // Get latest description from server
+ // TODO: check if reloading asset data is necessary
if (newAsset.id && !isSharedLink()) {
const data = await getAssetInfo({ id: asset.id });
people = data?.people || [];
-
- description = data.exifInfo?.description || '';
}
- originalDescription = description;
};
$: handlePromiseError(handleNewAsset(asset));
@@ -129,28 +118,10 @@
const handleRefreshPeople = async () => {
await getAssetInfo({ id: asset.id }).then((data) => {
people = data?.people || [];
- textArea.value = data?.exifInfo?.description || '';
});
showEditFaces = false;
};
- const handleFocusOut = async () => {
- textArea.blur();
- if (description === originalDescription) {
- return;
- }
- originalDescription = description;
- try {
- await updateAsset({ id: asset.id, updateAssetDto: { description } });
- notificationController.show({
- type: NotificationType.Info,
- message: 'Asset description has been updated',
- });
- } catch (error) {
- handleError(error, 'Cannot update the description');
- }
- };
-
const toggleAssetPath = () => (showAssetPath = !showAssetPath);
let isShowChangeDate = false;
@@ -185,31 +156,7 @@
{/if}
- {#if isOwner}
-
- {:else if description}
-
{description}
- {/if}
+
{#if !isSharedLink() && people.length > 0}