1
1
import { IconButton , Tooltip } from '@invoke-ai/ui-library' ;
2
- import { useStore } from '@nanostores/react' ;
3
- import { $projectUrl } from 'app/store/nanostores/projectId' ;
4
2
import { useShareWorkflow } from 'features/nodes/components/sidePanel/workflow/WorkflowLibrary/ShareWorkflowModal' ;
5
3
import type { MouseEvent } from 'react' ;
6
- import { useCallback } from 'react' ;
4
+ import { memo , useCallback } from 'react' ;
7
5
import { useTranslation } from 'react-i18next' ;
8
6
import { PiShareFatBold } from 'react-icons/pi' ;
9
7
import type { WorkflowRecordListItemWithThumbnailDTO } from 'services/api/types' ;
10
8
11
- export const ViewWorkflow = ( {
12
- isHovered,
13
- setIsHovered,
14
- workflow,
15
- } : {
16
- isHovered : boolean ;
17
- setIsHovered : ( isHovered : boolean ) => void ;
18
- workflow : WorkflowRecordListItemWithThumbnailDTO ;
19
- } ) => {
20
- const projectUrl = useStore ( $projectUrl ) ;
9
+ export const ShareWorkflowButton = memo ( ( { workflow } : { workflow : WorkflowRecordListItemWithThumbnailDTO } ) => {
21
10
const shareWorkflow = useShareWorkflow ( ) ;
22
11
const { t } = useTranslation ( ) ;
23
12
24
13
const handleClickShare = useCallback (
25
14
( e : MouseEvent < HTMLButtonElement > ) => {
26
15
e . stopPropagation ( ) ;
27
- setIsHovered ( false ) ;
28
16
shareWorkflow ( workflow ) ;
29
17
} ,
30
- [ shareWorkflow , workflow , setIsHovered ]
18
+ [ shareWorkflow , workflow ]
31
19
) ;
32
20
33
- if ( ! projectUrl || ! workflow . workflow_id || workflow . category === 'user' ) {
34
- return null ;
35
- }
36
-
37
21
return (
38
- < Tooltip
39
- label = { t ( 'workflows.copyShareLink' ) }
40
- // This prevents an issue where the tooltip isn't closed after the modal is opened
41
- isOpen = { ! isHovered ? false : undefined }
42
- closeOnScroll
43
- >
22
+ < Tooltip label = { t ( 'workflows.copyShareLink' ) } closeOnScroll >
44
23
< IconButton
45
24
size = "sm"
46
25
variant = "ghost"
@@ -50,4 +29,6 @@ export const ViewWorkflow = ({
50
29
/>
51
30
</ Tooltip >
52
31
) ;
53
- } ;
32
+ } ) ;
33
+
34
+ ShareWorkflowButton . displayName = 'ShareWorkflowButton' ;
0 commit comments