diff --git a/angular/src/components/export-scope-callout.component.html b/angular/src/components/export-scope-callout.component.html new file mode 100644 index 00000000000..c6b5e1e8523 --- /dev/null +++ b/angular/src/components/export-scope-callout.component.html @@ -0,0 +1,5 @@ + + + {{ scopeConfig.description | i18n: scopeConfig.scopeIdentifier }} + + diff --git a/angular/src/components/export-scope-callout.component.ts b/angular/src/components/export-scope-callout.component.ts new file mode 100644 index 00000000000..40154d728ca --- /dev/null +++ b/angular/src/components/export-scope-callout.component.ts @@ -0,0 +1,43 @@ +import { Component, Input, OnInit } from "@angular/core"; + +import { OrganizationService } from "jslib-common/abstractions/organization.service"; +import { StateService } from "jslib-common/abstractions/state.service"; + +@Component({ + selector: "app-export-scope-callout", + templateUrl: "export-scope-callout.component.html", +}) +export class ExportScopeCalloutComponent implements OnInit { + @Input() organizationId: string = null; + + show: boolean = false; + scopeConfig: { + title: string; + description: string; + scopeIdentifier: string; + }; + + constructor( + protected organizationService: OrganizationService, + protected stateService: StateService + ) {} + + async ngOnInit(): Promise { + if (!(await this.organizationService.hasOrganizations())) { + return; + } + this.scopeConfig = + this.organizationId != null + ? { + title: "exportingOrganizationVaultTitle", + description: "exportingOrganizationVaultDescription", + scopeIdentifier: (await this.organizationService.get(this.organizationId)).name, + } + : { + title: "exportingPersonalVaultTitle", + description: "exportingPersonalVaultDescription", + scopeIdentifier: await this.stateService.getEmail(), + }; + this.show = true; + } +} diff --git a/common/src/abstractions/organization.service.ts b/common/src/abstractions/organization.service.ts index 8c252430d2a..e0b5fde4369 100644 --- a/common/src/abstractions/organization.service.ts +++ b/common/src/abstractions/organization.service.ts @@ -7,4 +7,5 @@ export abstract class OrganizationService { getAll: (userId?: string) => Promise; save: (orgs: { [id: string]: OrganizationData }) => Promise; canManageSponsorships: () => Promise; + hasOrganizations: (userId?: string) => Promise; } diff --git a/common/src/services/organization.service.ts b/common/src/services/organization.service.ts index 08adb072f8c..0ff32e8167e 100644 --- a/common/src/services/organization.service.ts +++ b/common/src/services/organization.service.ts @@ -47,4 +47,9 @@ export class OrganizationService implements OrganizationServiceAbstraction { (o) => o.familySponsorshipAvailable || o.familySponsorshipFriendlyName !== null ); } + + async hasOrganizations(userId?: string): Promise { + const organizations = await this.getAll(userId); + return organizations.length > 0; + } }