Skip to content

armgit / ente

Public Imported from GitHub
0

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

[web][photos] Move Export ownership into Sidebar

Aswin Asok6ba2aa057b70
diff --git a/web/apps/photos/src/components/sidebar/Sidebar.tsx b/web/apps/photos/src/components/sidebar/Sidebar.tsx
index 59b11548ef..4f7131208a 100644
--- a/web/apps/photos/src/components/sidebar/Sidebar.tsx
+++ b/web/apps/photos/src/components/sidebar/Sidebar.tsx
@@ -1,3 +1,4 @@
+import { Export } from "@/components/Export";
import { downloadAppDialogAttributes } from "@/components/utils/download";
import exportService from "@/services/export";
import { performSidebarAction as performSidebarRegistryAction } from "@/services/search/sidebar-search-registry";
@@ -88,7 +89,7 @@ type SidebarProps = ModalVisibilityProps & {
collectionSummaryID: number,
isHiddenCollectionSummary?: boolean,
) => Promise<void>;
- onShowExport: () => void;
+ collectionNameByID: Map<number, string>;
onAuthenticateUser: () => Promise<boolean>;
};
@@ -101,7 +102,7 @@ export const Sidebar: React.FC<SidebarProps> = ({
onActionHandled,
onShowPlanSelector,
onShowCollectionSummary,
- onShowExport,
+ collectionNameByID,
onAuthenticateUser,
}) => {
const { show: showHelp, props: helpVisibilityProps } = useModalVisibility();
@@ -113,6 +114,14 @@ export const Sidebar: React.FC<SidebarProps> = ({
useModalVisibility();
const { show: showFreeUpSpace, props: freeUpSpaceVisibilityProps } =
useModalVisibility();
+ const { show: showExport, props: exportVisibilityProps } =
+ useModalVisibility();
+ const { onClose: closeExport } = exportVisibilityProps;
+
+ useEffect(() => {
+ if (!open) closeExport();
+ }, [open, closeExport]);
+
const { watchFolderView, setWatchFolderView } = usePhotosAppContext();
const { showMiniDialog, logout } = useBaseContext();
@@ -157,12 +166,12 @@ export const Sidebar: React.FC<SidebarProps> = ({
void (async () => {
try {
if (!(await onAuthenticateUser())) return;
- onShowExport();
+ showExport();
} catch (error) {
log.error("Failed to authenticate before export", error);
}
})();
- }, [onAuthenticateUser, onShowExport, showMiniDialog]);
+ }, [onAuthenticateUser, showExport, showMiniDialog]);
const performSidebarAction = useCallback(
async (actionID: SidebarActionID) =>
@@ -230,55 +239,65 @@ export const Sidebar: React.FC<SidebarProps> = ({
}, [pendingAction]);
return (
- <RootSidebarDrawer open={open} onClose={onClose} maxWidth="440px">
- <HeaderSection onCloseSidebar={onClose} />
- <UserDetailsSection
- sidebarOpen={open}
- {...{ onShowPlanSelector }}
- />
- <Stack sx={{ gap: 0.5, mb: 3 }}>
- <ShortcutSection
- onCloseSidebar={onClose}
- {...{
- normalCollectionSummaries,
- uncategorizedCollectionSummaryID,
- onShowCollectionSummary,
- }}
- />
- <UtilitySection
- onCloseSidebar={onClose}
- {...{
- onShowExport: handleShowExport,
- onAuthenticateUser,
- onShowPlanSelector,
- showAccount,
- accountVisibilityProps,
- showReferrals,
- referralsVisibilityProps,
- showPreferences,
- preferencesVisibilityProps,
- showHelp,
- helpVisibilityProps,
- showFreeUpSpace,
- freeUpSpaceVisibilityProps,
- watchFolderView,
- onShowWatchFolder: handleOpenWatchFolder,
- onCloseWatchFolder: handleCloseWatchFolder,
- pendingAccountAction,
- onAccountActionHandled: setPendingAccountAction,
- pendingPreferencesAction,
- onPreferencesActionHandled: setPendingPreferencesAction,
- pendingHelpAction,
- onHelpActionHandled: setPendingHelpAction,
- pendingFreeUpSpaceAction,
- onFreeUpSpaceActionHandled: setPendingFreeUpSpaceAction,
- }}
+ <>
+ <RootSidebarDrawer open={open} onClose={onClose} maxWidth="440px">
+ <HeaderSection onCloseSidebar={onClose} />
+ <UserDetailsSection
+ sidebarOpen={open}
+ {...{ onShowPlanSelector }}
/>
- <Divider sx={{ my: "2px" }} />
- <ExitSection onLogout={handleLogout} />
- <InfoSection />
- </Stack>
- </RootSidebarDrawer>
+ <Stack sx={{ gap: 0.5, mb: 3 }}>
+ <ShortcutSection
+ onCloseSidebar={onClose}
+ {...{
+ normalCollectionSummaries,
+ uncategorizedCollectionSummaryID,
+ onShowCollectionSummary,
+ }}
+ />
+ <UtilitySection
+ onCloseSidebar={onClose}
+ {...{
+ onShowExport: handleShowExport,
+ onAuthenticateUser,
+ onShowPlanSelector,
+ showAccount,
+ accountVisibilityProps,
+ showReferrals,
+ referralsVisibilityProps,
+ showPreferences,
+ preferencesVisibilityProps,
+ showHelp,
+ helpVisibilityProps,
+ showFreeUpSpace,
+ freeUpSpaceVisibilityProps,
+ watchFolderView,
+ onShowWatchFolder: handleOpenWatchFolder,
+ onCloseWatchFolder: handleCloseWatchFolder,
+ pendingAccountAction,
+ onAccountActionHandled: setPendingAccountAction,
+ pendingPreferencesAction,
+ onPreferencesActionHandled:
+ setPendingPreferencesAction,
+ pendingHelpAction,
+ onHelpActionHandled: setPendingHelpAction,
+ pendingFreeUpSpaceAction,
+ onFreeUpSpaceActionHandled:
+ setPendingFreeUpSpaceAction,
+ }}
+ />
+ <Divider sx={{ my: "2px" }} />
+ <ExitSection onLogout={handleLogout} />
+ <InfoSection />
+ </Stack>
+ </RootSidebarDrawer>
+ <Export
+ {...exportVisibilityProps}
+ open={open && exportVisibilityProps.open}
+ collectionNameByID={collectionNameByID}
+ onRootClose={onClose}
+ />
+ </>
);
};
@@ -562,10 +581,8 @@ const ShortcutSection: React.FC<ShortcutSectionProps> = ({
};
type UtilitySectionProps = SectionProps &
- Pick<
- SidebarProps,
- "onShowExport" | "onAuthenticateUser" | "onShowPlanSelector"
- > & {
+ Pick<SidebarProps, "onAuthenticateUser" | "onShowPlanSelector"> & {
+ onShowExport: () => void;
showAccount: () => void;
accountVisibilityProps: ModalVisibilityProps;
showReferrals: () => void;
diff --git a/web/apps/photos/src/pages/gallery.tsx b/web/apps/photos/src/pages/gallery.tsx
index 39e5ea8c82..8713d69434 100644
--- a/web/apps/photos/src/pages/gallery.tsx
+++ b/web/apps/photos/src/pages/gallery.tsx
@@ -16,7 +16,6 @@ import {
} from "@/components/Collections/EditAlbumDetailsDialog";
import { GalleryBarAndListHeader } from "@/components/Collections/GalleryBarAndListHeader";
import { slideshowFiles } from "@/components/Collections/album-slideshow";
-import { Export } from "@/components/Export";
import { FamilyManagement } from "@/components/FamilyManagement";
import type { FileListHeaderOrFooter } from "@/components/FileList";
import { FileListWithViewer } from "@/components/FileListWithViewer";
@@ -287,8 +286,6 @@ const Page: React.FC = () => {
useModalVisibility();
const { show: showFixCreationTime, props: fixCreationTimeVisibilityProps } =
useModalVisibility();
- const { show: showExport, props: exportVisibilityProps } =
- useModalVisibility();
const {
show: showAuthenticateUser,
props: authenticateUserVisibilityProps,
@@ -740,7 +737,6 @@ const Page: React.FC = () => {
sidebarVisibilityProps.open ||
planSelectorVisibilityProps.open ||
fixCreationTimeVisibilityProps.open ||
- exportVisibilityProps.open ||
authenticateUserVisibilityProps.open ||
albumNameInputVisibilityProps.open ||
editAlbumDetailsVisibilityProps.open ||
@@ -2034,7 +2030,7 @@ const Page: React.FC = () => {
onActionHandled={handleSidebarActionHandled}
onShowPlanSelector={showPlanSelector}
onShowCollectionSummary={handleSidebarShowCollectionSummary}
- onShowExport={showExport}
+ collectionNameByID={collectionNameByID}
onAuthenticateUser={authenticateUser}
/>
<WhatsNew {...whatsNewVisibilityProps} />
@@ -2163,11 +2159,6 @@ const Page: React.FC = () => {
onSubmit={handleEditAlbumDetails}
/>
)}
- <Export
- {...exportVisibilityProps}
- {...{ collectionNameByID }}
- onRootClose={handleSidebarClose}
- />
<AuthenticateUser
open={authenticateUserVisibilityProps.open}
onClose={handleCloseAuthenticateUser}