[PM-46898] fix: Use "My items" casing consistently (#24752)

* [PM-46898] fix: Name new My items collections with myItemsV2

The default user collection was named from the "myItems" key ("My Items"),
while the rest of the UI uses "myItemsV2" ("My items"). Switch the web,
browser, desktop and CLI paths that create the collection to "myItemsV2"
and drop the now-unused "myItems" key. Existing collections keep their
stored name.

* Use errorImportingMyItemsMultiCollectionV2 for the lowercase My items import error

* Label the My items shared folder from i18n in the vault table

* Label the My items shared folder from i18n in the item view and edit form

* Keep other members' emails on their My items collections and test the labels
This commit is contained in:
Nick Krantz
2026-11-13 10:36:16 -06:00
committed by GitHub
parent dbc5b470b6
commit 09e5296b1e
17 changed files with 172 additions and 38 deletions

View File

@@ -6731,9 +6731,6 @@
"copyAddress": {
"message": "Copy address"
},
"myItems": {
"message": "My Items"
},
"myItemsV2": {
"message": "My items"
},
@@ -8470,8 +8467,8 @@
"message": "This Send will automatically expire at the set deletion date",
"description": "'Send' is a noun and the name of a feature called 'Bitwarden Send'. It should not be translated."
},
"errorImportingMyItemsMultiCollection": {
"message": "You cannot import items into My Items that are part of multiple collections"
"errorImportingMyItemsMultiCollectionV2": {
"message": "You cannot import items into My items that are part of multiple collections"
},
"cannotSaveItemNoConfirmedOrgs": {
"message": "Unable to save item. You must be confirmed to the organization to save items."

View File

@@ -94,7 +94,7 @@ export class ConfirmCommand {
}
private async getEncryptedDefaultUserCollectionName(orgKey: OrgKey): Promise<EncString> {
const defaultCollectionName = this.i18nService.t("myItems");
const defaultCollectionName = this.i18nService.t("myItemsV2");
const encrypted = await this.encryptService.encryptString(defaultCollectionName, orgKey);
if (encrypted.encryptedString == null) {
throw new Error("Failed to encrypt default user collection name.");

View File

@@ -273,8 +273,8 @@
"youHaveBeenLoggedOut": {
"message": "You have been logged out."
},
"myItems": {
"message": "My Items"
"myItemsV2": {
"message": "My items"
},
"organizationUsingKeyConnectorConfirmLoggedOut": {
"message": "An organization you are a member of is using Key Connector. In order to access the vault, you must confirm the Key Connector domain now via the web vault. You have been logged out."

View File

@@ -7379,8 +7379,8 @@
"makeACopy": {
"message": "Make a copy"
},
"errorImportingMyItemsMultiCollection": {
"message": "You cannot import items into My Items that are part of multiple collections"
"errorImportingMyItemsMultiCollectionV2": {
"message": "You cannot import items into My items that are part of multiple collections"
},
"driversLicenseDetails": {
"message": "License details"

View File

@@ -129,7 +129,7 @@ export class OrganizationDataOwnershipPolicyComponent
}
private async getEncryptedDefaultUserCollectionName(orgKey: OrgKey): Promise<EncString> {
const defaultCollectionName = this.i18nService.t("myItems");
const defaultCollectionName = this.i18nService.t("myItemsV2");
const encrypted = await this.encryptService.encryptString(defaultCollectionName, orgKey);
if (!encrypted.encryptedString) {

View File

@@ -1803,9 +1803,6 @@
"me": {
"message": "Me"
},
"myItems": {
"message": "My Items"
},
"myItemsV2": {
"message": "My items"
},
@@ -18452,8 +18449,8 @@
"separateDomainsWithComma": {
"message": "Separate domains with a comma"
},
"errorImportingMyItemsMultiCollection": {
"message": "You cannot import items into My Items that are part of multiple collections"
"errorImportingMyItemsMultiCollectionV2": {
"message": "You cannot import items into My items that are part of multiple collections"
},
"searchDriversLicense": {
"message": "Search licenses"

View File

@@ -111,7 +111,7 @@ describe("DefaultOrganizationUserService", () => {
it("should confirm a user successfully", (done) => {
service.confirmUser(mockOrganization, mockUserId, mockPublicKey).subscribe({
next: () => {
expect(i18nService.t).toHaveBeenCalledWith("myItems");
expect(i18nService.t).toHaveBeenCalledWith("myItemsV2");
expect(encryptService.encryptString).toHaveBeenCalledWith(
mockDefaultCollectionName,
@@ -161,7 +161,7 @@ describe("DefaultOrganizationUserService", () => {
it("should bulk confirm users successfully", (done) => {
service.bulkConfirmUsers(mockOrganization, mockUserIdsWithKeys).subscribe({
next: (response) => {
expect(i18nService.t).toHaveBeenCalledWith("myItems");
expect(i18nService.t).toHaveBeenCalledWith("myItemsV2");
expect(encryptService.encryptString).toHaveBeenCalledWith(
mockDefaultCollectionName,
@@ -193,7 +193,7 @@ describe("DefaultOrganizationUserService", () => {
it("should build a restore request with encrypted collection name", (done) => {
service.buildRestoreUserRequest(mockOrganization).subscribe({
next: (request) => {
expect(i18nService.t).toHaveBeenCalledWith("myItems");
expect(i18nService.t).toHaveBeenCalledWith("myItemsV2");
expect(encryptService.encryptString).toHaveBeenCalledWith(
mockDefaultCollectionName,
mockOrgKey,
@@ -217,7 +217,7 @@ describe("DefaultOrganizationUserService", () => {
it("should restore a user successfully", (done) => {
service.restoreUser(mockOrganization, mockUserId).subscribe({
next: () => {
expect(i18nService.t).toHaveBeenCalledWith("myItems");
expect(i18nService.t).toHaveBeenCalledWith("myItemsV2");
expect(encryptService.encryptString).toHaveBeenCalledWith(
mockDefaultCollectionName,
mockOrgKey,
@@ -256,7 +256,7 @@ describe("DefaultOrganizationUserService", () => {
it("should bulk restore users successfully", (done) => {
service.bulkRestoreUsers(mockOrganization, mockUserIds).subscribe({
next: (response) => {
expect(i18nService.t).toHaveBeenCalledWith("myItems");
expect(i18nService.t).toHaveBeenCalledWith("myItemsV2");
expect(encryptService.encryptString).toHaveBeenCalledWith(
mockDefaultCollectionName,
mockOrgKey,
@@ -328,7 +328,7 @@ describe("DefaultOrganizationUserService", () => {
service.updateUser(org, mockUserId, request).subscribe({
next: () => {
expect(i18nService.t).toHaveBeenCalledWith("myItems");
expect(i18nService.t).toHaveBeenCalledWith("myItemsV2");
expect(encryptService.encryptString).toHaveBeenCalledWith(
mockDefaultCollectionName,
mockOrgKey,

View File

@@ -152,7 +152,7 @@ export class DefaultOrganizationUserService implements OrganizationUserService {
private getEncryptedDefaultCollectionName$(organization: Organization) {
return this.orgKey$(organization).pipe(
switchMap((orgKey) =>
this.encryptService.encryptString(this.i18nService.t("myItems"), orgKey),
this.encryptService.encryptString(this.i18nService.t("myItemsV2"), orgKey),
),
);
}

View File

@@ -720,7 +720,7 @@ export class ImportService implements ImportServiceAbstraction {
importResult.collectionRelationships.filter((cr) => cr[0] === c_idx).length > 1,
)
) {
throw new Error(this.i18nService.t("errorImportingMyItemsMultiCollection"));
throw new Error(this.i18nService.t("errorImportingMyItemsMultiCollectionV2"));
}
importResult.folders = importResult.collections.map((c) => {
const f = new FolderView();

View File

@@ -584,6 +584,46 @@ describe("ItemDetailsSectionComponent", () => {
expect(component["collectionOptions"].map((c) => c.id)).toEqual(["col1", "col2", "col3"]);
});
it("names the member's own My items collection from i18n and keeps other members' emails", async () => {
i18nService.t.calledWith("myItemsV2").mockReturnValue("My items");
component.config.admin = true;
component.config.organizationDataOwnershipDisabled = true;
component.config.organizations = [{ id: "org1" } as Organization];
const ownMyItems = createMockCollection("col1", "My Items", "org1");
const otherMyItems = Object.assign(createMockCollection("col2", "My Items", "org1"), {
defaultUserCollectionEmail: "member@example.com",
});
const shared = createMockCollection(
"col3",
"Engineering",
"org1",
false,
true,
CollectionTypes.SharedCollection,
);
component.config.collections = [ownMyItems, otherMyItems, shared];
fixture.detectChanges();
await fixture.whenStable();
component.itemDetailsForm.controls.organizationId.setValue("org1");
fixture.detectChanges();
await fixture.whenStable();
expect(
component["collectionOptions"].map(({ id, listName, labelName }) => ({
id,
listName,
labelName,
})),
).toEqual([
{ id: "col1", listName: "My items", labelName: "My items" },
{ id: "col2", listName: "member@example.com", labelName: "member@example.com" },
{ id: "col3", listName: "Engineering", labelName: "Engineering" },
]);
});
});
describe("readonlyCollections", () => {

View File

@@ -39,6 +39,7 @@ import {
import { orgIconTile, personalIconTile } from "../../../models/vault-icon-tile";
import { Vfo1I18nPipe } from "../../../pipes/vfo1-i18n.pipe";
import { Vfo1TerminologyService } from "../../../services/vfo1-terminology.service";
import { sharedFolderDisplayName } from "../../../utils/shared-folder-name";
import {
CipherFormConfig,
OptionalInitialValues,
@@ -498,12 +499,10 @@ export class ItemDetailsSectionComponent implements OnInit {
const bIsDefaultCollection = b.type === CollectionTypes.DefaultUserCollection ? -1 : 0;
return aIsDefaultCollection - bIsDefaultCollection;
})
.map((c) => ({
id: c.id,
name: c.name,
listName: c.name,
labelName: c.name,
}));
.map((c) => {
const name = sharedFolderDisplayName(c, this.i18nService);
return { id: c.id, name, listName: name, labelName: name };
});
collectionsControl.reset();
collectionsControl.enable();

View File

@@ -70,7 +70,7 @@
></i>
}
<span aria-hidden="true" class="tw-pl-1.5">
{{ item.name }}
{{ getItemName(item) }}
</span>
</span>
}

View File

@@ -11,7 +11,10 @@ import { By } from "@angular/platform-browser";
import { mock } from "jest-mock-extended";
import { of } from "rxjs";
import { CollectionView } from "@bitwarden/common/admin-console/models/collections";
import {
CollectionTypes,
CollectionView,
} from "@bitwarden/common/admin-console/models/collections";
import { Organization } from "@bitwarden/common/admin-console/models/domain/organization";
import { DomainSettingsService } from "@bitwarden/common/autofill/services/domain-settings.service";
import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service";
@@ -118,6 +121,20 @@ describe("ItemDetailsV2Component", () => {
expect(itemDetailsList[3].nativeElement.textContent.trim()).toContain(folder.name);
});
it("names the member's own My items collection from i18n rather than its stored name", () => {
const myItems = Object.assign(
new CollectionView({
id: "col1" as CollectionId,
organizationId: "org1" as OrganizationId,
name: "My Items",
}),
{ type: CollectionTypes.DefaultUserCollection },
);
expect(component.getItemName(myItems)).toBe("myItemsV2");
expect(component.getAriaLabel(myItems)).toBe("collectionAriaLabel myItemsV2");
});
describe("getAriaLabel", () => {
it("separates the label and name with a space for organizations", () => {
const org = Object.assign(new Organization(), { name: "Organization 1" });

View File

@@ -26,6 +26,7 @@ import { OrgIconDirective } from "../../components/org-icon.directive";
import { Vfo1I18nPipe } from "../../pipes/vfo1-i18n.pipe";
import { Vfo1TerminologyService } from "../../services/vfo1-terminology.service";
import { ITEM_DETAILS_BADGE, ItemDetailsBadge } from "../../tokens/item-details-badge.token";
import { sharedFolderDisplayName } from "../../utils/shared-folder-name";
// FIXME(https://bitwarden.atlassian.net/browse/CL-764): Migrate to OnPush
// eslint-disable-next-line @angular-eslint/prefer-on-push-component-change-detection
@@ -114,7 +115,7 @@ export class ItemDetailsV2Component {
return this.i18nService.t(key, item.name);
} else if (item instanceof CollectionView) {
const key = this.vfo1Enabled() ? "sharedFolderAriaLabel" : "collectionAriaLabel";
return this.i18nService.t(key, item.name);
return this.i18nService.t(key, this.getItemName(item));
} else if (item instanceof FolderView) {
const key = this.vfo1Enabled() ? "myFolderAriaLabel" : "folderAriaLabel";
return this.i18nService.t(key, item.name);
@@ -122,6 +123,13 @@ export class ItemDetailsV2Component {
return "";
}
/** The item's name, a shared folder's as {@link sharedFolderDisplayName} gives it. */
getItemName(item: Organization | CollectionView | FolderView): string {
return item instanceof CollectionView
? sharedFolderDisplayName(item, this.i18nService)
: item.name;
}
getIconClass(item: Organization | CollectionView | FolderView): string {
if (item instanceof CollectionView) {
return this.vfo1TerminologyService.iconClass(

View File

@@ -91,7 +91,7 @@ import {
VaultItemFilterOption,
} from "../../tokens/vault-item-filter.token";
import { isRowActivationClick } from "../../utils/row-activation";
import { sharedFolderName } from "../../utils/shared-folder-name";
import { sharedFolderDisplayName, sharedFolderName } from "../../utils/shared-folder-name";
import {
idString,
matchesFavorite,
@@ -597,12 +597,12 @@ export class VaultItemsTableComponent<C extends CipherViewLike> {
private readonly folderNames = computed(() => this.nameMap(this.folders()));
/** Each collection's own name, without its parent path — see {@link sharedFolderName}. */
/** Each shared folder's display name — see {@link sharedFolderLabel}. */
private readonly collectionNames = computed(() =>
this.nameMap(
this.collections().map((collection) => ({
id: collection.id,
name: sharedFolderName(collection),
name: this.sharedFolderLabel(collection),
})),
),
);
@@ -1270,6 +1270,14 @@ export class VaultItemsTableComponent<C extends CipherViewLike> {
?.setValue("");
}
/**
* A shared folder's display name (see {@link sharedFolderDisplayName}) without its parent path
* (see {@link sharedFolderName}).
*/
private sharedFolderLabel(collection: CollectionView): string {
return sharedFolderName({ name: sharedFolderDisplayName(collection, this.i18nService) });
}
/**
* Builds the shared folder tree via {@link getNestedCollectionTree}, the same name-delimited
* nesting used for the collections sidebar — so a collection whose parent path is missing
@@ -1288,7 +1296,7 @@ export class VaultItemsTableComponent<C extends CipherViewLike> {
): FilterOptionNode<CollectionId>[] {
const toNode = (node: TreeNode<CollectionView>): FilterOptionNode<CollectionId> => ({
value: node.node.id,
label: sharedFolderName(node.node),
label: this.sharedFolderLabel(node.node),
options: node.children.map(toNode),
});
return getNestedCollectionTree([...sharedFolders])

View File

@@ -1,4 +1,11 @@
import { sharedFolderName } from "./shared-folder-name";
import {
CollectionTypes,
CollectionView,
} from "@bitwarden/common/admin-console/models/collections";
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
import { CollectionId, OrganizationId } from "@bitwarden/common/types/guid";
import { sharedFolderDisplayName, sharedFolderName } from "./shared-folder-name";
describe("sharedFolderName", () => {
it.each([
@@ -10,3 +17,49 @@ describe("sharedFolderName", () => {
expect(sharedFolderName({ name })).toBe(expected);
});
});
describe("sharedFolderDisplayName", () => {
const i18nService = { t: (key: string) => key } as I18nService;
function collection(
name: string,
type: CollectionView["type"],
defaultUserCollectionEmail?: string,
): CollectionView {
return Object.assign(
new CollectionView({
id: "col1" as CollectionId,
organizationId: "org1" as OrganizationId,
name,
}),
{ type, defaultUserCollectionEmail },
);
}
it("names the member's own My items collection from i18n, whatever its stored name", () => {
expect(
sharedFolderDisplayName(
collection("My Items", CollectionTypes.DefaultUserCollection),
i18nService,
),
).toBe("myItemsV2");
});
it("keeps the email on another member's My items collection", () => {
expect(
sharedFolderDisplayName(
collection("My Items", CollectionTypes.DefaultUserCollection, "member@example.com"),
i18nService,
),
).toBe("member@example.com");
});
it("keeps a shared collection's stored name", () => {
expect(
sharedFolderDisplayName(
collection("Engineering/Backend", CollectionTypes.SharedCollection),
i18nService,
),
).toBe("Engineering/Backend");
});
});

View File

@@ -2,6 +2,7 @@ import {
CollectionView,
NestingDelimiter,
} from "@bitwarden/common/admin-console/models/collections";
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
/**
* A shared folder's own name, without the parent path its full name carries: "Deepest" for
@@ -12,3 +13,17 @@ export function sharedFolderName(collection: Pick<CollectionView, "name">): stri
const path = collection.name.replace(/^\/+|\/+$/g, "");
return path.slice(path.lastIndexOf(NestingDelimiter) + 1) || collection.name;
}
/**
* A shared folder's full name for display. The member's own "My items" collection reads from i18n
* rather than its stored name, which the server may hold in older casing. Another member's "My
* items" collection keeps the email its `name` resolves to, so an admin can tell them apart.
*/
export function sharedFolderDisplayName(
collection: Pick<CollectionView, "name" | "isDefaultCollection" | "defaultUserCollectionEmail">,
i18nService: Pick<I18nService, "t">,
): string {
return collection.isDefaultCollection && collection.defaultUserCollectionEmail == null
? i18nService.t("myItemsV2")
: collection.name;
}