Skip to content

armgit / ente

Public Imported from GitHub
0

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

Match material (and macOS) convention whilst retaining document order

Manav Rathi552116f51c7c
diff --git a/web/packages/base/components/MiniDialog.tsx b/web/packages/base/components/MiniDialog.tsx
index 4a740cd482..174aac3d67 100644
--- a/web/packages/base/components/MiniDialog.tsx
+++ b/web/packages/base/components/MiniDialog.tsx
@@ -161,6 +161,39 @@ export const AttributedMiniDialog: React.FC<
const { PaperProps, ...rest } = props;
+ const errorIndicator = phase == "failed" && (
+ <Typography variant="small" color="critical.main">
+ {t("generic_error")}
+ </Typography>
+ );
+
+ const loadingButton = attributes.continue && (
+ <LoadingButton
+ loading={phase == "loading"}
+ fullWidth
+ color={attributes.continue.color ?? "accent"}
+ autoFocus={attributes.continue.autoFocus}
+ onClick={async () => {
+ setPhase("loading");
+ try {
+ await attributes.continue?.action?.();
+ resetPhaseAndClose();
+ } catch (e) {
+ log.error("Error", e);
+ setPhase("failed");
+ }
+ }}
+ >
+ {attributes.continue.text ?? t("ok")}
+ </LoadingButton>
+ );
+
+ const cancelButton = cancelTitle && (
+ <FocusVisibleButton fullWidth color="secondary" onClick={handleCancel}>
+ {cancelTitle}
+ </FocusVisibleButton>
+ );
+
return (
<Dialog
open={open}
@@ -213,39 +246,17 @@ export const AttributedMiniDialog: React.FC<
sx={{ paddingBlockStart: "24px", gap: "12px" }}
direction={attributes.buttonDirection ?? "column"}
>
- {phase == "failed" && (
- <Typography variant="small" color="critical.main">
- {t("generic_error")}
- </Typography>
- )}
- {attributes.continue && (
- <LoadingButton
- loading={phase == "loading"}
- fullWidth
- color={attributes.continue.color ?? "accent"}
- autoFocus={attributes.continue.autoFocus}
- onClick={async () => {
- setPhase("loading");
- try {
- await attributes.continue?.action?.();
- resetPhaseAndClose();
- } catch (e) {
- log.error("Error", e);
- setPhase("failed");
- }
- }}
- >
- {attributes.continue.text ?? t("ok")}
- </LoadingButton>
- )}
- {cancelTitle && (
- <FocusVisibleButton
- fullWidth
- color="secondary"
- onClick={handleCancel}
- >
- {cancelTitle}
- </FocusVisibleButton>
+ {errorIndicator}
+ {attributes.buttonDirection == "row" ? (
+ <>
+ {cancelButton}
+ {loadingButton}
+ </>
+ ) : (
+ <>
+ {loadingButton}
+ {cancelButton}
+ </>
)}
</Stack>
</DialogContent>