1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-16 00:03:56 +00:00

[EC-143] [BEEEP] Allow linking to ciphers (#1579)

Co-authored-by: Matt Gibson <mgibson@bitwarden.com>
This commit is contained in:
Oscar Hinton
2022-04-25 15:41:44 +02:00
committed by GitHub
parent 705251fbe2
commit 0444b78ad1
30 changed files with 246 additions and 88 deletions

View File

@@ -12,6 +12,7 @@ import { first } from "rxjs/operators";
import { ModalService } from "jslib-angular/services/modal.service";
import { BroadcasterService } from "jslib-common/abstractions/broadcaster.service";
import { CipherService } from "jslib-common/abstractions/cipher.service";
import { CryptoService } from "jslib-common/abstractions/crypto.service";
import { I18nService } from "jslib-common/abstractions/i18n.service";
import { MessagingService } from "jslib-common/abstractions/messaging.service";
@@ -85,7 +86,8 @@ export class VaultComponent implements OnInit, OnDestroy {
private ngZone: NgZone,
private stateService: StateService,
private organizationService: OrganizationService,
private providerService: ProviderService
private providerService: ProviderService,
private cipherService: CipherService
) {}
async ngOnInit() {
@@ -136,6 +138,24 @@ export class VaultComponent implements OnInit, OnDestroy {
}
}
this.route.queryParams.subscribe(async (params) => {
if (params.cipherId) {
if ((await this.cipherService.get(params.cipherId)) != null) {
this.editCipherId(params.cipherId);
} else {
this.platformUtilsService.showToast(
"error",
this.i18nService.t("errorOccurred"),
this.i18nService.t("unknownCipher")
);
this.router.navigate([], {
queryParams: { cipherId: null },
queryParamsHandling: "merge",
});
}
}
});
this.broadcasterService.subscribe(BroadcasterSubscriptionId, (message: any) => {
this.ngZone.run(async () => {
switch (message.command) {
@@ -334,11 +354,15 @@ export class VaultComponent implements OnInit, OnDestroy {
}
async editCipher(cipher: CipherView) {
return this.editCipherId(cipher?.id);
}
async editCipherId(id: string) {
const [modal, childComponent] = await this.modalService.openViewRef(
AddEditComponent,
this.cipherAddEditModalRef,
(comp) => {
comp.cipherId = cipher == null ? null : cipher.id;
comp.cipherId = id;
comp.onSavedCipher.subscribe(async () => {
modal.close();
await this.ciphersComponent.refresh();
@@ -354,6 +378,11 @@ export class VaultComponent implements OnInit, OnDestroy {
}
);
modal.onClosedPromise().then(() => {
this.route.params;
this.router.navigate([], { queryParams: { cipherId: null }, queryParamsHandling: "merge" });
});
return childComponent;
}
@@ -388,6 +417,7 @@ export class VaultComponent implements OnInit, OnDestroy {
this.router.navigate([], {
relativeTo: this.route,
queryParams: queryParams,
queryParamsHandling: "merge",
replaceUrl: true,
});
}