@@ -39,6 +39,14 @@ function renderInstructions(parts) {
39
39
export class ClientView extends TemplateView {
40
40
41
41
render ( t , vm ) {
42
+ return t . mapView ( vm => vm . customWebInstanceFormOpen , open => {
43
+ switch ( open ) {
44
+ case true : return new SetCustomWebInstanceView ( vm ) ;
45
+ case false : return new TemplateView ( vm , t => this . renderContent ( t , vm ) ) ;
46
+ }
47
+ } ) ;
48
+ }
49
+ renderContent ( t , vm ) {
42
50
return t . div ( { className : { "ClientView" : true , "isPreferred" : vm => vm . hasPreferredWebInstance } } , [
43
51
... vm . hasPreferredWebInstance ? [ t . div ( { className : "hostedBanner" } , vm . hostedByBannerLabel ) ] : [ ] ,
44
52
t . div ( { className : "header" } , [
@@ -119,32 +127,40 @@ export class SetCustomWebInstanceView extends TemplateView {
119
127
"Use a custom web instance for the " , t . strong ( vm . name ) , " client:" ,
120
128
] ) ,
121
129
t . form ( { action : "#" , id : "setCustomWebInstanceForm" , onSubmit : evt => this . _onSubmit ( evt ) } , [
122
- t . label ( [
123
- "Host name: ",
124
- t . input ( {
125
- type : "text " ,
126
- className : "line " ,
127
- placeholder : "chat.example.org ",
128
- name : "instanceHostname" ,
129
- } )
130
- ] )
130
+ t . input ( {
131
+ type : "text ",
132
+ className : "fullwidth large" ,
133
+ placeholder : "chat.example.org " ,
134
+ name : "instanceHostname " ,
135
+ value : vm . preferredWebInstance || " ",
136
+ } ) ,
137
+ t . input ( { type : "submit" , value : "Save" , className : "primary fullwidth" } ) ,
138
+ t . input ( { type : "button" , value : "Use Default Instance" , className : "secondary fullwidth" , onClick : evt => this . _onReset ( evt ) } ) ,
131
139
] )
132
140
] ) ;
133
141
}
134
142
135
143
_onSubmit ( evt ) {
136
144
evt . preventDefault ( ) ;
137
- this . value . continueWithSelection ( this . _askEveryTimeChecked ) ;
145
+ const form = evt . target ;
146
+ const { instanceHostname} = form . elements ;
147
+ this . value . setCustomWebInstance ( instanceHostname . value || undefined ) ;
148
+ this . value . closeCustomWebInstanceForm ( ) ;
149
+ }
150
+
151
+ _onReset ( evt ) {
152
+ this . value . setCustomWebInstance ( undefined ) ;
153
+ this . value . closeCustomWebInstanceForm ( ) ;
138
154
}
139
155
}
140
156
141
157
function showBack ( t , vm ) {
142
158
return t . p ( { className : { caption : true , "back" : true , hidden : vm => ! vm . showBack } } , [
143
159
`Continue with ${ vm . name } · ` ,
144
160
t . button ( { className : "text" , onClick : ( ) => vm . back ( ) } , "Change" ) ,
145
- t . span ( { hidden : vm => ! vm . showSetWebInstance } , [
161
+ t . span ( { hidden : vm => ! vm . supportsCustomWebInstances } , [
146
162
' · ' ,
147
- t . button ( { className : "text" , onClick : ( ) => vm . setCustomWebInstance ( ) } , "Use Custom Web Instance" ) ,
163
+ t . button ( { className : "text" , onClick : ( ) => vm . configureCustomWebInstance ( ) } , "Use Custom Web Instance" ) ,
148
164
] )
149
165
150
166
] ) ;
0 commit comments