Skip to content

Commit

Permalink
Merge pull request #5654 from owncloud/fix-resolving-private-link
Browse files Browse the repository at this point in the history
Route into folders instead of parents in private links
  • Loading branch information
kulmann authored Mar 9, 2022
2 parents 9ada337 + 29d17e2 commit a97583c
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 26 deletions.
5 changes: 5 additions & 0 deletions changelog/unreleased/bugfix-resolve-private-link
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Bugfix: Resolve private links

Private links didn't resolve correctly anymore because the internal file path handling was changed in our api client (owncloud-sdk). We've adjusted it accordingly so that private links now resolve correctly again.

https://github.com/owncloud/web/pull/5654
6 changes: 6 additions & 0 deletions changelog/unreleased/enhancement-private-link-routing
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Enhancement: Resolve private links into folders instead of parent

Private links always resolved into the parent folder of the linked file and visually highlighted the file or folder from the link. We've changed this behaviour to directly navigate into the folder in case the linked resource is a folder and only keep the previous behaviour for when the linked resource is a file.

https://github.com/owncloud/web/issues/5533
https://github.com/owncloud/web/pull/5654
60 changes: 34 additions & 26 deletions packages/web-app-files/src/views/PrivateLink.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,11 @@
</template>

<script>
import path from 'path'
import { mapGetters } from 'vuex'
import { buildResource, buildWebDavFilesPath } from '../helpers/resources'
import { createLocationSpaces } from '../router'
import { DavProperties } from 'web-pkg/src/constants'
export default {
data() {
Expand All @@ -43,38 +46,43 @@ export default {
}
},
computed: {
...mapGetters(['configuration']),
...mapGetters(['configuration', 'user']),
pageTitle() {
return this.$gettext(this.$route.meta.title)
}
},
mounted() {
// query oc10 server to translate fileId to real path
async mounted() {
// query server to translate fileId to real path
this.loading = true
this.$client.files
.getPathForFileId(this.$route.params.fileId)
.then((path) => {
const lastSlash = path.lastIndexOf('/')
const folder = path.substring(0, lastSlash).replace(/^(\/)/, '')
const file = path.substring(lastSlash + 1)
this.$router.push(
createLocationSpaces('files-spaces-personal-home', {
params: {
item: folder || '/'
},
query: {
scrollTo: file
}
})
)
})
.catch((error) => {
this.errorMessage = error
})
.finally(() => {
this.loading = false
})
try {
let resourcePath = await this.$client.files.getPathForFileId(this.$route.params.fileId)
resourcePath = buildWebDavFilesPath(this.user.id, resourcePath)
let resource = await this.$client.files.fileInfo(resourcePath, DavProperties.Default)
resource = buildResource(resource)
const params = {}
const query = {}
if (resource.isFolder) {
// if folder: route directly into it
params.item = resource.path || ''
} else {
// if file: route into parent and highlight file
params.item = path.dirname(resource.path)
query.scrollTo = resource.name
}
this.$router.push(
createLocationSpaces('files-spaces-personal-home', {
params,
query
})
)
} catch (error) {
console.error(error)
this.errorMessage = error
} finally {
this.loading = false
}
}
}
</script>
Expand Down

0 comments on commit a97583c

Please sign in to comment.