1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-13 06:43:35 +00:00

[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`
This commit is contained in:
Nick Krantz
2024-07-23 21:21:39 -05:00
committed by GitHub
parent 26a3f6b8ec
commit 3093566f01
5 changed files with 89 additions and 23 deletions

View File

@@ -3500,8 +3500,8 @@
"noValuesToCopy": { "noValuesToCopy": {
"message": "No values to copy" "message": "No values to copy"
}, },
"assignCollections": { "assignToCollections": {
"message": "Assign collections" "message": "Assign to collections"
}, },
"copyEmail": { "copyEmail": {
"message": "Copy email" "message": "Copy email"
@@ -3797,21 +3797,33 @@
"selectCollectionsToAssign": { "selectCollectionsToAssign": {
"message": "Select collections to assign" "message": "Select collections to assign"
}, },
"personalItemsTransferWarning": { "personalItemTransferWarningSingular": {
"message": "$PERSONAL_ITEMS_COUNT$ will be permanently transferred to the selected organization. You will no longer own these items.", "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": { "placeholders": {
"personal_items_count": { "personal_items_count": {
"content": "$1", "content": "$1",
"example": "2 items" "example": "2"
} }
} }
}, },
"personalItemsWithOrgTransferWarning": { "personalItemWithOrgTransferWarningSingular": {
"message": "$PERSONAL_ITEMS_COUNT$ will be permanently transferred to $ORG$. You will no longer own these items.", "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": { "placeholders": {
"personal_items_count": { "personal_items_count": {
"content": "$1", "content": "$1",
"example": "2 items" "example": "2"
}, },
"org": { "org": {
"content": "$2", "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":{ "reorderFieldDown":{
"message": "$LABEL$ moved down, position $INDEX$ of $LENGTH$", "message": "$LABEL$ moved down, position $INDEX$ of $LENGTH$",
"placeholders": { "placeholders": {

View File

@@ -1,5 +1,5 @@
<popup-page> <popup-page>
<popup-header slot="header" [pageTitle]="'assignCollections' | i18n" showBackButton> <popup-header slot="header" [pageTitle]="'assignToCollections' | i18n" showBackButton>
<ng-container slot="end"> <ng-container slot="end">
<app-pop-out></app-pop-out> <app-pop-out></app-pop-out>
</ng-container> </ng-container>

View File

@@ -34,7 +34,7 @@
type="button" type="button"
bitMenuItem bitMenuItem
> >
{{ "assignCollections" | i18n }} {{ "assignToCollections" | i18n }}
</a> </a>
</ng-container> </ng-container>
</bit-menu> </bit-menu>

View File

@@ -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": { "deleteItem": {
"message": "Delete item" "message": "Delete item"
}, },
@@ -8570,21 +8588,33 @@
"selectFolder": { "selectFolder": {
"message": "Select folder" "message": "Select folder"
}, },
"personalItemsTransferWarning": { "personalItemTransferWarningSingular": {
"message": "$PERSONAL_ITEMS_COUNT$ will be permanently transferred to the selected organization. You will no longer own these items.", "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": { "placeholders": {
"personal_items_count": { "personal_items_count": {
"content": "$1", "content": "$1",
"example": "2 items" "example": "2"
} }
} }
}, },
"personalItemsWithOrgTransferWarning": { "personalItemWithOrgTransferWarningSingular": {
"message": "$PERSONAL_ITEMS_COUNT$ will be permanently transferred to $ORG$. You will no longer own these items.", "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": { "placeholders": {
"personal_items_count": { "personal_items_count": {
"content": "$1", "content": "$1",
"example": "2 items" "example": "2"
}, },
"org": { "org": {
"content": "$2", "content": "$2",

View File

@@ -13,7 +13,6 @@ import {
} from "rxjs"; } from "rxjs";
import { JslibModule } from "@bitwarden/angular/jslib.module"; 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 { OrganizationService } from "@bitwarden/common/admin-console/abstractions/organization/organization.service.abstraction";
import { OrganizationUserStatusType } from "@bitwarden/common/admin-console/enums"; import { OrganizationUserStatusType } from "@bitwarden/common/admin-console/enums";
import { Organization } from "@bitwarden/common/admin-console/models/domain/organization"; 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) => { protected transferWarningText = (orgName: string, itemsCount: number) => {
const pluralizedItems = this.pluralizePipe.transform(itemsCount, "item", "items"); const haveOrgName = !!orgName;
return orgName
? this.i18nService.t("personalItemsWithOrgTransferWarning", pluralizedItems, orgName) if (itemsCount > 1 && haveOrgName) {
: this.i18nService.t("personalItemsTransferWarning", pluralizedItems); 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[] = []; private editableItems: CipherView[] = [];
@@ -155,7 +162,6 @@ export class AssignCollectionsComponent implements OnInit {
private organizationService: OrganizationService, private organizationService: OrganizationService,
private collectionService: CollectionService, private collectionService: CollectionService,
private formBuilder: FormBuilder, private formBuilder: FormBuilder,
private pluralizePipe: PluralizePipe,
private toastService: ToastService, private toastService: ToastService,
) {} ) {}
@@ -416,7 +422,7 @@ export class AssignCollectionsComponent implements OnInit {
variant: "success", variant: "success",
title: null, title: null,
message: this.i18nService.t( message: this.i18nService.t(
"movedItemsToOrg", shareableCiphers.length === 1 ? "itemMovedToOrg" : "itemsMovedToOrg",
this.orgName ?? this.i18nService.t("organization"), this.orgName ?? this.i18nService.t("organization"),
), ),
}); });