-
Notifications
You must be signed in to change notification settings - Fork 159
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
546685c
commit c940681
Showing
15 changed files
with
224 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
Enhancement: Resolve alias links | ||
|
||
Alias links can now be resolved successfully. | ||
|
||
https://github.com/owncloud/web/pull/7405 | ||
https://github.com/owncloud/web/issues/7304 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './useLoadTokenInfo' |
22 changes: 22 additions & 0 deletions
22
packages/web-runtime/src/composables/tokenInfo/useLoadTokenInfo.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { unref } from '@vue/composition-api' | ||
import { useTask } from 'vue-concurrency' | ||
import { useClientService, useStore, useUserContext } from 'web-pkg/src/composables' | ||
|
||
export function useLoadTokenInfo(token) { | ||
const { owncloudSdk } = useClientService() | ||
const store = useStore() | ||
const isUserContext = useUserContext({ store }) | ||
|
||
const loadTokenInfoTask = useTask(function* () { | ||
try { | ||
if (unref(isUserContext)) { | ||
return yield owncloudSdk.shares.getProtectedTokenInfo(token) | ||
} else { | ||
return yield owncloudSdk.shares.getUnprotectedTokenInfo(token) | ||
} | ||
} catch (e) {} // backend doesn't support the token info endpoint | ||
return {} | ||
}) | ||
|
||
return { loadTokenInfoTask } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
<template> | ||
<div></div> | ||
</template> | ||
|
||
<script type="ts"> | ||
import { | ||
useRoute, | ||
useRouteParam, | ||
useStore, | ||
useTranslations, | ||
useUserContext, | ||
useRouter | ||
} from "web-pkg/src/composables"; | ||
import { unref, ref, defineComponent, computed, onMounted } from "@vue/composition-api"; | ||
import { authService } from "../services/auth"; | ||
import { useLoadTokenInfo } from "../composables/tokenInfo"; | ||
import { clientService } from "web-pkg/src/services"; | ||
import { createLocationSpaces } from "files/src/router"; | ||
import {urlJoin} from "web-pkg/src/utils"; | ||
export default defineComponent({ | ||
name: 'ResolveAliasLink', | ||
setup() { | ||
const store = useStore() | ||
const router = useRouter() | ||
const route = useRoute() | ||
const token = useRouteParam('token') | ||
const { $gettext } = useTranslations() | ||
const isUserContext = useUserContext({ store }) | ||
const { loadTokenInfoTask } = useLoadTokenInfo(unref(token)) | ||
const tokenInfo = ref(undefined) | ||
onMounted(async () => { | ||
if (!unref(isUserContext)) { | ||
await authService.loginUser() | ||
return router.push({ name: '/login' }) | ||
} | ||
tokenInfo.value = await loadTokenInfoTask.perform() | ||
resolveAliasLink() | ||
}) | ||
const pageTitle = computed(() => $gettext(route.meta.title)) | ||
const resolveAliasLink = async () => { | ||
const { id, storage_id: storageId, space_id: spaceId } = unref(tokenInfo) | ||
const path = await clientService.owncloudSdk.files.getPathForFileId(id) | ||
const matchingSpace = getMatchingSpace(`${storageId}$${spaceId}`) | ||
const resource = await clientService.webdav.getFileInfo(matchingSpace, { path }) | ||
let driveAliasPath | ||
let scrollTo | ||
if (resource.type !== 'file') { | ||
driveAliasPath = path | ||
scrollTo = '' | ||
} else { | ||
driveAliasPath = '' | ||
scrollTo = path | ||
} | ||
const location = createLocationSpaces('files-spaces-generic', { | ||
params: { | ||
driveAliasAndItem: matchingSpace.getDriveAliasAndItem({ path: driveAliasPath }) | ||
}, | ||
query: { scrollTo: urlJoin(scrollTo, { leadingSlash: false }) } | ||
}) | ||
return router.push(location) | ||
} | ||
const getMatchingSpace = (spaceId) => { | ||
return store.getters['runtime/spaces/spaces'].find((space) => space.id === spaceId) | ||
} | ||
return { | ||
pageTitle, | ||
} | ||
} | ||
}) | ||
</script> |
Oops, something went wrong.