mirror of
https://github.com/bitwarden/browser
synced 2025-12-30 15:13:32 +00:00
[AC-1782] Flexible collections import behavior in Password Manager and Admin Console (#6888)
* Added logic to only return organisations where user has import permissions and collections that he manages on Import * Changed the UnassignedCollections validation logic * Added validation to check if the user is coming from AdminConsole on the import component * Added import collection service abstraction to allow get admin collections * Corrected feature flag reads on import component * Refactor import component methods ngOnInit and performImport to improve codescene Using FeatureFlag Observable * Modified validation to allow import if user has organizations to import into * Using the new organization flexiblecollections property on import * Created collection-admin-import.service to return all the org collections to the import on Admin Console * Small changes on import flexible collections * Fix linting issues * changed canAccessImport rules and deprecated canAccessImportExport * Validating if user canAccessImportExport instead of admin before calling the handleOrganizationImportInit. * AC-2095 - Corrected getAllAdminCollections from ImportCollectionAdminService to properly get all the collections on AdminConsole * Reverting AC-2095 --------- Co-authored-by: Daniel James Smith <djsmith85@users.noreply.github.com>
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
import { CollectionView } from "@bitwarden/common/vault/models/view/collection.view";
|
||||
|
||||
export abstract class ImportCollectionServiceAbstraction {
|
||||
getAllAdminCollections: (organizationId: string) => Promise<CollectionView[]>;
|
||||
}
|
||||
@@ -152,9 +152,8 @@ export class ImportService implements ImportServiceAbstraction {
|
||||
Utils.isNullOrWhitespace(selectedImportTarget) &&
|
||||
!canAccessImportExport
|
||||
) {
|
||||
const hasUnassignedCollections = importResult.ciphers.some(
|
||||
(c) => !Array.isArray(c.collectionIds) || c.collectionIds.length == 0,
|
||||
);
|
||||
const hasUnassignedCollections =
|
||||
importResult.collectionRelationships.length < importResult.ciphers.length;
|
||||
if (hasUnassignedCollections) {
|
||||
throw new Error(this.i18nService.t("importUnassignedItemsError"));
|
||||
}
|
||||
|
||||
@@ -3,3 +3,5 @@ export { ImportApiService } from "./import-api.service";
|
||||
|
||||
export { ImportServiceAbstraction } from "./import.service.abstraction";
|
||||
export { ImportService } from "./import.service";
|
||||
|
||||
export { ImportCollectionServiceAbstraction } from "./import-collection.service.abstraction";
|
||||
|
||||
Reference in New Issue
Block a user