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

fix: resolving links without drive alias #10154

Merged
merged 1 commit into from
Dec 12, 2023
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
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