-
Notifications
You must be signed in to change notification settings - Fork 320
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Copy Button for Lineage ID (#2578)
* added copy button for id Signed-off-by: Amanda Yao <amanda.yao@berkeley.edu> * fixed prettier Signed-off-by: Amanda Yao <amanda.yao@berkeley.edu> --------- Signed-off-by: Amanda Yao <amanda.yao@berkeley.edu>
- Loading branch information
1 parent
6bfc0d5
commit 37bbd88
Showing
2 changed files
with
54 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// Copyright 2018-2023 contributors to the Marquez project | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
import { Snackbar, Tooltip } from '@mui/material' | ||
import ContentCopyIcon from '@mui/icons-material/ContentCopy' | ||
import IconButton from '@mui/material/IconButton' | ||
import React from 'react' | ||
|
||
interface MqCopyProps { | ||
string: string | ||
} | ||
|
||
const MqEmpty: React.FC<MqCopyProps> = ({ string }) => { | ||
const [open, setOpen] = React.useState(false) | ||
const handleClose = (event: React.SyntheticEvent | Event, reason?: string) => { | ||
if (reason === 'clickaway') { | ||
return | ||
} | ||
|
||
setOpen(false) | ||
} | ||
return ( | ||
<> | ||
<Tooltip title='Copy'> | ||
<IconButton | ||
onClick={(event) => { | ||
event.stopPropagation() | ||
navigator.clipboard.writeText(string) | ||
setOpen(true) | ||
}} | ||
aria-label='copy' | ||
size={'small'} | ||
color={'primary'} | ||
> | ||
<ContentCopyIcon fontSize={'small'} /> | ||
</IconButton> | ||
</Tooltip> | ||
<Snackbar | ||
open={open} | ||
autoHideDuration={2000} | ||
onClose={handleClose} | ||
message={`Copied ${string}`} | ||
anchorOrigin={{ vertical: 'bottom', horizontal: 'center' }} | ||
/> | ||
</> | ||
) | ||
} | ||
|
||
export default MqEmpty |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters