Skip to content

Commit 779f511

Browse files
authored
fix(ui): properly handle singular and plural bulk edit labels (#11198)
Bulk-many components are always using the plural format in their title, even if only one document has been selected. This fix checks the selection count and if its greater than 1 it will show the plural format otherwise it will show the singular format.
1 parent 35d845c commit 779f511

File tree

3 files changed

+17
-5
lines changed

3 files changed

+17
-5
lines changed

packages/ui/src/elements/BulkUpload/EditMany/DrawerContent.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,11 @@ export const EditManyBulkUploadsDrawerContent: React.FC<
2828
forms: State['forms']
2929
} & EditManyBulkUploadsProps
3030
> = (props) => {
31-
const { collection: { slug, fields, labels: { plural } } = {}, drawerSlug, forms } = props
31+
const {
32+
collection: { slug, fields, labels: { plural, singular } } = {},
33+
drawerSlug,
34+
forms,
35+
} = props
3236

3337
const { permissions } = useAuth()
3438
const { i18n, t } = useTranslation()
@@ -60,7 +64,7 @@ export const EditManyBulkUploadsDrawerContent: React.FC<
6064
<h2 className={`${baseClass}__header__title`}>
6165
{t('general:editingLabel', {
6266
count: forms.length,
63-
label: getTranslation(plural, i18n),
67+
label: getTranslation(forms.length > 1 ? plural : singular, i18n),
6468
})}
6569
</h2>
6670
<button

packages/ui/src/elements/DeleteMany/index.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,12 @@ export const DeleteMany: React.FC<Props> = (props) => {
159159
<div className={`${baseClass}__wrapper`}>
160160
<div className={`${baseClass}__content`}>
161161
<h1>{t('general:confirmDeletion')}</h1>
162-
<p>{t('general:aboutToDeleteCount', { count, label: getTranslation(plural, i18n) })}</p>
162+
<p>
163+
{t('general:aboutToDeleteCount', {
164+
count,
165+
label: getTranslation(count > 1 ? plural : singular, i18n),
166+
})}
167+
</p>
163168
</div>
164169
<div className={`${baseClass}__controls`}>
165170
<Button

packages/ui/src/elements/EditMany/DrawerContent.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ export const EditManyDrawerContent: React.FC<
135135
} & EditManyProps
136136
> = (props) => {
137137
const {
138-
collection: { slug, fields, labels: { plural } } = {},
138+
collection: { slug, fields, labels: { plural, singular } } = {},
139139
collection,
140140
drawerSlug,
141141
selected: selectedFromProps,
@@ -270,7 +270,10 @@ export const EditManyDrawerContent: React.FC<
270270
<div className={`${baseClass}__main`}>
271271
<div className={`${baseClass}__header`}>
272272
<h2 className={`${baseClass}__header__title`}>
273-
{t('general:editingLabel', { count, label: getTranslation(plural, i18n) })}
273+
{t('general:editingLabel', {
274+
count,
275+
label: getTranslation(count > 1 ? plural : singular, i18n),
276+
})}
274277
</h2>
275278
<button
276279
aria-label={t('general:close')}

0 commit comments

Comments
 (0)