Skip to content

Commit

Permalink
Merge pull request #10154 from owncloud/fix-resolving-without-drive-a…
Browse files Browse the repository at this point in the history
…lias

fix: resolving links without drive alias
  • Loading branch information
kulmann committed Dec 12, 2023
2 parents 585282a + accc87e commit b2397da
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 3 deletions.
6 changes: 6 additions & 0 deletions changelog/unreleased/bugfix-resolve-link-without-drive-alias
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Bugfix: Resolving links without drive alias

Resolving links without a drive alias has been fixed in case a fileId is given via query param.

https://github.com/owncloud/web/pull/10154
https://github.com/owncloud/web/issues/9269
12 changes: 12 additions & 0 deletions packages/web-app-files/src/views/spaces/DriveResolver.vue
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,18 @@ export default defineComponent({
}
onMounted(async () => {
if (!unref(driveAliasAndItem) && unref(fileId)) {
return router.push({
name: 'resolvePrivateLink',
params: { fileId: unref(fileId) },
query: {
...(configurationManager.options.openLinksWithDefaultApp && {
openWithDefaultApp: 'true'
})
}
})
}
const space = unref(resolvedDrive.space)
if (space && isPublicSpaceResource(space)) {
const isRunningOnEos = store.getters.configuration?.options?.runningOnEos
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import DriveResolver from '../../../../src/views/spaces/DriveResolver.vue'
import { useDriveResolver } from '@ownclouders/web-pkg'
import { queryItemAsString, useDriveResolver, useRouteParam } from '@ownclouders/web-pkg'
import { computed, ref } from 'vue'
import { mock, mockDeep } from 'jest-mock-extended'
import { ClientService } from '@ownclouders/web-pkg'
Expand All @@ -21,7 +21,9 @@ import {
jest.mock('@ownclouders/web-pkg', () => ({
...jest.requireActual('@ownclouders/web-pkg'),
useGetMatchingSpace: jest.fn(),
useDriveResolver: jest.fn()
useDriveResolver: jest.fn(),
useRouteParam: jest.fn(),
queryItemAsString: jest.fn()
}))

describe('DriveResolver view', () => {
Expand Down Expand Up @@ -102,15 +104,29 @@ describe('DriveResolver view', () => {
})
)
})
it('redirects to private link if no drive alias but a fileId is given', async () => {
const { wrapper, mocks } = getMountedWrapper({ driveAliasAndItem: '' })
await wrapper.vm.$nextTick()

expect(mocks.$router.push).toHaveBeenCalledWith(
expect.objectContaining({
name: 'resolvePrivateLink'
})
)
})
})

function getMountedWrapper({
mocks = {},
space = undefined,
internalSpace = undefined,
currentRouteName = 'files-spaces-generic',
isUserContextReady = false
isUserContextReady = false,
driveAliasAndItem = 'personal/einstein/file',
fileId = '1'
} = {}) {
jest.mocked(useRouteParam).mockReturnValue(ref(driveAliasAndItem))
jest.mocked(queryItemAsString).mockReturnValue(fileId)
jest.mocked(useDriveResolver).mockImplementation(() => ({
space,
item: ref('/'),
Expand Down

0 comments on commit b2397da

Please sign in to comment.