Skip to content

Commit d596553

Browse files
Merge pull request #61688 from nextcloud/fix/58645/background-file-picker
fix: adjust file picker for background image to allow folder navigation
2 parents a83035c + 1f1928d commit d596553

7 files changed

Lines changed: 73 additions & 5 deletions

apps/theming/src/components/UserSectionBackground.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ async function pickColor(color?: string) {
147147
async function pickFile() {
148148
await getFilePickerBuilder(t('theming', 'Select a background from your files'))
149149
.allowDirectories(false)
150-
.setFilter((node) => node.mime.startsWith('image/'))
150+
.setMimeTypeFilter(['image/*'])
151151
.setMultiSelect(false)
152152
.addButton({
153153
label: t('theming', 'Select background'),

dist/theming-settings-personal.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* extracted by css-entry-points-plugin */
2-
@import './theming-theming-settings-personal-Di6TWq9d.chunk.css';
2+
@import './theming-theming-settings-personal-CWngNMDC.chunk.css';
33
@import './common-createElementId-DhjFt1I9-C_oBIsvc.chunk.css';
44
@import './common-TrashCanOutline-BYHcrfvW.chunk.css';
55
@import './common-NcCheckboxRadioSwitch-D8Dfv4iw-CPGkDj-p.chunk.css';

dist/theming-settings-personal.mjs

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

dist/theming-settings-personal.mjs.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/theming-theming-settings-personal-Di6TWq9d.chunk.css renamed to dist/theming-theming-settings-personal-CWngNMDC.chunk.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/playwright/e2e/theming/user-settings-background.spec.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55

66
import { expect } from '@playwright/test'
77
import { test } from '../../support/fixtures/random-user-session.ts'
8+
import { BackgroundFilePickerDialogPage } from '../../support/sections/BackgroundFilePickerDialogPage.ts'
9+
import { mkdir, uploadContent } from '../../support/utils/dav.ts'
810
import { getBodyThemingSnapshot, pickColor } from '../../support/utils/theming.ts'
911

1012
test('User can configure background and plain color', async ({ page }) => {
@@ -32,3 +34,28 @@ test('User can configure background and plain color', async ({ page }) => {
3234
await page.reload()
3335
await expect.poll(async () => (await getBodyThemingSnapshot(page)).backgroundImage).toBe('none')
3436
})
37+
38+
test('User can pick a custom background from their files', {
39+
annotation: { type: 'issue', description: 'https://github.com/nextcloud/server/issues/58645' },
40+
}, async ({ page, user }) => {
41+
await mkdir(page.request, user, '/folder')
42+
43+
// this is a minimal image (1x1 red pixel), encoded as base64
44+
const imageBase64 = 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR4AWL6z8DwHwAAAP//A3ONEwAAAAZJREFUAwAFCgIByRpMngAAAABJRU5ErkJggg=='
45+
// Buffer.alloc(0) did not work when selecting image as background, using base64 image instead
46+
await uploadContent(page.request, user, Buffer.from(imageBase64, 'base64'), 'image/jpeg', '/folder/image.jpg')
47+
48+
await page.goto('settings/user/theming')
49+
await page.getByRole('heading', { name: 'Background and color' }).waitFor({ state: 'visible' })
50+
51+
await page.getByRole('button', { name: 'Custom background' }).click()
52+
53+
const filePicker = new BackgroundFilePickerDialogPage(page)
54+
await filePicker.openFolder('folder')
55+
await filePicker.selectFile('image.jpg')
56+
await filePicker.confirm()
57+
58+
await expect(page.getByRole('button', { name: 'Custom background', pressed: true })).toBeVisible()
59+
// backgroundImage is like this: "url(\"<nc-instance>/apps/theming/background?v=<hash>\")"
60+
await expect.poll(async () => (await getBodyThemingSnapshot(page)).backgroundImage).toContain('/apps/theming/background?')
61+
})
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
* SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
3+
* SPDX-License-Identifier: AGPL-3.0-or-later
4+
*/
5+
6+
import type { Locator, Page } from '@playwright/test'
7+
8+
/**
9+
* The file-picker dialog opened by the "Custom background" card/button on
10+
* Personal settings > Appearance and accessibility > Background and color
11+
*/
12+
export class BackgroundFilePickerDialogPage {
13+
constructor(private readonly page: Page) {}
14+
15+
/** The open file-picker dialog. */
16+
dialog(): Locator {
17+
return this.page.getByRole('dialog')
18+
}
19+
20+
/**
21+
* Returns a row (file or folder) from inside the picker.
22+
*/
23+
getRow(name: string): Locator {
24+
return this.dialog().getByTestId('row-name').filter({ hasText: name })
25+
}
26+
27+
/** Navigate into a folder. */
28+
async openFolder(name: string): Promise<void> {
29+
await this.getRow(name).click()
30+
}
31+
32+
/** Select a file row. */
33+
async selectFile(name: string): Promise<void> {
34+
await this.getRow(name).click()
35+
}
36+
37+
/** Confirm the current selection as the new background. */
38+
async confirm(): Promise<void> {
39+
await this.dialog().getByRole('button', { name: 'Select background', exact: true }).click()
40+
}
41+
}

0 commit comments

Comments
 (0)