Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Read changes

Neeraj Gupta3b8f40df1e6e
diff --git a/mobile/apps/photos/lib/services/collections_service.dart b/mobile/apps/photos/lib/services/collections_service.dart
index 811d924502..43ada6c5e7 100644
--- a/mobile/apps/photos/lib/services/collections_service.dart
+++ b/mobile/apps/photos/lib/services/collections_service.dart
@@ -829,9 +829,13 @@ class CollectionsService {
final PublicURL url = c.publicURLs.firstOrNull!;
Uri publicUrl = Uri.parse(url.url);
- // Replace with custom domain if configured
+ final int? currentUserID = Configuration.instance.getUserID();
+ final bool isOwner = currentUserID != null && currentUserID == c.owner.id;
final String customDomain = flagService.customDomain;
- if (customDomain.isNotEmpty) {
+ final bool applyCustomDomain = isOwner && customDomain.isNotEmpty;
+
+ // Replace with custom domain if configured for the owner
+ if (applyCustomDomain) {
publicUrl = publicUrl.replace(
host: customDomain,
scheme: "https",
@@ -849,7 +853,7 @@ class CollectionsService {
// Handle IDN domains - if the host was percent-encoded by Uri.replace,
// decode it for user-friendly display
- if (customDomain.isNotEmpty && publicUrl.host.contains('%')) {
+ if (applyCustomDomain && publicUrl.host.contains('%')) {
final decodedHost = Uri.decodeComponent(publicUrl.host);
finalUrl = finalUrl.replaceFirst(publicUrl.host, decodedHost);
}
diff --git a/mobile/apps/photos/lib/ui/sharing/share_collection_page.dart b/mobile/apps/photos/lib/ui/sharing/share_collection_page.dart
index f6bf42c180..b900546a61 100644
--- a/mobile/apps/photos/lib/ui/sharing/share_collection_page.dart
+++ b/mobile/apps/photos/lib/ui/sharing/share_collection_page.dart
@@ -2,13 +2,13 @@ import 'package:collection/collection.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
+import 'package:photos/core/configuration.dart';
import "package:photos/extensions/user_extension.dart";
import "package:photos/generated/l10n.dart";
import "package:photos/models/api/collection/user.dart";
import 'package:photos/models/collection/collection.dart';
import 'package:photos/service_locator.dart';
import 'package:photos/services/collections_service.dart';
-import 'package:photos/service_locator.dart';
import 'package:photos/theme/ente_theme.dart';
import 'package:photos/ui/actions/collection/collection_sharing_actions.dart';
import 'package:photos/ui/components/captioned_text_widget.dart';
@@ -64,9 +64,17 @@ class _ShareCollectionPageState extends State<ShareCollectionPage> {
@override
Widget build(BuildContext context) {
+ final int userID = Configuration.instance.getUserID() ?? -1;
_sharees = widget.collection.sharees;
final bool hasUrl = widget.collection.hasLink;
final bool adminRoleEnabled = flagService.enableAdminRole;
+ final CollectionParticipantRole role = widget.collection.getRole(userID);
+ final bool isOwner = widget.collection.owner.id == userID;
+ final bool isAdmin = role == CollectionParticipantRole.admin;
+ final bool canManageParticipants = isOwner || (adminRoleEnabled && isAdmin);
+ final bool canShowReadOnlyLink =
+ hasUrl && !isOwner && flagService.internalUser;
+ final bool showPublicSection = isOwner || canShowReadOnlyLink;
final children = <Widget>[];
children.add(
MenuSectionTitle(
@@ -83,22 +91,57 @@ class _ShareCollectionPageState extends State<ShareCollectionPage> {
),
);
- if (adminRoleEnabled) {
+ if (canManageParticipants) {
+ if (adminRoleEnabled) {
+ children.add(
+ MenuItemWidget(
+ captionedTextWidget: const CaptionedTextWidget(
+ title: 'Add admin',
+ makeTextBold: true,
+ ),
+ leadingIcon: Icons.add,
+ menuItemColor: getEnteColorScheme(context).fillFaint,
+ isTopBorderRadiusRemoved: _sharees.isNotEmpty,
+ onTap: () async {
+ routeToPage(
+ context,
+ AddParticipantPage(
+ [widget.collection],
+ const [ActionTypesToShow.addAdmin],
+ ),
+ ).then(
+ (value) => {
+ if (mounted) {setState(() => {})},
+ },
+ );
+ },
+ ),
+ );
+ children.add(
+ DividerWidget(
+ dividerType: DividerType.menu,
+ bgColor: getEnteColorScheme(context).fillFaint,
+ ),
+ );
+ }
children.add(
MenuItemWidget(
- captionedTextWidget: const CaptionedTextWidget(
- title: 'Add admin',
+ captionedTextWidget: CaptionedTextWidget(
+ title: AppLocalizations.of(context).addCollaborator,
makeTextBold: true,
),
leadingIcon: Icons.add,
menuItemColor: getEnteColorScheme(context).fillFaint,
- isTopBorderRadiusRemoved: _sharees.isNotEmpty,
+ isTopBorderRadiusRemoved:
+ adminRoleEnabled ? true : _sharees.isNotEmpty,
+ isBottomBorderRadiusRemoved: false,
onTap: () async {
+ // ignore: unawaited_futures
routeToPage(
context,
AddParticipantPage(
[widget.collection],
- const [ActionTypesToShow.addAdmin],
+ const [ActionTypesToShow.addCollaborator],
),
).then(
(value) => {
@@ -114,260 +157,231 @@ class _ShareCollectionPageState extends State<ShareCollectionPage> {
bgColor: getEnteColorScheme(context).fillFaint,
),
);
- }
- children.add(
- MenuItemWidget(
- captionedTextWidget: CaptionedTextWidget(
- title: AppLocalizations.of(context).addCollaborator,
- makeTextBold: true,
- ),
- leadingIcon: Icons.add,
- menuItemColor: getEnteColorScheme(context).fillFaint,
- isTopBorderRadiusRemoved:
- adminRoleEnabled ? true : _sharees.isNotEmpty,
- isBottomBorderRadiusRemoved: false,
- onTap: () async {
- // ignore: unawaited_futures
- routeToPage(
- context,
- AddParticipantPage(
- [widget.collection],
- const [ActionTypesToShow.addCollaborator],
- ),
- ).then(
- (value) => {
- if (mounted) {setState(() => {})},
- },
- );
- },
- ),
- );
- children.add(
- DividerWidget(
- dividerType: DividerType.menu,
- bgColor: getEnteColorScheme(context).fillFaint,
- ),
- );
- children.add(
- MenuItemWidget(
- captionedTextWidget: CaptionedTextWidget(
- title: AppLocalizations.of(context).addViewer,
- makeTextBold: true,
- ),
- leadingIcon: Icons.add,
- menuItemColor: getEnteColorScheme(context).fillFaint,
- isTopBorderRadiusRemoved: true,
- isBottomBorderRadiusRemoved: true,
- onTap: () async {
- routeToPage(
- context,
- AddParticipantPage(
- [widget.collection],
- const [ActionTypesToShow.addViewer],
- ),
- ).then(
- (value) => {
- if (mounted) {setState(() => {})},
- },
- );
- },
- ),
- );
- if (_sharees.isEmpty && !hasUrl) {
children.add(
- MenuSectionDescriptionWidget(
- content: AppLocalizations.of(context).sharedAlbumSectionDescription,
+ MenuItemWidget(
+ captionedTextWidget: CaptionedTextWidget(
+ title: AppLocalizations.of(context).addViewer,
+ makeTextBold: true,
+ ),
+ leadingIcon: Icons.add,
+ menuItemColor: getEnteColorScheme(context).fillFaint,
+ isTopBorderRadiusRemoved: true,
+ isBottomBorderRadiusRemoved: true,
+ onTap: () async {
+ routeToPage(
+ context,
+ AddParticipantPage(
+ [widget.collection],
+ const [ActionTypesToShow.addViewer],
+ ),
+ ).then(
+ (value) => {
+ if (mounted) {setState(() => {})},
+ },
+ );
+ },
),
);
- }
-
- final bool hasExpired =
- widget.collection.publicURLs.firstOrNull?.isExpired ?? false;
- children.addAll([
- const SizedBox(
- height: 24,
- ),
- MenuSectionTitle(
- title: hasUrl
- ? AppLocalizations.of(context).publicLinkEnabled
- : AppLocalizations.of(context).shareALink,
- iconData: Icons.public,
- ),
- ]);
- if (hasUrl) {
- if (hasExpired) {
+ if (_sharees.isEmpty && !hasUrl) {
children.add(
- MenuItemWidget(
- captionedTextWidget: CaptionedTextWidget(
- title: AppLocalizations.of(context).linkHasExpired,
- textColor: getEnteColorScheme(context).warning500,
- ),
- leadingIcon: Icons.error_outline,
- leadingIconColor: getEnteColorScheme(context).warning500,
- menuItemColor: getEnteColorScheme(context).fillFaint,
- isBottomBorderRadiusRemoved: true,
+ MenuSectionDescriptionWidget(
+ content: AppLocalizations.of(context).sharedAlbumSectionDescription,
),
);
- } else {
- final String url =
- CollectionsService.instance.getPublicUrl(widget.collection);
- children.addAll(
- [
+ }
+ }
+
+ if (showPublicSection) {
+ final bool hasExpired =
+ widget.collection.publicURLs.firstOrNull?.isExpired ?? false;
+ children.addAll([
+ const SizedBox(
+ height: 24,
+ ),
+ MenuSectionTitle(
+ title: hasUrl
+ ? AppLocalizations.of(context).publicLinkEnabled
+ : AppLocalizations.of(context).shareALink,
+ iconData: Icons.public,
+ ),
+ ]);
+ if (hasUrl) {
+ if (hasExpired) {
+ children.add(
MenuItemWidget(
captionedTextWidget: CaptionedTextWidget(
- title: AppLocalizations.of(context).copyLink,
- makeTextBold: true,
+ title: AppLocalizations.of(context).linkHasExpired,
+ textColor: getEnteColorScheme(context).warning500,
),
- leadingIcon: Icons.copy,
+ leadingIcon: Icons.error_outline,
+ leadingIconColor: getEnteColorScheme(context).warning500,
menuItemColor: getEnteColorScheme(context).fillFaint,
- showOnlyLoadingState: true,
- onTap: () async {
- await Clipboard.setData(ClipboardData(text: url));
- showShortToast(
- context,
- AppLocalizations.of(context).linkCopiedToClipboard,
- );
- },
isBottomBorderRadiusRemoved: true,
),
- DividerWidget(
- dividerType: DividerType.menu,
- bgColor: getEnteColorScheme(context).fillFaint,
- ),
- MenuItemWidget(
- key: sendLinkButtonKey,
- captionedTextWidget: CaptionedTextWidget(
- title: AppLocalizations.of(context).sendLink,
- makeTextBold: true,
+ );
+ } else {
+ final String url =
+ CollectionsService.instance.getPublicUrl(widget.collection);
+ children.addAll(
+ [
+ MenuItemWidget(
+ captionedTextWidget: CaptionedTextWidget(
+ title: AppLocalizations.of(context).copyLink,
+ makeTextBold: true,
+ ),
+ leadingIcon: Icons.copy,
+ menuItemColor: getEnteColorScheme(context).fillFaint,
+ showOnlyLoadingState: true,
+ onTap: () async {
+ await Clipboard.setData(ClipboardData(text: url));
+ showShortToast(
+ context,
+ AppLocalizations.of(context).linkCopiedToClipboard,
+ );
+ },
+ isBottomBorderRadiusRemoved: true,
),
- leadingIcon: Icons.adaptive.share,
- menuItemColor: getEnteColorScheme(context).fillFaint,
- onTap: () async {
- // ignore: unawaited_futures
- await shareAlbumLinkWithPlaceholder(
- context,
- widget.collection,
- url,
- sendLinkButtonKey,
- );
- },
- isTopBorderRadiusRemoved: true,
- isBottomBorderRadiusRemoved: true,
- ),
- DividerWidget(
- dividerType: DividerType.menu,
- bgColor: getEnteColorScheme(context).fillFaint,
- ),
- MenuItemWidget(
- captionedTextWidget: CaptionedTextWidget(
- title: AppLocalizations.of(context).sendQrCode,
- makeTextBold: true,
+ DividerWidget(
+ dividerType: DividerType.menu,
+ bgColor: getEnteColorScheme(context).fillFaint,
),
- leadingIcon: Icons.qr_code_outlined,
- menuItemColor: getEnteColorScheme(context).fillFaint,
- onTap: () async {
- await showDialog<void>(
- context: context,
- builder: (BuildContext context) {
- return QrCodeDialogWidget(
- collection: widget.collection,
- );
- },
- );
- },
- isTopBorderRadiusRemoved: true,
- isBottomBorderRadiusRemoved: true,
- ),
- ],
- );
- }
+ MenuItemWidget(
+ key: sendLinkButtonKey,
+ captionedTextWidget: CaptionedTextWidget(
+ title: AppLocalizations.of(context).sendLink,
+ makeTextBold: true,
+ ),
+ leadingIcon: Icons.adaptive.share,
+ menuItemColor: getEnteColorScheme(context).fillFaint,
+ onTap: () async {
+ // ignore: unawaited_futures
+ await shareAlbumLinkWithPlaceholder(
+ context,
+ widget.collection,
+ url,
+ sendLinkButtonKey,
+ );
+ },
+ isTopBorderRadiusRemoved: true,
+ isBottomBorderRadiusRemoved: true,
+ ),
+ DividerWidget(
+ dividerType: DividerType.menu,
+ bgColor: getEnteColorScheme(context).fillFaint,
+ ),
+ MenuItemWidget(
+ captionedTextWidget: CaptionedTextWidget(
+ title: AppLocalizations.of(context).sendQrCode,
+ makeTextBold: true,
+ ),
+ leadingIcon: Icons.qr_code_outlined,
+ menuItemColor: getEnteColorScheme(context).fillFaint,
+ onTap: () async {
+ await showDialog<void>(
+ context: context,
+ builder: (BuildContext context) {
+ return QrCodeDialogWidget(
+ collection: widget.collection,
+ );
+ },
+ );
+ },
+ isTopBorderRadiusRemoved: true,
+ isBottomBorderRadiusRemoved: true,
+ ),
+ ],
+ );
+ }
- children.addAll(
- [
- DividerWidget(
- dividerType: DividerType.menu,
- bgColor: getEnteColorScheme(context).fillFaint,
- ),
+ if (isOwner) {
+ children.addAll(
+ [
+ DividerWidget(
+ dividerType: DividerType.menu,
+ bgColor: getEnteColorScheme(context).fillFaint,
+ ),
+ MenuItemWidget(
+ captionedTextWidget: CaptionedTextWidget(
+ title: AppLocalizations.of(context).manageLink,
+ makeTextBold: true,
+ ),
+ leadingIcon: Icons.link,
+ trailingIcon: Icons.navigate_next,
+ menuItemColor: getEnteColorScheme(context).fillFaint,
+ trailingIconIsMuted: true,
+ onTap: () async {
+ // ignore: unawaited_futures
+ routeToPage(
+ context,
+ ManageSharedLinkWidget(collection: widget.collection),
+ ).then(
+ (value) => {
+ if (mounted) {setState(() => {})},
+ },
+ );
+ },
+ isTopBorderRadiusRemoved: true,
+ ),
+ ],
+ );
+ }
+ } else if (isOwner) {
+ children.addAll([
MenuItemWidget(
captionedTextWidget: CaptionedTextWidget(
- title: AppLocalizations.of(context).manageLink,
+ title: AppLocalizations.of(context).createPublicLink,
makeTextBold: true,
),
leadingIcon: Icons.link,
- trailingIcon: Icons.navigate_next,
menuItemColor: getEnteColorScheme(context).fillFaint,
- trailingIconIsMuted: true,
+ showOnlyLoadingState: true,
onTap: () async {
- // ignore: unawaited_futures
- routeToPage(
- context,
- ManageSharedLinkWidget(collection: widget.collection),
- ).then(
- (value) => {
- if (mounted) {setState(() => {})},
- },
- );
+ final bool result =
+ await collectionActions.enableUrl(context, widget.collection);
+ if (result && mounted) {
+ setState(() => {});
+ }
},
- isTopBorderRadiusRemoved: true,
),
- ],
- );
- } else {
- children.addAll([
- MenuItemWidget(
- captionedTextWidget: CaptionedTextWidget(
- title: AppLocalizations.of(context).createPublicLink,
- makeTextBold: true,
+ _sharees.isEmpty
+ ? MenuSectionDescriptionWidget(
+ content: AppLocalizations.of(context).shareWithNonenteUsers,
+ )
+ : const SizedBox.shrink(),
+ const SizedBox(
+ height: 24,
),
- leadingIcon: Icons.link,
- menuItemColor: getEnteColorScheme(context).fillFaint,
- showOnlyLoadingState: true,
- onTap: () async {
- final bool result =
- await collectionActions.enableUrl(context, widget.collection);
- if (result && mounted) {
- setState(() => {});
- }
- },
- ),
- _sharees.isEmpty
- ? MenuSectionDescriptionWidget(
- content: AppLocalizations.of(context).shareWithNonenteUsers,
- )
- : const SizedBox.shrink(),
- const SizedBox(
- height: 24,
- ),
- MenuSectionTitle(
- title: AppLocalizations.of(context).collectPhotos,
- iconData: Icons.public,
- ),
- MenuItemWidget(
- captionedTextWidget: CaptionedTextWidget(
- title: AppLocalizations.of(context).createCollaborativeLink,
- makeTextBold: true,
+ MenuSectionTitle(
+ title: AppLocalizations.of(context).collectPhotos,
+ iconData: Icons.public,
),
- leadingIcon: Icons.people_alt_outlined,
- menuItemColor: getEnteColorScheme(context).fillFaint,
- showOnlyLoadingState: true,
- onTap: () async {
- final bool result = await collectionActions.enableUrl(
- context,
- widget.collection,
- enableCollect: true,
- );
- if (result && mounted) {
- setState(() => {});
- }
- },
- ),
- _sharees.isEmpty
- ? MenuSectionDescriptionWidget(
- content:
- AppLocalizations.of(context).collabLinkSectionDescription,
- )
- : const SizedBox.shrink(),
- ]);
+ MenuItemWidget(
+ captionedTextWidget: CaptionedTextWidget(
+ title: AppLocalizations.of(context).createCollaborativeLink,
+ makeTextBold: true,
+ ),
+ leadingIcon: Icons.people_alt_outlined,
+ menuItemColor: getEnteColorScheme(context).fillFaint,
+ showOnlyLoadingState: true,
+ onTap: () async {
+ final bool result = await collectionActions.enableUrl(
+ context,
+ widget.collection,
+ enableCollect: true,
+ );
+ if (result && mounted) {
+ setState(() => {});
+ }
+ },
+ ),
+ _sharees.isEmpty
+ ? MenuSectionDescriptionWidget(
+ content:
+ AppLocalizations.of(context).collabLinkSectionDescription,
+ )
+ : const SizedBox.shrink(),
+ ]);
+ }
}
return Scaffold(
diff --git a/mobile/apps/photos/lib/ui/viewer/gallery/gallery_app_bar_widget.dart b/mobile/apps/photos/lib/ui/viewer/gallery/gallery_app_bar_widget.dart
index 3c6178cb13..53f1926b7f 100644
--- a/mobile/apps/photos/lib/ui/viewer/gallery/gallery_app_bar_widget.dart
+++ b/mobile/apps/photos/lib/ui/viewer/gallery/gallery_app_bar_widget.dart
@@ -903,15 +903,31 @@ class _GalleryAppBarWidgetState extends State<GalleryAppBarWidget> {
"Cannot share collection of type $galleryType",
);
}
- if (Configuration.instance.getUserID() == widget.collection!.owner.id) {
+ final int? userID = Configuration.instance.getUserID();
+ final bool isOwner = userID == collection.owner.id;
+ final bool enableAdminRole = flagService.enableAdminRole;
+ final CollectionParticipantRole role = collection.getRole(userID ?? -1);
+ final bool isAdmin =
+ enableAdminRole && role == CollectionParticipantRole.admin;
+ final bool canManageParticipants = isOwner || isAdmin;
+ if (canManageParticipants) {
+ final bool shouldOpenManageLink =
+ isOwner && isQuickLink && collection.hasLink;
unawaited(
routeToPage(
context,
- (isQuickLink && (collection.hasLink))
+ shouldOpenManageLink
? ManageSharedLinkWidget(collection: collection)
: ShareCollectionPage(collection),
),
);
+ } else if (collection.hasLink) {
+ unawaited(
+ routeToPage(
+ context,
+ ShareCollectionPage(collection),
+ ),
+ );
} else {
unawaited(
routeToPage(
diff --git a/server/pkg/controller/collections/file_action.go b/server/pkg/controller/collections/file_action.go
index 5a85381374..b186f4a114 100644
--- a/server/pkg/controller/collections/file_action.go
+++ b/server/pkg/controller/collections/file_action.go
@@ -132,7 +132,7 @@ func (c *CollectionController) RemoveFilesV3(ctx *gin.Context, req ente.RemoveFi
if err != nil {
return stacktrace.Propagate(err, "failed to verify collection access")
}
- err = c.isRemoveAllowed(ctx, actorUserID, resp.Collection.Owner.ID, req.FileIDs)
+ err = c.isRemoveAllowed(ctx, actorUserID, resp.Collection.Owner.ID, resp.Role, req.FileIDs)
if err != nil {
return stacktrace.Propagate(err, "file removal check failed")
}
@@ -144,7 +144,7 @@ func (c *CollectionController) RemoveFilesV3(ctx *gin.Context, req ente.RemoveFi
}
// isRemoveAllowed verifies that given set of files can be removed from the collection or not
-func (c *CollectionController) isRemoveAllowed(ctx *gin.Context, actorUserID int64, collectionOwnerID int64, fileIDs []int64) error {
+func (c *CollectionController) isRemoveAllowed(ctx *gin.Context, actorUserID int64, collectionOwnerID int64, role *ente.CollectionParticipantRole, fileIDs []int64) error {
ownerToFilesMap, err := c.FileRepo.GetOwnerToFileIDsMap(ctx, fileIDs)
if err != nil {
return stacktrace.Propagate(err, "failed to get owner to fileIDs map")
@@ -154,15 +154,21 @@ func (c *CollectionController) isRemoveAllowed(ctx *gin.Context, actorUserID int
return ente.NewBadRequestWithMessage("can not remove files owned by album owner")
}
- if collectionOwnerID != actorUserID {
- // verify that user is only trying to remove files owned by them
- if len(ownerToFilesMap) > 1 {
- return stacktrace.Propagate(ente.ErrPermissionDenied, "can not remove files owned by others")
- }
- // verify that user is only trying to remove files owned by them
- if _, ok := ownerToFilesMap[actorUserID]; !ok {
- return stacktrace.Propagate(ente.ErrPermissionDenied, "can not remove files owned by others")
- }
+ if collectionOwnerID == actorUserID {
+ return nil
+ }
+
+ if role != nil && *role == ente.ADMIN {
+ return nil
+ }
+
+ // verify that user is only trying to remove files owned by them
+ if len(ownerToFilesMap) > 1 {
+ return stacktrace.Propagate(ente.ErrPermissionDenied, "can not remove files owned by others")
+ }
+ // verify that user is only trying to remove files owned by them
+ if _, ok := ownerToFilesMap[actorUserID]; !ok {
+ return stacktrace.Propagate(ente.ErrPermissionDenied, "can not remove files owned by others")
}
return nil
}
diff --git a/web/apps/photos/src/components/Collections/CollectionShare.tsx b/web/apps/photos/src/components/Collections/CollectionShare.tsx
index 8e8fa9d194..087354b2dc 100644
--- a/web/apps/photos/src/components/Collections/CollectionShare.tsx
+++ b/web/apps/photos/src/components/Collections/CollectionShare.tsx
@@ -155,6 +155,9 @@ export const CollectionShare: React.FC<CollectionShareProps> = ({
const canManageParticipants = isOwner || (isAdminRoleEnabled && isAdmin);
const isSharedIncoming = collectionSummary.type == "sharedIncoming";
const showEmailSection = !isSharedIncoming || canManageParticipants;
+ const hasPublicLink = collection.publicURLs.length > 0;
+ const showPublicShare =
+ isOwner || (isSharedIncoming && hasPublicLink && isAdminRoleEnabled);
return (
<SidebarDrawer anchor="right" {...{ open, onClose }}>
@@ -183,7 +186,7 @@ export const CollectionShare: React.FC<CollectionShareProps> = ({
}}
/>
) : null}
- {isOwner ? (
+ {showPublicShare ? (
<PublicShare
onRootClose={onClose}
{...{
@@ -191,6 +194,7 @@ export const CollectionShare: React.FC<CollectionShareProps> = ({
setBlockingLoad,
onRemotePull,
}}
+ canManage={isOwner}
/>
) : null}
{isSharedIncoming ? (
@@ -1385,7 +1389,7 @@ const ManageParticipant: React.FC<ManageParticipantProps> = ({
);
};
-type PublicShareProps = { onRootClose: () => void } & Pick<
+type PublicShareProps = { onRootClose: () => void; canManage: boolean } & Pick<
CollectionShareProps,
"collection" | "setBlockingLoad" | "onRemotePull"
>;
@@ -1395,6 +1399,7 @@ const PublicShare: React.FC<PublicShareProps> = ({
onRootClose,
setBlockingLoad,
onRemotePull,
+ canManage,
}) => {
const { customDomain } = useSettingsSnapshot();
@@ -1421,13 +1426,16 @@ const PublicShare: React.FC<PublicShareProps> = ({
collection.key,
).then((url) =>
setResolvedURL(
- substituteCustomDomainIfNeeded(url, customDomain),
+ substituteCustomDomainIfNeeded(
+ url,
+ canManage ? customDomain : undefined,
+ ),
),
);
} else {
setResolvedURL(undefined);
}
- }, [collection.key, publicURL, customDomain]);
+ }, [collection.key, publicURL, customDomain, canManage]);
const handleCopyLink = () => {
if (resolvedURL) void navigator.clipboard.writeText(resolvedURL);
@@ -1436,22 +1444,28 @@ const PublicShare: React.FC<PublicShareProps> = ({
return (
<>
{publicURL && resolvedURL ? (
- <ManagePublicShare
- {...{
- onRootClose,
- collection,
- publicURL,
- setPublicURL,
- resolvedURL,
- setBlockingLoad,
- onRemotePull,
- }}
- />
+ canManage ? (
+ <ManagePublicShare
+ {...{
+ onRootClose,
+ collection,
+ publicURL,
+ setPublicURL,
+ resolvedURL,
+ setBlockingLoad,
+ onRemotePull,
+ }}
+ />
+ ) : (
+ <ReadOnlyPublicShare resolvedURL={resolvedURL} />
+ )
) : (
- <EnablePublicShareOptions
- {...{ collection, onRemotePull, setPublicURL }}
- onLinkCreated={showPublicLinkCreated}
- />
+ canManage ? (
+ <EnablePublicShareOptions
+ {...{ collection, onRemotePull, setPublicURL }}
+ onLinkCreated={showPublicLinkCreated}
+ />
+ ) : null
)}
<PublicLinkCreated
{...publicLinkCreatedVisibilityProps}
@@ -1633,6 +1647,32 @@ const ManagePublicShare: React.FC<ManagePublicShareProps> = ({
const isLinkExpired = (validTill: number) =>
validTill > 0 && validTill < Date.now() * 1000;
+const ReadOnlyPublicShare: React.FC<{ resolvedURL: string }> = ({
+ resolvedURL,
+}) => {
+ const [copied, handleCopyLink] = useClipboardCopy(resolvedURL);
+ return (
+ <Stack>
+ <RowButtonGroupTitle icon={<PublicIcon />}>
+ {t("public_link_enabled")}
+ </RowButtonGroupTitle>
+ <RowButtonGroup>
+ <RowButton
+ startIcon={
+ copied ? (
+ <DoneIcon sx={{ color: "accent.main" }} />
+ ) : (
+ <ContentCopyIcon />
+ )
+ }
+ onClick={handleCopyLink}
+ label={t("copy_link")}
+ />
+ </RowButtonGroup>
+ </Stack>
+ );
+};
+
type ManagePublicShareOptionsProps = ModalVisibilityProps & {
onRootClose: () => void;
publicURL: PublicURL;
diff --git a/web/packages/new/photos/services/settings.ts b/web/packages/new/photos/services/settings.ts
index 2b71b32ce8..ef70ce1726 100644
--- a/web/packages/new/photos/services/settings.ts
+++ b/web/packages/new/photos/services/settings.ts
@@ -197,7 +197,7 @@ type FeatureFlags = z.infer<typeof FeatureFlags>;
const syncSettingsSnapshotWithLocalStorage = () => {
const flags = savedRemoteFeatureFlags();
const settings = createDefaultSettings();
- settings.isInternalUser = flags?.internalUser || isDevBuild;
+ settings.isInternalUser = flags?.internalUser || false;
settings.isAdminRoleEnabled =
(flags?.internalUser ?? false) || isDevBuild;
settings.mapEnabled = flags?.mapEnabled || false;