Skip to content

Commit 8c6b7f4

Browse files
authored
Merge pull request #60134 from nextcloud/fix-rendering-custom-columns-in-file-lists
Fix rendering custom columns in file lists
2 parents dfec8db + ad38c5d commit 8c6b7f4

5 files changed

Lines changed: 108 additions & 4 deletions

File tree

apps/files/src/components/FileEntry.vue

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@
9898
<CustomElementRender
9999
:active-folder="activeFolder"
100100
:active-view="activeView"
101-
:render="column.render"
101+
:render="adaptColumnRenderToCustomElementRender(column)"
102102
:source="source" />
103103
</td>
104104
</tr>
@@ -299,6 +299,12 @@ export default defineComponent({
299299
view: this.activeView!,
300300
})
301301
},
302+
303+
adaptColumnRenderToCustomElementRender(column) {
304+
return ({ nodes, view }) => {
305+
return column.render(nodes[0], view)
306+
}
307+
},
302308
},
303309
})
304310
</script>

cypress/e2e/files_trashbin/files.cy.ts

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55

66
import type { User } from '@nextcloud/e2e-test-server/cypress'
77

8+
import { ShareType } from '@nextcloud/sharing'
89
import { deleteDownloadsFolderBeforeEach } from '../../support/utils/deleteDownloadsFolder.ts'
10+
import { randomString } from '../../support/utils/randomString.ts'
911
import { deleteFileWithRequest, getRowForFileId, selectAllFiles, triggerActionForFileId } from '../files/FilesUtils.ts'
1012

1113
describe('files_trashbin: download files', { testIsolation: true }, () => {
@@ -67,3 +69,69 @@ describe('files_trashbin: download files', { testIsolation: true }, () => {
6769
cy.get('[data-cy-files-list-selection-action="download"]').should('not.exist')
6870
})
6971
})
72+
73+
describe('files_trashbin: file row', { testIsolation: true }, () => {
74+
let alice: User
75+
let bob: User
76+
let randomGroupName: string
77+
let fileId: number
78+
79+
before(() => {
80+
randomGroupName = randomString(10)
81+
cy.runOccCommand(`group:add ${randomGroupName}`)
82+
83+
cy.createRandomUser().then((user) => {
84+
alice = user
85+
86+
cy.modifyUser(alice, 'display', 'Alice')
87+
88+
cy.mkdir(alice, '/Shared')
89+
})
90+
91+
cy.createRandomUser().then((user) => {
92+
bob = user
93+
94+
cy.modifyUser(bob, 'display', 'Bob')
95+
96+
cy.runOccCommand(`group:adduser ${randomGroupName} ${bob.userId}`)
97+
})
98+
})
99+
100+
it('shows data for file deleted by owner', () => {
101+
cy.uploadContent(alice, new Blob(['<content>']), 'text/plain', '/test-file.txt')
102+
.then(({ headers }) => fileId = Number.parseInt(headers['oc-fileid']))
103+
.then(() => deleteFileWithRequest(alice, '/test-file.txt'))
104+
105+
cy.login(alice)
106+
cy.visit('/apps/files/trashbin')
107+
108+
getRowForFileId(fileId).should('be.visible')
109+
// The full name includes one span for the name and one span for the
110+
// extension, so text() returns a space when composing them even if it
111+
// will not be visible when rendered in the browser.
112+
getRowForFileId(fileId).find('[data-cy-files-list-row-name]').should((element) => expect(element.text().trim()).to.equal('test-file .txt'))
113+
getRowForFileId(fileId).find('[data-cy-files-list-row-column-custom="files_trashbin--original-location"]').should('have.text', 'All files')
114+
getRowForFileId(fileId).find('[data-cy-files-list-row-column-custom="files_trashbin--deleted-by"]').should('have.text', 'You')
115+
getRowForFileId(fileId).find('[data-cy-files-list-row-column-custom="files_trashbin--deleted"]').should('have.text', 'few seconds ago')
116+
})
117+
118+
it('shows data for file deleted by sharee in a folder shared with a group', () => {
119+
cy.createShare(alice, '/Shared', ShareType.Group, randomGroupName)
120+
121+
cy.uploadContent(alice, new Blob(['<content>']), 'text/plain', '/Shared/test-file.txt')
122+
.then(({ headers }) => fileId = Number.parseInt(headers['oc-fileid']))
123+
.then(() => deleteFileWithRequest(bob, '/Shared/test-file.txt'))
124+
125+
cy.login(alice)
126+
cy.visit('/apps/files/trashbin')
127+
128+
getRowForFileId(fileId).should('be.visible')
129+
// The full name includes one span for the name and one span for the
130+
// extension, so text() returns a space when composing them even if it
131+
// will not be visible when rendered in the browser.
132+
getRowForFileId(fileId).find('[data-cy-files-list-row-name]').should((element) => expect(element.text().trim()).to.equal('test-file .txt'))
133+
getRowForFileId(fileId).find('[data-cy-files-list-row-column-custom="files_trashbin--original-location"]').should('have.text', 'Shared')
134+
getRowForFileId(fileId).find('[data-cy-files-list-row-column-custom="files_trashbin--deleted-by"]').should('have.text', 'Bob')
135+
getRowForFileId(fileId).find('[data-cy-files-list-row-column-custom="files_trashbin--deleted"]').should('have.text', 'few seconds ago')
136+
})
137+
})

cypress/support/commands.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,36 @@ Cypress.Commands.add('uploadContent', (user: User, blob: Blob, mimeType: string,
181181
})
182182
})
183183

184+
Cypress.Commands.add('createShare', (sharer: User, path: string, shareType: number, shareWith: string) => {
185+
return cy.clearCookies()
186+
.then(async () => {
187+
try {
188+
const url = `${Cypress.env('baseUrl')}/ocs/v2.php/apps/files_sharing/api/v1/shares`
189+
const response = await axios({
190+
url,
191+
method: 'POST',
192+
auth: {
193+
username: sharer.userId,
194+
password: sharer.password,
195+
},
196+
headers: {
197+
'OCS-ApiRequest': 'true',
198+
},
199+
data: {
200+
path,
201+
shareType,
202+
shareWith,
203+
},
204+
})
205+
cy.log(`Created share for ${path} of type ${shareType} with ${shareWith}`, response)
206+
return response
207+
} catch (cause) {
208+
cy.log('error', cause)
209+
throw new Error(`Unable to create share for ${path} of type ${shareType} with ${shareWith}`, { cause })
210+
}
211+
})
212+
})
213+
184214
/**
185215
* Reset the admin theming entirely
186216
*/

dist/files-main.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/files-main.js.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.

0 commit comments

Comments
 (0)