Skip to content

Commit

Permalink
Use user id as storage id for share pages
Browse files Browse the repository at this point in the history
  • Loading branch information
kulmann committed Jun 10, 2022
1 parent 8944526 commit 87b8130
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 21 deletions.
2 changes: 1 addition & 1 deletion .drone.env
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# The version of OCIS to use in pipelines that test against OCIS
OCIS_COMMITID=6cde9c540557954172c530b5f6c0e0f2b7d14b01
OCIS_COMMITID=383b58f9e7a4420e7cc9de3061ad71009c13f0ba
OCIS_BRANCH=master
Original file line number Diff line number Diff line change
Expand Up @@ -577,24 +577,24 @@ export default defineComponent({
this.openWithPanel('sharing-item')
},
folderLink(file) {
return this.createFolderLink(file.path, file, false)
return this.createFolderLink(file.path, file)
},
parentFolderLink(file) {
return this.createFolderLink(path.dirname(file.path), file, true)
return this.createFolderLink(path.dirname(file.path), file)
},
createFolderLink(path, resource, parentFolder) {
createFolderLink(path, resource) {
if (this.targetRoute === null) {
return {}
}
const params = {
item: path.replace(/^\//, '') || '/',
...this.targetRoute.params,
...mapResourceFields(resource, this.targetRouteParamMapping)
...mapResourceFields(resource, this.targetRouteParamMapping),
...this.targetRoute.params
}
const query = {
...this.targetRoute.query,
...mapResourceFields(resource, this.targetRouteQueryMapping)
...mapResourceFields(resource, this.targetRouteQueryMapping),
...this.targetRoute.query
}
if (this.hasProjectSpaces) {
Expand Down
6 changes: 5 additions & 1 deletion packages/web-app-files/src/views/shares/SharedViaLink.vue
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ import { useResourcesViewDefaults } from '../../composables'
import { defineComponent } from '@vue/composition-api'
import { Resource } from '../../helpers/resource'
import { shareQuickLinkHelp } from '../../helpers/contextualHelpers'
import { useStore } from 'web-pkg/src/composables'
const visibilityObserver = new VisibilityObserver()
Expand All @@ -89,10 +90,13 @@ export default defineComponent({
mixins: [FileActions, MixinResources, MixinMountSideBar, MixinFilesListFilter],
setup() {
const store = useStore()
return {
...useResourcesViewDefaults<Resource, any, any[]>(),
resourceTargetLocation: createLocationSpaces('files-spaces-personal')
resourceTargetLocation: createLocationSpaces('files-spaces-personal', {
params: { storageId: store.getters.user.id }
})
}
},
Expand Down
9 changes: 7 additions & 2 deletions packages/web-app-files/src/views/shares/SharedWithMe.vue
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ import MixinMountSideBar from '../../mixins/sidebar/mountSideBar'
import { VisibilityObserver } from 'web-pkg/src/observer'
import { ImageDimension, ImageType } from '../../constants'
import { useSort, useResourcesViewDefaults } from '../../composables'
import { useCapabilityShareJailEnabled, useRouteQuery } from 'web-pkg/src/composables'
import { useCapabilityShareJailEnabled, useRouteQuery, useStore } from 'web-pkg/src/composables'
import debounce from 'lodash-es/debounce'
import AppLoadingSpinner from 'web-pkg/src/components/AppLoadingSpinner.vue'
Expand Down Expand Up @@ -216,9 +216,14 @@ export default defineComponent({
any[]
>()
const store = useStore()
const hasShareJail = useCapabilityShareJailEnabled()
const resourceTargetLocation = computed(() =>
createLocationSpaces(unref(hasShareJail) ? 'files-spaces-share' : 'files-spaces-personal')
unref(hasShareJail)
? createLocationSpaces('files-spaces-share')
: createLocationSpaces('files-spaces-personal', {
params: { storageId: store.getters.user.id }
})
)
const resourceTargetParamMapping = computed(() =>
unref(hasShareJail) ? { name: 'shareName', path: 'item' } : undefined
Expand Down
7 changes: 6 additions & 1 deletion packages/web-app-files/src/views/shares/SharedWithOthers.vue
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ import { createLocationSpaces } from '../../router'
import { useResourcesViewDefaults } from '../../composables'
import { defineComponent } from '@vue/composition-api'
import { Resource } from '../../helpers/resource'
import { useStore } from 'web-pkg/src/composables'
const visibilityObserver = new VisibilityObserver()
Expand All @@ -89,9 +90,13 @@ export default defineComponent({
mixins: [FileActions, MixinResources, MixinMountSideBar, MixinFilesListFilter],
setup() {
const store = useStore()
return {
...useResourcesViewDefaults<Resource, any, any[]>(),
resourceTargetLocation: createLocationSpaces('files-spaces-personal')
resourceTargetLocation: createLocationSpaces('files-spaces-personal', {
params: { storageId: store.getters.user.id }
})
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { getStore, localVue, createFile } from '../views.setup.js'
import { createLocationSpaces } from '../../../../src/router'
import FileActions from '@files/src/mixins/fileActions'
import SharedViaLink from '@files/src/views/shares/SharedViaLink.vue'
import Users from '@/__fixtures__/users'

const component = { ...SharedViaLink, mounted: jest.fn() }

Expand Down Expand Up @@ -190,6 +191,7 @@ function createStore({ totalFilesCount, highlightedFile, selectedFiles } = {}) {
return getStore({
highlightedFile,
totalFilesCount,
selectedFiles
selectedFiles,
user: { id: Users.alice.id }
})
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { localVue, getStore, getRouter } from '../views.setup'
import SharedWithMe from '@files/src/views/shares/SharedWithMe.vue'
import { ShareStatus, ShareTypes } from '@files/src/helpers/share'
import { extractDomSelector } from '../../../../src/helpers/resource'
import Users from '@/__fixtures__/users'

const stubs = {
'app-bar': true,
Expand Down Expand Up @@ -54,7 +55,8 @@ describe('SharedWithMe view', () => {
store: getStore({
highlightedFile: file,
activeFiles: [file],
totalFilesCount: { files: 0, folders: 1 }
totalFilesCount: { files: 0, folders: 1 },
user: { id: Users.alice.id }
})
})
expect(wrapper.find(selectors.pendingTable).exists()).toBeFalsy()
Expand All @@ -68,7 +70,8 @@ describe('SharedWithMe view', () => {
store: getStore({
highlightedFile: file,
activeFiles: [file],
totalFilesCount: { files: 0, folders: 1 }
totalFilesCount: { files: 0, folders: 1 },
user: { id: Users.alice.id }
})
})
expect(wrapper.find(selectors.pendingTable).exists()).toBeTruthy()
Expand All @@ -88,7 +91,8 @@ describe('SharedWithMe view', () => {
store: getStore({
highlightedFile: pendingShares[0],
activeFiles: pendingShares,
totalFilesCount: { files: 0, folders: pendingShares.length }
totalFilesCount: { files: 0, folders: pendingShares.length },
user: { id: Users.alice.id }
})
})
describe('as long as the pending shares are collapsed', () => {
Expand All @@ -106,7 +110,8 @@ describe('SharedWithMe view', () => {
store: getStore({
highlightedFile: pendingShares[0],
activeFiles: pendingShares,
totalFilesCount: { files: 0, folders: pendingShares.length }
totalFilesCount: { files: 0, folders: pendingShares.length },
user: { id: Users.alice.id }
})
})
await wrapper.find(selectors.pendingExpand).trigger('click')
Expand Down Expand Up @@ -137,7 +142,8 @@ describe('SharedWithMe view', () => {
store: getStore({
highlightedFile: file,
activeFiles: [file],
totalFilesCount: { files: 0, folders: 1 }
totalFilesCount: { files: 0, folders: 1 },
user: { id: Users.alice.id }
})
})
it('should not show a "no content" message', () => {
Expand All @@ -159,7 +165,8 @@ describe('SharedWithMe view', () => {
store: getStore({
highlightedFile: file,
activeFiles: [file],
totalFilesCount: { files: 0, folders: 1 }
totalFilesCount: { files: 0, folders: 1 },
user: { id: Users.alice.id }
}),
viewMode: ShareStatus.declined
})
Expand All @@ -182,7 +189,8 @@ describe('SharedWithMe view', () => {
function mountOptions({
store = getStore({
activeFiles: [],
totalFilesCount: { files: 0, folders: 0 }
totalFilesCount: { files: 0, folders: 0 },
user: { id: Users.alice.id }
}),
loading = false,
viewMode = ShareStatus.accepted
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { getStore, localVue } from '../views.setup.js'
import FileActions from '@files/src/mixins/fileActions.js'
import SharedWithOthers from '@files/src/views/shares/SharedWithOthers.vue'
import SharedData from '@/__fixtures__/sharedFiles.js'
import Users from '@/__fixtures__/users'
import { createLocationShares } from '../../../../src/router'
import { buildSharedResource } from '../../../../src/helpers/resources'
import { Settings, DateTime } from 'luxon'
Expand Down Expand Up @@ -203,7 +204,8 @@ describe('SharedWithOthers view', () => {
} = {}) {
const store = getStore({
selectedFiles,
totalFilesCount: { files: paginatedResources.length, folders: 0 }
totalFilesCount: { files: paginatedResources.length, folders: 0 },
user: { id: Users.alice.id }
})
const component = {
...SharedWithOthers,
Expand Down

0 comments on commit 87b8130

Please sign in to comment.