Skip to content

armgit / ente

Public Imported from GitHub
0

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

Move to the same file

Manav Rathiea0532d76aa5
diff --git a/web/apps/accounts/src/pages/_app.tsx b/web/apps/accounts/src/pages/_app.tsx
index a9a64937cc..2451b12329 100644
--- a/web/apps/accounts/src/pages/_app.tsx
+++ b/web/apps/accounts/src/pages/_app.tsx
@@ -6,8 +6,8 @@ import { setupI18n } from "@/base/i18n";
import { disableDiskLogs } from "@/base/log";
import { logUnhandledErrorsAndRejections } from "@/base/log-web";
import { Overlay } from "@ente/shared/components/Container";
+import type { DialogBoxAttributesV2 } from "@ente/shared/components/DialogBoxV2";
import DialogBoxV2 from "@ente/shared/components/DialogBoxV2";
-import type { DialogBoxAttributesV2 } from "@ente/shared/components/DialogBoxV2/types";
import { getTheme } from "@ente/shared/themes";
import { THEME_COLOR } from "@ente/shared/themes/constants";
import { CssBaseline } from "@mui/material";
diff --git a/web/apps/accounts/src/types/context.ts b/web/apps/accounts/src/types/context.ts
index edd0a18ddd..a6410ee57d 100644
--- a/web/apps/accounts/src/types/context.ts
+++ b/web/apps/accounts/src/types/context.ts
@@ -1,5 +1,5 @@
import { ensure } from "@/utils/ensure";
-import type { DialogBoxAttributesV2 } from "@ente/shared/components/DialogBoxV2/types";
+import type { DialogBoxAttributesV2 } from "@ente/shared/components/DialogBoxV2";
import { createContext, useContext } from "react";
/**
diff --git a/web/apps/auth/src/pages/_app.tsx b/web/apps/auth/src/pages/_app.tsx
index 8474047c72..dd8ad5f2f1 100644
--- a/web/apps/auth/src/pages/_app.tsx
+++ b/web/apps/auth/src/pages/_app.tsx
@@ -11,8 +11,8 @@ import {
} from "@/base/log-web";
import { ensure } from "@/utils/ensure";
import { Overlay } from "@ente/shared/components/Container";
+import type { DialogBoxAttributesV2 } from "@ente/shared/components/DialogBoxV2";
import DialogBoxV2 from "@ente/shared/components/DialogBoxV2";
-import type { DialogBoxAttributesV2 } from "@ente/shared/components/DialogBoxV2/types";
import { MessageContainer } from "@ente/shared/components/MessageContainer";
import { useLocalState } from "@ente/shared/hooks/useLocalState";
import HTTPService from "@ente/shared/network/HTTPService";
diff --git a/web/apps/photos/src/components/AuthenticateUserModal.tsx b/web/apps/photos/src/components/AuthenticateUserModal.tsx
index 53d3d8f1d7..c4de939371 100644
--- a/web/apps/photos/src/components/AuthenticateUserModal.tsx
+++ b/web/apps/photos/src/components/AuthenticateUserModal.tsx
@@ -1,8 +1,8 @@
import { checkSessionValidity } from "@/accounts/services/session";
import log from "@/base/log";
import { AppContext } from "@/new/photos/types/context";
+import type { DialogBoxAttributesV2 } from "@ente/shared/components/DialogBoxV2";
import DialogBoxV2 from "@ente/shared/components/DialogBoxV2";
-import type { DialogBoxAttributesV2 } from "@ente/shared/components/DialogBoxV2/types";
import VerifyMasterPasswordForm, {
type VerifyMasterPasswordFormProps,
} from "@ente/shared/components/VerifyMasterPasswordForm";
diff --git a/web/apps/photos/src/pages/_app.tsx b/web/apps/photos/src/pages/_app.tsx
index b50afc4340..3bdeb3ddd9 100644
--- a/web/apps/photos/src/pages/_app.tsx
+++ b/web/apps/photos/src/pages/_app.tsx
@@ -16,8 +16,8 @@ import { AppContext } from "@/new/photos/types/context";
import { Overlay } from "@ente/shared/components/Container";
import DialogBox from "@ente/shared/components/DialogBox";
import { DialogBoxAttributes } from "@ente/shared/components/DialogBox/types";
+import type { DialogBoxAttributesV2 } from "@ente/shared/components/DialogBoxV2";
import DialogBoxV2 from "@ente/shared/components/DialogBoxV2";
-import type { DialogBoxAttributesV2 } from "@ente/shared/components/DialogBoxV2/types";
import { MessageContainer } from "@ente/shared/components/MessageContainer";
import { useLocalState } from "@ente/shared/hooks/useLocalState";
import HTTPService from "@ente/shared/network/HTTPService";
diff --git a/web/packages/accounts/pages/two-factor/recover.tsx b/web/packages/accounts/pages/two-factor/recover.tsx
index ab7492e443..fe681f3824 100644
--- a/web/packages/accounts/pages/two-factor/recover.tsx
+++ b/web/packages/accounts/pages/two-factor/recover.tsx
@@ -10,7 +10,7 @@ import type { B64EncryptionResult } from "@/base/crypto/libsodium";
import log from "@/base/log";
import { ensure } from "@/utils/ensure";
import { VerticallyCentered } from "@ente/shared/components/Container";
-import type { DialogBoxAttributesV2 } from "@ente/shared/components/DialogBoxV2/types";
+import type { DialogBoxAttributesV2 } from "@ente/shared/components/DialogBoxV2";
import FormPaper from "@ente/shared/components/Form/FormPaper";
import FormPaperFooter from "@ente/shared/components/Form/FormPaper/Footer";
import FormPaperTitle from "@ente/shared/components/Form/FormPaper/Title";
diff --git a/web/packages/accounts/types/context.ts b/web/packages/accounts/types/context.ts
index 92de7c7b74..deba96a681 100644
--- a/web/packages/accounts/types/context.ts
+++ b/web/packages/accounts/types/context.ts
@@ -1,4 +1,4 @@
-import type { DialogBoxAttributesV2 } from "@ente/shared/components/DialogBoxV2/types";
+import type { DialogBoxAttributesV2 } from "@ente/shared/components/DialogBoxV2";
/**
* Properties expected to be present in the AppContext types for pages that
diff --git a/web/packages/shared/components/DialogBoxV2/index.tsx b/web/packages/shared/components/DialogBoxV2.tsx
similarity index 66%
rename from web/packages/shared/components/DialogBoxV2/index.tsx
rename to web/packages/shared/components/DialogBoxV2.tsx
index ecec83f7a5..db091d3f8a 100644
--- a/web/packages/shared/components/DialogBoxV2/index.tsx
+++ b/web/packages/shared/components/DialogBoxV2.tsx
@@ -1,6 +1,7 @@
import { FocusVisibleButton } from "@/base/components/mui/FocusVisibleButton";
import { LoadingButton } from "@/base/components/mui/LoadingButton";
import { dialogCloseHandler } from "@ente/shared/components/DialogBox/TitleWithCloseButton";
+import type { ButtonProps } from "@mui/material";
import {
Box,
Dialog,
@@ -10,7 +11,81 @@ import {
} from "@mui/material";
import { t } from "i18next";
import React, { useState } from "react";
-import type { DialogBoxAttributesV2 } from "./types";
+
+/**
+ * Customize the properties of the dialog box.
+ *
+ * Our custom dialog box helpers are meant for small message boxes, usually
+ * meant to confirm some user action. If more customization is needed, it might
+ * be a better idea to reach out for a bespoke MUI {@link DialogBox} instead.
+ */
+export interface DialogBoxAttributesV2 {
+ icon?: React.ReactNode;
+ /**
+ * The dialog's title
+ *
+ * Usually this will be a string, but it can be any {@link ReactNode}. Note
+ * that it always gets wrapped in a Typography element to set the font
+ * style, so if your ReactNode wants to do its own thing, it'll need to
+ * reset or override these customizations.
+ */
+ title?: React.ReactNode;
+ staticBackdrop?: boolean;
+ nonClosable?: boolean;
+ /**
+ * The dialog's content.
+ */
+ content?: React.ReactNode;
+ /**
+ * Customize the cancel (dismiss) action button offered by the dialog box.
+ *
+ * Usually dialog boxes should have a cancel action, but this can be skipped
+ * to only show one of the other types of buttons.
+ */
+ close?: {
+ /** The string to use as the label for the cancel button. */
+ text?: string;
+ /** The color of the button. */
+ variant?: ButtonProps["color"];
+ /**
+ * The function to call when the user cancels.
+ *
+ * If provided, this callback is invoked before closing the dialog.
+ */
+ action?: () => void;
+ };
+ /**
+ * Customize the primary action button offered by the dialog box.
+ */
+ proceed?: {
+ /** The string to use as the label for the primary action. */
+ text: string;
+ /**
+ * The function to call when the user presses the primary action button.
+ *
+ * It is passed a {@link setLoading} function that can be used to show
+ * or hide loading indicator or the primary action button.
+ */
+ action:
+ | (() => void | Promise<void>)
+ | ((setLoading: (value: boolean) => void) => void | Promise<void>);
+ variant?: ButtonProps["color"];
+ disabled?: boolean;
+ };
+ secondary?: {
+ text: string;
+ action: () => void;
+ variant?: ButtonProps["color"];
+ disabled?: boolean;
+ };
+ buttons?: {
+ text: string;
+ action: () => void;
+ variant: ButtonProps["color"];
+ disabled?: boolean;
+ }[];
+ buttonDirection?: "row" | "column";
+}
type IProps = React.PropsWithChildren<
Omit<DialogProps, "onClose"> & {
diff --git a/web/packages/shared/components/DialogBoxV2/types.ts b/web/packages/shared/components/DialogBoxV2/types.ts
deleted file mode 100644
index cb89cb48c2..0000000000
--- a/web/packages/shared/components/DialogBoxV2/types.ts
+++ /dev/null
@@ -1,76 +0,0 @@
-import type { ButtonProps } from "@mui/material";
-
-/**
- * Customize the properties of the dialog box.
- *
- * Our custom dialog box helpers are meant for small message boxes, usually
- * meant to confirm some user action. If more customization is needed, it might
- * be a better idea to reach out for a bespoke MUI {@link DialogBox} instead.
- */
-export interface DialogBoxAttributesV2 {
- icon?: React.ReactNode;
- /**
- * The dialog's title
- *
- * Usually this will be a string, but it can be any {@link ReactNode}. Note
- * that it always gets wrapped in a Typography element to set the font
- * style, so if your ReactNode wants to do its own thing, it'll need to
- * reset or override these customizations.
- */
- title?: React.ReactNode;
- staticBackdrop?: boolean;
- nonClosable?: boolean;
- /**
- * The dialog's content.
- */
- content?: React.ReactNode;
- /**
- * Customize the cancel (dismiss) action button offered by the dialog box.
- *
- * Usually dialog boxes should have a cancel action, but this can be skipped
- * to only show one of the other types of buttons.
- */
- close?: {
- /** The string to use as the label for the cancel button. */
- text?: string;
- /** The color of the button. */
- variant?: ButtonProps["color"];
- /**
- * The function to call when the user cancels.
- *
- * If provided, this callback is invoked before closing the dialog.
- */
- action?: () => void;
- };
- /**
- * Customize the primary action button offered by the dialog box.
- */
- proceed?: {
- /** The string to use as the label for the primary action. */
- text: string;
- /**
- * The function to call when the user presses the primary action button.
- *
- * It is passed a {@link setLoading} function that can be used to show
- * or hide loading indicator or the primary action button.
- */
- action:
- | (() => void | Promise<void>)
- | ((setLoading: (value: boolean) => void) => void | Promise<void>);
- variant?: ButtonProps["color"];
- disabled?: boolean;
- };
- secondary?: {
- text: string;
- action: () => void;
- variant?: ButtonProps["color"];
- disabled?: boolean;
- };
- buttons?: {
- text: string;
- action: () => void;
- variant: ButtonProps["color"];
- disabled?: boolean;
- }[];
- buttonDirection?: "row" | "column";
-}
diff --git a/web/packages/shared/components/ErrorComponents.tsx b/web/packages/shared/components/ErrorComponents.tsx
index fb564c9ba1..c53ab442ad 100644
--- a/web/packages/shared/components/ErrorComponents.tsx
+++ b/web/packages/shared/components/ErrorComponents.tsx
@@ -1,5 +1,5 @@
import { t } from "i18next";
-import type { DialogBoxAttributesV2 } from "./DialogBoxV2/types";
+import type { DialogBoxAttributesV2 } from "./DialogBoxV2";
/**
* {@link DialogBoxAttributesV2} for showing a generic error.
diff --git a/web/packages/shared/components/LoginComponents.tsx b/web/packages/shared/components/LoginComponents.tsx
index 528399fc98..8a859591f1 100644
--- a/web/packages/shared/components/LoginComponents.tsx
+++ b/web/packages/shared/components/LoginComponents.tsx
@@ -11,7 +11,7 @@ import { t } from "i18next";
import { useRouter } from "next/router";
import React, { useEffect, useState } from "react";
import { VerticallyCentered } from "./Container";
-import type { DialogBoxAttributesV2 } from "./DialogBoxV2/types";
+import type { DialogBoxAttributesV2 } from "./DialogBoxV2";
import { genericErrorAttributes } from "./ErrorComponents";
import FormPaper from "./Form/FormPaper";
import FormPaperFooter from "./Form/FormPaper/Footer";