diff --git a/web/apps/photos/src/components/Sidebar.tsx b/web/apps/photos/src/components/Sidebar.tsx index b5fddbc168..fb471f3a25 100644 --- a/web/apps/photos/src/components/Sidebar.tsx +++ b/web/apps/photos/src/components/Sidebar.tsx @@ -109,7 +109,7 @@ import { useColorScheme, } from "@mui/material"; import Typography from "@mui/material/Typography"; -import DeleteAccountModal from "components/DeleteAccount"; +import { DeleteAccount } from "components/DeleteAccount"; import { WatchFolder } from "components/WatchFolder"; import { t } from "i18next"; import { useRouter } from "next/router"; @@ -144,6 +144,13 @@ type SidebarProps = ModalVisibilityProps & { * Called when the export dialog should be shown. */ onShowExport: () => void; + /** + * Called when the user should be authenticated again. + * + * This will be invoked before sensitive actions, and the action will only + * proceed if the promise returned by this function is fulfilled. + */ + onAuthenticateUser: () => Promise; }; export const Sidebar: React.FC = ({ @@ -152,6 +159,7 @@ export const Sidebar: React.FC = ({ collectionSummaries, onShowPlanSelector, onShowExport, + onAuthenticateUser, }) => ( @@ -161,7 +169,10 @@ export const Sidebar: React.FC = ({ onCloseSidebar={onClose} collectionSummaries={collectionSummaries} /> - + @@ -515,11 +526,13 @@ const ShortcutSection: React.FC = ({ ); }; -type UtilitySectionProps = SectionProps & Pick; +type UtilitySectionProps = SectionProps & + Pick; const UtilitySection: React.FC = ({ onCloseSidebar, onShowExport, + onAuthenticateUser, }) => { const { showMiniDialog } = useBaseContext(); const { watchFolderView, setWatchFolderView } = usePhotosAppContext(); @@ -589,7 +602,11 @@ const UtilitySection: React.FC = ({ onClose={handleCloseWatchFolder} /> )} - + { ); }; -const Account: React.FC = ({ +type AccountProps = NestedSidebarDrawerVisibilityProps & + Pick; +const Account: React.FC = ({ open, onClose, onRootClose, + onAuthenticateUser, }) => { const { showMiniDialog } = useBaseContext(); @@ -735,7 +755,10 @@ const Account: React.FC = ({ {...twoFactorVisibilityProps} onRootClose={onRootClose} /> - + ); }; diff --git a/web/apps/photos/src/pages/gallery.tsx b/web/apps/photos/src/pages/gallery.tsx index 04fd8e198c..3ac32c397e 100644 --- a/web/apps/photos/src/pages/gallery.tsx +++ b/web/apps/photos/src/pages/gallery.tsx @@ -217,6 +217,12 @@ const Page: React.FC = () => { setAuthenticateUserModalView(true); }; + const authenticateUser2 = () => + new Promise((resolve) => { + onAuthenticateCallback.current = resolve; + setAuthenticateUserModalView(true); + }); + const closeAuthenticateUserModal = () => setAuthenticateUserModalView(false); @@ -1001,6 +1007,7 @@ const Page: React.FC = () => { {...{ collectionSummaries }} onShowPlanSelector={showPlanSelector} onShowExport={showExport} + onAuthenticateUser={authenticateUser2} /> {!isInSearchMode &&