@@ -38,10 +38,9 @@ <h1 class="mat-h1 connectForm__fullLine">
3838 </ mat-select >
3939 </ mat-form-field >
4040
41- < div class ="connectForm__fullLine ">
41+ < div class ="connectForm__fullLine connectForm__toggle connectForm__typeSwitch ">
4242 < mat-button-toggle-group name ="connectionType "
4343 data-testid ="connection-type-toggle "
44- class ="connectForm__typeSwitch "
4544 [disabled] ="submitting || db.isTestConnection || db.type === 'dynamodb' "
4645 [(ngModel)] ="db.connectionType ">
4746 < mat-button-toggle value ="direct "> Direct connection</ mat-button-toggle >
@@ -51,7 +50,7 @@ <h1 class="mat-h1 connectForm__fullLine">
5150
5251 < div *ngIf ="db && db.connectionType === 'direct' && !db.isTestConnection && isSaas && db.type !== 'dynamodb' "
5352 data-testid ="direct-connection-warning "
54- class ="connectForm__fullLine ">
53+ class ="connectForm__fullLine connectForm__warningMessage ">
5554 < div *ngIf ="connectionID; else warningAlert " class ="warningMessage ">
5655 < mat-icon class ="warningMessage__icon "> warning_amber</ mat-icon >
5756 < div class ="mat-body-1 ">
@@ -72,156 +71,53 @@ <h1 class="mat-h1 connectForm__fullLine">
7271 </ ng-template >
7372 </ div >
7473
75- < app-mysql-credentials-form *ngIf ="db.type === 'mysql' && db.connectionType === 'direct' "
76- [ngClass] ="{
77- 'credentials-fieldset': !db.isTestConnection,
78- 'credentials-fieldset-no-warning': db.isTestConnection || !isSaas
79- } "
80- [connection] ="db "
81- [submitting] ="submitting "
82- [accessLevel] ="accessLevel "
83- [masterKey] ="masterKey "
84- [readonly] ="(accessLevel === 'readonly' || db.isTestConnection) && db.id "
85- (switchToAgent) ="switchToAgent() "
86- (masterKeyChange) ="handleMasterKeyChange($event) ">
87- </ app-mysql-credentials-form >
88-
89- < app-postgres-credentials-form *ngIf ="db.type === 'postgres' && db.connectionType === 'direct' "
90- [ngClass] ="{
91- 'credentials-fieldset': !db.isTestConnection,
92- 'credentials-fieldset-no-warning': db.isTestConnection || !isSaas
93- } "
94- [connection] ="db "
95- [submitting] ="submitting "
96- [accessLevel] ="accessLevel "
97- [masterKey] ="masterKey "
98- [readonly] ="(accessLevel === 'readonly' || db.isTestConnection) && db.id "
99- (switchToAgent) ="switchToAgent "
100- (masterKeyChange) ="handleMasterKeyChange($event) ">
101- </ app-postgres-credentials-form >
102-
103- < app-mongodb-credentials-form *ngIf ="db.type === 'mongodb' && db.connectionType === 'direct' "
104- [ngClass] ="{
105- 'credentials-fieldset': !db.isTestConnection,
106- 'credentials-fieldset-no-warning': db.isTestConnection || !isSaas
107- } "
108- [connection] ="db "
109- [submitting] ="submitting "
110- [accessLevel] ="accessLevel "
111- [masterKey] ="masterKey "
112- [readonly] ="(accessLevel === 'readonly' || db.isTestConnection) && db.id "
113- (switchToAgent) ="switchToAgent "
114- (masterKeyChange) ="handleMasterKeyChange($event) ">
115- </ app-mongodb-credentials-form >
116-
117- < app-dynamodb-credentials-form *ngIf ="db.type === 'dynamodb' && db.connectionType === 'direct' "
118- class ="credentials-fieldset-no-warning "
119- [connection] ="db "
120- [submitting] ="submitting "
121- [accessLevel] ="accessLevel "
122- [masterKey] ="masterKey "
123- [readonly] ="(accessLevel === 'readonly' || db.isTestConnection) && db.id "
124- (switchToAgent) ="switchToAgent "
125- (masterKeyChange) ="handleMasterKeyChange($event) ">
126- </ app-dynamodb-credentials-form >
127-
128- < app-cassandra-credentials-form *ngIf ="db.type === 'cassandra' && db.connectionType === 'direct' "
129- [ngClass] ="{
130- 'credentials-fieldset': !db.isTestConnection,
131- 'credentials-fieldset-no-warning': db.isTestConnection || !isSaas
132- } "
133- [connection] ="db "
134- [submitting] ="submitting "
135- [accessLevel] ="accessLevel "
136- [masterKey] ="masterKey "
137- [readonly] ="(accessLevel === 'readonly' || db.isTestConnection) && db.id "
138- (switchToAgent) ="switchToAgent "
139- (masterKeyChange) ="handleMasterKeyChange($event) ">
140- </ app-cassandra-credentials-form >
141-
142- < app-oracledb-credentials-form *ngIf ="db.type === 'oracledb' && db.connectionType === 'direct' "
143- [ngClass] ="{
144- 'credentials-fieldset': !db.isTestConnection,
145- 'credentials-fieldset-no-warning': db.isTestConnection || !isSaas
146- } "
147- [connection] ="db "
148- [submitting] ="submitting "
149- [accessLevel] ="accessLevel "
150- [masterKey] ="masterKey "
151- [readonly] ="(accessLevel === 'readonly' || db.isTestConnection) && db.id "
152- (switchToAgent) ="switchToAgent "
153- (masterKeyChange) ="handleMasterKeyChange($event) ">
154- </ app-oracledb-credentials-form >
155-
156- < app-mssql-credentials-form *ngIf ="db.type === 'mssql' && db.connectionType === 'direct' "
157- [ngClass] ="{
158- 'credentials-fieldset': !db.isTestConnection,
159- 'credentials-fieldset-no-warning': db.isTestConnection || !isSaas
160- } "
161- [connection] ="db "
162- [submitting] ="submitting "
163- [accessLevel] ="accessLevel "
164- [masterKey] ="masterKey "
165- [readonly] ="(accessLevel === 'readonly' || db.isTestConnection) && db.id "
166- (switchToAgent) ="switchToAgent "
167- (masterKeyChange) ="handleMasterKeyChange($event) ">
168- </ app-mssql-credentials-form >
169-
170- < app-redis-credentials-form *ngIf ="db.type === 'redis' && db.connectionType === 'direct' "
171- [ngClass] ="{
172- 'credentials-fieldset': !db.isTestConnection,
173- 'credentials-fieldset-no-warning': db.isTestConnection || !isSaas
174- } "
175- [connection] ="db "
176- [submitting] ="submitting "
177- [accessLevel] ="accessLevel "
178- [masterKey] ="masterKey "
179- [readonly] ="(accessLevel === 'readonly' || db.isTestConnection) && db.id "
180- (switchToAgent) ="switchToAgent "
181- (masterKeyChange) ="handleMasterKeyChange($event) ">
182- </ app-redis-credentials-form >
183-
184- < app-elastic-credentials-form *ngIf ="db.type === 'elasticsearch' && db.connectionType === 'direct' "
185- [ngClass] ="{
186- 'credentials-fieldset': !db.isTestConnection,
187- 'credentials-fieldset-no-warning': db.isTestConnection || !isSaas
188- } "
189- [connection] ="db "
190- [submitting] ="submitting "
191- [accessLevel] ="accessLevel "
192- [masterKey] ="masterKey "
193- [readonly] ="(accessLevel === 'readonly' || db.isTestConnection) && db.id "
194- (switchToAgent) ="switchToAgent "
195- (masterKeyChange) ="handleMasterKeyChange($event) ">
196- </ app-elastic-credentials-form >
197-
198- < app-clickhouse-credentials-form *ngIf ="db.type === 'clickhouse' && db.connectionType === 'direct' "
199- [ngClass] ="{
200- 'credentials-fieldset': !db.isTestConnection,
201- 'credentials-fieldset-no-warning': db.isTestConnection || !isSaas
202- } "
203- [connection] ="db "
204- [submitting] ="submitting "
205- [accessLevel] ="accessLevel "
206- [masterKey] ="masterKey "
207- [readonly] ="(accessLevel === 'readonly' || db.isTestConnection) && db.id "
208- (switchToAgent) ="switchToAgent() "
209- (masterKeyChange) ="handleMasterKeyChange($event) ">
210- </ app-clickhouse-credentials-form >
74+ @if (db.connectionType === 'direct' && !db.id) {
75+ < div class ="connectForm__fullLine connectForm__connectionString ">
76+ < mat-form-field appearance ="outline " style ="width: 100% ">
77+ < mat-label > Connection string</ mat-label >
78+ < input matInput name ="connectionString "
79+ #connectionStringInput ="ngModel "
80+ data-testid ="connection-string-input "
81+ placeholder ="e.g. postgresql://user:password@host:5432/dbname "
82+ connectionStringValidator
83+ [disabled] ="submitting "
84+ [(ngModel)] ="connectionString ">
85+ < mat-hint > Paste your database connection URI to auto-fill credentials</ mat-hint >
86+ @if (connectionStringInput.errors?.invalidConnectionStringFormat) {
87+ < mat-error > Invalid format. Expected: scheme://user:password@host:port/database</ mat-error >
88+ }
89+ @if (connectionStringInput.errors?.unsupportedScheme) {
90+ < mat-error > Unsupported scheme "{{ connectionStringInput.errors?.unsupportedScheme }}"</ mat-error >
91+ }
92+ @if (connectionStringInput.errors?.invalidConnectionString) {
93+ < mat-error > Failed to parse connection string</ mat-error >
94+ }
95+ </ mat-form-field >
96+ < button type ="button " mat-button color ="primary "
97+ class ="connectForm__connectionStringApplyButton "
98+ data-testid ="connection-string-apply-button "
99+ [disabled] ="submitting || !connectionString.trim() || connectionStringInput.invalid "
100+ (click) ="applyConnectionString() ">
101+ Apply
102+ </ button >
103+ </ div >
104+ }
211105
212- < app-db2-credentials-form *ngIf ="db.type === 'ibmdb2' && db.connectionType === 'direct' "
213- [ngClass] ="{
214- 'credentials-fieldset': !db.isTestConnection,
215- 'credentials-fieldset-no-warning': db.isTestConnection || !isSaas
216- } "
217- [connection] ="db "
218- [submitting] ="submitting "
219- [accessLevel] ="accessLevel "
220- [masterKey] ="masterKey "
221- [readonly] ="(accessLevel === 'readonly' || db.isTestConnection) && db.id "
222- (switchToAgent) ="switchToAgent "
223- (masterKeyChange) ="handleMasterKeyChange($event) ">
224- </ app-db2-credentials-form >
106+ @if (db.connectionType === 'direct') {
107+ < ndc-dynamic
108+ [ndcDynamicComponent] ="credentialsFormComponent "
109+ [ndcDynamicInputs] ="{
110+ connection: db,
111+ submitting: submitting,
112+ accessLevel: accessLevel,
113+ masterKey: masterKey,
114+ readonly: !!((accessLevel === 'readonly' || db.isTestConnection) && db.id)
115+ } "
116+ [ndcDynamicOutputs] ="credentialsFormOutputs "
117+ [ndcDynamicAttributes] ="credentialsFormAttributes "
118+ > </ ndc-dynamic >
119+ }
120+
225121
226122 < div *ngIf ="db.connectionType === 'agent' " class ="connectForm__fullLine instruction ">
227123
0 commit comments