@@ -11,7 +11,19 @@ import dayjs from "dayjs";
11
11
import localizedFormat from "dayjs/plugin/localizedFormat" ;
12
12
import { GlobalModel , GlobalCommandRunner , RemotesModel } from "../../../model/model" ;
13
13
import * as T from "../../../types/types" ;
14
- import { Markdown , Toggle , Modal , TextField , NumberField , InputDecoration , Dropdown , PasswordField , Tooltip , Button , Status } from "../common" ;
14
+ import {
15
+ Markdown ,
16
+ Toggle ,
17
+ Modal ,
18
+ TextField ,
19
+ NumberField ,
20
+ InputDecoration ,
21
+ Dropdown ,
22
+ PasswordField ,
23
+ Tooltip ,
24
+ Button ,
25
+ Status ,
26
+ } from "../common" ;
15
27
import * as util from "../../../util/util" ;
16
28
import * as textmeasure from "../../../util/textmeasure" ;
17
29
import { ClientDataType } from "../../../types/types" ;
@@ -37,18 +49,18 @@ const PasswordUnchangedSentinel = "--unchanged--";
37
49
38
50
@mobxReact . observer
39
51
class ModalsProvider extends React . Component {
40
- renderModals ( ) {
41
- const modals = GlobalModel . modalsModel . activeModals ;
42
-
52
+ render ( ) {
53
+ let store = GlobalModel . modalsModel . store . slice ( ) ;
43
54
if ( GlobalModel . needsTos ( ) ) {
44
55
return < TosModal /> ;
45
56
}
46
-
47
- return modals . map ( ( ModalComponent , index ) => < ModalComponent key = { index } /> ) ;
48
- }
49
-
50
- render ( ) {
51
- return < > { this . renderModals ( ) } </ > ;
57
+ let rtn : JSX . Element [ ] = [ ] ;
58
+ for ( let i = 0 ; i < store . length ; i ++ ) {
59
+ let entry = store [ i ] ;
60
+ let Comp = entry . component ;
61
+ rtn . push ( < Comp key = { entry . uniqueKey } /> ) ;
62
+ }
63
+ return < > { rtn } </ > ;
52
64
}
53
65
}
54
66
@@ -277,7 +289,11 @@ class TosModal extends React.Component<{}, {}> {
277
289
</ div >
278
290
</ div >
279
291
< div className = "item" >
280
- < a target = "_blank" href = { util . makeExternLink ( "https://discord.gg/XfvZ334gwU" ) } rel = { "noopener" } >
292
+ < a
293
+ target = "_blank"
294
+ href = { util . makeExternLink ( "https://discord.gg/XfvZ334gwU" ) }
295
+ rel = { "noopener" }
296
+ >
281
297
< img src = { help } alt = "Help" />
282
298
</ a >
283
299
< div className = "item-inner" >
@@ -286,7 +302,11 @@ class TosModal extends React.Component<{}, {}> {
286
302
Get help, submit feature requests, report bugs, or just chat with fellow
287
303
terminal enthusiasts.
288
304
< br />
289
- < a target = "_blank" href = { util . makeExternLink ( "https://discord.gg/XfvZ334gwU" ) } rel = { "noopener" } >
305
+ < a
306
+ target = "_blank"
307
+ href = { util . makeExternLink ( "https://discord.gg/XfvZ334gwU" ) }
308
+ rel = { "noopener" }
309
+ >
290
310
Join the Wave Discord Channel
291
311
</ a >
292
312
</ div >
@@ -846,7 +866,7 @@ class ViewRemoteConnDetailModal extends React.Component<{}, {}> {
846
866
847
867
@boundMethod
848
868
openEditModal ( ) : void {
849
- GlobalModel . remotesModel . openEditModal ( ) ;
869
+ GlobalModel . remotesModel . startEditAuth ( ) ;
850
870
}
851
871
852
872
@boundMethod
@@ -959,7 +979,7 @@ class ViewRemoteConnDetailModal extends React.Component<{}, {}> {
959
979
</ Button >
960
980
) ;
961
981
if ( remote . local ) {
962
- installNowButton = < > </ > ;
982
+ installNowButton = < > </ > ;
963
983
updateAuthButton = < > </ > ;
964
984
cancelInstallButton = < > </ > ;
965
985
}
@@ -1115,74 +1135,47 @@ class ViewRemoteConnDetailModal extends React.Component<{}, {}> {
1115
1135
1116
1136
@mobxReact . observer
1117
1137
class EditRemoteConnModal extends React . Component < { } , { } > {
1118
- internalTempAlias : OV < string > ;
1119
- internalTempKeyFile : OV < string > ;
1120
- internalTempPassword : OV < string > ;
1138
+ tempAlias : OV < string > ;
1139
+ tempKeyFile : OV < string > ;
1140
+ tempPassword : OV < string > ;
1141
+ tempConnectMode : OV < string > ;
1142
+ tempAuthMode : OV < string > ;
1121
1143
model : RemotesModel ;
1122
1144
1123
1145
constructor ( props : { remotesModel ?: RemotesModel } ) {
1124
1146
super ( props ) ;
1125
1147
this . model = GlobalModel . remotesModel ;
1126
- this . internalTempAlias = mobx . observable . box ( null , { name : "EditRemoteSettings-internalTempAlias" } ) ;
1127
- this . internalTempKeyFile = mobx . observable . box ( null , { name : "EditRemoteSettings-internalTempKeyFile" } ) ;
1128
- this . internalTempPassword = mobx . observable . box ( null , { name : "EditRemoteSettings-internalTempPassword" } ) ;
1148
+ this . tempAlias = mobx . observable . box ( null , { name : "EditRemoteSettings-tempAlias" } ) ;
1149
+ this . tempAuthMode = mobx . observable . box ( null , { name : "EditRemoteSettings-tempAuthMode" } ) ;
1150
+ this . tempKeyFile = mobx . observable . box ( null , { name : "EditRemoteSettings-tempKeyFile" } ) ;
1151
+ this . tempPassword = mobx . observable . box ( null , { name : "EditRemoteSettings-tempPassword" } ) ;
1152
+ this . tempConnectMode = mobx . observable . box ( null , { name : "EditRemoteSettings-tempConnectMode" } ) ;
1129
1153
}
1130
1154
1131
- @mobx . computed
1132
1155
get selectedRemoteId ( ) {
1133
1156
return this . model . selectedRemoteId . get ( ) ;
1134
1157
}
1135
1158
1136
- @mobx . computed
1137
1159
get selectedRemote ( ) : T . RemoteType {
1138
1160
return GlobalModel . getRemote ( this . selectedRemoteId ) ;
1139
1161
}
1140
1162
1141
- @mobx . computed
1142
1163
get remoteEdit ( ) : T . RemoteEditType {
1143
1164
return this . model . remoteEdit . get ( ) ;
1144
1165
}
1145
1166
1146
- @mobx . computed
1147
1167
get isAuthEditMode ( ) : boolean {
1148
1168
return this . model . isAuthEditMode ( ) ;
1149
1169
}
1150
1170
1151
- @mobx . computed
1152
- get tempAuthMode ( ) : mobx . IObservableValue < string > {
1153
- return mobx . observable . box ( this . selectedRemote ?. authtype , {
1154
- name : "EditRemoteConnModal-authMode" ,
1155
- } ) ;
1156
- }
1157
-
1158
- @mobx . computed
1159
- get tempConnectMode ( ) : mobx . IObservableValue < string > {
1160
- return mobx . observable . box ( this . selectedRemote ?. connectmode , {
1161
- name : "EditRemoteConnModal-connectMode" ,
1162
- } ) ;
1163
- }
1164
-
1165
- @mobx . computed
1166
- get tempAlias ( ) : mobx . IObservableValue < string > {
1167
- return mobx . observable . box ( this . internalTempAlias . get ( ) || this . selectedRemote . remotealias , {
1168
- name : "EditRemoteConnModal-alias" ,
1169
- } ) ;
1170
- }
1171
-
1172
- @mobx . computed
1173
- get tempKeyFile ( ) : mobx . IObservableValue < string > {
1174
- return mobx . observable . box ( this . internalTempKeyFile . get ( ) || this . remoteEdit ?. keystr , {
1175
- name : "EditRemoteConnModal-keystr" ,
1176
- } ) ;
1177
- }
1178
-
1179
- @mobx . computed
1180
- get tempPassword ( ) : mobx . IObservableValue < string > {
1181
- const oldPassword = this . remoteEdit ?. haspassword ? PasswordUnchangedSentinel : "" ;
1182
- const newPassword = this . internalTempPassword . get ( ) || oldPassword ;
1183
- return mobx . observable . box ( newPassword , {
1184
- name : "EditRemoteConnModal-password" ,
1185
- } ) ;
1171
+ componentDidMount ( ) : void {
1172
+ mobx . action ( ( ) => {
1173
+ this . tempAlias . set ( this . selectedRemote ?. remotealias ) ;
1174
+ this . tempKeyFile . set ( this . remoteEdit ?. keystr ) ;
1175
+ this . tempPassword . set ( this . remoteEdit ?. haspassword ? PasswordUnchangedSentinel : "" ) ;
1176
+ this . tempConnectMode . set ( this . selectedRemote ?. connectmode ) ;
1177
+ this . tempAuthMode . set ( this . selectedRemote ?. authtype ) ;
1178
+ } ) ( ) ;
1186
1179
}
1187
1180
1188
1181
componentDidUpdate ( ) {
@@ -1194,21 +1187,35 @@ class EditRemoteConnModal extends React.Component<{}, {}> {
1194
1187
@boundMethod
1195
1188
handleChangeKeyFile ( value : string ) : void {
1196
1189
mobx . action ( ( ) => {
1197
- this . internalTempKeyFile . set ( value ) ;
1190
+ this . tempKeyFile . set ( value ) ;
1198
1191
} ) ( ) ;
1199
1192
}
1200
1193
1201
1194
@boundMethod
1202
1195
handleChangePassword ( value : string ) : void {
1203
1196
mobx . action ( ( ) => {
1204
- this . internalTempPassword . set ( value ) ;
1197
+ this . tempPassword . set ( value ) ;
1205
1198
} ) ( ) ;
1206
1199
}
1207
1200
1208
1201
@boundMethod
1209
1202
handleChangeAlias ( value : string ) : void {
1210
1203
mobx . action ( ( ) => {
1211
- this . internalTempAlias . set ( value ) ;
1204
+ this . tempAlias . set ( value ) ;
1205
+ } ) ( ) ;
1206
+ }
1207
+
1208
+ @boundMethod
1209
+ handleChangeAuthMode ( value : string ) : void {
1210
+ mobx . action ( ( ) => {
1211
+ this . tempAuthMode . set ( value ) ;
1212
+ } ) ( ) ;
1213
+ }
1214
+
1215
+ @boundMethod
1216
+ handleChangeConnectMode ( value : string ) : void {
1217
+ mobx . action ( ( ) => {
1218
+ this . tempConnectMode . set ( value ) ;
1212
1219
} ) ( ) ;
1213
1220
}
1214
1221
@@ -1238,10 +1245,13 @@ class EditRemoteConnModal extends React.Component<{}, {}> {
1238
1245
submitRemote ( ) : void {
1239
1246
let authMode = this . tempAuthMode . get ( ) ;
1240
1247
let kwargs : Record < string , string > = { } ;
1241
- if ( ! util . isStrEq ( this . tempKeyFile . get ( ) , this . remoteEdit ?. keystr ) ) {
1242
- if ( authMode == "key" || authMode == "key+password" ) {
1248
+ if ( authMode == "key" || authMode == "key+password" ) {
1249
+ let keyStrEq = util . isStrEq ( this . tempKeyFile . get ( ) , this . remoteEdit ?. keystr ) ;
1250
+ if ( ! keyStrEq ) {
1243
1251
kwargs [ "key" ] = this . tempKeyFile . get ( ) ;
1244
- } else {
1252
+ }
1253
+ } else {
1254
+ if ( ! util . isBlank ( this . tempKeyFile . get ( ) ) ) {
1245
1255
kwargs [ "key" ] = "" ;
1246
1256
}
1247
1257
}
@@ -1291,11 +1301,9 @@ class EditRemoteConnModal extends React.Component<{}, {}> {
1291
1301
1292
1302
render ( ) {
1293
1303
let authMode = this . tempAuthMode . get ( ) ;
1294
-
1295
1304
if ( this . remoteEdit === null || ! this . isAuthEditMode ) {
1296
1305
return null ;
1297
1306
}
1298
-
1299
1307
return (
1300
1308
< Modal className = "erconn-modal" >
1301
1309
< Modal . Header title = "Edit Connection" onClose = { this . model . closeModal } />
@@ -1333,9 +1341,7 @@ class EditRemoteConnModal extends React.Component<{}, {}> {
1333
1341
{ value : "key+password" , label : "key+password" } ,
1334
1342
] }
1335
1343
value = { this . tempAuthMode . get ( ) }
1336
- onChange = { ( val : string ) => {
1337
- this . tempAuthMode . set ( val ) ;
1338
- } }
1344
+ onChange = { this . handleChangeAuthMode }
1339
1345
decoration = { {
1340
1346
endDecoration : (
1341
1347
< InputDecoration >
@@ -1406,9 +1412,7 @@ class EditRemoteConnModal extends React.Component<{}, {}> {
1406
1412
{ value : "manual" , label : "manual" } ,
1407
1413
] }
1408
1414
value = { this . tempConnectMode . get ( ) }
1409
- onChange = { ( val : string ) => {
1410
- this . tempConnectMode . set ( val ) ;
1411
- } }
1415
+ onChange = { this . handleChangeConnectMode }
1412
1416
/>
1413
1417
</ div >
1414
1418
< If condition = { ! util . isBlank ( this . remoteEdit ?. errorstr ) } >
0 commit comments