1
- import { Component , useState , useRef } from "@odoo/owl" ;
2
-
3
- import { CopyPopover } from "@t9n/core/copy_button_popover" ;
1
+ import { Component , useState } from "@odoo/owl" ;
4
2
3
+ import { _t } from "@web/core/l10n/translation" ;
5
4
import { useService } from "@web/core/utils/hooks" ;
6
- import { usePopover } from "@web/core/popover/popover_hook" ;
7
5
8
6
export class MessageForm extends Component {
9
7
static props = { } ;
@@ -15,13 +13,7 @@ export class MessageForm extends Component {
15
13
} ) ;
16
14
this . store = useState ( useService ( "mail.store" ) ) ;
17
15
this . orm = useService ( "orm" ) ;
18
- this . popoverButtonRef = useRef ( "popover-button" ) ;
19
- this . copyPopover = usePopover ( CopyPopover , {
20
- position : "top" ,
21
- animation : true ,
22
- arrow : true ,
23
- closeOnClickAway : true ,
24
- } ) ;
16
+ this . notification = useService ( "notification" ) ;
25
17
}
26
18
27
19
get message ( ) {
@@ -38,11 +30,11 @@ export class MessageForm extends Component {
38
30
39
31
async onClickCopy ( ev ) {
40
32
try {
41
- await navigator . clipboard . writeText ( this . state . suggestedTranslationText . trim ( ) ) ;
42
- this . copyPopover . open ( this . popoverButtonRef . el , { } ) ;
43
- setTimeout ( ( ) => {
44
- this . copyPopover . close ( ) ;
45
- } , 3000 ) ;
33
+ await navigator . clipboard . writeText ( this . message . body . trim ( ) ) ;
34
+ this . notification . add (
35
+ _t ( "Copied to clipboard!" ) ,
36
+ { type : "info" }
37
+ ) ;
46
38
} catch ( error ) {
47
39
console . error ( "Error copying text:" , error ) ;
48
40
}
@@ -56,7 +48,7 @@ export class MessageForm extends Component {
56
48
lang_id : this . store . t9n . activeLanguage . id ,
57
49
} ,
58
50
) ;
59
- console . log ( data ) ;
51
+
60
52
this . store [ "t9n.translation" ] . insert ( data ) ;
61
53
this . state . suggestedTranslationText = "" ;
62
54
}
0 commit comments