mirror of
https://github.com/bitwarden/browser
synced 2025-12-06 00:13:28 +00:00
[PM-18685] Disable MyVault when the Person Ownership policy is true (#13930)
This commit is contained in:
@@ -1,17 +1,23 @@
|
|||||||
<bit-callout type="danger" title="{{ 'vaultExportDisabled' | i18n }}" *ngIf="disabledByPolicy">
|
<bit-callout
|
||||||
|
type="danger"
|
||||||
|
title="{{ 'vaultExportDisabled' | i18n }}"
|
||||||
|
*ngIf="disablePersonalVaultExportPolicy$ | async"
|
||||||
|
>
|
||||||
{{ "personalVaultExportPolicyInEffect" | i18n }}
|
{{ "personalVaultExportPolicyInEffect" | i18n }}
|
||||||
</bit-callout>
|
</bit-callout>
|
||||||
<tools-export-scope-callout
|
<tools-export-scope-callout [organizationId]="organizationId"></tools-export-scope-callout>
|
||||||
[organizationId]="organizationId"
|
|
||||||
*ngIf="!disabledByPolicy"
|
|
||||||
></tools-export-scope-callout>
|
|
||||||
|
|
||||||
<form [formGroup]="exportForm" [bitSubmit]="submit" id="export_form_exportForm">
|
<form [formGroup]="exportForm" [bitSubmit]="submit" id="export_form_exportForm">
|
||||||
<ng-container *ngIf="organizations$ | async as organizations">
|
<ng-container *ngIf="organizations$ | async as organizations">
|
||||||
<bit-form-field *ngIf="organizations.length > 0">
|
<bit-form-field *ngIf="organizations.length > 0">
|
||||||
<bit-label>{{ "exportFrom" | i18n }}</bit-label>
|
<bit-label>{{ "exportFrom" | i18n }}</bit-label>
|
||||||
<bit-select formControlName="vaultSelector">
|
<bit-select formControlName="vaultSelector">
|
||||||
<bit-option [label]="'myVault' | i18n" value="myVault" icon="bwi-user" />
|
<bit-option
|
||||||
|
[label]="'myVault' | i18n"
|
||||||
|
value="myVault"
|
||||||
|
icon="bwi-user"
|
||||||
|
*ngIf="!(disablePersonalOwnershipPolicy$ | async)"
|
||||||
|
/>
|
||||||
<bit-option
|
<bit-option
|
||||||
*ngFor="let o of organizations$ | async"
|
*ngFor="let o of organizations$ | async"
|
||||||
[value]="o.id"
|
[value]="o.id"
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ import {
|
|||||||
Subject,
|
Subject,
|
||||||
switchMap,
|
switchMap,
|
||||||
takeUntil,
|
takeUntil,
|
||||||
|
tap,
|
||||||
} from "rxjs";
|
} from "rxjs";
|
||||||
|
|
||||||
import { CollectionService } from "@bitwarden/admin-console/common";
|
import { CollectionService } from "@bitwarden/admin-console/common";
|
||||||
@@ -154,6 +155,9 @@ export class ExportComponent implements OnInit, OnDestroy, AfterViewInit {
|
|||||||
return this._disabledByPolicy;
|
return this._disabledByPolicy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
disablePersonalVaultExportPolicy$: Observable<boolean>;
|
||||||
|
disablePersonalOwnershipPolicy$: Observable<boolean>;
|
||||||
|
|
||||||
exportForm = this.formBuilder.group({
|
exportForm = this.formBuilder.group({
|
||||||
vaultSelector: [
|
vaultSelector: [
|
||||||
"myVault",
|
"myVault",
|
||||||
@@ -201,15 +205,13 @@ export class ExportComponent implements OnInit, OnDestroy, AfterViewInit {
|
|||||||
this.formDisabled.emit(c === "DISABLED");
|
this.formDisabled.emit(c === "DISABLED");
|
||||||
});
|
});
|
||||||
|
|
||||||
this.policyService
|
// policies
|
||||||
.policyAppliesToActiveUser$(PolicyType.DisablePersonalVaultExport)
|
this.disablePersonalVaultExportPolicy$ = this.policyService.policyAppliesToActiveUser$(
|
||||||
.pipe(takeUntil(this.destroy$))
|
PolicyType.DisablePersonalVaultExport,
|
||||||
.subscribe((policyAppliesToActiveUser) => {
|
);
|
||||||
this._disabledByPolicy = policyAppliesToActiveUser;
|
this.disablePersonalOwnershipPolicy$ = this.policyService.policyAppliesToActiveUser$(
|
||||||
if (this.disabledByPolicy) {
|
PolicyType.PersonalOwnership,
|
||||||
this.exportForm.disable();
|
);
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
merge(
|
merge(
|
||||||
this.exportForm.get("format").valueChanges,
|
this.exportForm.get("format").valueChanges,
|
||||||
@@ -269,13 +271,45 @@ export class ExportComponent implements OnInit, OnDestroy, AfterViewInit {
|
|||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
combineLatest([
|
||||||
|
this.disablePersonalVaultExportPolicy$,
|
||||||
|
this.disablePersonalOwnershipPolicy$,
|
||||||
|
this.organizations$,
|
||||||
|
])
|
||||||
|
.pipe(
|
||||||
|
tap(([disablePersonalVaultExport, disablePersonalOwnership, organizations]) => {
|
||||||
|
this._disabledByPolicy = disablePersonalVaultExport;
|
||||||
|
|
||||||
|
// When personalOwnership is disabled and we have orgs, set the first org as the selected vault
|
||||||
|
if (disablePersonalOwnership && organizations.length > 0) {
|
||||||
|
this.exportForm.enable();
|
||||||
|
this.exportForm.controls.vaultSelector.setValue(organizations[0].id);
|
||||||
|
}
|
||||||
|
|
||||||
|
// When personalOwnership is disabled and we have no orgs, disable the form
|
||||||
|
if (disablePersonalOwnership && organizations.length === 0) {
|
||||||
|
this.exportForm.disable();
|
||||||
|
}
|
||||||
|
|
||||||
|
// When personalVaultExport is disabled, disable the form
|
||||||
|
if (disablePersonalVaultExport) {
|
||||||
|
this.exportForm.disable();
|
||||||
|
}
|
||||||
|
|
||||||
|
// When neither policy is enabled, enable the form and set the default vault to "myVault"
|
||||||
|
if (!disablePersonalVaultExport && !disablePersonalOwnership) {
|
||||||
|
this.exportForm.controls.vaultSelector.setValue("myVault");
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
takeUntil(this.destroy$),
|
||||||
|
)
|
||||||
|
.subscribe();
|
||||||
|
|
||||||
this.exportForm.controls.vaultSelector.valueChanges
|
this.exportForm.controls.vaultSelector.valueChanges
|
||||||
.pipe(takeUntil(this.destroy$))
|
.pipe(takeUntil(this.destroy$))
|
||||||
.subscribe((value) => {
|
.subscribe((value) => {
|
||||||
this.organizationId = value != "myVault" ? value : undefined;
|
this.organizationId = value != "myVault" ? value : undefined;
|
||||||
});
|
});
|
||||||
|
|
||||||
this.exportForm.controls.vaultSelector.setValue("myVault");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ngAfterViewInit(): void {
|
ngAfterViewInit(): void {
|
||||||
@@ -286,6 +320,7 @@ export class ExportComponent implements OnInit, OnDestroy, AfterViewInit {
|
|||||||
|
|
||||||
ngOnDestroy(): void {
|
ngOnDestroy(): void {
|
||||||
this.destroy$.next();
|
this.destroy$.next();
|
||||||
|
this.destroy$.complete();
|
||||||
}
|
}
|
||||||
|
|
||||||
get encryptedFormat() {
|
get encryptedFormat() {
|
||||||
|
|||||||
Reference in New Issue
Block a user