Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Route into folders instead of parents in private links #5654

Merged
merged 2 commits into from
Mar 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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