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

[full-ci] Improve error message for internal links on unaccepted shares #7814

Merged
merged 4 commits into from
Oct 18, 2022
Merged
Show file tree
Hide file tree
Changes from 3 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
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Enhancement: Internal link on unaccepted share

The error message when resolving an internal link to an unaccepted share has been improved for a better UX.

https://github.com/owncloud/web/issues/7803
https://github.com/owncloud/web/pull/7814
142 changes: 101 additions & 41 deletions packages/web-runtime/src/pages/resolvePrivateLink.vue
Original file line number Diff line number Diff line change
@@ -1,32 +1,43 @@
<template>
<div class="oc-height-1-1 oc-link-resolve">
<h1 class="oc-invisible-sr">{{ pageTitle }}</h1>
<div class="oc-card oc-border oc-rounded oc-position-center oc-text-center oc-width-large">
<template v-if="loading">
<div class="oc-card-header">
<h2 key="private-link-loading">
<translate>Resolving private link…</translate>
</h2>
</div>
<div class="oc-card-body">
<oc-spinner :aria-hidden="true" />
</div>
</template>
<template v-else-if="errorMessage">
<div class="oc-card-header oc-link-resolve-error-title">
<h2 key="private-link-error">
<translate>An error occurred while resolving the private link</translate>
</h2>
</div>
<div class="oc-card-body oc-link-resolve-error-message">
<p class="oc-text-xlarge">{{ errorMessage }}</p>
</div>
</template>
<div class="oc-card-footer">
<p>
{{ configuration.currentTheme.general.slogan }}
</p>
<div class="oc-link-resolve-wrapper oc-flex oc-flex-center oc-flex-middle">
<h1 class="oc-invisible-sr">{{ pageTitle }}</h1>
<div class="oc-card oc-text-center oc-width-medium">
<template v-if="loading">
<div class="oc-card-body">
<h2 key="private-link-loading">
<translate>Resolving private link…</translate>
</h2>
<oc-spinner class="oc-mt-m" :aria-hidden="true" />
</div>
</template>
<template v-else-if="errorMessage">
<div class="oc-card-body oc-link-resolve-error-message">
<h2 v-if="isUnacceptedShareError" class="oc-link-resolve-error-title">
{{ resource.name }}
</h2>
<h2 v-else key="private-link-error" class="oc-link-resolve-error-title">
<translate>An error occurred while resolving the private link</translate>
</h2>
<p>{{ errorMessage }}</p>
<p
v-if="isUnacceptedShareError"
v-text="$gettext('Note: You can reload this page after you accept the share.')"
></p>
</div>
</template>
</div>
<oc-button
v-if="isUnacceptedShareError"
type="router-link"
variation="primary"
appearance="filled"
target="_blank"
class="oc-mt-m oc-text-center oc-width-medium"
:to="sharedWithMeRoute"
>
<span class="text" v-text="openSharedWithMeLabel" />
</oc-button>
</div>
</div>
</template>
Expand All @@ -41,7 +52,7 @@ import {
queryItemAsString,
useCapabilitySpacesEnabled
} from 'web-pkg/src/composables'
import { unref, defineComponent, computed, onMounted } from '@vue/composition-api'
import { unref, defineComponent, computed, onMounted, ref } from '@vue/composition-api'
import { clientService } from 'web-pkg/src/services'
import { createLocationSpaces } from 'files/src/router'
import { dirname } from 'path'
Expand All @@ -67,8 +78,11 @@ export default defineComponent({
const router = useRouter()
const route = useRoute()
const id = useRouteParam('fileId')
const { $gettext } = useTranslations()
const { $gettext, $gettextInterpolate } = useTranslations()
const hasSpaces = useCapabilitySpacesEnabled(store)
const resource = ref(undefined)
JammingBen marked this conversation as resolved.
Show resolved Hide resolved
const sharedParentResource = ref(undefined)
const isUnacceptedShareError = ref(false)

const pageTitle = computed(() => $gettext(unref(route).meta.title))
const configuration = computed(() => {
Expand All @@ -80,20 +94,27 @@ export default defineComponent({
})

const resolvePrivateLinkTask = useTask(function* (signal, id) {
let path, resource
let path
let matchingSpace = getMatchingSpace(id)
if (matchingSpace) {
path = yield clientService.owncloudSdk.files.getPathForFileId(id)
resource = yield clientService.webdav.getFileInfo(matchingSpace, { path })
resource.value = yield clientService.webdav.getFileInfo(matchingSpace, { path })
} else {
// no matching space found => the file doesn't lie in own spaces => it's a share.
// do PROPFINDs on parents until root of accepted share is found in `mountpoint` spaces
let mountPoint = findMatchingMountPoint(id)
resource = yield fetchFileInfoById(id)
const sharePathSegments = mountPoint ? [] : [resource.name]
let tmpResource = resource
resource.value = yield fetchFileInfoById(id)
const sharePathSegments = mountPoint ? [] : [unref(resource).name]
let tmpResource = unref(resource)
while (!mountPoint) {
tmpResource = yield fetchFileInfoById(tmpResource.parentFolderId)
try {
tmpResource = yield fetchFileInfoById(tmpResource.parentFolderId)
} catch (e) {
isUnacceptedShareError.value = true
throw Error(e)
}

sharedParentResource.value = tmpResource
mountPoint = findMatchingMountPoint(tmpResource.id)
if (!mountPoint) {
sharePathSegments.unshift(tmpResource.name)
Expand All @@ -110,11 +131,11 @@ export default defineComponent({

let fileId
let scrollTo
if (resource.type === 'folder') {
fileId = resource.fileId
if (unref(resource).type === 'folder') {
fileId = unref(resource).fileId
} else {
fileId = resource.parentFolderId
scrollTo = resource.name
fileId = unref(resource).parentFolderId
scrollTo = unref(resource).name
path = dirname(path)
}

Expand Down Expand Up @@ -164,7 +185,32 @@ export default defineComponent({
return !resolvePrivateLinkTask.last || resolvePrivateLinkTask.isRunning
})

const sharedWithMeRoute = computed(() => {
return { name: 'files-shares-with-me' }
})

const openSharedWithMeLabel = computed(() => {
return $gettext('Open "Shared with me"')
})

const errorMessage = computed(() => {
if (unref(isUnacceptedShareError)) {
if (
!unref(sharedParentResource) ||
unref(resource).name === unref(sharedParentResource).name
) {
return $gettext(
'has been shared with you. Accept it in "Shares" > "Shared with me" to view it.'
)
}
const translated = $gettext(
'has been shared with you via "%{parentShareName}". Accept the share "%{parentShareName}" in "Shares" > "Shared with me" to view it.'
)
return $gettextInterpolate(translated, {
parentShareName: unref(sharedParentResource).name
})
}

if (resolvePrivateLinkTask.isError) {
return resolvePrivateLinkTask.last.error
}
Expand All @@ -175,16 +221,30 @@ export default defineComponent({
pageTitle,
configuration,
errorMessage,
loading
loading,
resource,
isUnacceptedShareError,
sharedWithMeRoute,
openSharedWithMeLabel
}
}
})
</script>

<style lang="scss">
.oc-link-resolve {
.oc-card-header h2,
.oc-card-footer p {
&-wrapper {
flex-flow: column;
min-height: 96vh;
}

.oc-card {
background: var(--oc-color-background-highlight);
border-radius: 15px;
}

h2 {
font-size: var(--oc-font-size-medium);
margin: 0;
}
}
Expand Down