Skip to content

Commit

Permalink
fix: resolving private links to hidden shares
Browse files Browse the repository at this point in the history
  • Loading branch information
JammingBen committed Jan 11, 2024
1 parent 2394630 commit b4b8d5f
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 1 deletion.
1 change: 1 addition & 0 deletions changelog/unreleased/enhancement-show-hide-shares
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ Furthermore, accepting and rejecting shares has been renamed to "enable sync"/"d
https://github.com/owncloud/web/issues/9531
https://github.com/owncloud/web/pull/9718
https://github.com/owncloud/web/pull/10097
https://github.com/owncloud/web/pull/10321
11 changes: 10 additions & 1 deletion packages/web-runtime/src/pages/resolvePrivateLink.vue
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ import {
useRouteQuery,
useConfigurationManager,
createLocationSpaces,
createLocationShares
createLocationShares,
useClientService
} from '@ownclouders/web-pkg'
import { unref, defineComponent, computed, onMounted, ref, Ref } from 'vue'
// import { createLocationSpaces } from 'web-app-files/src/router'
Expand All @@ -70,6 +71,8 @@ export default defineComponent({
const id = useRouteParam('fileId')
const configurationManager = useConfigurationManager()
const { $gettext } = useGettext()
const clientService = useClientService()
const resource: Ref<Resource> = ref()
const sharedParentResource: Ref<Resource> = ref()
const isUnacceptedShareError = ref(false)
Expand Down Expand Up @@ -114,9 +117,14 @@ export default defineComponent({
}
let resourceIsNestedInShare = false
let isHiddenShare = false
if (isShareSpaceResource(space)) {
sharedParentResource.value = resource
resourceIsNestedInShare = path !== '/'
if (!resourceIsNestedInShare && space.shareId) {
const { shareInfo } = yield clientService.owncloudSdk.shares.getShare(space.shareId)
isHiddenShare = shareInfo.hidden === 'true'
}
}
let fileId: string
Expand Down Expand Up @@ -145,6 +153,7 @@ export default defineComponent({
scrollTo:
targetLocation.name === 'files-shares-with-me' ? space.shareId : unref(resource).fileId,
...(unref(details) && { details: unref(details) }),
...(isHiddenShare && { 'q_share-visibility': 'hidden' }),
...(openWithDefault && { openWithDefaultApp: 'true' })
}
Expand Down
27 changes: 27 additions & 0 deletions packages/web-runtime/tests/unit/pages/resolvePrivateLink.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,28 @@ describe('resolvePrivateLink', () => {
expect.objectContaining({ name: 'files-shares-with-me' })
)
})
it('adds the hidden share param for hidden shares', async () => {
const fileId = '1'
const driveAliasAndItem = 'shares/someShare'
const space = mock<SpaceResource>({
driveType: 'share',
getDriveAliasAndItem: () => driveAliasAndItem
})
const resource = mock<Resource>({ fileId, type: 'file' })
const { wrapper, mocks } = getWrapper({
space,
resource,
fileId,
path: '/',
hiddenShare: true
})
await wrapper.vm.resolvePrivateLinkTask.last
expect(mocks.$router.push).toHaveBeenCalledWith(
expect.objectContaining({
query: expect.objectContaining({ 'q_share-visibility': 'hidden' })
})
)
})
})
it('passes the details query param if given via query', async () => {
const details = 'sharing'
Expand Down Expand Up @@ -137,6 +159,7 @@ function getWrapper({
path = '',
fileId = '',
details = '',
hiddenShare = false,
openWithDefaultAppQuery = 'true',
openLinksWithDefaultApp = true
} = {}) {
Expand Down Expand Up @@ -165,6 +188,10 @@ function getWrapper({
)

const mocks = { ...defaultComponentMocks() }
mocks.$clientService.owncloudSdk.shares.getShare.mockResolvedValue({
shareInfo: { hidden: hiddenShare ? 'true' : 'false' }
})

const storeOptions = defaultStoreMockOptions
const store = createStore(storeOptions)

Expand Down

0 comments on commit b4b8d5f

Please sign in to comment.