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" ; 
42
3+ import  {  _t  }  from  "@web/core/l10n/translation" ; 
54import  {  useService  }  from  "@web/core/utils/hooks" ; 
6- import  {  usePopover  }  from  "@web/core/popover/popover_hook" ; 
75
86export  class  MessageForm  extends  Component  { 
97    static  props  =  { } ; 
@@ -15,13 +13,7 @@ export class MessageForm extends Component {
1513        } ) ; 
1614        this . store  =  useState ( useService ( "mail.store" ) ) ; 
1715        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" ) ; 
2517    } 
2618
2719    get  message ( )  { 
@@ -38,11 +30,11 @@ export class MessageForm extends Component {
3830
3931    async  onClickCopy ( ev )  { 
4032        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+             ) ; 
4638        }  catch  ( error )  { 
4739            console . error ( "Error copying text:" ,  error ) ; 
4840        } 
@@ -56,7 +48,7 @@ export class MessageForm extends Component {
5648                lang_id : this . store . t9n . activeLanguage . id , 
5749            } , 
5850        ) ; 
59-          console . log ( data ) ; 
51+ 
6052        this . store [ "t9n.translation" ] . insert ( data ) ; 
6153        this . state . suggestedTranslationText  =  "" ; 
6254    } 
0 commit comments