mirror of
https://github.com/bitwarden/browser.git
synced 2024-11-06 09:20:43 +01:00
[PM-8780] Added validation to only display organizations with managed collections (#10065)
* Added validation to only display organizations with managed collections on the export org selector * using the decryptedCollection$ directly instead of creating a new observable from the encryptedCollections array
This commit is contained in:
parent
b5447f326c
commit
94d6cc3ef1
@ -9,7 +9,7 @@ import {
|
|||||||
ViewChild,
|
ViewChild,
|
||||||
} from "@angular/core";
|
} from "@angular/core";
|
||||||
import { ReactiveFormsModule, UntypedFormBuilder, Validators } from "@angular/forms";
|
import { ReactiveFormsModule, UntypedFormBuilder, Validators } from "@angular/forms";
|
||||||
import { map, merge, Observable, startWith, Subject, takeUntil } from "rxjs";
|
import { combineLatest, map, merge, Observable, startWith, Subject, takeUntil } from "rxjs";
|
||||||
|
|
||||||
import { JslibModule } from "@bitwarden/angular/jslib.module";
|
import { JslibModule } from "@bitwarden/angular/jslib.module";
|
||||||
import { PasswordStrengthV2Component } from "@bitwarden/angular/tools/password-strength/password-strength-v2.component";
|
import { PasswordStrengthV2Component } from "@bitwarden/angular/tools/password-strength/password-strength-v2.component";
|
||||||
@ -25,6 +25,7 @@ import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.servic
|
|||||||
import { LogService } from "@bitwarden/common/platform/abstractions/log.service";
|
import { LogService } from "@bitwarden/common/platform/abstractions/log.service";
|
||||||
import { Utils } from "@bitwarden/common/platform/misc/utils";
|
import { Utils } from "@bitwarden/common/platform/misc/utils";
|
||||||
import { EncryptedExportType } from "@bitwarden/common/tools/enums/encrypted-export-type.enum";
|
import { EncryptedExportType } from "@bitwarden/common/tools/enums/encrypted-export-type.enum";
|
||||||
|
import { CollectionService } from "@bitwarden/common/vault/abstractions/collection.service";
|
||||||
import {
|
import {
|
||||||
AsyncActionsModule,
|
AsyncActionsModule,
|
||||||
BitSubmitDirective,
|
BitSubmitDirective,
|
||||||
@ -160,6 +161,7 @@ export class ExportComponent implements OnInit, OnDestroy {
|
|||||||
protected fileDownloadService: FileDownloadService,
|
protected fileDownloadService: FileDownloadService,
|
||||||
protected dialogService: DialogService,
|
protected dialogService: DialogService,
|
||||||
protected organizationService: OrganizationService,
|
protected organizationService: OrganizationService,
|
||||||
|
private collectionService: CollectionService,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
async ngOnInit() {
|
async ngOnInit() {
|
||||||
@ -196,8 +198,21 @@ export class ExportComponent implements OnInit, OnDestroy {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.organizations$ = this.organizationService.memberOrganizations$.pipe(
|
this.organizations$ = combineLatest({
|
||||||
map((orgs) => orgs.sort(Utils.getSortFunction(this.i18nService, "name"))),
|
collections: this.collectionService.decryptedCollections$,
|
||||||
|
memberOrganizations: this.organizationService.memberOrganizations$,
|
||||||
|
}).pipe(
|
||||||
|
map(({ collections, memberOrganizations }) => {
|
||||||
|
const managedCollectionsOrgIds = new Set(
|
||||||
|
collections.filter((c) => c.manage).map((c) => c.organizationId),
|
||||||
|
);
|
||||||
|
// Filter organizations that exist in managedCollectionsOrgIds
|
||||||
|
const filteredOrgs = memberOrganizations.filter((org) =>
|
||||||
|
managedCollectionsOrgIds.has(org.id),
|
||||||
|
);
|
||||||
|
// Sort the filtered organizations based on the name
|
||||||
|
return filteredOrgs.sort(Utils.getSortFunction(this.i18nService, "name"));
|
||||||
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
this.exportForm.controls.vaultSelector.valueChanges
|
this.exportForm.controls.vaultSelector.valueChanges
|
||||||
|
Loading…
Reference in New Issue
Block a user