Skip to content

Commit

Permalink
Refactor AppBar drop logic into GenericSpace
Browse files Browse the repository at this point in the history
  • Loading branch information
lookacat committed May 31, 2023
1 parent ccc8f6e commit 30606d2
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 20 deletions.
18 changes: 1 addition & 17 deletions packages/web-app-files/src/components/AppBar/AppBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -204,23 +204,7 @@ export default defineComponent({
: 2
})
const fileDroppedBreadcrumb = async (data) => {
const spaceRootRoutePath = router.resolve(
createLocationSpaces('files-spaces-generic', {
params: {
driveAliasAndItem: props.space.driveAlias
}
})
).path
const splitIndex = data.path.indexOf(spaceRootRoutePath) + spaceRootRoutePath.length
const path = decodeURIComponent(data.path.slice(splitIndex, data.path.length))
try {
const targetResource = await clientService.webdav.getFileInfo(props.space, { path })
emit(EVENT_ITEM_DROPPED, targetResource)
} catch (e) {
console.error(e)
}
emit(EVENT_ITEM_DROPPED, data)
}
return {
Expand Down
24 changes: 21 additions & 3 deletions packages/web-app-files/src/views/spaces/GenericSpace.vue
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ import SpaceHeader from '../../components/Spaces/SpaceHeader.vue'
import AppLoadingSpinner from 'web-pkg/src/components/AppLoadingSpinner.vue'
import NoContentMessage from 'web-pkg/src/components/NoContentMessage.vue'
import WhitespaceContextMenu from 'web-app-files/src/components/Spaces/WhitespaceContextMenu.vue'
import { useRoute } from 'web-pkg/src/composables'
import { useClientService, useRoute } from 'web-pkg/src/composables'
import { useDocumentTitle } from 'web-pkg/src/composables/appDefaults/useDocumentTitle'
import { ImageType } from 'web-pkg/src/constants'
import { VisibilityObserver } from 'web-pkg/src/observer'
Expand Down Expand Up @@ -232,6 +232,7 @@ export default defineComponent({
setup(props) {
const store = useStore()
const { $gettext, $ngettext, interpolate: $gettextInterpolate } = useGettext()
const clientService = useClientService()
let loadResourcesEventToken
const canUpload = computed(() => {
Expand Down Expand Up @@ -469,7 +470,8 @@ export default defineComponent({
uploadHint: $gettext(
'Drag files and folders here or use the "New" or "Upload" buttons to add files'
),
whitespaceContextMenu
whitespaceContextMenu,
clientService
}
},
Expand Down Expand Up @@ -542,7 +544,23 @@ export default defineComponent({
return
}
} else if (fileTarget instanceof Object) {
targetFolder = fileTarget
const spaceRootRoutePath = this.$router.resolve(
createLocationSpaces('files-spaces-generic', {
params: {
driveAliasAndItem: this.space.driveAlias
}
})
).path
const splitIndex = fileTarget.path.indexOf(spaceRootRoutePath) + spaceRootRoutePath.length
const path = decodeURIComponent(fileTarget.path.slice(splitIndex, fileTarget.path.length))
try {
targetFolder = await this.clientService.webdav.getFileInfo(this.space, { path })
} catch (e) {
console.error(e)
return
}
}
if (!targetFolder) {
return
Expand Down

0 comments on commit 30606d2

Please sign in to comment.