Skip to content

Commit 369e550

Browse files
hosted databases: consistent behaviour with creds dialog
1 parent 34092ff commit 369e550

4 files changed

Lines changed: 23 additions & 3 deletions

File tree

frontend/src/app/components/hosted-databases/hosted-database-reset-password-dialog/hosted-database-reset-password-dialog.component.css

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,12 @@
4646
padding-top: 8px;
4747
}
4848

49+
.reset-dialog__copy-check {
50+
font-size: 18px;
51+
width: 18px;
52+
height: 18px;
53+
}
54+
4955
@media (prefers-color-scheme: dark) {
5056
.reset-dialog__credentials {
5157
background: transparent;

frontend/src/app/components/hosted-databases/hosted-database-reset-password-dialog/hosted-database-reset-password-dialog.component.html

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,18 @@ <h1 mat-dialog-title>New password for <strong>{{ result()!.databaseName }}</stro
4040
</p>
4141
</mat-dialog-content>
4242
<mat-dialog-actions align="end" class="reset-dialog__actions">
43-
<button type="button" mat-stroked-button mat-dialog-close>Close</button>
43+
@if (canClose()) {
44+
<button type="button" mat-stroked-button mat-dialog-close>Close</button>
45+
}
4446
<button type="button" mat-flat-button color="accent"
4547
[cdkCopyToClipboard]="credentialsText"
4648
(cdkCopyToClipboardCopied)="handleCredentialsCopied()">
47-
Copy credentials
49+
@if (copied()) {
50+
<mat-icon class="reset-dialog__copy-check">check</mat-icon>
51+
Credentials copied
52+
} @else {
53+
Copy connection string
54+
}
4855
</button>
4956
</mat-dialog-actions>
5057
}

frontend/src/app/components/hosted-databases/hosted-database-reset-password-dialog/hosted-database-reset-password-dialog.component.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { CdkCopyToClipboard } from '@angular/cdk/clipboard';
22
import { Component, computed, inject, signal } from '@angular/core';
33
import { MatButtonModule } from '@angular/material/button';
44
import { MAT_DIALOG_DATA, MatDialogModule } from '@angular/material/dialog';
5+
import { MatIconModule } from '@angular/material/icon';
56
import posthog from 'posthog-js';
67
import { CreatedHostedDatabase, FoundHostedDatabase } from 'src/app/models/hosted-database';
78
import { HostedDatabaseService } from 'src/app/services/hosted-database.service';
@@ -11,7 +12,7 @@ import { NotificationsService } from 'src/app/services/notifications.service';
1112
selector: 'app-hosted-database-reset-password-dialog',
1213
templateUrl: './hosted-database-reset-password-dialog.component.html',
1314
styleUrls: ['./hosted-database-reset-password-dialog.component.css'],
14-
imports: [MatDialogModule, MatButtonModule, CdkCopyToClipboard],
15+
imports: [MatDialogModule, MatButtonModule, MatIconModule, CdkCopyToClipboard],
1516
})
1617
export class HostedDatabaseResetPasswordDialogComponent {
1718
private _hostedDatabaseService = inject(HostedDatabaseService);
@@ -21,6 +22,8 @@ export class HostedDatabaseResetPasswordDialogComponent {
2122
protected submitting = signal(false);
2223
protected result = signal<CreatedHostedDatabase | null>(null);
2324
protected phase = computed(() => (this.result() ? 'result' : 'confirm'));
25+
protected copied = signal(false);
26+
protected canClose = signal(false);
2427

2528
get credentialsText(): string {
2629
const r = this.result();
@@ -45,5 +48,8 @@ export class HostedDatabaseResetPasswordDialogComponent {
4548

4649
handleCredentialsCopied(): void {
4750
this._notifications.showSuccessSnackbar('New credentials were copied to clipboard.');
51+
this.copied.set(true);
52+
this.canClose.set(true);
53+
setTimeout(() => { this.copied.set(false); }, 2000);
4854
}
4955
}

frontend/src/app/components/hosted-databases/hosted-databases.component.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ export class HostedDatabasesComponent implements OnInit {
6666
width: '32em',
6767
maxWidth: '95vw',
6868
data: db,
69+
disableClose: true,
6970
});
7071
}
7172

0 commit comments

Comments
 (0)