π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Add comments and reactions toggle to public link settings
Anand Baburajanca74dd808c92
diff --git a/web/apps/photos/src/components/Collections/CollectionShare.tsx b/web/apps/photos/src/components/Collections/CollectionShare.tsxindex 330fe387f8..d4c1325a1d 100644--- a/web/apps/photos/src/components/Collections/CollectionShare.tsx+++ b/web/apps/photos/src/components/Collections/CollectionShare.tsx@@ -1882,10 +1882,6 @@ const ManagePublicShareOptions: React.FC<ManagePublicShareOptionsProps> = ({onUpdate={handlePublicURLUpdate}/></RowButtonGroup>- <ManageComments- {...{ onRootClose, publicURL }}- onUpdate={handlePublicURLUpdate}- /><RowButtonGroup><RowButtonstartIcon={@@ -1953,17 +1949,27 @@ const ManagePublicCollect: React.FC<ManagePublicLinkSettingProps> = ({publicURL,onUpdate,}) => {- const handleFileDownloadSetting = () => {+ const handleCollectSetting = () => {void onUpdate({ enableCollect: !publicURL.enableCollect });};+ const handleCommentSetting = () => {+ void onUpdate({ enableComment: !publicURL.enableComment });+ };+return (<Stack><RowButtonGroup><RowSwitchlabel={t("allow_adding_photos")}checked={publicURL.enableCollect}- onClick={handleFileDownloadSetting}+ onClick={handleCollectSetting}+ />+ <RowButtonDivider />+ <RowSwitch+ label={t("enable_comments")}+ checked={publicURL.enableComment}+ onClick={handleCommentSetting}/></RowButtonGroup></Stack>@@ -2262,142 +2268,6 @@ const SetPublicLinkPassword: React.FC<SetPublicLinkPasswordProps> = ({);};-type CommentPermission = "anyone" | "signed_in" | "no_one";--const commentPermissionOptions: {- value: CommentPermission;- label: string;- caption: string;- description: string;-}[] = [- {- value: "anyone",- label: "Anyone (anonymous allowed)",- caption: "Anonymous",- description:- "Anyone with the link can comment, even without signing in.",- },- {- value: "signed_in",- label: "Signed-in only",- caption: "Signed-in",- description:- "Only people signed in to Ente can comment on this memory.",- },- {- value: "no_one",- label: "No one",- caption: "No one",- description: "Comments are turned off for this memory.",- },-];--const getCommentPermissionCaption = (permission: CommentPermission) => {- const option = commentPermissionOptions.find((o) => o.value === permission);- return option?.caption ?? "Anonymous";-};--const ManageComments: React.FC<ManagePublicLinkSettingDrawerProps> = ({- onRootClose,- // TODO: Use these when backend is ready- publicURL: _publicURL, // eslint-disable-line @typescript-eslint/no-unused-vars- onUpdate: _onUpdate, // eslint-disable-line @typescript-eslint/no-unused-vars-}) => {- const { show: showCommentOptions, props: commentOptionsVisibilityProps } =- useModalVisibility();-- // TODO: Replace with actual state from publicURL when backend is ready- const [viewComments, setViewComments] = useState(true);- const [commentPermission, setCommentPermission] =- useState<CommentPermission>("anyone");- const [loadingPermission, setLoadingPermission] =- useState<CommentPermission | null>(null);-- const handleViewCommentsToggle = () => {- setViewComments(!viewComments);- // TODO: Add actual update call when backend is ready- };-- const handleCommentPermissionChange =- (permission: CommentPermission) => async () => {- if (permission === commentPermission) return;-- setLoadingPermission(permission);- try {- // TODO: Replace with actual API call when backend is ready- await wait(500);- setCommentPermission(permission);- } finally {- setLoadingPermission(null);- }- };-- const selectedOption = commentPermissionOptions.find(- (o) => o.value === commentPermission,- );-- return (- <>- <RowButtonGroup>- <RowSwitch- label={"View comments"}- checked={viewComments}- onClick={handleViewCommentsToggle}- />- <RowButtonDivider />- <RowButton- onClick={showCommentOptions}- endIcon={<ChevronRightIcon />}- label={"Who can comment"}- caption={getCommentPermissionCaption(commentPermission)}- />- </RowButtonGroup>- <TitledNestedSidebarDrawer- anchor="right"- {...commentOptionsVisibilityProps}- onRootClose={onRootClose}- title={"Who can comment"}- >- <Stack sx={{ py: "20px", px: "8px" }}>- <RowButtonGroup>- {commentPermissionOptions.map(- ({ value, label }, index) => (- <React.Fragment key={value}>- <RowButton- fontWeight="regular"- onClick={handleCommentPermissionChange(- value,- )}- label={label}- disabled={loadingPermission !== null}- endIcon={- loadingPermission === value ? (- <RowButtonEndActivityIndicator />- ) : commentPermission === value &&- !loadingPermission ? (- <DoneIcon />- ) : undefined- }- />- {index !=- commentPermissionOptions.length - 1 && (- <RowButtonDivider />- )}- </React.Fragment>- ),- )}- </RowButtonGroup>- {selectedOption && (- <RowButtonGroupHint>- {selectedOption.description}- </RowButtonGroupHint>- )}- </Stack>- </TitledNestedSidebarDrawer>- </>- );-};-interface ManageLayoutProps {onRootClose: () => void;collection: Collection;diff --git a/web/apps/photos/src/components/FileListWithViewer.tsx b/web/apps/photos/src/components/FileListWithViewer.tsxindex 596cd8546e..de525a99b9 100644--- a/web/apps/photos/src/components/FileListWithViewer.tsx+++ b/web/apps/photos/src/components/FileListWithViewer.tsx@@ -128,6 +128,7 @@ export type FileListWithViewerProps = {| "publicAlbumsCredentials"| "collectionKey"| "onJoinAlbum"+ | "enableComment">;/**@@ -182,6 +183,7 @@ export const FileListWithViewer: React.FC<FileListWithViewerProps> = ({publicAlbumsCredentials,collectionKey,onJoinAlbum,+ enableComment,}) => {const [openFileViewer, setOpenFileViewer] = useState(false);const [currentIndex, setCurrentIndex] = useState(0);@@ -381,6 +383,7 @@ export const FileListWithViewer: React.FC<FileListWithViewerProps> = ({publicAlbumsCredentials,collectionKey,onJoinAlbum,+ enableComment,}}onTriggerRemotePull={handleTriggerRemotePull}onDownload={handleDownload}diff --git a/web/apps/photos/src/components/TripLayout/index.tsx b/web/apps/photos/src/components/TripLayout/index.tsxindex 48ad1b0e17..0efaab2896 100644--- a/web/apps/photos/src/components/TripLayout/index.tsx+++ b/web/apps/photos/src/components/TripLayout/index.tsx@@ -51,6 +51,11 @@ interface TripLayoutProps {accessToken?: string;collectionKey?: string;credentials?: React.RefObject<PublicAlbumsCredentials | undefined>;+ /**+ * `true` if comments/reactions are enabled on the public link.+ * When `false`, the feed button will be hidden.+ */+ enableComment?: boolean;}export const TripLayout: React.FC<TripLayoutProps> = ({@@ -65,6 +70,7 @@ export const TripLayout: React.FC<TripLayoutProps> = ({accessToken,collectionKey,credentials,+ enableComment = true,}) => {// Extract collection info if availableconst collectionTitle = collection?.name || albumTitle || "Trip";@@ -337,7 +343,7 @@ export const TripLayout: React.FC<TripLayoutProps> = ({onAddPhotos={onAddPhotos}downloadAllFiles={downloadAllFiles}enableDownload={enableDownload}- onShowFeed={showPublicFeed}+ onShowFeed={enableComment ? showPublicFeed : undefined}collectionTitle={collectionTitle}publicCollection={collection}accessToken={accessToken}@@ -349,7 +355,7 @@ export const TripLayout: React.FC<TripLayoutProps> = ({onAddPhotos={onAddPhotos}downloadAllFiles={downloadAllFiles}enableDownload={enableDownload}- onShowFeed={showPublicFeed}+ onShowFeed={enableComment ? showPublicFeed : undefined}publicCollection={collection}accessToken={accessToken}collectionKey={collectionKey}diff --git a/web/apps/photos/src/pages/shared-albums.tsx b/web/apps/photos/src/pages/shared-albums.tsxindex af03205965..6ddbc0a353 100644--- a/web/apps/photos/src/pages/shared-albums.tsx+++ b/web/apps/photos/src/pages/shared-albums.tsx@@ -490,6 +490,9 @@ export default function PublicCollectionGallery() {setUploadTypeSelectorView(false);};+ const commentsEnabled =+ publicCollection?.publicURLs[0]?.enableComment ?? false;+const fileListHeader = useMemo<FileListHeaderOrFooter | undefined>(() =>publicCollection && publicFiles@@ -501,7 +504,9 @@ export default function PublicCollectionGallery() {publicFiles,downloadEnabled,onAddSaveGroup,- onShowFeed: showPublicFeed,+ onShowFeed: commentsEnabled+ ? showPublicFeed+ : undefined,}}/>),@@ -514,6 +519,7 @@ export default function PublicCollectionGallery() {publicFiles,downloadEnabled,showPublicFeed,+ commentsEnabled,],);@@ -581,6 +587,7 @@ export default function PublicCollectionGallery() {accessToken={credentials.current.accessToken}collectionKey={collectionKey.current}credentials={credentials}+ enableComment={commentsEnabled}/>) : (<>@@ -646,6 +653,7 @@ export default function PublicCollectionGallery() {publicAlbumsCredentials={credentials.current}collectionKey={collectionKey.current}onJoinAlbum={handleJoinAlbum}+ enableComment={commentsEnabled}pendingFileIndex={pendingFileNavigation?.fileIndex}pendingFileSidebar={pendingFileNavigation?.sidebar}pendingHighlightCommentID={diff --git a/web/packages/base/locales/en-US/translation.json b/web/packages/base/locales/en-US/translation.jsonindex 92c1f4900b..337c6f13b7 100644--- a/web/packages/base/locales/en-US/translation.json+++ b/web/packages/base/locales/en-US/translation.json@@ -444,6 +444,7 @@"allow_downloads": "Allow downloads","allow_adding_photos": "Allow adding photos","allow_adding_photos_hint": "Allow people with the link to also add photos to the shared album.",+ "enable_comments": "Comments and reactions","device_limit": "Device limit","none": "None","link_expiry": "Link expiry",diff --git a/web/packages/gallery/components/viewer/FileViewer.tsx b/web/packages/gallery/components/viewer/FileViewer.tsxindex 252fed8a2e..733e1ffa38 100644--- a/web/packages/gallery/components/viewer/FileViewer.tsx+++ b/web/packages/gallery/components/viewer/FileViewer.tsx@@ -346,6 +346,13 @@ export type FileViewerProps = ModalVisibilityProps & {* Should trigger the join album flow (with mobile deep link fallback).*/onJoinAlbum?: () => void;+ /**+ * `true` if comments are enabled on the public link.+ *+ * When `false`, the comment button and comments sidebar will be hidden.+ * Defaults to `true`.+ */+ enableComment?: boolean;} & Pick<FileInfoProps,"collectionNameByID" | "onSelectCollection" | "onSelectPerson"@@ -388,6 +395,7 @@ export const FileViewer: React.FC<FileViewerProps> = ({publicAlbumsCredentials,collectionKey,onJoinAlbum,+ enableComment = true,}) => {const { onGenericError } = useBaseContext();@@ -2182,6 +2190,7 @@ export const FileViewer: React.FC<FileViewerProps> = ({initialIndex,haveUser,showSocialButtons,+ enableComment,showFullscreenButton,delegate: delegateRef.current!,onClose: () => {diff --git a/web/packages/gallery/components/viewer/photoswipe.ts b/web/packages/gallery/components/viewer/photoswipe.tsindex a28d036655..03ede8a8f2 100644--- a/web/packages/gallery/components/viewer/photoswipe.ts+++ b/web/packages/gallery/components/viewer/photoswipe.ts@@ -143,6 +143,13 @@ type FileViewerPhotoSwipeOptions = Pick<* (incoming or outgoing) or in a public album.*/showSocialButtons: boolean;+ /**+ * `true` if comments are enabled on the public link.+ *+ * When `false`, the comment button will be hidden even if+ * {@link showSocialButtons} is `true`.+ */+ enableComment: boolean;/*** Dynamic callbacks.*@@ -241,6 +248,7 @@ export class FileViewerPhotoSwipe {initialIndex,haveUser,showSocialButtons,+ enableComment,showFullscreenButton,delegate,onClose,@@ -1516,12 +1524,16 @@ export class FileViewerPhotoSwipe {// Show buttons if: static showSocialButtons is true// (public album) OR delegate says this file should// show buttons (file in shared collection).+ // For public albums (no logged-in user), also check+ // if comments are enabled on the public link.const af = currentAnnotatedFile();// Guard: af may be undefined during initial setup.if (!af) return;- const shouldShow =+ const baseShow =showSocialButtons ||delegate.shouldShowSocialButtons(af);+ // For public albums (!haveUser), also require enableComment+ const shouldShow = baseShow && (haveUser || enableComment);actionButtonsEl.style.display = shouldShow? "flex": "none";diff --git a/web/packages/media/collection.ts b/web/packages/media/collection.tsindex 5d8e3d05f8..0d2cff553f 100644--- a/web/packages/media/collection.ts+++ b/web/packages/media/collection.ts@@ -321,6 +321,10 @@ export interface PublicURL {* shared collection.*/enableCollect: boolean;+ /**+ * `true` if comments are enabled on this public link.+ */+ enableComment: boolean;/*** `true` if the link is password protected.*@@ -360,6 +364,7 @@ export const RemotePublicURL = z.looseObject({enableDownload: z.boolean().nullish().transform(nullishToFalse),enableJoin: z.boolean().nullish().transform(nullishToFalse),enableCollect: z.boolean().nullish().transform(nullishToFalse),+ enableComment: z.boolean().nullish().transform(nullishToFalse),passwordEnabled: z.boolean().nullish().transform(nullishToFalse),nonce: z.string().nullish().transform(nullToUndefined),memLimit: z.number().nullish().transform(nullToUndefined),diff --git a/web/packages/new/photos/services/collection.ts b/web/packages/new/photos/services/collection.tsindex b04601534f..85506a8262 100644--- a/web/packages/new/photos/services/collection.ts+++ b/web/packages/new/photos/services/collection.ts@@ -1435,7 +1435,7 @@ export const unshareCollection = async (collectionID: number, email: string) =>*/export type CreatePublicURLAttributes = Pick<Partial<PublicURL>,- "enableCollect" | "enableJoin" | "validTill" | "deviceLimit"+ "enableCollect" | "enableJoin" | "enableComment" | "validTill" | "deviceLimit">;/**@@ -1455,7 +1455,11 @@ export const createPublicURL = async (const res = await fetch(await apiURL("/collections/share-url"), {method: "POST",headers: await authenticatedRequestHeaders(),- body: JSON.stringify({ collectionID, ...attributes }),+ body: JSON.stringify({+ collectionID,+ enableComment: true,+ ...attributes,+ }),});ensureOk(res);return z.object({ result: RemotePublicURL }).parse(await res.json()).result;