Skip to content

armgit / ente

Public Imported from GitHub
0

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

Inline

Manav Rathic6bdd4bd8f56
diff --git a/web/apps/photos/src/components/Collections/CollectionShare/index.tsx b/web/apps/photos/src/components/Collections/CollectionShare/index.tsx
index 9b8915c697..2774fabc3c 100644
--- a/web/apps/photos/src/components/Collections/CollectionShare/index.tsx
+++ b/web/apps/photos/src/components/Collections/CollectionShare/index.tsx
@@ -24,6 +24,7 @@ import { formatDateTime } from "@ente/shared/time/format";
import AdminPanelSettingsIcon from "@mui/icons-material/AdminPanelSettings";
import ChevronRightIcon from "@mui/icons-material/ChevronRight";
import ContentCopyIcon from "@mui/icons-material/ContentCopyOutlined";
+import DownloadSharp from "@mui/icons-material/DownloadSharp";
import ErrorOutlineIcon from "@mui/icons-material/ErrorOutline";
import LinkIcon from "@mui/icons-material/Link";
import ModeEditIcon from "@mui/icons-material/ModeEdit";
@@ -34,9 +35,10 @@ import { Dialog, DialogProps, Stack, Typography } from "@mui/material";
import Avatar from "components/pages/gallery/Avatar";
import { t } from "i18next";
import { GalleryContext } from "pages/gallery";
-import { useContext, useEffect, useMemo, useState } from "react";
+import React, { useContext, useEffect, useMemo, useState } from "react";
import { Trans } from "react-i18next";
import {
+ createShareableURL,
deleteShareableURL,
updateShareableURL,
} from "services/collectionService";
@@ -48,7 +50,6 @@ import {
} from "utils/collection";
import { handleSharingErrors } from "utils/error/ui";
import EmailShare from "./emailShare";
-import EnablePublicShareOptions from "./publicShare/EnablePublicShareOptions";
interface CollectionShareProps {
open: boolean;
@@ -211,6 +212,91 @@ function SharingDetails({ collection, type }) {
);
}
+interface EnablePublicShareOptionsProps {
+ collection: Collection;
+ setPublicShareProp: (value: PublicURL) => void;
+ onLinkCreated: () => void;
+}
+
+const EnablePublicShareOptions: React.FC<EnablePublicShareOptionsProps> = ({
+ collection,
+ setPublicShareProp,
+ onLinkCreated,
+}) => {
+ const galleryContext = useContext(GalleryContext);
+ const [sharableLinkError, setSharableLinkError] = useState(null);
+
+ const createSharableURLHelper = async () => {
+ try {
+ setSharableLinkError(null);
+ galleryContext.setBlockingLoad(true);
+ const publicURL = await createShareableURL(collection);
+ setPublicShareProp(publicURL);
+ onLinkCreated();
+ galleryContext.syncWithRemote(false, true);
+ } catch (e) {
+ const errorMessage = handleSharingErrors(e);
+ setSharableLinkError(errorMessage);
+ } finally {
+ galleryContext.setBlockingLoad(false);
+ }
+ };
+
+ const createCollectPhotoShareableURLHelper = async () => {
+ try {
+ setSharableLinkError(null);
+ galleryContext.setBlockingLoad(true);
+ const publicURL = await createShareableURL(collection);
+ await updateShareableURL({
+ collectionID: collection.id,
+ enableCollect: true,
+ });
+ setPublicShareProp(publicURL);
+ onLinkCreated();
+ galleryContext.syncWithRemote(false, true);
+ } catch (e) {
+ const errorMessage = handleSharingErrors(e);
+ setSharableLinkError(errorMessage);
+ } finally {
+ galleryContext.setBlockingLoad(false);
+ }
+ };
+
+ return (
+ <Stack>
+ <MenuSectionTitle
+ title={t("LINK_SHARE_TITLE")}
+ icon={<PublicIcon />}
+ />
+ <MenuItemGroup>
+ <EnteMenuItem
+ label={t("CREATE_PUBLIC_SHARING")}
+ startIcon={<LinkIcon />}
+ onClick={createSharableURLHelper}
+ />
+ <MenuItemDivider hasIcon />
+ <EnteMenuItem
+ label={t("COLLECT_PHOTOS")}
+ startIcon={<DownloadSharp />}
+ onClick={createCollectPhotoShareableURLHelper}
+ />
+ </MenuItemGroup>
+ {sharableLinkError && (
+ <Typography
+ textAlign={"center"}
+ variant="small"
+ sx={{
+ color: (theme) => theme.colors.danger.A700,
+ mt: 0.5,
+ }}
+ >
+ {sharableLinkError}
+ </Typography>
+ )}
+ </Stack>
+ );
+};
+
interface PublicShareProps {
collection: Collection;
onRootClose: () => void;
@@ -776,7 +862,7 @@ interface ManageLinkPasswordProps {
updatePublicShareURLHelper: (req: UpdatePublicURL) => Promise<void>;
}
-export const ManageLinkPassword: React.FC<ManageLinkPasswordProps> = ({
+const ManageLinkPassword: React.FC<ManageLinkPasswordProps> = ({
collection,
publicShareProp,
updatePublicShareURLHelper,
diff --git a/web/apps/photos/src/components/Collections/CollectionShare/publicShare/EnablePublicShareOptions.tsx b/web/apps/photos/src/components/Collections/CollectionShare/publicShare/EnablePublicShareOptions.tsx
deleted file mode 100644
index 9c5f77c467..0000000000
--- a/web/apps/photos/src/components/Collections/CollectionShare/publicShare/EnablePublicShareOptions.tsx
+++ /dev/null
@@ -1,103 +0,0 @@
-import {
- MenuItemDivider,
- MenuItemGroup,
- MenuSectionTitle,
-} from "@/base/components/Menu";
-import type { Collection, PublicURL } from "@/media/collection";
-import { EnteMenuItem } from "@ente/shared/components/Menu/EnteMenuItem";
-import DownloadSharp from "@mui/icons-material/DownloadSharp";
-import LinkIcon from "@mui/icons-material/Link";
-import PublicIcon from "@mui/icons-material/Public";
-import { Stack, Typography } from "@mui/material";
-import { t } from "i18next";
-import { GalleryContext } from "pages/gallery";
-import { useContext, useState } from "react";
-import {
- createShareableURL,
- updateShareableURL,
-} from "services/collectionService";
-import { handleSharingErrors } from "utils/error/ui";
-interface Iprops {
- collection: Collection;
- setPublicShareProp: (value: PublicURL) => void;
- onLinkCreated: () => void;
-}
-
-export default function EnablePublicShareOptions({
- collection,
- setPublicShareProp,
- onLinkCreated,
-}: Iprops) {
- const galleryContext = useContext(GalleryContext);
- const [sharableLinkError, setSharableLinkError] = useState(null);
-
- const createSharableURLHelper = async () => {
- try {
- setSharableLinkError(null);
- galleryContext.setBlockingLoad(true);
- const publicURL = await createShareableURL(collection);
- setPublicShareProp(publicURL);
- onLinkCreated();
- galleryContext.syncWithRemote(false, true);
- } catch (e) {
- const errorMessage = handleSharingErrors(e);
- setSharableLinkError(errorMessage);
- } finally {
- galleryContext.setBlockingLoad(false);
- }
- };
-
- const createCollectPhotoShareableURLHelper = async () => {
- try {
- setSharableLinkError(null);
- galleryContext.setBlockingLoad(true);
- const publicURL = await createShareableURL(collection);
- await updateShareableURL({
- collectionID: collection.id,
- enableCollect: true,
- });
- setPublicShareProp(publicURL);
- onLinkCreated();
- galleryContext.syncWithRemote(false, true);
- } catch (e) {
- const errorMessage = handleSharingErrors(e);
- setSharableLinkError(errorMessage);
- } finally {
- galleryContext.setBlockingLoad(false);
- }
- };
-
- return (
- <Stack>
- <MenuSectionTitle
- title={t("LINK_SHARE_TITLE")}
- icon={<PublicIcon />}
- />
- <MenuItemGroup>
- <EnteMenuItem
- label={t("CREATE_PUBLIC_SHARING")}
- startIcon={<LinkIcon />}
- onClick={createSharableURLHelper}
- />
- <MenuItemDivider hasIcon />
- <EnteMenuItem
- label={t("COLLECT_PHOTOS")}
- startIcon={<DownloadSharp />}
- onClick={createCollectPhotoShareableURLHelper}
- />
- </MenuItemGroup>
- {sharableLinkError && (
- <Typography
- textAlign={"center"}
- variant="small"
- sx={{
- color: (theme) => theme.colors.danger.A700,
- mt: 0.5,
- }}
- >
- {sharableLinkError}
- </Typography>
- )}
- </Stack>
- );
-}
diff --git a/web/apps/photos/src/components/Collections/CollectionShare/publicShare/index.tsx b/web/apps/photos/src/components/Collections/CollectionShare/publicShare/index.tsx
deleted file mode 100644
index e69de29bb2..0000000000