1
- import { Divider , IconButton , Menu , MenuButton , MenuList } from '@invoke-ai/ui-library' ;
1
+ import { Button , Divider , IconButton , Menu , MenuButton , MenuList } from '@invoke-ai/ui-library' ;
2
2
import { useStore } from '@nanostores/react' ;
3
- import { useAppSelector } from 'app/store/storeHooks' ;
3
+ import { useAppSelector , useAppStore } from 'app/store/storeHooks' ;
4
4
import { selectIsStaging } from 'features/controlLayers/store/canvasStagingAreaSlice' ;
5
5
import { DeleteImageButton } from 'features/deleteImageModal/components/DeleteImageButton' ;
6
6
import SingleSelectionMenuItems from 'features/gallery/components/ImageContextMenu/SingleSelectionMenuItems' ;
7
7
import { useImageActions } from 'features/gallery/hooks/useImageActions' ;
8
8
import { selectLastSelectedImage } from 'features/gallery/store/gallerySelectors' ;
9
+ import { newCanvasFromImage } from 'features/imageActions/actions' ;
9
10
import { $hasTemplates } from 'features/nodes/store/nodesSlice' ;
10
11
import { PostProcessingPopover } from 'features/parameters/components/PostProcessing/PostProcessingPopover' ;
11
12
import { useFeatureStatus } from 'features/system/hooks/useFeatureStatus' ;
13
+ import { toast } from 'features/toast/toast' ;
14
+ import { useAutoLayoutContext } from 'features/ui/layouts/auto-layout-context' ;
15
+ import { WORKSPACE_PANEL_ID } from 'features/ui/layouts/shared' ;
12
16
import { selectShouldShowProgressInViewer } from 'features/ui/store/uiSelectors' ;
13
- import { memo } from 'react' ;
17
+ import { setActiveTab } from 'features/ui/store/uiSlice' ;
18
+ import { memo , useCallback } from 'react' ;
14
19
import { useTranslation } from 'react-i18next' ;
15
20
import {
16
21
PiArrowsCounterClockwiseBold ,
17
22
PiAsteriskBold ,
18
23
PiDotsThreeOutlineFill ,
19
24
PiFlowArrowBold ,
25
+ PiPencilBold ,
20
26
PiPlantBold ,
21
27
PiQuotesBold ,
22
28
PiRulerBold ,
@@ -38,6 +44,29 @@ export const CurrentImageButtons = memo(() => {
38
44
const imageActions = useImageActions ( imageDTO ) ;
39
45
const isStaging = useAppSelector ( selectIsStaging ) ;
40
46
const isUpscalingEnabled = useFeatureStatus ( 'upscaling' ) ;
47
+ const { getState, dispatch } = useAppStore ( ) ;
48
+ const autoLayoutContext = useAutoLayoutContext ( ) ;
49
+
50
+ const handleEdit = useCallback ( async ( ) => {
51
+ if ( ! imageDTO ) {
52
+ return ;
53
+ }
54
+
55
+ await newCanvasFromImage ( {
56
+ imageDTO,
57
+ type : 'raster_layer' ,
58
+ withInpaintMask : true ,
59
+ getState,
60
+ dispatch,
61
+ } ) ;
62
+ dispatch ( setActiveTab ( 'canvas' ) ) ;
63
+ autoLayoutContext ?. focusPanel ( WORKSPACE_PANEL_ID ) ;
64
+ toast ( {
65
+ id : 'SENT_TO_CANVAS' ,
66
+ title : t ( 'toast.sentToCanvas' ) ,
67
+ status : 'success' ,
68
+ } ) ;
69
+ } , [ imageDTO , getState , dispatch , t , autoLayoutContext ] ) ;
41
70
42
71
return (
43
72
< >
@@ -56,6 +85,20 @@ export const CurrentImageButtons = memo(() => {
56
85
57
86
< Divider orientation = "vertical" h = { 8 } mx = { 2 } />
58
87
88
+ < Button
89
+ leftIcon = { < PiPencilBold /> }
90
+ onClick = { handleEdit }
91
+ isDisabled = { isDisabledOverride || ! imageDTO }
92
+ variant = "link"
93
+ size = "sm"
94
+ alignSelf = "stretch"
95
+ px = { 2 }
96
+ >
97
+ { t ( 'common.edit' ) }
98
+ </ Button >
99
+
100
+ < Divider orientation = "vertical" h = { 8 } mx = { 2 } />
101
+
59
102
< IconButton
60
103
icon = { < PiFlowArrowBold /> }
61
104
tooltip = { `${ t ( 'nodes.loadWorkflow' ) } (W)` }
0 commit comments