Skip to content

armgit / ente

Public Imported from GitHub
0

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

Remove unused

Manav Rathi60987c268f03
diff --git a/web/packages/shared/components/DialogBox/DialogIcon.tsx b/web/packages/shared/components/DialogBox/DialogIcon.tsx
deleted file mode 100644
index 006b7cfeb2..0000000000
--- a/web/packages/shared/components/DialogBox/DialogIcon.tsx
+++ /dev/null
@@ -1,19 +0,0 @@
-import { Box } from "@mui/material";
-import React from "react";
-
-export default function DialogIcon({ icon }: { icon: React.ReactNode }) {
- return (
- <Box
- className="DialogIcon"
- sx={{
- svg: {
- width: "48px",
- height: "48px",
- },
- color: "stroke.muted",
- }}
- >
- {icon}
- </Box>
- );
-}
diff --git a/web/packages/shared/components/DialogBox/base.tsx b/web/packages/shared/components/DialogBox/base.tsx
deleted file mode 100644
index 86495da5e9..0000000000
--- a/web/packages/shared/components/DialogBox/base.tsx
+++ /dev/null
@@ -1,40 +0,0 @@
-import { Dialog, styled } from "@mui/material";
-
-const DialogBoxBase = styled(Dialog)(({ theme }) => ({
- "& .MuiDialog-paper": {
- padding: theme.spacing(1, 1.5),
- maxWidth: "346px",
- },
-
- "& .DialogIcon": {
- padding: theme.spacing(2),
- paddingBottom: theme.spacing(1),
- },
-
- "& .MuiDialogTitle-root": {
- padding: theme.spacing(2),
- paddingBottom: theme.spacing(1),
- },
- "& .MuiDialogContent-root": {
- padding: theme.spacing(2),
- },
-
- ".DialogIcon + .MuiDialogTitle-root": {
- paddingTop: 0,
- },
-
- ".MuiDialogTitle-root + .MuiDialogContent-root": {
- paddingTop: 0,
- },
- ".MuiDialogTitle-root + .MuiDialogActions-root": {
- paddingTop: theme.spacing(3),
- },
- "& .MuiDialogActions-root": {
- flexWrap: "wrap-reverse",
- },
- "& .MuiButton-root": {
- margin: `${theme.spacing(0.5, 0)} !important`,
- },
-}));
-
-export default DialogBoxBase;
diff --git a/web/packages/shared/components/DialogBox/index.tsx b/web/packages/shared/components/DialogBox/index.tsx
deleted file mode 100644
index 5393e1112d..0000000000
--- a/web/packages/shared/components/DialogBox/index.tsx
+++ /dev/null
@@ -1,143 +0,0 @@
-import { FocusVisibleButton } from "@/base/components/mui/FocusVisibleButton";
-import {
- Breakpoint,
- DialogActions,
- DialogContent,
- DialogProps,
- Typography,
- type ButtonBaseActions,
-} from "@mui/material";
-import { t } from "i18next";
-import React, { useRef } from "react";
-import DialogIcon from "./DialogIcon";
-import DialogTitleWithCloseButton, {
- dialogCloseHandler,
-} from "./TitleWithCloseButton";
-import DialogBoxBase from "./base";
-import { DialogBoxAttributes } from "./types";
-
-type IProps = React.PropsWithChildren<
- Omit<DialogProps, "onClose" | "maxSize"> & {
- onClose: () => void;
- attributes: DialogBoxAttributes;
- size?: Breakpoint;
- titleCloseButton?: boolean;
- }
->;
-
-export default function DialogBox({
- attributes,
- children,
- open,
- size,
- onClose,
- titleCloseButton,
- ...props
-}: IProps) {
- // Sometimes we wish to autoFocus on the primary action button in the dialog
- // (e.g. in the delete confirmation) so that the user can use their keyboard
- // to quickly select it.
- //
- // To allow this, MUI buttons provide an `autoFocus` prop. However, while
- // the button does get auto focused, it doesn't show the visual
- // focus-visible state until the user does an keyboard action.
- //
- // Below is the current best workaround to get the focused button to also
- // show the focus-visible state. It uses the onEnter callback of the
- // transition to focus on the ref to the auto focused button (if any).
- //
- // https://github.com/mui/material-ui/issues/8438
- const proceedButtonRef = useRef<ButtonBaseActions | null>(null);
-
- if (!attributes) {
- return <></>;
- }
-
- const handleClose = dialogCloseHandler({
- staticBackdrop: attributes.staticBackdrop,
- nonClosable: attributes.nonClosable,
- onClose: onClose,
- });
-
- const handleDialogEnter = () => {
- if (attributes.proceed?.autoFocus)
- proceedButtonRef?.current.focusVisible();
- };
-
- return (
- <DialogBoxBase
- open={open}
- maxWidth={size}
- onClose={handleClose}
- TransitionProps={{ onEnter: handleDialogEnter }}
- {...props}
- >
- {attributes.icon && <DialogIcon icon={attributes.icon} />}
- {attributes.title && (
- <DialogTitleWithCloseButton
- onClose={
- titleCloseButton && !attributes.nonClosable && onClose
- }
- >
- {attributes.title}
- </DialogTitleWithCloseButton>
- )}
- {(children || attributes?.content) && (
- <DialogContent>
- {children || (
- <Typography color="text.muted">
- {attributes.content}
- </Typography>
- )}
- </DialogContent>
- )}
- {(attributes.close || attributes.proceed) && (
- <DialogActions>
- <>
- {attributes.close && (
- <FocusVisibleButton
- size="large"
- color={attributes.close?.variant ?? "secondary"}
- onClick={() => {
- attributes.close.action &&
- attributes.close?.action();
- onClose();
- }}
- >
- {attributes.close?.text ?? t("ok")}
- </FocusVisibleButton>
- )}
- {attributes.proceed && (
- <FocusVisibleButton
- action={proceedButtonRef}
- size="large"
- color={attributes.proceed?.variant}
- onClick={() => {
- attributes.proceed.action();
- onClose();
- }}
- disabled={attributes.proceed.disabled}
- autoFocus={attributes.proceed?.autoFocus}
- >
- {attributes.proceed.text}
- </FocusVisibleButton>
- )}
- {attributes.secondary && (
- <FocusVisibleButton
- size="large"
- color={attributes.secondary?.variant}
- onClick={() => {
- attributes.secondary.action();
- onClose();
- }}
- disabled={attributes.secondary.disabled}
- >
- {attributes.secondary.text}
- </FocusVisibleButton>
- )}
- </>
- </DialogActions>
- )}
- </DialogBoxBase>
- );
-}
diff --git a/web/packages/shared/components/DialogBox/types.ts b/web/packages/shared/components/DialogBox/types.ts
deleted file mode 100644
index 7b22d48433..0000000000
--- a/web/packages/shared/components/DialogBox/types.ts
+++ /dev/null
@@ -1,36 +0,0 @@
-import type { ButtonProps } from "@mui/material";
-
-export interface DialogBoxAttributes {
- icon?: React.ReactNode;
- title?: string;
- /**
- * Set this to `true` to prevent the dialog from being closed when the user
- * clicks the backdrop outside the dialog.
- */
- staticBackdrop?: boolean;
- nonClosable?: boolean;
- content?: any;
- close?: {
- text?: string;
- variant?: ButtonProps["color"];
- action?: () => void;
- };
- proceed?: {
- text: string;
- action: () => void;
- variant?: ButtonProps["color"];
- disabled?: boolean;
- /**
- * If `true`, then the button representing the proceed action is focused
- * when the dialog is opened. This allows the user to directly press
- * ENTER to complete that action.
- */
- autoFocus?: boolean;
- };
- secondary?: {
- text: string;
- action: () => void;
- variant: ButtonProps["color"];
- disabled?: boolean;
- };
-}
diff --git a/web/packages/shared/components/DialogBox/TitleWithCloseButton.tsx b/web/packages/shared/components/TitleWithCloseButton.tsx
similarity index 100%
rename from web/packages/shared/components/DialogBox/TitleWithCloseButton.tsx
rename to web/packages/shared/components/TitleWithCloseButton.tsx