Skip to content

Commit 79dcdd7

Browse files
committed
chore: review comments
1 parent c300a1c commit 79dcdd7

File tree

5 files changed

+13
-15
lines changed

5 files changed

+13
-15
lines changed

.eslintignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ src/Common/BreadCrumb/BreadcrumbStore.tsx
1010
src/Common/CIPipeline.Types.ts
1111
src/Common/ChartVersionAndTypeSelector.tsx
1212
src/Common/Checkbox.tsx
13-
src/Common/ClipboardButton/ClipboardButton.tsx
1413
src/Common/ClipboardButton/__tests__/ClipboardButton.test.tsx
1514
src/Common/CodeEditor/CodeEditor.tsx
1615
src/Common/Common.service.ts

src/Common/ClipboardButton/ClipboardButton.tsx

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
*/
1616

1717
import { useState, useEffect, useRef } from 'react'
18-
import { copyToClipboard, noop, stopPropagation } from '../Helper'
1918
import Tooltip from '@Common/Tooltip/Tooltip'
19+
import { copyToClipboard, noop, stopPropagation } from '../Helper'
2020
import ClipboardProps from './types'
2121
import { ReactComponent as ICCopy } from '../../Assets/Icon/ic-copy.svg'
2222
import { ReactComponent as Check } from '../../Assets/Icon/ic-check.svg'
@@ -29,14 +29,14 @@ import { ReactComponent as Check } from '../../Assets/Icon/ic-check.svg'
2929
* @param rootClassName - additional classes to add to button
3030
* @param iconSize - size of svg icon to be shown, default 16 (icon-dim-16)
3131
*/
32-
export default function ClipboardButton({
32+
export const ClipboardButton = ({
3333
content,
3434
copiedTippyText = 'Copied!',
3535
duration = 1000,
3636
copyToClipboardPromise,
3737
rootClassName = '',
3838
iconSize = 16,
39-
}: ClipboardProps) {
39+
}: ClipboardProps) => {
4040
const [copied, setCopied] = useState<boolean>(false)
4141
const setCopiedFalseTimeoutRef = useRef<ReturnType<typeof setTimeout>>(-1)
4242

@@ -80,21 +80,20 @@ export default function ClipboardButton({
8080
handleAwaitCopyToClipboardPromise().catch(noop)
8181
}, [copyToClipboardPromise])
8282

83-
useEffect(() => {
84-
return () => {
83+
useEffect(
84+
() => () => {
8585
if (setCopiedFalseTimeoutRef.current > -1) {
8686
clearTimeout(setCopiedFalseTimeoutRef.current)
8787
}
88-
}
89-
}, [])
88+
},
89+
[],
90+
)
9091

9192
const iconClassName = `icon-dim-${iconSize} dc__no-shrink`
9293

9394
return (
94-
<Tooltip
95-
content={'Copy'}
96-
alwaysShowTippyOnHover={!copied}
97-
>
95+
<Tooltip content="Copy" alwaysShowTippyOnHover={!copied}>
96+
{/* TODO: semantically buttons should not be nested; fix later */}
9897
<button
9998
type="button"
10099
className={`dc__outline-none-imp p-0 flex dc__transparent--unstyled dc__no-border ${rootClassName}`}

src/Common/CodeEditor/CodeEditor.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ import { YAMLStringify, cleanKubeManifest, useJsonYaml } from '../Helper'
3131
import { useWindowSize } from '../Hooks'
3232
import Select from '../Select/Select'
3333
import RadioGroup from '../RadioGroup/RadioGroup'
34-
import ClipboardButton from '../ClipboardButton/ClipboardButton'
34+
import { ClipboardButton } from '../ClipboardButton/ClipboardButton'
3535
import { Progressing } from '../Progressing'
3636
import {
3737
CodeEditorComposition,

src/Common/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ export { default as DebouncedSearch } from './DebouncedSearch/DebouncedSearch'
5555
export { default as Grid } from './Grid/Grid'
5656
// export { default as CodeEditor } from './CodeEditor/CodeEditor'
5757
export { default as Select } from './Select/Select'
58-
export { default as ClipboardButton } from './ClipboardButton/ClipboardButton'
58+
export { ClipboardButton } from './ClipboardButton/ClipboardButton'
5959
export * from './Hooks'
6060
export * from './RJSF'
6161
export * from './DevtronProgressing'

src/Shared/Components/GitCommitInfoGeneric/GitCommitInfoGeneric.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
import { useState } from 'react'
1919
import moment from 'moment'
2020
import Tippy from '@tippyjs/react'
21-
import ClipboardButton from '@Common/ClipboardButton/ClipboardButton'
21+
import { ClipboardButton } from '@Common/ClipboardButton/ClipboardButton'
2222
import { ReactComponent as Circle } from '@Icons/ic-circle.svg'
2323
import { ReactComponent as Commit } from '@Icons/ic-commit.svg'
2424
import { ReactComponent as CommitIcon } from '@Icons/ic-code-commit.svg'

0 commit comments

Comments
 (0)