From 3093566f018ee917d11ee7edb0be2f5d3cd90311 Mon Sep 17 00:00:00 2001 From: Nick Krantz <125900171+nick-livefront@users.noreply.github.com> Date: Tue, 23 Jul 2024 21:21:39 -0500 Subject: [PATCH] [PM-9951] Assign to Collection copy (#10205) * refactor "Assign collections" to "Assign to collections" * show singular or plural version of collection assignment success message * update singular and plural warning text * refactor switch to be an `if` --- apps/browser/src/_locales/en/messages.json | 46 +++++++++++++++---- .../assign-collections.component.html | 2 +- .../item-more-options.component.html | 2 +- apps/web/src/locales/en/messages.json | 42 ++++++++++++++--- .../assign-collections.component.ts | 20 +++++--- 5 files changed, 89 insertions(+), 23 deletions(-) diff --git a/apps/browser/src/_locales/en/messages.json b/apps/browser/src/_locales/en/messages.json index 4c149676feb..fa900cf4e8b 100644 --- a/apps/browser/src/_locales/en/messages.json +++ b/apps/browser/src/_locales/en/messages.json @@ -3500,8 +3500,8 @@ "noValuesToCopy": { "message": "No values to copy" }, - "assignCollections": { - "message": "Assign collections" + "assignToCollections": { + "message": "Assign to collections" }, "copyEmail": { "message": "Copy email" @@ -3797,21 +3797,33 @@ "selectCollectionsToAssign": { "message": "Select collections to assign" }, - "personalItemsTransferWarning": { - "message": "$PERSONAL_ITEMS_COUNT$ will be permanently transferred to the selected organization. You will no longer own these items.", + "personalItemTransferWarningSingular": { + "message": "1 item will be permanently transferred to the selected organization. You will no longer own this item." + }, + "personalItemsTransferWarningPlural": { + "message": "$PERSONAL_ITEMS_COUNT$ items will be permanently transferred to the selected organization. You will no longer own these items.", "placeholders": { "personal_items_count": { "content": "$1", - "example": "2 items" + "example": "2" } } }, - "personalItemsWithOrgTransferWarning": { - "message": "$PERSONAL_ITEMS_COUNT$ will be permanently transferred to $ORG$. You will no longer own these items.", + "personalItemWithOrgTransferWarningSingular": { + "message": "1 item will be permanently transferred to $ORG$. You will no longer own this item.", + "placeholders": { + "org": { + "content": "$1", + "example": "Organization name" + } + } + }, + "personalItemsWithOrgTransferWarningPlural": { + "message": "$PERSONAL_ITEMS_COUNT$ items will be permanently transferred to $ORG$. You will no longer own these items.", "placeholders": { "personal_items_count": { "content": "$1", - "example": "2 items" + "example": "2" }, "org": { "content": "$2", @@ -3834,6 +3846,24 @@ } } }, + "itemsMovedToOrg": { + "message": "Items moved to $ORGNAME$", + "placeholders": { + "orgname": { + "content": "$1", + "example": "Company Name" + } + } + }, + "itemMovedToOrg": { + "message": "Item moved to $ORGNAME$", + "placeholders": { + "orgname": { + "content": "$1", + "example": "Company Name" + } + } + }, "reorderFieldDown":{ "message": "$LABEL$ moved down, position $INDEX$ of $LENGTH$", "placeholders": { diff --git a/apps/browser/src/vault/popup/components/vault-v2/assign-collections/assign-collections.component.html b/apps/browser/src/vault/popup/components/vault-v2/assign-collections/assign-collections.component.html index 8e8ce1f997c..b0e651e8e2b 100644 --- a/apps/browser/src/vault/popup/components/vault-v2/assign-collections/assign-collections.component.html +++ b/apps/browser/src/vault/popup/components/vault-v2/assign-collections/assign-collections.component.html @@ -1,5 +1,5 @@ - + diff --git a/apps/browser/src/vault/popup/components/vault-v2/item-more-options/item-more-options.component.html b/apps/browser/src/vault/popup/components/vault-v2/item-more-options/item-more-options.component.html index 0a0f44e8e00..cd2e849f95b 100644 --- a/apps/browser/src/vault/popup/components/vault-v2/item-more-options/item-more-options.component.html +++ b/apps/browser/src/vault/popup/components/vault-v2/item-more-options/item-more-options.component.html @@ -34,7 +34,7 @@ type="button" bitMenuItem > - {{ "assignCollections" | i18n }} + {{ "assignToCollections" | i18n }} diff --git a/apps/web/src/locales/en/messages.json b/apps/web/src/locales/en/messages.json index 26a7426837e..d5617336207 100644 --- a/apps/web/src/locales/en/messages.json +++ b/apps/web/src/locales/en/messages.json @@ -570,6 +570,24 @@ } } }, + "itemsMovedToOrg": { + "message": "Items moved to $ORGNAME$", + "placeholders": { + "orgname": { + "content": "$1", + "example": "Company Name" + } + } + }, + "itemMovedToOrg": { + "message": "Item moved to $ORGNAME$", + "placeholders": { + "orgname": { + "content": "$1", + "example": "Company Name" + } + } + }, "deleteItem": { "message": "Delete item" }, @@ -8570,21 +8588,33 @@ "selectFolder": { "message": "Select folder" }, - "personalItemsTransferWarning": { - "message": "$PERSONAL_ITEMS_COUNT$ will be permanently transferred to the selected organization. You will no longer own these items.", + "personalItemTransferWarningSingular": { + "message": "1 item will be permanently transferred to the selected organization. You will no longer own this item." + }, + "personalItemsTransferWarningPlural": { + "message": "$PERSONAL_ITEMS_COUNT$ items will be permanently transferred to the selected organization. You will no longer own these items.", "placeholders": { "personal_items_count": { "content": "$1", - "example": "2 items" + "example": "2" } } }, - "personalItemsWithOrgTransferWarning": { - "message": "$PERSONAL_ITEMS_COUNT$ will be permanently transferred to $ORG$. You will no longer own these items.", + "personalItemWithOrgTransferWarningSingular": { + "message": "1 item will be permanently transferred to $ORG$. You will no longer own this item.", + "placeholders": { + "org": { + "content": "$1", + "example": "Organization name" + } + } + }, + "personalItemsWithOrgTransferWarningPlural": { + "message": "$PERSONAL_ITEMS_COUNT$ items will be permanently transferred to $ORG$. You will no longer own these items.", "placeholders": { "personal_items_count": { "content": "$1", - "example": "2 items" + "example": "2" }, "org": { "content": "$2", diff --git a/libs/vault/src/components/assign-collections.component.ts b/libs/vault/src/components/assign-collections.component.ts index a333cd35233..ff98e6d5e52 100644 --- a/libs/vault/src/components/assign-collections.component.ts +++ b/libs/vault/src/components/assign-collections.component.ts @@ -13,7 +13,6 @@ import { } from "rxjs"; import { JslibModule } from "@bitwarden/angular/jslib.module"; -import { PluralizePipe } from "@bitwarden/angular/pipes/pluralize.pipe"; import { OrganizationService } from "@bitwarden/common/admin-console/abstractions/organization/organization.service.abstraction"; import { OrganizationUserStatusType } from "@bitwarden/common/admin-console/enums"; import { Organization } from "@bitwarden/common/admin-console/models/domain/organization"; @@ -134,10 +133,18 @@ export class AssignCollectionsComponent implements OnInit { ); protected transferWarningText = (orgName: string, itemsCount: number) => { - const pluralizedItems = this.pluralizePipe.transform(itemsCount, "item", "items"); - return orgName - ? this.i18nService.t("personalItemsWithOrgTransferWarning", pluralizedItems, orgName) - : this.i18nService.t("personalItemsTransferWarning", pluralizedItems); + const haveOrgName = !!orgName; + + if (itemsCount > 1 && haveOrgName) { + return this.i18nService.t("personalItemsWithOrgTransferWarningPlural", itemsCount, orgName); + } + if (itemsCount > 1 && !haveOrgName) { + return this.i18nService.t("personalItemsTransferWarningPlural", itemsCount); + } + if (itemsCount === 1 && haveOrgName) { + return this.i18nService.t("personalItemWithOrgTransferWarningSingular", orgName); + } + return this.i18nService.t("personalItemTransferWarningSingular"); }; private editableItems: CipherView[] = []; @@ -155,7 +162,6 @@ export class AssignCollectionsComponent implements OnInit { private organizationService: OrganizationService, private collectionService: CollectionService, private formBuilder: FormBuilder, - private pluralizePipe: PluralizePipe, private toastService: ToastService, ) {} @@ -416,7 +422,7 @@ export class AssignCollectionsComponent implements OnInit { variant: "success", title: null, message: this.i18nService.t( - "movedItemsToOrg", + shareableCiphers.length === 1 ? "itemMovedToOrg" : "itemsMovedToOrg", this.orgName ?? this.i18nService.t("organization"), ), });