a shared link is a URL, not a key

Create, edit and revoke shared links from the album header, the selection
bar and the Sharing panel. Password, expiry, and the three flags that
decide what the person opening it can do.

The panel showed a bare key because this plugin never learned the
instance's public address. It does not need to store one: Immich has
`externalDomain` in its own admin settings, `/server/config` already
returns it, and it is the same field Immich's own copy-link button reads,
so the two cannot disagree. Empty is a real state and the UI says so
rather than inventing a host.

Payload shapes came from the live instance's spec.json, not from memory.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-09-02 18:16:02 +01:00
co-authored by Claude Opus 5
parent 470bb42fe8
commit 70fc2b08c6
7 changed files with 598 additions and 41 deletions
+20 -1
View File
@@ -1,5 +1,6 @@
import type { Selection } from './useSelection';
import { Archive, ArchiveRestore, Heart, Plus, Trash2, Undo2, X } from 'lucide-react';
import { useState } from 'react';
import { Archive, ArchiveRestore, Heart, Plus, Share2, Trash2, Undo2, X } from 'lucide-react';
import { Button } from '@/components/ui/button';
import {
DropdownMenu,
@@ -8,6 +9,7 @@ import {
DropdownMenuSeparator,
DropdownMenuTrigger,
} from '@/components/ui/dropdown-menu';
import { ShareLinkDialog } from './ShareLinkDialog';
import { useAlbums } from './usePhotosData';
import { useAssetActions } from './useAssetActions';
@@ -29,6 +31,12 @@ export const SelectionBar = ({ selection, inTrash = false, albumId, archived = f
const { setFavorite, setArchived, trash, restore, deleteForever, addToAlbum, removeFromAlbum, createAlbum } =
useAssetActions();
const { data: albums } = useAlbums();
/*
The ids are captured when Share is pressed rather than read live, so the dialog keeps acting on what was
selected even if the selection changes behind it. Selection is deliberately NOT cleared: a link is usually
made to send, and losing the selection makes a second link over the same photos a re-selection job.
*/
const [sharing, setSharing] = useState<string[] | null>(null);
const run = (action: () => void) => {
action();
@@ -95,6 +103,11 @@ export const SelectionBar = ({ selection, inTrash = false, albumId, archived = f
</Button>
)}
<Button variant="ghost" size="sm" onClick={() => setSharing(ids)}>
<Share2 className="mr-1.5 h-4 w-4" />
Share
</Button>
<Button
variant="ghost"
size="icon"
@@ -116,6 +129,12 @@ export const SelectionBar = ({ selection, inTrash = false, albumId, archived = f
</Button>
</>
)}
<ShareLinkDialog
open={!!sharing}
onOpenChange={(next) => !next && setSharing(null)}
target={sharing ? { kind: 'assets', assetIds: sharing } : null}
/>
</div>
);
};