@@ -20,13 +20,6 @@ module.exports = BaseModal.extend({
2020 'click .js-msg-bar-close' : 'hideMessageBar'
2121 } ,
2222
23- // constructor: function (options) {
24- // BaseModal.prototype.constructor.call(this,
25- // __.extend({
26- // showCloseButton: true
27- // }, options));
28- // },
29-
3023 initialize : function ( options ) {
3124 this . options = options || { } ;
3225
@@ -46,48 +39,6 @@ module.exports = BaseModal.extend({
4639 this . listenTo ( this . serverConfigsVw , 'edit-config' , this . onEditConfig ) ;
4740 this . listenTo ( this . serverConfigsVw , 'connect' , this . onConnectClick ) ;
4841 this . listenTo ( this . serverConfigsVw , 'cancel' , this . onCancelClick ) ;
49-
50- // In case connection drops outside of this modal's connect() flow.
51- app . getHeartbeatSocket ( ) . on ( 'close' , ( e ) => {
52- return ;
53- console . log ( 'close detected' ) ;
54-
55- if ( ! this . connectAttempt ) {
56- // console.log('you be bringin it straight fleece out style');
57- this . failConnection ( null , this . serverConfigs . getActive ( ) ) ;
58-
59- // !this.isOpen() && this.open();
60- }
61- } ) ;
62-
63- $ ( document ) . ajaxComplete ( ( this . onAjaxComplete = ( e , jqXhr , settings ) => {
64- return ;
65- var failedConfig ,
66- activeConfig ;
67-
68- if (
69- jqXhr . status === 401 ||
70- (
71- settings && settings . url . endsWith ( '/login' ) &&
72- ! ( jqXhr . responseJSON && jqXhr . responseJSON . success )
73- )
74- ) {
75- // auth failed
76- if (
77- ! this . connectAttempt &&
78- ( failedConfig = this . serverConfigs . get ( jqXhr . serverConfig ) ) &&
79- ( activeConfig = this . serverConfigs . getActive ( ) ) &&
80- activeConfig . id === failedConfig . id
81- ) {
82- this . failConnection (
83- jqXhr . responseJSON . reason === 'too many attempts' ?
84- 'failed-auth-too-many' : 'failed-auth' ,
85- activeConfig
86- ) ;
87- ! this . isOpen ( ) && this . open ( ) ;
88- }
89- }
90- } ) ) ;
9142 } ,
9243
9344 remove : function ( ) {
@@ -175,8 +126,6 @@ module.exports = BaseModal.extend({
175126
176127 if ( this . connectAttempt && this . connectAttempt . state ( ) === 'pending' ) return this ;
177128
178- console . log ( `gonna succeed ${ configMd . get ( 'name' ) } ` ) ;
179-
180129 this . serverConfigsVw . setConnectionState ( {
181130 id : configMd . id ,
182131 status : 'connected'
@@ -196,7 +145,6 @@ module.exports = BaseModal.extend({
196145
197146 var msg ;
198147
199- console . log ( `you fail me, but the conny is ${ this . connectAttempt ? this . connectAttempt . state ( ) : ' no mo no mo no mo ' } ` ) ;
200148 if ( this . connectAttempt && this . connectAttempt . state ( ) === 'pending' ) return this ;
201149
202150 this . serverConfigsVw . setConnectionState ( {
@@ -228,36 +176,24 @@ module.exports = BaseModal.extend({
228176 }
229177
230178 this . connectAttempt && this . connectAttempt . cancel ( ) ;
231- this . serverConfigs . setActive ( configMd . id ) ;
232179 this . hideMessageBar ( ) ;
233180
234181 this . serverConfigsVw . setConnectionState ( {
235- id : configMd . id ,
236- status : 'connecting '
182+ id : this . serverConfigs . getActive ( ) . id ,
183+ status : 'not-connected '
237184 } ) ;
238185
239- this . serverConfigs . each ( ( md ) => {
240- if ( md . id !== configMd . id ) {
241- this . serverConfigsVw . setConnectionState ( {
242- id : md . id ,
243- status : 'not-connected'
244- } ) ;
245- }
186+ this . serverConfigsVw . setConnectionState ( {
187+ id : configMd . id ,
188+ status : 'connecting'
246189 } ) ;
247190
248191 this . setModalOptions ( { showCloseButton : false } ) ;
192+ this . serverConfigs . setActive ( configMd . id ) ;
249193
250194 this . connectAttempt = this . attemptConnection ( ) . done ( ( ) => {
251- console . log ( 'great success' ) ;
252-
253- // this.serverConfigsVw.setConnectionState({
254- // id: configMd.id,
255- // status: 'connected'
256- // });
257-
258195 this . succeedConnection ( configMd ) ;
259196 } ) . fail ( ( reason ) => {
260- console . log ( `yuo be rejected because ${ reason } ` ) ;
261197 this . failConnection ( reason , configMd )
262198 } ) . always ( ( ) => {
263199 this . connectAttempt = null ;
0 commit comments