Skip to content

Commit a53876d

Browse files
authored
fix(ui): logic for showing copyToLocale button and adds test (#11584)
### What? This [PR](#11546) introduced a bug where the `CopyToLocale` button can show up when localization is false. ### Why? `const disableCopyToLocale = localization && collectionConfig?.admin?.disableCopyToLocale` this line was faulty ### How? Fixed the logic and added test to confirm button doesn't show when localization is false.
1 parent 6f90d62 commit a53876d

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ export const DocumentControls: React.FC<{
137137
(collectionConfig?.versions?.drafts && collectionConfig?.versions?.drafts?.autosave) ||
138138
(globalConfig?.versions?.drafts && globalConfig?.versions?.drafts?.autosave)
139139

140-
const disableCopyToLocale = localization && collectionConfig?.admin?.disableCopyToLocale
140+
const showCopyToLocale = localization && !collectionConfig?.admin?.disableCopyToLocale
141141

142142
return (
143143
<Gutter className={baseClass}>
@@ -265,7 +265,7 @@ export const DocumentControls: React.FC<{
265265
verticalAlign="bottom"
266266
>
267267
<PopupList.ButtonGroup>
268-
{!disableCopyToLocale && <CopyLocaleData />}
268+
{showCopyToLocale && <CopyLocaleData />}
269269
{hasCreatePermission && (
270270
<React.Fragment>
271271
{!disableCreate && (

test/admin-root/e2e.spec.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,15 @@ test.describe('Admin Panel (Root)', () => {
8080
await expect(firstRow).toBeVisible()
8181
})
8282

83+
test('collection - should hide Copy To Locale button when localization is false', async () => {
84+
await page.goto(url.create)
85+
const textField = page.locator('#field-text')
86+
await textField.fill('test')
87+
await saveDocAndAssert(page)
88+
await page.locator('.doc-controls__popup >> .popup-button').click()
89+
await expect(page.locator('#copy-locale-data__button')).toBeHidden()
90+
})
91+
8392
test('global — navigates to edit view', async () => {
8493
await page.goto(url.global('menu'))
8594
const pageURL = page.url()

0 commit comments

Comments
 (0)