mirror of
https://github.com/bitwarden/browser
synced 2025-12-26 05:03:33 +00:00
* [AC-1707] Add feature flag * [AC-1707] Prevent loading ciphers for provider users in the org vault when the feature flag is enabled * [AC-1707] Ensure new canEditAllCiphers logic only applies to organizations that have FC enabled * [AC-1707] Update editAllCiphers helper to check for restrictProviderAccess feature flag * [AC-1707] Remove un-used vaultFilterComponent reference * [AC-1707] Hide vault filter for providers * [AC-1707] Add search to vault header for provider users * [AC-1707] Hide New Item button for Providers when restrict provider access feature flag is enabled * [AC-1707] Remove leftover debug statement * [AC-1707] Update canEditAllCiphers references to consider the restrictProviderAccessFlag * [AC-1707] Fix collections component changes from main * [AC-1707] Fix some feature flag issues from merge with main * [AC-1707] Avoid 'readonly' collection dialog for providers * [AC-1707] Fix broken Browser component * [AC-1707] Fix broken Desktop component * [AC-1707] Add restrict provider flag to add access badge logic
94 lines
3.0 KiB
TypeScript
94 lines
3.0 KiB
TypeScript
import { Jsonify } from "type-fest";
|
|
|
|
import { Organization } from "../../../admin-console/models/domain/organization";
|
|
import { View } from "../../../models/view/view";
|
|
import { Collection } from "../domain/collection";
|
|
import { ITreeNodeObject } from "../domain/tree-node";
|
|
import { CollectionAccessDetailsResponse } from "../response/collection.response";
|
|
|
|
export const NestingDelimiter = "/";
|
|
|
|
export class CollectionView implements View, ITreeNodeObject {
|
|
id: string = null;
|
|
organizationId: string = null;
|
|
name: string = null;
|
|
externalId: string = null;
|
|
// readOnly applies to the items within a collection
|
|
readOnly: boolean = null;
|
|
hidePasswords: boolean = null;
|
|
manage: boolean = null;
|
|
addAccess: boolean = false;
|
|
assigned: boolean = null;
|
|
|
|
constructor(c?: Collection | CollectionAccessDetailsResponse) {
|
|
if (!c) {
|
|
return;
|
|
}
|
|
|
|
this.id = c.id;
|
|
this.organizationId = c.organizationId;
|
|
this.externalId = c.externalId;
|
|
if (c instanceof Collection) {
|
|
this.readOnly = c.readOnly;
|
|
this.hidePasswords = c.hidePasswords;
|
|
this.manage = c.manage;
|
|
this.assigned = true;
|
|
}
|
|
if (c instanceof CollectionAccessDetailsResponse) {
|
|
this.assigned = c.assigned;
|
|
}
|
|
}
|
|
|
|
canEditItems(
|
|
org: Organization,
|
|
v1FlexibleCollections: boolean,
|
|
restrictProviderAccess: boolean,
|
|
): boolean {
|
|
if (org != null && org.id !== this.organizationId) {
|
|
throw new Error(
|
|
"Id of the organization provided does not match the org id of the collection.",
|
|
);
|
|
}
|
|
|
|
if (org?.flexibleCollections) {
|
|
return (
|
|
org?.canEditAllCiphers(v1FlexibleCollections, restrictProviderAccess) ||
|
|
this.manage ||
|
|
(this.assigned && !this.readOnly)
|
|
);
|
|
}
|
|
|
|
return org?.canEditAnyCollection(false) || (org?.canEditAssignedCollections && this.assigned);
|
|
}
|
|
|
|
// For editing collection details, not the items within it.
|
|
canEdit(org: Organization, flexibleCollectionsV1Enabled: boolean): boolean {
|
|
if (org != null && org.id !== this.organizationId) {
|
|
throw new Error(
|
|
"Id of the organization provided does not match the org id of the collection.",
|
|
);
|
|
}
|
|
|
|
return org?.flexibleCollections
|
|
? org?.canEditAnyCollection(flexibleCollectionsV1Enabled) || this.manage
|
|
: org?.canEditAnyCollection(flexibleCollectionsV1Enabled) || org?.canEditAssignedCollections;
|
|
}
|
|
|
|
// For deleting a collection, not the items within it.
|
|
canDelete(org: Organization): boolean {
|
|
if (org != null && org.id !== this.organizationId) {
|
|
throw new Error(
|
|
"Id of the organization provided does not match the org id of the collection.",
|
|
);
|
|
}
|
|
|
|
return org?.flexibleCollections
|
|
? org?.canDeleteAnyCollection || (!org?.limitCollectionCreationDeletion && this.manage)
|
|
: org?.canDeleteAnyCollection || org?.canDeleteAssignedCollections;
|
|
}
|
|
|
|
static fromJSON(obj: Jsonify<CollectionView>) {
|
|
return Object.assign(new CollectionView(new Collection()), obj);
|
|
}
|
|
}
|