@@ -10,9 +10,12 @@ import {
10
10
PopoverContent ,
11
11
PopoverTrigger ,
12
12
Portal ,
13
+ Spacer ,
13
14
Text ,
14
15
} from '@invoke-ai/ui-library' ;
15
- import { useAppSelector } from 'app/store/storeHooks' ;
16
+ import { useAppDispatch , useAppSelector } from 'app/store/storeHooks' ;
17
+ import { setShouldEnableInformationalPopovers } from 'features/system/store/systemSlice' ;
18
+ import { toast } from 'features/toast/toast' ;
16
19
import { merge , omit } from 'lodash-es' ;
17
20
import type { ReactElement } from 'react' ;
18
21
import { memo , useCallback , useMemo } from 'react' ;
@@ -71,7 +74,7 @@ type ContentProps = {
71
74
72
75
const Content = ( { data, feature } : ContentProps ) => {
73
76
const { t } = useTranslation ( ) ;
74
-
77
+ const dispatch = useAppDispatch ( ) ;
75
78
const heading = useMemo < string | undefined > ( ( ) => t ( `popovers.${ feature } .heading` ) , [ feature , t ] ) ;
76
79
77
80
const paragraphs = useMemo < string [ ] > (
@@ -82,16 +85,25 @@ const Content = ({ data, feature }: ContentProps) => {
82
85
[ feature , t ]
83
86
) ;
84
87
85
- const handleClick = useCallback ( ( ) => {
88
+ const onClickLearnMore = useCallback ( ( ) => {
86
89
if ( ! data ?. href ) {
87
90
return ;
88
91
}
89
92
window . open ( data . href ) ;
90
93
} , [ data ?. href ] ) ;
91
94
95
+ const onClickDontShowMeThese = useCallback ( ( ) => {
96
+ dispatch ( setShouldEnableInformationalPopovers ( false ) ) ;
97
+ toast ( {
98
+ title : t ( 'settings.informationalPopoversDisabled' ) ,
99
+ description : t ( 'settings.informationalPopoversDisabledDesc' ) ,
100
+ status : 'info' ,
101
+ } ) ;
102
+ } , [ dispatch , t ] ) ;
103
+
92
104
return (
93
- < PopoverContent w = { 96 } >
94
- < PopoverCloseButton />
105
+ < PopoverContent maxW = { 300 } >
106
+ < PopoverCloseButton top = { 2 } />
95
107
< PopoverBody >
96
108
< Flex gap = { 2 } flexDirection = "column" alignItems = "flex-start" >
97
109
{ heading && (
@@ -116,20 +128,19 @@ const Content = ({ data, feature }: ContentProps) => {
116
128
{ paragraphs . map ( ( p ) => (
117
129
< Text key = { p } > { p } </ Text >
118
130
) ) }
119
- { data ?. href && (
120
- < >
121
- < Divider />
122
- < Button
123
- pt = { 1 }
124
- onClick = { handleClick }
125
- leftIcon = { < PiArrowSquareOutBold /> }
126
- alignSelf = "flex-end"
127
- variant = "link"
128
- >
131
+
132
+ < Divider />
133
+ < Flex alignItems = "center" justifyContent = "space-between" w = "full" >
134
+ < Button onClick = { onClickDontShowMeThese } variant = "link" size = "sm" >
135
+ { t ( 'common.dontShowMeThese' ) }
136
+ </ Button >
137
+ < Spacer />
138
+ { data ?. href && (
139
+ < Button onClick = { onClickLearnMore } leftIcon = { < PiArrowSquareOutBold /> } variant = "link" size = "sm" >
129
140
{ t ( 'common.learnMore' ) ?? heading }
130
141
</ Button >
131
- </ >
132
- ) }
142
+ ) }
143
+ </ Flex >
133
144
</ Flex >
134
145
</ PopoverBody >
135
146
</ PopoverContent >
0 commit comments