@@ -39,6 +39,14 @@ function renderInstructions(parts) {
3939export class ClientView extends TemplateView {
4040
4141 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 ) {
4250 return t . div ( { className : { "ClientView" : true , "isPreferred" : vm => vm . hasPreferredWebInstance } } , [
4351 ... vm . hasPreferredWebInstance ? [ t . div ( { className : "hostedBanner" } , vm . hostedByBannerLabel ) ] : [ ] ,
4452 t . div ( { className : "header" } , [
@@ -119,32 +127,40 @@ export class SetCustomWebInstanceView extends TemplateView {
119127 "Use a custom web instance for the " , t . strong ( vm . name ) , " client:" ,
120128 ] ) ,
121129 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 ) } ) ,
131139 ] )
132140 ] ) ;
133141 }
134142
135143 _onSubmit ( evt ) {
136144 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 ( ) ;
138154 }
139155}
140156
141157function showBack ( t , vm ) {
142158 return t . p ( { className : { caption : true , "back" : true , hidden : vm => ! vm . showBack } } , [
143159 `Continue with ${ vm . name } · ` ,
144160 t . button ( { className : "text" , onClick : ( ) => vm . back ( ) } , "Change" ) ,
145- t . span ( { hidden : vm => ! vm . showSetWebInstance } , [
161+ t . span ( { hidden : vm => ! vm . supportsCustomWebInstances } , [
146162 ' · ' ,
147- t . button ( { className : "text" , onClick : ( ) => vm . setCustomWebInstance ( ) } , "Use Custom Web Instance" ) ,
163+ t . button ( { className : "text" , onClick : ( ) => vm . configureCustomWebInstance ( ) } , "Use Custom Web Instance" ) ,
148164 ] )
149165
150166 ] ) ;
0 commit comments