@@ -82,52 +82,76 @@ qx.Class.define("osparc.ui.message.FlashMessageOEC", {
8282 } ,
8383
8484 __getContext : function ( ) {
85- const currentStudy = osparc . store . Store . getInstance ( ) . getCurrentStudy ( ) ;
8685 const dataToClipboard = {
8786 message : this . getMessage ( ) ,
8887 supportId : this . getSupportId ( ) ,
8988 timestamp : new Date ( ) . toString ( ) ,
9089 url : window . location . href ,
9190 releaseTag : osparc . utils . Utils . getReleaseTag ( ) ,
92- studyId : currentStudy ? currentStudy . getUuid ( ) : "" ,
91+ }
92+ if ( osparc . store . Store . getInstance ( ) . getCurrentStudy ( ) ) {
93+ dataToClipboard [ "projectId" ] = osparc . store . Store . getInstance ( ) . getCurrentStudy ( ) . getUuid ( ) ;
9394 }
9495 return osparc . utils . Utils . prettifyJson ( dataToClipboard ) ;
9596 } ,
9697
98+ __getSupportFriendlyContext : function ( ) {
99+ let curatedText = "Extra Context:" ;
100+ curatedText += "\nError: " + this . getMessage ( ) ;
101+ curatedText += "\nSupportID: " + this . getSupportId ( ) ;
102+ curatedText += "\nTimestamp: " + new Date ( ) . toISOString ( ) ;
103+ curatedText += "\nURL: " + window . location . href ;
104+ curatedText += "\nRelease Tag: " + osparc . utils . Utils . getReleaseTag ( ) ;
105+ if ( osparc . store . Store . getInstance ( ) . getCurrentStudy ( ) ) {
106+ curatedText += "\nProject ID: " + osparc . store . Store . getInstance ( ) . getCurrentStudy ( ) . getUuid ( ) ;
107+ }
108+ return curatedText ;
109+ } ,
110+
97111 __copyToClipboard : function ( ) {
98112 osparc . utils . Utils . copyTextToClipboard ( this . __getContext ( ) ) ;
99113 } ,
100114
101115 __openSupportChat : function ( ) {
116+ const supportCenter = osparc . support . SupportCenter . openWindow ( ) ;
117+ supportCenter . openConversation ( null ) ;
118+
119+ const textToAddMessageField = msg => {
120+ if (
121+ supportCenter . getChildControl ( "conversation-page" ) &&
122+ supportCenter . getChildControl ( "conversation-page" ) . getChildControl ( "conversation-content" ) &&
123+ supportCenter . getChildControl ( "conversation-page" ) . getChildControl ( "conversation-content" ) . getChildControl ( "add-message" ) &&
124+ supportCenter . getChildControl ( "conversation-page" ) . getChildControl ( "conversation-content" ) . getChildControl ( "add-message" ) . getChildControl ( "comment-field" )
125+ ) {
126+ supportCenter . getChildControl ( "conversation-page" ) . getChildControl ( "conversation-content" ) . getChildControl ( "add-message" ) . getChildControl ( "comment-field" ) . setText ( msg ) ;
127+ }
128+ }
129+
102130 const caption = this . tr ( "Something went wrong" ) ;
103131 const introText = this . tr ( "Please describe what you were doing before the error (optional).\nThis will help our support team understand the context and resolve the issue faster." ) ;
104- const dialog = new osparc . ui . window . Confirmation ( introText ) ;
105- dialog . setCaption ( caption ) ;
106- dialog . getChildControl ( "message-label" ) . setFont ( "text-13" ) ;
107- const extraContext = new qx . ui . form . TextArea ( ) . set ( {
132+ const confirmationWindow = new osparc . ui . window . Confirmation ( introText ) ;
133+ confirmationWindow . setCaption ( caption ) ;
134+ confirmationWindow . getChildControl ( "message-label" ) . setFont ( "text-13" ) ;
135+ const extraContextTA = new qx . ui . form . TextArea ( ) . set ( {
108136 font : "text-13" ,
109137 autoSize : true ,
110138 minHeight : 70 ,
111139 maxHeight : 140
112140 } ) ;
113- dialog . addWidget ( extraContext ) ;
114- dialog . addCancelButton ( ) ;
115- dialog . setConfirmText ( this . tr ( "Send Report" ) ) ;
116- dialog . open ( ) ;
117-
118- const supportCenter = osparc . support . SupportCenter . openWindow ( ) ;
119- supportCenter . openConversation ( null ) ;
120-
121- /*
122- if (
123- supportCenter.getChildControl("conversation-page") &&
124- supportCenter.getChildControl("conversation-page").getChildControl("conversation-content") &&
125- supportCenter.getChildControl("conversation-page").getChildControl("conversation-content").getChildControl("add-message") &&
126- supportCenter.getChildControl("conversation-page").getChildControl("conversation-content").getChildControl("add-message").getChildControl("comment-field")
127- ) {
128- supportCenter.getChildControl("conversation-page").getChildControl("conversation-content").getChildControl("add-message").getChildControl("comment-field").setText(this.__getContext());
129- }
130- */
141+ confirmationWindow . addWidget ( extraContextTA ) ;
142+ confirmationWindow . addCancelButton ( ) ;
143+ confirmationWindow . setConfirmText ( this . tr ( "Send Report" ) ) ;
144+ confirmationWindow . open ( ) ;
145+ confirmationWindow . addListener ( "close" , ( ) => {
146+ if ( confirmationWindow . getConfirmed ( ) ) {
147+ const extraContext = extraContextTA . getValue ( )
148+ const friendlyContext = this . __getSupportFriendlyContext ( ) ;
149+ const text = "Dear Support Team,\n" + extraContext + "\n" + friendlyContext ;
150+ textToAddMessageField ( text ) ;
151+ } else {
152+ supportCenter . close ( ) ;
153+ }
154+ } ) ;
131155 } ,
132156 }
133157} ) ;
0 commit comments