mirror of
https://github.com/bitwarden/browser.git
synced 2024-11-26 12:25:20 +01:00
[feature] Implement scope warning for exports (#688)
* [feature] Add a hasOrganizations() service method * [feature] Add a component to warn users about export scope
This commit is contained in:
parent
1fb3d54014
commit
78b5f15042
@ -0,0 +1,5 @@
|
|||||||
|
<ng-container *ngIf="show">
|
||||||
|
<app-callout type="info" title="{{ scopeConfig.title | i18n }}">
|
||||||
|
{{ scopeConfig.description | i18n: scopeConfig.scopeIdentifier }}
|
||||||
|
</app-callout>
|
||||||
|
</ng-container>
|
43
angular/src/components/export-scope-callout.component.ts
Normal file
43
angular/src/components/export-scope-callout.component.ts
Normal file
@ -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<void> {
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
@ -7,4 +7,5 @@ export abstract class OrganizationService {
|
|||||||
getAll: (userId?: string) => Promise<Organization[]>;
|
getAll: (userId?: string) => Promise<Organization[]>;
|
||||||
save: (orgs: { [id: string]: OrganizationData }) => Promise<any>;
|
save: (orgs: { [id: string]: OrganizationData }) => Promise<any>;
|
||||||
canManageSponsorships: () => Promise<boolean>;
|
canManageSponsorships: () => Promise<boolean>;
|
||||||
|
hasOrganizations: (userId?: string) => Promise<boolean>;
|
||||||
}
|
}
|
||||||
|
@ -47,4 +47,9 @@ export class OrganizationService implements OrganizationServiceAbstraction {
|
|||||||
(o) => o.familySponsorshipAvailable || o.familySponsorshipFriendlyName !== null
|
(o) => o.familySponsorshipAvailable || o.familySponsorshipFriendlyName !== null
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async hasOrganizations(userId?: string): Promise<boolean> {
|
||||||
|
const organizations = await this.getAll(userId);
|
||||||
|
return organizations.length > 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user