MCPcopy Create free account
hub / github.com/gotify/server / CopyableSecret

Function CopyableSecret

ui/src/common/CopyableSecret.tsx:14–39  ·  view source on GitHub ↗
({value, style}: IProps)

Source from the content-addressed store, hash-verified

12}
13
14const CopyableSecret = ({value, style}: IProps) => {
15 const [visible, setVisible] = React.useState(false);
16 const text = visible ? value : '•••••••••••••••';
17 const {snackManager} = useStores();
18 const toggleVisibility = () => setVisible((b) => !b);
19 const copyToClipboard = async () => {
20 try {
21 await navigator.clipboard.writeText(value);
22 snackManager.snack('Copied to clipboard');
23 } catch (error) {
24 console.error('Failed to copy to clipboard:', error);
25 snackManager.snack('Failed to copy to clipboard');
26 }
27 };
28 return (
29 <div style={style}>
30 <IconButton onClick={copyToClipboard} title="Copy to clipboard" size="large">
31 <Copy />
32 </IconButton>
33 <IconButton onClick={toggleVisibility} className="toggle-visibility" size="large">
34 {visible ? <VisibilityOff /> : <Visibility />}
35 </IconButton>
36 <Typography style={{fontFamily: 'monospace', fontSize: 16}}>{text}</Typography>
37 </div>
38 );
39};
40
41export default CopyableSecret;

Callers

nothing calls this directly

Calls 1

useStoresFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…