Skip to content

Commit

Permalink
Shared with me/others/links views
Browse files Browse the repository at this point in the history
Shares will always appear as a space, which breaks opening single files shares with apps. It breaks because web was supposed to redirect to the universal url (all files), instead of a "share" url. I consider this to be broken in upstream, as this redirection was supposed to be supported.
  • Loading branch information
elizavetaRa authored and diocas committed Jun 1, 2023
1 parent f972d1d commit 49e125f
Show file tree
Hide file tree
Showing 6 changed files with 83 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -776,10 +776,10 @@ export default defineComponent({
space = buildShareSpaceResource({
shareId: resource.shareId,
shareName: resource.name,
serverUrl: configurationManager.serverUrl
serverUrl: configurationManager.serverUrl,
webDavPath: resource.webDavPath
})
}
/**
* Triggered when a default action is triggered on a file
* @property {object} resource resource for which the event is triggered
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@

<script lang="ts">
import ResourceTable from '../FilesList/ResourceTable.vue'
import { computed, defineComponent, unref } from 'vue'
import { computed, defineComponent, unref, ref } from 'vue'
import { debounce } from 'lodash-es'
import { ImageDimension, ImageType } from 'web-pkg/src/constants'
import { VisibilityObserver } from 'web-pkg/src/observer'
Expand Down Expand Up @@ -193,7 +193,7 @@ export default defineComponent({
},
setup() {
const store = useStore()
const hasShareJail = useCapabilityShareJailEnabled()
const hasShareJail = ref(false)
const resourceTargetRouteCallback = ({
path,
fileId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ export const useResourceRouteResolver = (options: ResourceRouteResolverOptions,
buildShareSpaceResource({
shareId: resource.shareId,
shareName: resource.name,
serverUrl: configurationManager.serverUrl
serverUrl: configurationManager.serverUrl,
webDavPath: resource.webDavPath
})
)
}
Expand Down
36 changes: 34 additions & 2 deletions packages/web-app-files/src/views/shares/SharedViaLink.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
:are-paths-displayed="true"
:resources="paginatedResources"
:header-position="fileListHeaderY"
:target-route-callback="resourceTargetRouteCallback"
:sort-by="sortBy"
:sort-dir="sortDir"
@file-click="$_fileActions_triggerDefaultAction"
Expand Down Expand Up @@ -79,11 +80,15 @@ import FilesViewWrapper from '../../components/FilesViewWrapper.vue'
import ResourceTable from '../../components/FilesList/ResourceTable.vue'
import { useResourcesViewDefaults } from '../../composables'
import { defineComponent } from 'vue'
import { defineComponent, unref } from 'vue'
import { Resource } from 'web-client'
import { useCapabilityProjectSpacesEnabled, useStore } from 'web-pkg/src/composables'
import { useCapabilityShareJailEnabled, useCapabilityProjectSpacesEnabled, useStore } from 'web-pkg/src/composables'
import { buildShareSpaceResource, SpaceResource } from 'web-client/src/helpers'
import { configurationManager } from 'web-pkg/src/configuration'
import { CreateTargetRouteOptions } from 'web-app-files/src/helpers/folderLink'
import { createLocationSpaces } from 'web-app-files/src/router'
import { createFileRouteOptions } from 'web-pkg/src/helpers/router'
import { Location } from 'vue-router'
const visibilityObserver = new VisibilityObserver()
Expand All @@ -104,6 +109,7 @@ export default defineComponent({
setup() {
const store = useStore()
const hasShareJail = useCapabilityShareJailEnabled()
const getSpace = (resource: Resource): SpaceResource => {
const storageId = resource.storageId
// FIXME: Once we have the shareId in the OCS response, we can check for that and early return the share
Expand All @@ -119,7 +125,33 @@ export default defineComponent({
})
}
const resourceTargetRouteCallback = ({
path,
fileId,
resource
}: CreateTargetRouteOptions): Location => {
if (unref(hasShareJail)) {
const space = buildShareSpaceResource({
shareId: resource.id,
shareName: resource.name,
serverUrl: configurationManager.serverUrl
})
return createLocationSpaces(
'files-spaces-generic',
createFileRouteOptions(space, { path, fileId })
)
}
const personalSpace = store.getters['runtime/spaces/spaces'].find(
(space) => space.driveType === 'personal'
)
return createLocationSpaces(
'files-spaces-generic',
createFileRouteOptions(personalSpace, { path, fileId })
)
}
return {
resourceTargetRouteCallback,
...useResourcesViewDefaults<Resource, any, any[]>(),
getSpace,
hasProjectSpaces: useCapabilityProjectSpacesEnabled()
Expand Down
38 changes: 35 additions & 3 deletions packages/web-app-files/src/views/shares/SharedWithOthers.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
:are-paths-displayed="true"
:resources="paginatedResources"
:header-position="fileListHeaderY"
:target-route-callback="resourceTargetRouteCallback"
:sort-by="sortBy"
:sort-dir="sortDir"
@file-click="$_fileActions_triggerDefaultAction"
Expand Down Expand Up @@ -80,11 +81,15 @@ import SideBar from '../../components/SideBar/SideBar.vue'
import FilesViewWrapper from '../../components/FilesViewWrapper.vue'
import { useResourcesViewDefaults } from '../../composables'
import { defineComponent } from 'vue'
import { defineComponent, unref } from 'vue'
import { Resource } from 'web-client'
import { buildShareSpaceResource, SpaceResource } from 'web-client/src/helpers'
import { useStore } from 'web-pkg/src/composables'
import { useCapabilityShareJailEnabled, useStore } from 'web-pkg/src/composables'
import { configurationManager } from 'web-pkg/src/configuration'
import { CreateTargetRouteOptions } from 'web-app-files/src/helpers/folderLink'
import { createLocationSpaces } from 'web-app-files/src/router'
import { createFileRouteOptions } from 'web-pkg/src/helpers/router'
import { Location } from 'vue-router'
const visibilityObserver = new VisibilityObserver()
Expand All @@ -105,13 +110,14 @@ export default defineComponent({
setup() {
const store = useStore()
const hasShareJail = useCapabilityShareJailEnabled()
const getSpace = (resource: Resource): SpaceResource => {
const storageId = resource.storageId
// FIXME: Once we have the shareId in the OCS response, we can check for that and early return the share
const space = store.getters['runtime/spaces/spaces'].find((space) => space.id === storageId)
if (space) {
return space
}
}
return buildShareSpaceResource({
shareId: resource.shareId,
Expand All @@ -120,7 +126,33 @@ export default defineComponent({
})
}
const resourceTargetRouteCallback = ({
path,
fileId,
resource
}: CreateTargetRouteOptions): Location => {
if (unref(hasShareJail)) {
const space = buildShareSpaceResource({
shareId: resource.id,
shareName: resource.name,
serverUrl: configurationManager.serverUrl
})
return createLocationSpaces(
'files-spaces-generic',
createFileRouteOptions(space, { path, fileId })
)
}
const personalSpace = store.getters['runtime/spaces/spaces'].find(
(space) => space.driveType === 'personal'
)
return createLocationSpaces(
'files-spaces-generic',
createFileRouteOptions(personalSpace, { path, fileId })
)
}
return {
resourceTargetRouteCallback,
...useResourcesViewDefaults<Resource, any, any[]>(),
getSpace
}
Expand Down
13 changes: 8 additions & 5 deletions packages/web-client/src/helpers/space/functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,22 +44,25 @@ export function buildPublicSpaceResource(data): PublicSpaceResource {
export function buildShareSpaceResource({
shareId,
shareName,
serverUrl
serverUrl,
webDavPath
}: {
shareId: string | number
shareName: string
serverUrl: string
webDavPath?: string
}): ShareSpaceResource {
const space = buildSpace({
id: [SHARE_JAIL_ID, shareId].join('!'),
driveAlias: `share/${shareName}`,
driveType: 'share',
driveAlias: "/",
driveType: 'personal',
name: shareName,
shareId,
serverUrl
serverUrl,
webDavPath
}) as ShareSpaceResource
space.rename = (newName: string) => {
space.driveAlias = `share/${newName}`
space.driveAlias = "/",
space.name = newName
}
return space
Expand Down

0 comments on commit 49e125f

Please sign in to comment.