Skip to content

armgit / ente

Public Imported from GitHub
0

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

[web][photos] Show subscription plans inline in settings

Aswin Asok954a649c1676
diff --git a/web/apps/photos/src/components/PlanSelector.tsx b/web/apps/photos/src/components/PlanSelector.tsx
index cd7393150d..f1e768e4c1 100644
--- a/web/apps/photos/src/components/PlanSelector.tsx
+++ b/web/apps/photos/src/components/PlanSelector.tsx
@@ -22,6 +22,8 @@ import { SpacedRow } from "ente-base/components/containers";
import type { ButtonishProps } from "ente-base/components/mui";
import { DialogCloseIconButton } from "ente-base/components/mui/DialogCloseIconButton";
import { FocusVisibleButton } from "ente-base/components/mui/FocusVisibleButton";
+import { SidebarDrawer } from "ente-base/components/mui/SidebarDrawer";
+import { SidebarPanelContext } from "ente-base/components/mui/SidebarDrawerContext";
import {
errorDialogAttributes,
genericRetriableErrorDialogAttributes,
@@ -54,7 +56,7 @@ import {
userDetailsAddOnBonuses,
} from "ente-new/photos/services/user-details";
import { t } from "i18next";
-import React, { useCallback, useEffect, useState } from "react";
+import React, { useCallback, useContext, useEffect, useState } from "react";
import { Trans } from "react-i18next";
type PlanSelectorProps = ModalVisibilityProps & {
@@ -69,11 +71,24 @@ export const PlanSelector: React.FC<PlanSelectorProps> = ({
onManageFamily,
}) => {
const fullScreen = useMediaQuery(useTheme().breakpoints.down("sm"));
+ const sidebarPanel = useContext(SidebarPanelContext);
if (!open) {
return <></>;
}
+ if (sidebarPanel) {
+ return (
+ <SidebarDrawer {...{ open, onClose }} transitionDuration={0}>
+ <Box sx={{ maxWidth: 420, mx: "auto", py: 1 }}>
+ <PlanSelectorContents
+ {...{ onClose, setLoading, onManageFamily }}
+ />
+ </Box>
+ </SidebarDrawer>
+ );
+ }
+
return (
<Dialog
{...{ open, onClose, fullScreen }}
@@ -107,6 +122,7 @@ export const PlanSelectorContents: React.FC<PlanSelectorContentsProps> = ({
onBeginCheckout,
}) => {
const { showMiniDialog } = useBaseContext();
+ const showCloseButton = !useContext(SidebarPanelContext);
const userDetails = useUserDetailsSnapshot();
@@ -220,6 +236,7 @@ export const PlanSelectorContents: React.FC<PlanSelectorContentsProps> = ({
const commonCardData = {
onClose,
+ showCloseButton,
onManageFamily,
addOnBonuses,
planPeriod,
@@ -283,6 +300,7 @@ type FreeSubscriptionPlanSelectorCardProps = Pick<
PlanSelectorProps,
"onClose" | "onManageFamily"
> & {
+ showCloseButton: boolean;
subscription: Subscription | undefined;
addOnBonuses: Bonus[];
planPeriod: PlanPeriod;
@@ -293,6 +311,7 @@ const FreeSubscriptionPlanSelectorCard: React.FC<
React.PropsWithChildren<FreeSubscriptionPlanSelectorCardProps>
> = ({
onClose,
+ showCloseButton,
onManageFamily,
subscription,
addOnBonuses,
@@ -303,9 +322,11 @@ const FreeSubscriptionPlanSelectorCard: React.FC<
<>
<SpacedRow sx={{ alignItems: "flex-start" }}>
<Typography variant="h3">{t("choose_plan")}</Typography>
- {subscription && !isSubscriptionFree(subscription) && (
- <DialogCloseIconButton {...{ onClose }} />
- )}
+ {showCloseButton &&
+ subscription &&
+ !isSubscriptionFree(subscription) && (
+ <DialogCloseIconButton {...{ onClose }} />
+ )}
</SpacedRow>
<Stack sx={{ gap: 3 }}>
<Box>
@@ -345,6 +366,7 @@ const PaidSubscriptionPlanSelectorCard: React.FC<
React.PropsWithChildren<PaidSubscriptionPlanSelectorCardProps>
> = ({
onClose,
+ showCloseButton,
onManageFamily,
subscription,
addOnBonuses,
@@ -368,9 +390,11 @@ const PaidSubscriptionPlanSelectorCard: React.FC<
{t("storage_unit.gb")}
</Typography>
</Box>
- <IconButton onClick={onClose} color="secondary">
- <CloseIcon />
- </IconButton>
+ {showCloseButton && (
+ <IconButton onClick={onClose} color="secondary">
+ <CloseIcon />
+ </IconButton>
+ )}
</Stack>
<Typography