-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #50739 from nextcloud/feat/share-grid-view
feat(sharing): Allow to set default view mode for public shares
- Loading branch information
Showing
15 changed files
with
215 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/** | ||
* SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors | ||
* SPDX-License-Identifier: AGPL-3.0-or-later | ||
*/ | ||
import type { Folder, Node } from '@nextcloud/files' | ||
|
||
declare module '@nextcloud/event-bus' { | ||
export interface NextcloudEvents { | ||
// mapping of 'event name' => 'event type' | ||
'files:list:updated': { folder: Folder, contents: Node[] } | ||
'files:config:updated': { key: string, value: boolean } | ||
} | ||
} | ||
|
||
export {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
102 changes: 102 additions & 0 deletions
102
cypress/e2e/files_sharing/public-share/default-view.cy.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
/*! | ||
* SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors | ||
* SPDX-License-Identifier: AGPL-3.0-or-later | ||
*/ | ||
import type { User } from '@nextcloud/cypress' | ||
import { getRowForFile } from '../../files/FilesUtils.ts' | ||
import { createShare, setupData } from './setup-public-share.ts' | ||
|
||
describe('files_sharing: Public share - setting the default view mode', () => { | ||
|
||
let user: User | ||
|
||
beforeEach(() => { | ||
cy.createRandomUser() | ||
.then(($user) => (user = $user)) | ||
.then(() => setupData(user, 'shared')) | ||
}) | ||
|
||
it('is by default in list view', () => { | ||
const context = { user } | ||
createShare(context, 'shared') | ||
.then((url) => { | ||
cy.logout() | ||
cy.visit(url!) | ||
|
||
// See file is visible | ||
getRowForFile('foo.txt').should('be.visible') | ||
// See we are in list view | ||
cy.findByRole('button', { name: 'Switch to grid view' }) | ||
.should('be.visible') | ||
.and('not.be.disabled') | ||
}) | ||
}) | ||
|
||
it('can be toggled by user', () => { | ||
const context = { user } | ||
createShare(context, 'shared') | ||
.then((url) => { | ||
cy.logout() | ||
cy.visit(url!) | ||
|
||
// See file is visible | ||
getRowForFile('foo.txt') | ||
.should('be.visible') | ||
// See we are in list view | ||
.find('.files-list__row-icon') | ||
.should(($el) => expect($el.outerWidth()).to.be.lessThan(99)) | ||
|
||
// See the grid view toggle | ||
cy.findByRole('button', { name: 'Switch to grid view' }) | ||
.should('be.visible') | ||
.and('not.be.disabled') | ||
// And can change to grid view | ||
.click() | ||
|
||
// See we are in grid view | ||
getRowForFile('foo.txt') | ||
.find('.files-list__row-icon') | ||
.should(($el) => expect($el.outerWidth()).to.be.greaterThan(99)) | ||
|
||
// See the grid view toggle is now the list view toggle | ||
cy.findByRole('button', { name: 'Switch to list view' }) | ||
.should('be.visible') | ||
.and('not.be.disabled') | ||
}) | ||
}) | ||
|
||
it('can be changed to default grid view', () => { | ||
const context = { user } | ||
createShare(context, 'shared') | ||
.then((url) => { | ||
// Can set the "grid" view checkbox | ||
cy.findByRole('list', { name: 'Link shares' }) | ||
.findAllByRole('listitem') | ||
.first() | ||
.findByRole('button', { name: /Actions/i }) | ||
.click() | ||
cy.findByRole('menuitem', { name: /Customize link/i }).click() | ||
cy.findByRole('checkbox', { name: /Show files in grid view/i }) | ||
.scrollIntoView() | ||
cy.findByRole('checkbox', { name: /Show files in grid view/i }) | ||
.should('not.be.checked') | ||
.check({ force: true }) | ||
|
||
// Wait for the share update | ||
cy.intercept('PUT', '**/ocs/v2.php/apps/files_sharing/api/v1/shares/*').as('updateShare') | ||
cy.findByRole('button', { name: 'Update share' }).click() | ||
cy.wait('@updateShare').its('response.statusCode').should('eq', 200) | ||
|
||
// Logout and visit the share | ||
cy.logout() | ||
cy.visit(url!) | ||
|
||
// See file is visible | ||
getRowForFile('foo.txt').should('be.visible') | ||
// See we are in list view | ||
cy.findByRole('button', { name: 'Switch to list view' }) | ||
.should('be.visible') | ||
.and('not.be.disabled') | ||
}) | ||
}) | ||
}) |
Large diffs are not rendered by default.
Oops, something went wrong.
File renamed without changes.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
1031-1031.js.license |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.