-
-
Notifications
You must be signed in to change notification settings - Fork 18
hosted databases: add Change title #1705
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| .rename-dialog__field { | ||
| margin-top: 12px; | ||
| margin-bottom: -12px; | ||
| width: 100%; | ||
| } | ||
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,16 @@ | ||||||||||
| <h1 mat-dialog-title>Rename <strong>{{ data.databaseName }}</strong></h1> | ||||||||||
| <mat-dialog-content> | ||||||||||
| <mat-form-field appearance="outline" class="rename-dialog__field"> | ||||||||||
| <mat-label>Connection name</mat-label> | ||||||||||
|
||||||||||
| <mat-label>Connection name</mat-label> | |
| <mat-label>Connection title</mat-label> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inconsistent label: should be "Connection title".
This label says "Connection name" but the PR updates other templates to use "Connection title" (see connect-db.component.html line 12 and connections-list/hosted-database-rename-dialog line 6). Update for consistency.
- <mat-label>Connection name</mat-label>
+ <mat-label>Connection title</mat-label>📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| <mat-label>Connection name</mat-label> | |
| <mat-label>Connection title</mat-label> |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In
`@frontend/src/app/components/hosted-databases/hosted-database-rename-dialog/hosted-database-rename-dialog.component.html`
at line 4, Update the mat-label text in the hosted-database-rename-dialog
template: replace the existing "Connection name" label used in
hosted-database-rename-dialog.component.html with "Connection title" so it
matches the other templates (e.g., connect-db.component.html and
connections-list/hosted-database-rename-dialog) and keeps the UI wording
consistent.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| import { Component, inject, signal } from '@angular/core'; | ||
| import { FormsModule } from '@angular/forms'; | ||
| import { MatButtonModule } from '@angular/material/button'; | ||
| import { MAT_DIALOG_DATA, MatDialogModule, MatDialogRef } from '@angular/material/dialog'; | ||
| import { MatFormFieldModule } from '@angular/material/form-field'; | ||
| import { MatInputModule } from '@angular/material/input'; | ||
| import { firstValueFrom } from 'rxjs'; | ||
| import posthog from 'posthog-js'; | ||
| import { FoundHostedDatabase } from 'src/app/models/hosted-database'; | ||
| import { ConnectionsService } from 'src/app/services/connections.service'; | ||
| import { NotificationsService } from 'src/app/services/notifications.service'; | ||
|
|
||
| @Component({ | ||
| selector: 'app-hosted-databases-rename-dialog', | ||
| templateUrl: './hosted-database-rename-dialog.component.html', | ||
| styleUrls: ['./hosted-database-rename-dialog.component.css'], | ||
| imports: [MatDialogModule, MatButtonModule, MatFormFieldModule, MatInputModule, FormsModule], | ||
| }) | ||
| export class HostedDatabasesRenameDialogComponent { | ||
| private _connectionsService = inject(ConnectionsService); | ||
| private _notifications = inject(NotificationsService); | ||
| private _dialogRef = inject(MatDialogRef<HostedDatabasesRenameDialogComponent>); | ||
|
|
||
| protected data: FoundHostedDatabase = inject(MAT_DIALOG_DATA); | ||
| protected title = this.data.title || this.data.databaseName || ''; | ||
| protected submitting = signal(false); | ||
|
|
||
| async save(): Promise<void> { | ||
| const title = this.title.trim(); | ||
| if (!title || this.submitting()) return; | ||
|
|
||
| this.submitting.set(true); | ||
|
|
||
| try { | ||
| const connections = await firstValueFrom(this._connectionsService.fetchConnections()); | ||
| const match = connections?.find( | ||
| (item) => | ||
| item.connection.host === this.data.hostname && | ||
| item.connection.database === this.data.databaseName, | ||
| ); | ||
|
|
||
| if (!match) { | ||
| this._notifications.showErrorSnackbar('Matching connection not found.'); | ||
| this.submitting.set(false); | ||
| return; | ||
| } | ||
|
|
||
| await firstValueFrom(this._connectionsService.updateConnectionTitle(match.connection.id, title)); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Handle potential The 🛡️ Proposed fix if (!match) {
this._notifications.showErrorSnackbar('Matching connection not found.');
this.submitting.set(false);
return;
}
+ if (!match.connection.id) {
+ this._notifications.showErrorSnackbar('Connection ID is missing.');
+ this.submitting.set(false);
+ return;
+ }
+
await firstValueFrom(this._connectionsService.updateConnectionTitle(match.connection.id, title));🤖 Prompt for AI Agents |
||
| posthog.capture('Hosted Databases: database renamed', { databaseName: this.data.databaseName }); | ||
| this._connectionsService.fetchConnections().subscribe(); | ||
| this._dialogRef.close(title); | ||
| } finally { | ||
| this.submitting.set(false); | ||
| } | ||
|
Comment on lines
+34
to
+54
|
||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -47,6 +47,11 @@ <h1 class="mat-h1">Hosted Databases</h1> | |
| </div> | ||
| </div> | ||
| <div class="db-card__actions"> | ||
| <button type="button" mat-icon-button | ||
| matTooltip="Change connection title" | ||
| (click)="renameDatabase(db)"> | ||
| <mat-icon>edit</mat-icon> | ||
| </button> | ||
|
Comment on lines
+50
to
+54
|
||
| <button type="button" mat-icon-button | ||
| matTooltip="Reset password" | ||
| (click)="resetPassword(db)"> | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,6 +15,7 @@ import { UserService } from 'src/app/services/user.service'; | |
| import { ProfileSidebarComponent } from '../profile/profile-sidebar/profile-sidebar.component'; | ||
| import { AlertComponent } from '../ui-components/alert/alert.component'; | ||
| import { HostedDatabaseDeleteDialogComponent } from './hosted-database-delete-dialog/hosted-database-delete-dialog.component'; | ||
| import { HostedDatabasesRenameDialogComponent } from './hosted-database-rename-dialog/hosted-database-rename-dialog.component'; | ||
| import { HostedDatabaseResetPasswordDialogComponent } from './hosted-database-reset-password-dialog/hosted-database-reset-password-dialog.component'; | ||
|
|
||
| @Component({ | ||
|
|
@@ -64,6 +65,20 @@ export class HostedDatabasesComponent implements OnInit { | |
| }); | ||
| } | ||
|
|
||
| renameDatabase(db: FoundHostedDatabase): void { | ||
| const dialogRef = this._dialog.open(HostedDatabasesRenameDialogComponent, { | ||
| width: '28em', | ||
| maxWidth: '95vw', | ||
| data: db, | ||
| }); | ||
|
|
||
| dialogRef.afterClosed().subscribe(async (newTitle) => { | ||
| if (newTitle) { | ||
| await this._loadDatabases(); | ||
| } | ||
| }); | ||
|
Comment on lines
+75
to
+79
|
||
| } | ||
|
|
||
| resetPassword(db: FoundHostedDatabase): void { | ||
| this._dialog.open(HostedDatabaseResetPasswordDialogComponent, { | ||
| width: '32em', | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indentation is inconsistent (mixed tabs/spaces) on the
margin-bottomline, which will trip linters/formatters and makes diffs noisy. Reformat to match the surrounding CSS indentation.