mirror of
https://github.com/bitwarden/browser
synced 2025-12-16 16:23:44 +00:00
PM-26439 minor code improvements related to pm 19467 (#16704)
* add support for export-scope-callout.component to conditionally render organizational export message * avoid null comparison and remove explicit undefined type parameter
This commit is contained in:
@@ -9,7 +9,9 @@ import { OrganizationService } from "@bitwarden/common/admin-console/abstraction
|
|||||||
import { AccountService } from "@bitwarden/common/auth/abstractions/account.service";
|
import { AccountService } from "@bitwarden/common/auth/abstractions/account.service";
|
||||||
import { getUserId } from "@bitwarden/common/auth/services/account.service";
|
import { getUserId } from "@bitwarden/common/auth/services/account.service";
|
||||||
import { getById } from "@bitwarden/common/platform/misc/rxjs-operators";
|
import { getById } from "@bitwarden/common/platform/misc/rxjs-operators";
|
||||||
|
import { OrganizationId } from "@bitwarden/common/types/guid";
|
||||||
import { CalloutModule } from "@bitwarden/components";
|
import { CalloutModule } from "@bitwarden/components";
|
||||||
|
import { ExportFormat } from "@bitwarden/vault-export-core";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: "tools-export-scope-callout",
|
selector: "tools-export-scope-callout",
|
||||||
@@ -25,9 +27,9 @@ export class ExportScopeCalloutComponent {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/* Optional OrganizationId, if not provided, it will display individual vault export message */
|
/* Optional OrganizationId, if not provided, it will display individual vault export message */
|
||||||
readonly organizationId = input<string>();
|
readonly organizationId = input<OrganizationId>();
|
||||||
/* Optional export format, determines which individual export description to display */
|
/* Optional export format, determines which individual export description to display */
|
||||||
readonly exportFormat = input<string>();
|
readonly exportFormat = input<ExportFormat>();
|
||||||
/* The description key to use for organizational exports */
|
/* The description key to use for organizational exports */
|
||||||
readonly orgExportDescription = input<string>();
|
readonly orgExportDescription = input<string>();
|
||||||
|
|
||||||
@@ -47,13 +49,13 @@ export class ExportScopeCalloutComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private async getScopeMessage(
|
private async getScopeMessage(
|
||||||
organizationId: string,
|
organizationId: OrganizationId | undefined,
|
||||||
exportFormat: string,
|
exportFormat: ExportFormat | undefined,
|
||||||
orgExportDescription: string,
|
orgExportDescription: string,
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const userId = await firstValueFrom(getUserId(this.accountService.activeAccount$));
|
const userId = await firstValueFrom(getUserId(this.accountService.activeAccount$));
|
||||||
|
|
||||||
if (organizationId != null) {
|
if (organizationId) {
|
||||||
// exporting from organizational vault
|
// exporting from organizational vault
|
||||||
const org = await firstValueFrom(
|
const org = await firstValueFrom(
|
||||||
this.organizationService.organizations$(userId).pipe(getById(organizationId)),
|
this.organizationService.organizations$(userId).pipe(getById(organizationId)),
|
||||||
@@ -64,18 +66,19 @@ export class ExportScopeCalloutComponent {
|
|||||||
description: orgExportDescription,
|
description: orgExportDescription,
|
||||||
scopeIdentifier: org?.name ?? "",
|
scopeIdentifier: org?.name ?? "",
|
||||||
};
|
};
|
||||||
} else {
|
|
||||||
this.scopeConfig = {
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// exporting from individual vault
|
// exporting from individual vault
|
||||||
|
this.scopeConfig = {
|
||||||
title: "exportingPersonalVaultTitle",
|
title: "exportingPersonalVaultTitle",
|
||||||
description:
|
description:
|
||||||
exportFormat === "zip"
|
exportFormat === "zip"
|
||||||
? "exportingIndividualVaultWithAttachmentsDescription"
|
? "exportingIndividualVaultWithAttachmentsDescription"
|
||||||
: "exportingIndividualVaultDescription",
|
: "exportingIndividualVaultDescription",
|
||||||
scopeIdentifier:
|
scopeIdentifier:
|
||||||
(await firstValueFrom(this.accountService.activeAccount$.pipe(map((a) => a?.email)))) ??
|
(await firstValueFrom(this.accountService.activeAccount$.pipe(map((a) => a?.email)))) ?? "",
|
||||||
"",
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user