File tree 5 files changed +70
-6
lines changed 5 files changed +70
-6
lines changed Original file line number Diff line number Diff line change
1
+ import { makeStyles } from "@material-ui/core/styles"
2
+ import Tooltip from "@material-ui/core/Tooltip"
3
+ import { useClickable } from "hooks/useClickable"
4
+ import { useClipboard } from "hooks/useClipboard"
5
+ import React , { HTMLProps } from "react"
6
+ import { combineClasses } from "util/combineClasses"
7
+
8
+ interface CopyableValueProps extends HTMLProps < HTMLDivElement > {
9
+ value : string
10
+ }
11
+
12
+ export const CopyableValue : React . FC < CopyableValueProps > = ( {
13
+ value,
14
+ className,
15
+ ...props
16
+ } ) => {
17
+ const { isCopied, copy } = useClipboard ( value )
18
+ const clickableProps = useClickable ( copy )
19
+ const styles = useStyles ( )
20
+
21
+ return (
22
+ < Tooltip
23
+ title = { isCopied ? "Copied!" : "Click to copy" }
24
+ placement = "bottom-start"
25
+ >
26
+ < span
27
+ { ...props }
28
+ { ...clickableProps }
29
+ className = { combineClasses ( [ styles . value , className ] ) }
30
+ />
31
+ </ Tooltip >
32
+ )
33
+ }
34
+
35
+ const useStyles = makeStyles ( ( ) => ( {
36
+ value : {
37
+ cursor : "pointer" ,
38
+ } ,
39
+ } ) )
Original file line number Diff line number Diff line change @@ -34,7 +34,7 @@ export const AgentVersion: FC<{
34
34
onMouseEnter = { ( ) => setIsOpen ( true ) }
35
35
className = { styles . trigger }
36
36
>
37
- { displayVersion }
37
+ Agent Outdated
38
38
</ span >
39
39
< HelpPopover
40
40
id = { id }
@@ -54,9 +54,8 @@ export const AgentVersion: FC<{
54
54
)
55
55
}
56
56
57
- const useStyles = makeStyles ( ( theme ) => ( {
57
+ const useStyles = makeStyles ( ( ) => ( {
58
58
trigger : {
59
59
cursor : "pointer" ,
60
- color : theme . palette . warning . light ,
61
60
} ,
62
61
} ) )
Original file line number Diff line number Diff line change @@ -23,6 +23,7 @@ import {
23
23
import IconButton from "@material-ui/core/IconButton"
24
24
import Tooltip from "@material-ui/core/Tooltip"
25
25
import { Maybe } from "components/Conditionals/Maybe"
26
+ import { CopyableValue } from "components/CopyableValue/CopyableValue"
26
27
27
28
const getAgentStatusColor = ( theme : Theme , agent : WorkspaceAgent ) => {
28
29
switch ( agent . status ) {
@@ -101,7 +102,9 @@ export const ResourceCard: FC<ResourceCardProps> = ({
101
102
{ meta . sensitive ? (
102
103
< SensitiveValue value = { meta . value } />
103
104
) : (
104
- meta . value
105
+ < CopyableValue value = { meta . value } >
106
+ { meta . value }
107
+ </ CopyableValue >
105
108
) }
106
109
</ div >
107
110
</ div >
@@ -264,7 +267,6 @@ const useStyles = makeStyles((theme) => ({
264
267
textOverflow : "ellipsis" ,
265
268
overflow : "hidden" ,
266
269
whiteSpace : "nowrap" ,
267
- userSelect : "all" ,
268
270
} ,
269
271
270
272
agentRow : {
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ import { makeStyles } from "@material-ui/core/styles"
3
3
import Tooltip from "@material-ui/core/Tooltip"
4
4
import VisibilityOffOutlined from "@material-ui/icons/VisibilityOffOutlined"
5
5
import VisibilityOutlined from "@material-ui/icons/VisibilityOutlined"
6
+ import { CopyableValue } from "components/CopyableValue/CopyableValue"
6
7
import { useState } from "react"
7
8
8
9
const Language = {
@@ -23,7 +24,9 @@ export const SensitiveValue: React.FC<{ value: string }> = ({ value }) => {
23
24
24
25
return (
25
26
< div className = { styles . sensitiveValue } >
26
- < div className = { styles . value } > { displayValue } </ div >
27
+ < CopyableValue value = { value } className = { styles . value } >
28
+ { displayValue }
29
+ </ CopyableValue >
27
30
< Tooltip title = { buttonLabel } >
28
31
< IconButton
29
32
className = { styles . button }
Original file line number Diff line number Diff line change
1
+ import { KeyboardEvent } from "react"
2
+
3
+ interface UseClickableResult {
4
+ tabIndex : 0
5
+ role : "button"
6
+ onClick : ( ) => void
7
+ onKeyDown : ( event : KeyboardEvent ) => void
8
+ }
9
+
10
+ export const useClickable = ( onClick : ( ) => void ) : UseClickableResult => {
11
+ return {
12
+ tabIndex : 0 ,
13
+ role : "button" ,
14
+ onClick,
15
+ onKeyDown : ( event : KeyboardEvent ) => {
16
+ if ( event . key === "Enter" ) {
17
+ onClick ( )
18
+ }
19
+ } ,
20
+ }
21
+ }
You can’t perform that action at this time.
0 commit comments