Skip to content

Commit

Permalink
[PM-9951] Assign to Collection copy (#10205)
Browse files Browse the repository at this point in the history
* 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`
  • Loading branch information
nick-livefront authored Jul 24, 2024
1 parent 26a3f6b commit 3093566
Show file tree
Hide file tree
Showing 5 changed files with 89 additions and 23 deletions.
46 changes: 38 additions & 8 deletions apps/browser/src/_locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -3500,8 +3500,8 @@
"noValuesToCopy": {
"message": "No values to copy"
},
"assignCollections": {
"message": "Assign collections"
"assignToCollections": {
"message": "Assign to collections"
},
"copyEmail": {
"message": "Copy email"
Expand Down Expand Up @@ -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"
}
}
},
"personalItemWithOrgTransferWarningSingular": {
"message": "1 item will be permanently transferred to $ORG$. You will no longer own this item.",
"placeholders": {
"org": {
"content": "$1",
"example": "Organization name"
}
}
},
"personalItemsWithOrgTransferWarning": {
"message": "$PERSONAL_ITEMS_COUNT$ will be permanently transferred to $ORG$. You will no longer own these items.",
"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",
Expand All @@ -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": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<popup-page>
<popup-header slot="header" [pageTitle]="'assignCollections' | i18n" showBackButton>
<popup-header slot="header" [pageTitle]="'assignToCollections' | i18n" showBackButton>
<ng-container slot="end">
<app-pop-out></app-pop-out>
</ng-container>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
type="button"
bitMenuItem
>
{{ "assignCollections" | i18n }}
{{ "assignToCollections" | i18n }}
</a>
</ng-container>
</bit-menu>
Expand Down
42 changes: 36 additions & 6 deletions apps/web/src/locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down Expand Up @@ -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"
}
}
},
"personalItemWithOrgTransferWarningSingular": {
"message": "1 item will be permanently transferred to $ORG$. You will no longer own this item.",
"placeholders": {
"org": {
"content": "$1",
"example": "Organization name"
}
}
},
"personalItemsWithOrgTransferWarning": {
"message": "$PERSONAL_ITEMS_COUNT$ will be permanently transferred to $ORG$. You will no longer own these items.",
"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",
Expand Down
20 changes: 13 additions & 7 deletions libs/vault/src/components/assign-collections.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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[] = [];
Expand All @@ -155,7 +162,6 @@ export class AssignCollectionsComponent implements OnInit {
private organizationService: OrganizationService,
private collectionService: CollectionService,
private formBuilder: FormBuilder,
private pluralizePipe: PluralizePipe,
private toastService: ToastService,
) {}

Expand Down Expand Up @@ -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"),
),
});
Expand Down

0 comments on commit 3093566

Please sign in to comment.