1
0
mirror of https://github.com/bitwarden/browser synced 2026-01-08 03:23:50 +00:00

[PM-20633] rename personal ownership (#15228)

* sensible renames

* renames

* clean up comments
This commit is contained in:
Brandon Treston
2025-06-24 09:31:40 -04:00
committed by GitHub
parent fa23a905e0
commit 1c237a3753
37 changed files with 170 additions and 162 deletions

View File

@@ -175,7 +175,7 @@ export class VaultFilterComponent implements OnInit, OnDestroy {
merge(
this.policyService.policiesByType$(PolicyType.SingleOrg, userId).pipe(getFirstPolicy),
this.policyService
.policiesByType$(PolicyType.PersonalOwnership, userId)
.policiesByType$(PolicyType.OrganizationDataOwnership, userId)
.pipe(getFirstPolicy),
),
),
@@ -268,7 +268,7 @@ export class VaultFilterComponent implements OnInit, OnDestroy {
this.accountService.activeAccount$.pipe(
getUserId,
switchMap((userId) =>
this.policyService.policyAppliesToUser$(PolicyType.PersonalOwnership, userId),
this.policyService.policyAppliesToUser$(PolicyType.OrganizationDataOwnership, userId),
),
),
);

View File

@@ -36,7 +36,7 @@ describe("vault filter service", () => {
let folderViews: ReplaySubject<FolderView[]>;
let collectionViews: ReplaySubject<CollectionView[]>;
let cipherViews: ReplaySubject<CipherView[]>;
let personalOwnershipPolicy: ReplaySubject<boolean>;
let organizationDataOwnershipPolicy: ReplaySubject<boolean>;
let singleOrgPolicy: ReplaySubject<boolean>;
let stateProvider: FakeStateProvider;
@@ -59,15 +59,15 @@ describe("vault filter service", () => {
folderViews = new ReplaySubject<FolderView[]>(1);
collectionViews = new ReplaySubject<CollectionView[]>(1);
cipherViews = new ReplaySubject<CipherView[]>(1);
personalOwnershipPolicy = new ReplaySubject<boolean>(1);
organizationDataOwnershipPolicy = new ReplaySubject<boolean>(1);
singleOrgPolicy = new ReplaySubject<boolean>(1);
organizationService.memberOrganizations$.mockReturnValue(organizations);
folderService.folderViews$.mockReturnValue(folderViews);
collectionService.decryptedCollections$ = collectionViews;
policyService.policyAppliesToUser$
.calledWith(PolicyType.PersonalOwnership, mockUserId)
.mockReturnValue(personalOwnershipPolicy);
.calledWith(PolicyType.OrganizationDataOwnership, mockUserId)
.mockReturnValue(organizationDataOwnershipPolicy);
policyService.policyAppliesToUser$
.calledWith(PolicyType.SingleOrg, mockUserId)
.mockReturnValue(singleOrgPolicy);
@@ -113,7 +113,7 @@ describe("vault filter service", () => {
beforeEach(() => {
const storedOrgs = [createOrganization("1", "org1"), createOrganization("2", "org2")];
organizations.next(storedOrgs);
personalOwnershipPolicy.next(false);
organizationDataOwnershipPolicy.next(false);
singleOrgPolicy.next(false);
});
@@ -125,8 +125,8 @@ describe("vault filter service", () => {
expect(tree.children.find((o) => o.node.name === "org2"));
});
it("hides My Vault if personal ownership policy is enabled", async () => {
personalOwnershipPolicy.next(true);
it("hides My Vault if organization data ownership policy is enabled", async () => {
organizationDataOwnershipPolicy.next(true);
const tree = await firstValueFrom(vaultFilterService.organizationTree$);
@@ -144,9 +144,9 @@ describe("vault filter service", () => {
expect(tree.children.find((o) => o.node.id === "MyVault"));
});
it("returns 1 organization if both single organization and personal ownership policies are enabled", async () => {
it("returns 1 organization if both single organization and organization data ownership policies are enabled", async () => {
singleOrgPolicy.next(true);
personalOwnershipPolicy.next(true);
organizationDataOwnershipPolicy.next(true);
const tree = await firstValueFrom(vaultFilterService.organizationTree$);

View File

@@ -67,12 +67,12 @@ export class VaultFilterService implements VaultFilterServiceAbstraction {
),
this.activeUserId$.pipe(
switchMap((userId) =>
this.policyService.policyAppliesToUser$(PolicyType.PersonalOwnership, userId),
this.policyService.policyAppliesToUser$(PolicyType.OrganizationDataOwnership, userId),
),
),
]).pipe(
switchMap(([orgs, singleOrgPolicy, personalOwnershipPolicy]) =>
this.buildOrganizationTree(orgs, singleOrgPolicy, personalOwnershipPolicy),
switchMap(([orgs, singleOrgPolicy, organizationDataOwnershipPolicy]) =>
this.buildOrganizationTree(orgs, singleOrgPolicy, organizationDataOwnershipPolicy),
),
);
@@ -166,10 +166,10 @@ export class VaultFilterService implements VaultFilterServiceAbstraction {
protected async buildOrganizationTree(
orgs: Organization[],
singleOrgPolicy: boolean,
personalOwnershipPolicy: boolean,
organizationDataOwnershipPolicy: boolean,
): Promise<TreeNode<OrganizationFilter>> {
const headNode = this.getOrganizationFilterHead();
if (!personalOwnershipPolicy) {
if (!organizationDataOwnershipPolicy) {
const myVaultNode = this.getOrganizationFilterMyVault();
headNode.children.push(myVaultNode);
}

View File

@@ -166,7 +166,7 @@ export class VaultOnboardingComponent implements OnInit, OnChanges, OnDestroy {
.pipe(
getUserId,
switchMap((userId) =>
this.policyService.policyAppliesToUser$(PolicyType.PersonalOwnership, userId),
this.policyService.policyAppliesToUser$(PolicyType.OrganizationDataOwnership, userId),
),
takeUntil(this.destroy$),
)

View File

@@ -128,18 +128,18 @@ describe("AdminConsoleCipherFormConfigService", () => {
expect(result.admin).toBe(true);
});
it("sets `allowPersonalOwnership`", async () => {
it("sets `organizationDataOwnershipDisabled`", async () => {
policyAppliesToUser$.next(true);
let result = await adminConsoleConfigService.buildConfig("clone", cipherId);
expect(result.allowPersonalOwnership).toBe(false);
expect(result.organizationDataOwnershipDisabled).toBe(false);
policyAppliesToUser$.next(false);
result = await adminConsoleConfigService.buildConfig("clone", cipherId);
expect(result.allowPersonalOwnership).toBe(true);
expect(result.organizationDataOwnershipDisabled).toBe(true);
});
it("disables personal ownership when not cloning", async () => {
@@ -147,15 +147,15 @@ describe("AdminConsoleCipherFormConfigService", () => {
let result = await adminConsoleConfigService.buildConfig("add", cipherId);
expect(result.allowPersonalOwnership).toBe(false);
expect(result.organizationDataOwnershipDisabled).toBe(false);
result = await adminConsoleConfigService.buildConfig("edit", cipherId);
expect(result.allowPersonalOwnership).toBe(false);
expect(result.organizationDataOwnershipDisabled).toBe(false);
result = await adminConsoleConfigService.buildConfig("clone", cipherId);
expect(result.allowPersonalOwnership).toBe(true);
expect(result.organizationDataOwnershipDisabled).toBe(true);
});
it("returns all ciphers when cloning a cipher", async () => {

View File

@@ -31,10 +31,10 @@ export class AdminConsoleCipherFormConfigService implements CipherFormConfigServ
private apiService: ApiService = inject(ApiService);
private accountService: AccountService = inject(AccountService);
private allowPersonalOwnership$ = this.accountService.activeAccount$.pipe(
private organizationDataOwnershipDisabled$ = this.accountService.activeAccount$.pipe(
getUserId,
switchMap((userId) =>
this.policyService.policyAppliesToUser$(PolicyType.PersonalOwnership, userId),
this.policyService.policyAppliesToUser$(PolicyType.OrganizationDataOwnership, userId),
),
map((p) => !p),
);
@@ -69,11 +69,11 @@ export class AdminConsoleCipherFormConfigService implements CipherFormConfigServ
cipherId?: CipherId,
cipherType?: CipherType,
): Promise<CipherFormConfig> {
const [organization, allowPersonalOwnership, allOrganizations, allCollections] =
const [organization, organizationDataOwnershipDisabled, allOrganizations, allCollections] =
await firstValueFrom(
combineLatest([
this.organization$,
this.allowPersonalOwnership$,
this.organizationDataOwnershipDisabled$,
this.allOrganizations$,
this.allCollections$,
]),
@@ -84,13 +84,14 @@ export class AdminConsoleCipherFormConfigService implements CipherFormConfigServ
const organizations = mode === "clone" ? allOrganizations : [organization];
// Only allow the user to assign to their personal vault when cloning and
// the policies are enabled for it.
const allowPersonalOwnershipOnlyForClone = mode === "clone" ? allowPersonalOwnership : false;
const disableOrganizationDataOwnershipOnlyForClone =
mode === "clone" ? organizationDataOwnershipDisabled : false;
const cipher = await this.getCipher(cipherId, organization);
return {
mode,
cipherType: cipher?.type ?? cipherType ?? CipherType.Login,
admin: organization.canEditAllCiphers ?? false,
allowPersonalOwnership: allowPersonalOwnershipOnlyForClone,
organizationDataOwnershipDisabled: disableOrganizationDataOwnershipOnlyForClone,
originalCipher: cipher,
collections: allCollections,
organizations,