@@ -17,11 +17,16 @@ export function initNewServerForm({$root, onChange}: NewServerFormProps): void {
17
17
< div class ="server-input-container ">
18
18
< div class ="title "> ${ t . __ ( "Organization URL" ) } </ div >
19
19
< div class ="add-server-info-row ">
20
- < input
21
- class ="setting-input-value "
22
- autofocus
23
- placeholder ="your-organization.zulipchat.com or zulip.your-organization.com "
24
- />
20
+ < label class ="setting-input-value ">
21
+ < input
22
+ class ="setting-input-add-server "
23
+ autofocus
24
+ placeholder ="your-organization.zulipchat.com "
25
+ style ="width: 34ch "
26
+ />
27
+ < span class ="add-server-domain "> </ span >
28
+ < span class ="server-url-size-calc "> </ span >
29
+ </ label >
25
30
</ div >
26
31
< div class ="server-center ">
27
32
< button id ="connect "> ${ t . __ ( "Connect" ) } </ button >
@@ -53,8 +58,15 @@ export function initNewServerForm({$root, onChange}: NewServerFormProps): void {
53
58
$root . textContent = "" ;
54
59
$root . append ( $newServerForm ) ;
55
60
const $newServerUrl : HTMLInputElement = $newServerForm . querySelector (
56
- "input.setting-input-value " ,
61
+ "input.setting-input-add-server " ,
57
62
) ! ;
63
+ const $serverDomain : HTMLSpanElement = $newServerForm . querySelector (
64
+ "span.add-server-domain" ,
65
+ ) ! ;
66
+ const $urlSizeCalc : HTMLSpanElement = $newServerForm . querySelector (
67
+ "span.server-url-size-calc" ,
68
+ ) ! ;
69
+ const urlValidationPattern = / ^ [ a - z A - Z \d - ] * $ / ;
58
70
59
71
async function submitFormHandler ( ) : Promise < void > {
60
72
$saveServerButton . textContent = "Connecting..." ;
@@ -99,6 +111,15 @@ export function initNewServerForm({$root, onChange}: NewServerFormProps): void {
99
111
await submitFormHandler ( ) ;
100
112
}
101
113
} ) ;
114
+ $newServerUrl . addEventListener ( "input" , async ( ) => {
115
+ const url = $newServerUrl . value ;
116
+ $urlSizeCalc . textContent = url ;
117
+ $newServerUrl . style . width = `${ $urlSizeCalc . offsetWidth } px` ;
118
+
119
+ $serverDomain . textContent = urlValidationPattern . test ( url )
120
+ ? ".zulipchat.com"
121
+ : "" ;
122
+ } ) ;
102
123
103
124
// Open create new org link in default browser
104
125
const link = "https://zulip.com/new/" ;
0 commit comments