mirror of
https://github.com/bitwarden/browser
synced 2025-12-12 06:13:38 +00:00
[SM-520] add secret copy actions (#4887)
This commit is contained in:
@@ -57,6 +57,8 @@
|
|||||||
(deleteSecretsEvent)="openDeleteSecret($event)"
|
(deleteSecretsEvent)="openDeleteSecret($event)"
|
||||||
(newSecretEvent)="openNewSecretDialog()"
|
(newSecretEvent)="openNewSecretDialog()"
|
||||||
(editSecretEvent)="openEditSecret($event)"
|
(editSecretEvent)="openEditSecret($event)"
|
||||||
|
(copySecretNameEvent)="copySecretName($event)"
|
||||||
|
(copySecretValueEvent)="copySecretValue($event)"
|
||||||
[secrets]="view.latestSecrets"
|
[secrets]="view.latestSecrets"
|
||||||
></sm-secrets-list>
|
></sm-secrets-list>
|
||||||
<div *ngIf="view.allSecrets.length > 0" class="tw-ml-auto tw-mt-4 tw-max-w-max">
|
<div *ngIf="view.allSecrets.length > 0" class="tw-ml-auto tw-mt-4 tw-max-w-max">
|
||||||
|
|||||||
@@ -11,7 +11,9 @@ import {
|
|||||||
distinct,
|
distinct,
|
||||||
} from "rxjs";
|
} from "rxjs";
|
||||||
|
|
||||||
|
import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
|
||||||
import { OrganizationService } from "@bitwarden/common/abstractions/organization/organization.service.abstraction";
|
import { OrganizationService } from "@bitwarden/common/abstractions/organization/organization.service.abstraction";
|
||||||
|
import { PlatformUtilsService } from "@bitwarden/common/abstractions/platformUtils.service";
|
||||||
import { DialogService } from "@bitwarden/components";
|
import { DialogService } from "@bitwarden/components";
|
||||||
|
|
||||||
import { ProjectListView } from "../models/view/project-list.view";
|
import { ProjectListView } from "../models/view/project-list.view";
|
||||||
@@ -75,7 +77,9 @@ export class OverviewComponent implements OnInit, OnDestroy {
|
|||||||
private secretService: SecretService,
|
private secretService: SecretService,
|
||||||
private serviceAccountService: ServiceAccountService,
|
private serviceAccountService: ServiceAccountService,
|
||||||
private dialogService: DialogService,
|
private dialogService: DialogService,
|
||||||
private organizationService: OrganizationService
|
private organizationService: OrganizationService,
|
||||||
|
private platformUtilsService: PlatformUtilsService,
|
||||||
|
private i18nService: I18nService
|
||||||
) {
|
) {
|
||||||
/**
|
/**
|
||||||
* We want to remount the `sm-onboarding` component on route change.
|
* We want to remount the `sm-onboarding` component on route change.
|
||||||
@@ -222,4 +226,23 @@ export class OverviewComponent implements OnInit, OnDestroy {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
copySecretName(name: string) {
|
||||||
|
this.platformUtilsService.copyToClipboard(name);
|
||||||
|
this.platformUtilsService.showToast(
|
||||||
|
"success",
|
||||||
|
null,
|
||||||
|
this.i18nService.t("valueCopied", this.i18nService.t("name"))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
async copySecretValue(id: string) {
|
||||||
|
const secret = await this.secretService.getBySecretId(id);
|
||||||
|
this.platformUtilsService.copyToClipboard(secret.value);
|
||||||
|
this.platformUtilsService.showToast(
|
||||||
|
"success",
|
||||||
|
null,
|
||||||
|
this.i18nService.t("valueCopied", this.i18nService.t("value"))
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,8 @@
|
|||||||
(deleteSecretsEvent)="openDeleteSecret($event)"
|
(deleteSecretsEvent)="openDeleteSecret($event)"
|
||||||
(newSecretEvent)="openNewSecretDialog()"
|
(newSecretEvent)="openNewSecretDialog()"
|
||||||
(editSecretEvent)="openEditSecret($event)"
|
(editSecretEvent)="openEditSecret($event)"
|
||||||
|
(copySecretNameEvent)="copySecretName($event)"
|
||||||
|
(copySecretValueEvent)="copySecretValue($event)"
|
||||||
[secrets]="secrets"
|
[secrets]="secrets"
|
||||||
></sm-secrets-list>
|
></sm-secrets-list>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ import { Component } from "@angular/core";
|
|||||||
import { ActivatedRoute } from "@angular/router";
|
import { ActivatedRoute } from "@angular/router";
|
||||||
import { combineLatestWith, Observable, startWith, switchMap } from "rxjs";
|
import { combineLatestWith, Observable, startWith, switchMap } from "rxjs";
|
||||||
|
|
||||||
|
import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
|
||||||
|
import { PlatformUtilsService } from "@bitwarden/common/abstractions/platformUtils.service";
|
||||||
import { DialogService } from "@bitwarden/components";
|
import { DialogService } from "@bitwarden/components";
|
||||||
|
|
||||||
import { SecretListView } from "../../models/view/secret-list.view";
|
import { SecretListView } from "../../models/view/secret-list.view";
|
||||||
@@ -29,7 +31,9 @@ export class ProjectSecretsComponent {
|
|||||||
constructor(
|
constructor(
|
||||||
private route: ActivatedRoute,
|
private route: ActivatedRoute,
|
||||||
private secretService: SecretService,
|
private secretService: SecretService,
|
||||||
private dialogService: DialogService
|
private dialogService: DialogService,
|
||||||
|
private platformUtilsService: PlatformUtilsService,
|
||||||
|
private i18nService: I18nService
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
@@ -75,4 +79,23 @@ export class ProjectSecretsComponent {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
copySecretName(name: string) {
|
||||||
|
this.platformUtilsService.copyToClipboard(name);
|
||||||
|
this.platformUtilsService.showToast(
|
||||||
|
"success",
|
||||||
|
null,
|
||||||
|
this.i18nService.t("valueCopied", this.i18nService.t("name"))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
async copySecretValue(id: string) {
|
||||||
|
const secret = await this.secretService.getBySecretId(id);
|
||||||
|
this.platformUtilsService.copyToClipboard(secret.value);
|
||||||
|
this.platformUtilsService.showToast(
|
||||||
|
"success",
|
||||||
|
null,
|
||||||
|
this.i18nService.t("valueCopied", this.i18nService.t("value"))
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,8 @@
|
|||||||
(deleteSecretsEvent)="openDeleteSecret($event)"
|
(deleteSecretsEvent)="openDeleteSecret($event)"
|
||||||
(newSecretEvent)="openNewSecretDialog()"
|
(newSecretEvent)="openNewSecretDialog()"
|
||||||
(editSecretEvent)="openEditSecret($event)"
|
(editSecretEvent)="openEditSecret($event)"
|
||||||
|
(copySecretNameEvent)="copySecretName($event)"
|
||||||
|
(copySecretValueEvent)="copySecretValue($event)"
|
||||||
[secrets]="secrets$ | async"
|
[secrets]="secrets$ | async"
|
||||||
[search]="search"
|
[search]="search"
|
||||||
></sm-secrets-list>
|
></sm-secrets-list>
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ import { Component, OnInit } from "@angular/core";
|
|||||||
import { ActivatedRoute } from "@angular/router";
|
import { ActivatedRoute } from "@angular/router";
|
||||||
import { combineLatestWith, Observable, startWith, switchMap } from "rxjs";
|
import { combineLatestWith, Observable, startWith, switchMap } from "rxjs";
|
||||||
|
|
||||||
|
import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
|
||||||
|
import { PlatformUtilsService } from "@bitwarden/common/abstractions/platformUtils.service";
|
||||||
import { DialogService } from "@bitwarden/components";
|
import { DialogService } from "@bitwarden/components";
|
||||||
|
|
||||||
import { SecretListView } from "../models/view/secret-list.view";
|
import { SecretListView } from "../models/view/secret-list.view";
|
||||||
@@ -30,7 +32,9 @@ export class SecretsComponent implements OnInit {
|
|||||||
constructor(
|
constructor(
|
||||||
private route: ActivatedRoute,
|
private route: ActivatedRoute,
|
||||||
private secretService: SecretService,
|
private secretService: SecretService,
|
||||||
private dialogService: DialogService
|
private dialogService: DialogService,
|
||||||
|
private platformUtilsService: PlatformUtilsService,
|
||||||
|
private i18nService: I18nService
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
@@ -78,4 +82,23 @@ export class SecretsComponent implements OnInit {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
copySecretName(name: string) {
|
||||||
|
this.platformUtilsService.copyToClipboard(name);
|
||||||
|
this.platformUtilsService.showToast(
|
||||||
|
"success",
|
||||||
|
null,
|
||||||
|
this.i18nService.t("valueCopied", this.i18nService.t("name"))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
async copySecretValue(id: string) {
|
||||||
|
const secret = await this.secretService.getBySecretId(id);
|
||||||
|
this.platformUtilsService.copyToClipboard(secret.value);
|
||||||
|
this.platformUtilsService.showToast(
|
||||||
|
"success",
|
||||||
|
null,
|
||||||
|
this.i18nService.t("valueCopied", this.i18nService.t("value"))
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -97,7 +97,7 @@
|
|||||||
<i class="bwi bwi-fw bwi-pencil" aria-hidden="true"></i>
|
<i class="bwi bwi-fw bwi-pencil" aria-hidden="true"></i>
|
||||||
{{ "editSecret" | i18n }}
|
{{ "editSecret" | i18n }}
|
||||||
</button>
|
</button>
|
||||||
<button type="button" bitMenuItem (click)="copySecretNameEvent.emit(secret.id)">
|
<button type="button" bitMenuItem (click)="copySecretNameEvent.emit(secret.name)">
|
||||||
<i class="bwi bwi-fw bwi-clone" aria-hidden="true"></i>
|
<i class="bwi bwi-fw bwi-clone" aria-hidden="true"></i>
|
||||||
{{ "copySecretName" | i18n }}
|
{{ "copySecretName" | i18n }}
|
||||||
</button>
|
</button>
|
||||||
|
|||||||
Reference in New Issue
Block a user