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

fix: displaying external shares on 'Shared With Me'-page #11426

Merged
merged 1 commit into from
Aug 27, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,21 @@
class="oc-text-nowrap oc-flex oc-flex-middle oc-flex-right"
>
<oc-icon
v-if="resource.shareRoles?.length"
v-oc-tooltip="$gettext(resource.shareRoles[0].displayName)"
:accessible-label="$gettext(resource.shareRoles[0].description)"
:name="resource.shareRoles[0].icon"
fill-type="line"
size="small"
/>
<oc-icon
v-else-if="isExternalShare(resource)"
v-oc-tooltip="ShareTypes.remote.label"
:accessible-label="ShareTypes.remote.label"
:name="ShareTypes.remote.icon"
fill-type="line"
size="small"
/>
<oc-icon
v-if="resource.syncEnabled"
v-oc-tooltip="$gettext('Synced with your devices')"
Expand Down Expand Up @@ -104,7 +113,7 @@ import { VisibilityObserver } from '@ownclouders/web-pkg'
import { SortDir, useGetMatchingSpace } from '@ownclouders/web-pkg'
import { createLocationSpaces } from '@ownclouders/web-pkg'
import ListInfo from '../../components/FilesList/ListInfo.vue'
import { IncomingShareResource } from '@ownclouders/web-client'
import { IncomingShareResource, ShareTypes } from '@ownclouders/web-client'
import { ContextActions } from '@ownclouders/web-pkg'
import { NoContentMessage } from '@ownclouders/web-pkg'
import { useSelectedResources } from '@ownclouders/web-pkg'
Expand Down Expand Up @@ -195,6 +204,10 @@ export default defineComponent({

const { updateResourceField } = useResourcesStore()

const isExternalShare = (resource: IncomingShareResource) => {
return resource.shareTypes.includes(ShareTypes.remote.value)
}

const resourceTargetRouteCallback = ({
path,
fileId,
Expand All @@ -214,7 +227,9 @@ export default defineComponent({
resourceTargetRouteCallback,
...useSelectedResources(),
getMatchingSpace,
updateResourceField
updateResourceField,
isExternalShare,
ShareTypes
}
},

Expand Down
7 changes: 6 additions & 1 deletion packages/web-client/src/helpers/share/functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ export function buildIncomingShareResource({
const resourceName = driveItem.name || driveItem.remoteItem.name
const storageId = extractStorageId(driveItem.remoteItem.id)

const shareTypes = uniq(driveItem.remoteItem.permissions.map(getShareTypeFromPermission))
const sharedWith = driveItem.remoteItem.permissions.map((permission) => {
const { grantedToV2 } = permission
const identity = grantedToV2.group || grantedToV2.user
Expand All @@ -117,6 +116,12 @@ export function buildIncomingShareResource({
return acc
}, [])

let shareTypes = uniq(driveItem.remoteItem.permissions.map(getShareTypeFromPermission))
const isExternal = sharedBy.some((s) => s['@libre.graph.userType'] === 'Federated')
if (isExternal) {
shareTypes = [ShareTypes.remote.value]
}

const shareRoles = getShareResourceRoles({ driveItem, graphRoles })
const sharePermissions = getShareResourcePermissions({ driveItem, shareRoles })

Expand Down