Skip to content

armgit / ente

Public Imported from GitHub
0

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

[share] Add password visibility toggle and fix mask character count

Anand Baburajanfa368f10454f
diff --git a/web/apps/share/src/components/file-share/CopyableField.tsx b/web/apps/share/src/components/file-share/CopyableField.tsx
index dd0efab689..4727cf24a8 100644
--- a/web/apps/share/src/components/file-share/CopyableField.tsx
+++ b/web/apps/share/src/components/file-share/CopyableField.tsx
@@ -1,6 +1,6 @@
import CheckIcon from "@mui/icons-material/Check";
import { Box, IconButton, Typography } from "@mui/material";
-import { Copy01Icon } from "hugeicons-react";
+import { Copy01Icon, ViewIcon, ViewOffSlashIcon } from "hugeicons-react";
import React, { useState } from "react";
interface CopyableFieldProps {
@@ -19,6 +19,7 @@ export const CopyableField: React.FC<CopyableFieldProps> = ({
maskValue = false,
}) => {
const [copied, setCopied] = useState(false);
+ const [showValue, setShowValue] = useState(false);
const handleCopy = () => {
onCopy(value);
@@ -61,40 +62,61 @@ export const CopyableField: React.FC<CopyableFieldProps> = ({
wordBreak: "break-word",
}}
>
- {maskValue ? "**********************" : value}
+ {maskValue && !showValue
+ ? "β€’".repeat(value.length)
+ : value}
</Typography>
</Box>
- {copied ? (
- <Box
- sx={{
- position: "absolute",
- top: multiline ? 8 : "50%",
- right: 8,
- transform: multiline ? "none" : "translateY(-50%)",
- color: "success.main",
- display: "flex",
- alignItems: "center",
- justifyContent: "center",
- p: 1,
- }}
- >
- <CheckIcon fontSize="small" />
- </Box>
- ) : (
- <IconButton
- onClick={handleCopy}
- sx={{
- position: "absolute",
- top: multiline ? 8 : "50%",
- right: 8,
- transform: multiline ? "none" : "translateY(-50%)",
- color: "text.muted",
- "&:hover": { bgcolor: "fill.faintHover" },
- }}
- >
- <Copy01Icon size={16} />
- </IconButton>
- )}
+ <Box
+ sx={{
+ position: "absolute",
+ top: multiline ? 8 : "50%",
+ right: 8,
+ transform: multiline ? "none" : "translateY(-50%)",
+ display: "flex",
+ alignItems: "center",
+ gap: 0.5,
+ }}
+ >
+ {maskValue && (
+ <IconButton
+ onClick={() => setShowValue(!showValue)}
+ sx={{
+ color: "text.muted",
+ "&:hover": { bgcolor: "fill.faintHover" },
+ }}
+ >
+ {showValue ? (
+ <ViewOffSlashIcon size={18} />
+ ) : (
+ <ViewIcon size={18} />
+ )}
+ </IconButton>
+ )}
+ {copied ? (
+ <Box
+ sx={{
+ color: "success.main",
+ display: "flex",
+ alignItems: "center",
+ justifyContent: "center",
+ p: 1,
+ }}
+ >
+ <CheckIcon fontSize="small" />
+ </Box>
+ ) : (
+ <IconButton
+ onClick={handleCopy}
+ sx={{
+ color: "text.muted",
+ "&:hover": { bgcolor: "fill.faintHover" },
+ }}
+ >
+ <Copy01Icon size={16} />
+ </IconButton>
+ )}
+ </Box>
</Box>
</Box>
);