bitwarden-estensione-browser/src/popup/vault/share.component.ts

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

64 lines
1.9 KiB
TypeScript
Raw Normal View History

2021-12-21 20:48:22 +01:00
import { Component } from "@angular/core";
import { ActivatedRoute, Router } from "@angular/router";
2021-12-21 20:48:22 +01:00
import { first } from "rxjs/operators";
2021-12-21 20:48:22 +01:00
import { CipherService } from "jslib-common/abstractions/cipher.service";
import { CollectionService } from "jslib-common/abstractions/collection.service";
import { I18nService } from "jslib-common/abstractions/i18n.service";
import { LogService } from "jslib-common/abstractions/log.service";
import { OrganizationService } from "jslib-common/abstractions/organization.service";
import { PlatformUtilsService } from "jslib-common/abstractions/platformUtils.service";
2021-12-21 20:48:22 +01:00
import { ShareComponent as BaseShareComponent } from "jslib-angular/components/share.component";
@Component({
2021-12-21 20:48:22 +01:00
selector: "app-vault-share",
templateUrl: "share.component.html",
})
export class ShareComponent extends BaseShareComponent {
2021-12-21 20:48:22 +01:00
constructor(
collectionService: CollectionService,
platformUtilsService: PlatformUtilsService,
i18nService: I18nService,
logService: LogService,
cipherService: CipherService,
private route: ActivatedRoute,
private router: Router,
organizationService: OrganizationService
) {
super(
collectionService,
platformUtilsService,
i18nService,
cipherService,
logService,
organizationService
);
}
2021-12-21 20:48:22 +01:00
async ngOnInit() {
this.onSharedCipher.subscribe(() => {
this.router.navigate(["view-cipher", { cipherId: this.cipherId }]);
});
this.route.queryParams.pipe(first()).subscribe(async (params) => {
this.cipherId = params.cipherId;
await this.load();
});
}
2021-12-21 20:48:22 +01:00
async submit(): Promise<boolean> {
const success = await super.submit();
if (success) {
this.cancel();
2019-05-10 20:10:40 +02:00
}
2021-12-21 20:48:22 +01:00
return success;
}
2019-05-10 20:10:40 +02:00
2021-12-21 20:48:22 +01:00
cancel() {
this.router.navigate(["/view-cipher"], {
replaceUrl: true,
queryParams: { cipherId: this.cipher.id },
});
}
}