Skip to content

Commit aa2b0a9

Browse files
authored
Add a copy button to browser ext about dialog (bitwarden#13465)
Add a copy button to browser extension about dialog for quickly copying the version number now that we have 3 different values we'd like to collect.
1 parent 2425cda commit aa2b0a9

File tree

3 files changed

+54
-28
lines changed

3 files changed

+54
-28
lines changed

apps/browser/src/_locales/en/messages.json

+4
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,10 @@
176176
"copyNotes": {
177177
"message": "Copy notes"
178178
},
179+
"copy": {
180+
"message": "Copy",
181+
"description": "Copy to clipboard"
182+
},
179183
"fill":{
180184
"message": "Fill",
181185
"description": "This string is used on the vault page to indicate autofilling. Horizontal space is limited in the interface here so try and keep translations as concise as possible."

apps/browser/src/tools/popup/settings/about-dialog/about-dialog.component.html

+31-25
Original file line numberDiff line numberDiff line change
@@ -5,43 +5,49 @@
55
<div bitDialogTitle>Bitwarden</div>
66
<div bitDialogContent>
77
<p>&copy; Bitwarden Inc. 2015-{{ year }}</p>
8-
<p class="user-select">{{ "version" | i18n }}: {{ version$ | async }}</p>
9-
<p class="user-select">SDK: {{ sdkVersion$ | async }}</p>
10-
<ng-container *ngIf="data$ | async as data">
11-
<p *ngIf="data.isCloud">
12-
{{ "serverVersion" | i18n }}: {{ data.serverConfig?.version }}
13-
<span *ngIf="!data.serverConfig.isValid()">
14-
({{ "lastSeenOn" | i18n: (data.serverConfig.utcDate | date: "mediumDate") }})
15-
</span>
16-
</p>
178

18-
<ng-container *ngIf="!data.isCloud">
19-
<ng-container *ngIf="data.serverConfig.server">
20-
<p class="user-select">
21-
{{ "serverVersion" | i18n }} <small>({{ "thirdParty" | i18n }})</small>:
9+
<div #version class="user-select">
10+
<p>{{ "version" | i18n }}: {{ version$ | async }}</p>
11+
<p>SDK: {{ sdkVersion$ | async }}</p>
12+
<ng-container *ngIf="data$ | async as data">
13+
<p *ngIf="data.isCloud">
14+
{{ "serverVersion" | i18n }}: {{ data.serverConfig?.version }}
15+
<span *ngIf="!data.serverConfig.isValid()">
16+
({{ "lastSeenOn" | i18n: (data.serverConfig.utcDate | date: "mediumDate") }})
17+
</span>
18+
</p>
19+
20+
<ng-container *ngIf="!data.isCloud">
21+
<ng-container *ngIf="data.serverConfig.server">
22+
<p>
23+
{{ "serverVersion" | i18n }} <small>({{ "thirdParty" | i18n }})</small>:
24+
{{ data.serverConfig?.version }}
25+
<span *ngIf="!data.serverConfig.isValid()">
26+
({{ "lastSeenOn" | i18n: (data.serverConfig.utcDate | date: "mediumDate") }})
27+
</span>
28+
</p>
29+
<div>
30+
<small>{{ "thirdPartyServerMessage" | i18n: data.serverConfig.server?.name }}</small>
31+
</div>
32+
</ng-container>
33+
34+
<p *ngIf="!data.serverConfig.server">
35+
{{ "serverVersion" | i18n }} <small>({{ "selfHostedServer" | i18n }})</small>:
2236
{{ data.serverConfig?.version }}
2337
<span *ngIf="!data.serverConfig.isValid()">
2438
({{ "lastSeenOn" | i18n: (data.serverConfig.utcDate | date: "mediumDate") }})
2539
</span>
2640
</p>
27-
<div>
28-
<small>{{ "thirdPartyServerMessage" | i18n: data.serverConfig.server?.name }}</small>
29-
</div>
3041
</ng-container>
31-
32-
<p class="user-select" *ngIf="!data.serverConfig.server">
33-
{{ "serverVersion" | i18n }} <small>({{ "selfHostedServer" | i18n }})</small>:
34-
{{ data.serverConfig?.version }}
35-
<span *ngIf="!data.serverConfig.isValid()">
36-
({{ "lastSeenOn" | i18n: (data.serverConfig.utcDate | date: "mediumDate") }})
37-
</span>
38-
</p>
3942
</ng-container>
40-
</ng-container>
43+
</div>
4144
</div>
4245
<div bitDialogFooter>
4346
<button bitButton bitDialogClose buttonType="primary" type="button">
4447
{{ "close" | i18n }}
4548
</button>
49+
<button bitButton type="button" (click)="copyVersion()">
50+
{{ "copy" | i18n }}
51+
</button>
4652
</div>
4753
</bit-simple-dialog>

apps/browser/src/tools/popup/settings/about-dialog/about-dialog.component.ts

+19-3
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,24 @@
1+
import { DialogRef } from "@angular/cdk/dialog";
12
import { CommonModule } from "@angular/common";
2-
import { Component } from "@angular/core";
3+
import { Component, ElementRef, ViewChild } from "@angular/core";
34
import { Observable, combineLatest, defer, map } from "rxjs";
45

56
import { JslibModule } from "@bitwarden/angular/jslib.module";
67
import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service";
78
import { EnvironmentService } from "@bitwarden/common/platform/abstractions/environment.service";
9+
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
810
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
911
import { SdkService } from "@bitwarden/common/platform/abstractions/sdk/sdk.service";
10-
import { ButtonModule, DialogModule } from "@bitwarden/components";
12+
import { ButtonModule, DialogModule, ToastService, TypographyModule } from "@bitwarden/components";
1113

1214
@Component({
1315
templateUrl: "about-dialog.component.html",
1416
standalone: true,
15-
imports: [CommonModule, JslibModule, DialogModule, ButtonModule],
17+
imports: [CommonModule, JslibModule, DialogModule, ButtonModule, TypographyModule],
1618
})
1719
export class AboutDialogComponent {
20+
@ViewChild("version") protected version!: ElementRef;
21+
1822
protected year = new Date().getFullYear();
1923
protected version$: Observable<string>;
2024

@@ -26,11 +30,23 @@ export class AboutDialogComponent {
2630
protected sdkVersion$ = this.sdkService.version$;
2731

2832
constructor(
33+
private dialogRef: DialogRef,
2934
private configService: ConfigService,
3035
private environmentService: EnvironmentService,
3136
private platformUtilsService: PlatformUtilsService,
37+
private toastService: ToastService,
38+
private i18nService: I18nService,
3239
private sdkService: SdkService,
3340
) {
3441
this.version$ = defer(() => this.platformUtilsService.getApplicationVersion());
3542
}
43+
44+
protected copyVersion() {
45+
this.platformUtilsService.copyToClipboard(this.version.nativeElement.innerText);
46+
this.toastService.showToast({
47+
message: this.i18nService.t("copySuccessful"),
48+
variant: "success",
49+
});
50+
this.dialogRef.close();
51+
}
3652
}

0 commit comments

Comments
 (0)