Skip to content

armgit / ente

Public Imported from GitHub
0

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

Route quick-link header action directly to manage link

Anand Baburajan997198df7095
diff --git a/web/apps/photos/src/components/Collections/CollectionHeader.tsx b/web/apps/photos/src/components/Collections/CollectionHeader.tsx
index f4201daf6f..ec8c39a737 100644
--- a/web/apps/photos/src/components/Collections/CollectionHeader.tsx
+++ b/web/apps/photos/src/components/Collections/CollectionHeader.tsx
@@ -99,6 +99,7 @@ export interface CollectionHeaderProps
*/
onRemotePull: (opts?: RemotePullOpts) => Promise<void>;
onCollectionShare: () => void;
+ onCollectionManageLink: () => void;
onCollectionCast: () => void;
/**
* A function that can be used to create a UI notification to track the
@@ -155,6 +156,7 @@ const CollectionHeaderOptions: React.FC<CollectionHeaderProps> = ({
setActiveCollectionID,
onRemotePull,
onCollectionShare,
+ onCollectionManageLink,
onCollectionCast,
onAddSaveGroup,
isActiveCollectionDownloadInProgress,
@@ -754,10 +756,15 @@ const CollectionHeaderOptions: React.FC<CollectionHeaderProps> = ({
<Box sx={{ display: "inline-flex", gap: "16px" }}>
<QuickOptions
collectionSummary={collectionSummary}
+ isQuickLinkAlbum={!!isQuickLinkAlbum}
isDownloadInProgress={isActiveCollectionDownloadInProgress}
onEmptyTrashClick={confirmEmptyTrash}
onDownloadClick={downloadCollection}
- onShareClick={onCollectionShare}
+ onShareClick={
+ isQuickLinkAlbum
+ ? onCollectionManageLink
+ : onCollectionShare
+ }
onCleanUncategorizedClick={confirmCleanUncategorized}
/>
{validMenuOptions.length > 0 && (
@@ -812,6 +819,7 @@ interface OptionProps {
interface QuickOptionsProps {
collectionSummary: CollectionSummary;
+ isQuickLinkAlbum: boolean;
isDownloadInProgress: () => boolean;
onEmptyTrashClick: () => void;
onDownloadClick: () => void;
@@ -825,6 +833,7 @@ const QuickOptions: React.FC<QuickOptionsProps> = ({
onShareClick,
onCleanUncategorizedClick,
collectionSummary,
+ isQuickLinkAlbum,
isDownloadInProgress,
}) => (
<Stack direction="row" sx={{ alignItems: "center", gap: "16px" }}>
@@ -849,6 +858,7 @@ const QuickOptions: React.FC<QuickOptionsProps> = ({
{showShareQuickOption(collectionSummary) && (
<ShareQuickOption
collectionSummary={collectionSummary}
+ isQuickLinkAlbum={isQuickLinkAlbum}
onClick={onShareClick}
/>
)}
@@ -981,6 +991,7 @@ const showShareQuickOption = ({ type, attributes }: CollectionSummary) =>
interface ShareQuickOptionProps {
collectionSummary: CollectionSummary;
+ isQuickLinkAlbum: boolean;
onClick: () => void;
}
@@ -1018,17 +1029,20 @@ const SmallShareIcon: React.FC<React.SVGProps<SVGSVGElement>> = (props) => (
const ShareQuickOption: React.FC<ShareQuickOptionProps> = ({
collectionSummary: { attributes },
+ isQuickLinkAlbum,
onClick,
}) => (
<Tooltip
title={
- attributes.has("userFavorites")
- ? t("share_favorites")
- : attributes.has("sharedIncoming")
- ? t("sharing_details")
- : attributes.has("shared")
- ? t("modify_sharing")
- : t("share_album")
+ isQuickLinkAlbum
+ ? t("manage_link")
+ : attributes.has("userFavorites")
+ ? t("share_favorites")
+ : attributes.has("sharedIncoming")
+ ? t("sharing_details")
+ : attributes.has("shared")
+ ? t("modify_sharing")
+ : t("share_album")
}
>
<IconButton onClick={onClick}>
@@ -1041,7 +1055,7 @@ const ShareQuickOption: React.FC<ShareQuickOptionProps> = ({
justifyContent: "center",
}}
>
- <ShareIcon />
+ {isQuickLinkAlbum ? <LinkIcon /> : <ShareIcon />}
</Box>
</IconButton>
</Tooltip>
diff --git a/web/apps/photos/src/components/Collections/CollectionShare.tsx b/web/apps/photos/src/components/Collections/CollectionShare.tsx
index 8704b2a5e2..463bf0b9b3 100644
--- a/web/apps/photos/src/components/Collections/CollectionShare.tsx
+++ b/web/apps/photos/src/components/Collections/CollectionShare.tsx
@@ -109,8 +109,14 @@ export type CollectionShareProps = ModalVisibilityProps & {
* Called when an operation in the share menu requires a full remote pull.
*/
onRemotePull: (opts?: RemotePullOpts) => Promise<void>;
+ /**
+ * When set, opens a specific nested share view directly.
+ */
+ intent?: CollectionShareIntent;
};
+export type CollectionShareIntent = "manage-link";
+
export const CollectionShare: React.FC<CollectionShareProps> = ({
open,
onClose,
@@ -121,6 +127,7 @@ export const CollectionShare: React.FC<CollectionShareProps> = ({
shareSuggestionEmails,
setBlockingLoad,
onRemotePull,
+ intent,
}) => {
const { onGenericError } = useBaseContext();
const { showLoadingBar, hideLoadingBar } = usePhotosAppContext();
@@ -271,6 +278,7 @@ export const CollectionShare: React.FC<CollectionShareProps> = ({
onRootClose={onClose}
{...{ collection, setBlockingLoad, onRemotePull }}
canManage={isOwner}
+ openManageLink={intent == "manage-link"}
/>
) : null}
{isSharedIncoming ? (
@@ -1433,7 +1441,11 @@ const ManageParticipant: React.FC<ManageParticipantProps> = ({
);
};
-type PublicShareProps = { onRootClose: () => void; canManage: boolean } & Pick<
+type PublicShareProps = {
+ onRootClose: () => void;
+ canManage: boolean;
+ openManageLink: boolean;
+} & Pick<
CollectionShareProps,
"collection" | "setBlockingLoad" | "onRemotePull"
>;
@@ -1444,6 +1456,7 @@ const PublicShare: React.FC<PublicShareProps> = ({
setBlockingLoad,
onRemotePull,
canManage,
+ openManageLink,
}) => {
const { customDomain } = useSettingsSnapshot();
@@ -1490,6 +1503,7 @@ const PublicShare: React.FC<PublicShareProps> = ({
{publicURL && resolvedURL ? (
canManage ? (
<ManagePublicShare
+ openOnMount={openManageLink}
{...{
onRootClose,
collection,
@@ -1614,7 +1628,7 @@ type ManagePublicShareProps = { onRootClose: () => void } & Pick<
Pick<
CollectionShareProps,
"collection" | "setBlockingLoad" | "onRemotePull"
- >;
+ > & { openOnMount: boolean };
const ManagePublicShare: React.FC<ManagePublicShareProps> = ({
onRootClose,
@@ -1624,6 +1638,7 @@ const ManagePublicShare: React.FC<ManagePublicShareProps> = ({
resolvedURL,
setBlockingLoad,
onRemotePull,
+ openOnMount,
}) => {
const {
show: showManagePublicShare,
@@ -1632,6 +1647,15 @@ const ManagePublicShare: React.FC<ManagePublicShareProps> = ({
const [copied, handleCopyLink] = useClipboardCopy(resolvedURL);
+ useEffect(() => {
+ if (openOnMount) showManagePublicShare();
+ }, [openOnMount, showManagePublicShare]);
+
+ const handleManagePublicShareClose = useCallback(() => {
+ managePublicShareVisibilityProps.onClose();
+ if (openOnMount) onRootClose();
+ }, [managePublicShareVisibilityProps, openOnMount, onRootClose]);
+
return (
<>
<Stack>
@@ -1672,6 +1696,7 @@ const ManagePublicShare: React.FC<ManagePublicShareProps> = ({
</Stack>
<ManagePublicShareOptions
{...managePublicShareVisibilityProps}
+ onClose={handleManagePublicShareClose}
{...{
onRootClose,
collection,
diff --git a/web/apps/photos/src/components/Collections/GalleryBarAndListHeader.tsx b/web/apps/photos/src/components/Collections/GalleryBarAndListHeader.tsx
index b33551bbe8..ba0c9902ac 100644
--- a/web/apps/photos/src/components/Collections/GalleryBarAndListHeader.tsx
+++ b/web/apps/photos/src/components/Collections/GalleryBarAndListHeader.tsx
@@ -2,6 +2,7 @@
import { AllAlbums } from "components/Collections/AllAlbums";
import {
CollectionShare,
+ type CollectionShareIntent,
type CollectionShareProps,
} from "components/Collections/CollectionShare";
import type { FileListHeaderOrFooter } from "components/FileList";
@@ -125,6 +126,23 @@ export const GalleryBarAndListHeader: React.FC<
useModalVisibility();
const { show: showCollectionCast, props: collectionCastVisibilityProps } =
useModalVisibility();
+ const [collectionShareIntent, setCollectionShareIntent] =
+ useState<CollectionShareIntent>();
+
+ const openCollectionShare = useCallback(() => {
+ setCollectionShareIntent(undefined);
+ showCollectionShare();
+ }, [showCollectionShare]);
+
+ const openCollectionManageLink = useCallback(() => {
+ setCollectionShareIntent("manage-link");
+ showCollectionShare();
+ }, [showCollectionShare]);
+
+ const closeCollectionShare = useCallback(() => {
+ setCollectionShareIntent(undefined);
+ collectionShareVisibilityProps.onClose();
+ }, [collectionShareVisibilityProps]);
const [collectionsSortBy, setCollectionsSortBy] =
useCollectionsSortByLocalState("updation-time-desc");
@@ -186,7 +204,8 @@ export const GalleryBarAndListHeader: React.FC<
onSelectPerson,
}}
collectionSummary={collectionSummary}
- onCollectionShare={showCollectionShare}
+ onCollectionShare={openCollectionShare}
+ onCollectionManageLink={openCollectionManageLink}
onCollectionCast={showCollectionCast}
/>
) : mode != "people" && collectionSummary ? (
@@ -216,6 +235,8 @@ export const GalleryBarAndListHeader: React.FC<
isActiveCollectionDownloadInProgress,
activePerson,
showCollectionShare,
+ openCollectionShare,
+ openCollectionManageLink,
showCollectionCast,
onRemotePull,
onAddSaveGroup,
@@ -271,10 +292,12 @@ export const GalleryBarAndListHeader: React.FC<
<>
<CollectionShare
{...collectionShareVisibilityProps}
+ onClose={closeCollectionShare}
collectionSummary={
toShowCollectionSummaries.get(activeCollectionID!)!
}
collection={activeCollection}
+ intent={collectionShareIntent}
{...{
user,
emailByUserID,