Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Omit 'page'-query in breadcrumb navigation #8061

Merged
merged 2 commits into from
Dec 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Bugfix: Omit "page"-query in breadcrumb navigation

We've omitted the "page"-query when navigating via breadcrumb. This solves an issue were the file list would be empty after navigating via breadcrumb from a paginated folder.

https://github.com/owncloud/web/pull/8061
https://github.com/owncloud/web/issues/8060
2 changes: 1 addition & 1 deletion packages/web-app-files/src/helpers/breadcrumbs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export const breadcrumbsFromPath = (
text,
to: {
path: '/' + [...current].splice(0, current.length - resource.length + i + 1).join('/'),
query: omit(currentRoute.query, 'fileId') // TODO: we need the correct fileId in the query. until we have that we must omit it because otherwise we would correct the path to the one of the (wrong) fileId.
query: omit(currentRoute.query, 'fileId', 'page') // TODO: we need the correct fileId in the query. until we have that we must omit it because otherwise we would correct the path to the one of the (wrong) fileId.
}
} as BreadcrumbItem)
)
Expand Down
2 changes: 1 addition & 1 deletion packages/web-app-files/src/views/spaces/GenericSpace.vue
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ export default defineComponent({

let spaceBreadcrumbItem
let { params, query } = createFileRouteOptions(space, { fileId: space.fileId })
query = { ...unref(route).query, ...query }
query = omit({ ...unref(route).query, ...query }, 'page')
if (isPersonalSpaceResource(space)) {
spaceBreadcrumbItem = {
text: space.name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,30 @@ describe('GenericSpace view', () => {
expect(wrapper.find('resource-table-stub').exists()).toBeTruthy()
})
})
describe('breadcrumbs', () => {
it.each([
{ driveType: 'personal', expectedItems: 1 },
{ driveType: 'project', expectedItems: 2 },
{ driveType: 'share', expectedItems: 3 }
])('include root item(s)', (data) => {
const { driveType } = data
const space = { id: 1, getDriveAliasAndItem: jest.fn(), driveType }
const { wrapper } = getMountedWrapper({ files, props: { space } })
expect(wrapper.find('app-bar-stub').props().breadcrumbs.length).toBe(data.expectedItems)
})
it('include the root item and the current folder', () => {
const folderName = 'someFolder'
const { wrapper } = getMountedWrapper({ files, props: { item: `/${folderName}` } })
expect(wrapper.find('app-bar-stub').props().breadcrumbs.length).toBe(2)
expect(wrapper.find('app-bar-stub').props().breadcrumbs[1].text).toEqual(folderName)
})
it('omit the "page"-query of the current route', () => {
const currentRoute = { name: 'files-spaces-generic', path: '/', query: { page: '2' } }
const { wrapper } = getMountedWrapper({ files, props: { item: 'someFolder' }, currentRoute })
const breadCrumbItem = wrapper.find('app-bar-stub').props().breadcrumbs[0]
expect(breadCrumbItem.to.query.page).toBeUndefined()
})
})
describe('loader task', () => {
it('re-loads the resources on item change', async () => {
const loaderSpy = jest.spyOn((GenericSpace as any).methods, 'performLoaderTask')
Expand All @@ -85,17 +109,21 @@ describe('GenericSpace view', () => {
})
})

function getMountedWrapper({ mocks = {}, props = {}, files = [], loading = false } = {}) {
function getMountedWrapper({
mocks = {},
props = {},
files = [],
loading = false,
currentRoute = { name: 'files-spaces-generic', path: '/' }
} = {}) {
jest.mocked(useResourcesViewDefaults).mockImplementation(() =>
useResourcesViewDefaultsMock({
paginatedResources: ref(files),
areResourcesLoading: ref(loading)
})
)
const defaultMocks = {
...defaultComponentMocks({
currentRoute: { name: 'files-spaces-generic', path: '/' }
}),
...defaultComponentMocks({ currentRoute }),
...(mocks && mocks)
}
const storeOptions = { ...defaultStoreMockOptions }
Expand Down