ryanahamilton commented on code in PR #22988:
URL: https://github.com/apache/airflow/pull/22988#discussion_r849699668
##########
airflow/www/static/js/tree/Clipboard.jsx:
##########
@@ -0,0 +1,64 @@
+import React from 'react';
+import {
+ Box,
+ Button,
+ IconButton,
+ Tooltip,
+ useClipboard,
+ forwardRef,
+} from '@chakra-ui/react';
+import { FiCopy } from 'react-icons/fi';
+
+import { useContainerRef } from './context/containerRef';
+
+export const ClipboardButton = forwardRef(
+ (
+ {
+ value,
+ variant = 'outline',
+ iconOnly = false,
+ label = 'copy',
+ title = 'Copy',
+ 'aria-label': ariaLabel = 'Copy',
+ ...rest
+ },
+ ref,
+ ) => {
+ const { hasCopied, onCopy } = useClipboard(value);
+ const containerRef = useContainerRef();
+
+ const commonProps = {
+ onClick: onCopy,
+ variant,
+ title,
+ ref,
+ ...rest,
+ };
+
+ return (
+ <Tooltip
+ label="Copied"
+ isOpen={hasCopied}
+ isDisabled={!hasCopied}
+ closeDelay={500}
+ placement="top"
+ portalProps={{ containerRef }}
+ >
+ {iconOnly ? (
+ <IconButton icon={<FiCopy />} aria-label={ariaLabel}
{...commonProps} />
+ ) : (
+ <Button leftIcon={<FiCopy />} {...commonProps}>
+ {label}
+ </Button>
+ )}
+ </Tooltip>
+ );
+ },
+);
+
+export const ClipboardText = ({ value }) => (
+ <Box as="span">
+ {value}
+ <ClipboardButton value={value} iconOnly variant="ghost" size="xs"
fontSize="lg" ml={1} />
+ </Box>
Review Comment:
This doesn't appear to be needed, is it? If it was, you could just use a
plain 'ol `<span>`
```suggestion
<>
{value}
<ClipboardButton value={value} iconOnly variant="ghost" size="xs"
fontSize="lg" ml={1} />
</>
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]