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] Fix spaces on the 'Shared via link'-page #7651

Merged
merged 5 commits into from
Sep 20, 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
6 changes: 6 additions & 0 deletions changelog/unreleased/bugfix-spaces-on-share-via-link-page
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Bugfix: Spaces on "Shared via link"-page

Spaces on the "Shared via link"-page are now being displayed correctly. Also, the sidebar for those has been fixed.

https://github.com/owncloud/web/pull/7651
https://github.com/owncloud/web/issues/7103
17 changes: 12 additions & 5 deletions packages/web-app-files/src/components/FilesList/ResourceTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
<oc-resource
:key="`${item.path}-${resourceDomSelector(item)}-${item.thumbnail}`"
:resource="item"
:is-path-displayed="arePathsDisplayed"
:is-path-displayed="getArePathsDisplayed(item)"
:parent-folder-name-default="getDefaultParentFolderName(item)"
:is-thumbnail-displayed="areThumbnailsDisplayed"
:is-extension-displayed="areFileExtensionsShown"
Expand Down Expand Up @@ -583,11 +583,15 @@ export default defineComponent({
this.$_rename_trigger({ resources: [item] })
},
openSharingSidebar(file) {
if (file.share?.shareType === ShareTypes.link.value) {
bus.publish(SideBarEventTopics.openWithPanel, 'sharing-item#linkShares')
return
let panelToOpen
if (file.type === 'space') {
panelToOpen = 'space-share-item'
} else if (file.share?.shareType === ShareTypes.link.value) {
panelToOpen = 'sharing-item#linkShares'
} else {
panelToOpen = 'sharing-item#peopleShares'
}
bus.publish(SideBarEventTopics.openWithPanel, 'sharing-item#peopleShares')
bus.publish(SideBarEventTopics.openWithPanel, panelToOpen)
},
folderLink(file) {
return this.createFolderLink(file.path, file)
Expand Down Expand Up @@ -822,6 +826,9 @@ export default defineComponent({
}

return this.$gettext('Personal')
},
getArePathsDisplayed(resource) {
kulmann marked this conversation as resolved.
Show resolved Hide resolved
return this.arePathsDisplayed && resource.type !== 'space'
}
}
})
Expand Down
6 changes: 3 additions & 3 deletions packages/web-app-files/src/fileSideBars.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import SharesPanel from './components/SideBar/Shares/SharesPanel.vue'
import NoSelection from './components/SideBar/NoSelection.vue'
import SpaceActions from './components/SideBar/Actions/SpaceActions.vue'
import SpaceDetails from './components/SideBar/Details/SpaceDetails.vue'
import { isLocationSpacesActive, isLocationTrashActive, isLocationPublicActive } from './router'
import { isLocationTrashActive, isLocationPublicActive } from './router'
import { spaceRoleEditor, spaceRoleManager } from 'web-client/src/helpers/share'

import { Panel } from '../../web-pkg/src/components/sideBar'
Expand Down Expand Up @@ -72,12 +72,12 @@ const panelGenerators: (({
return multipleSelection && !rootFolder
}
}),
({ router, highlightedFile }) => ({
({ highlightedFile }) => ({
app: 'details-space-item',
icon: 'questionnaire-line',
title: $gettext('Details'),
component: SpaceDetails,
default: isLocationSpacesActive(router, 'files-spaces-projects'),
default: highlightedFile?.type === 'space',
JammingBen marked this conversation as resolved.
Show resolved Hide resolved
get enabled() {
return highlightedFile?.type === 'space'
}
Expand Down
26 changes: 24 additions & 2 deletions packages/web-app-files/src/helpers/resources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,14 +136,19 @@ export function attachIndicators(resource, sharesTree) {
* @param {Boolean} incomingShares Asserts whether the shares are incoming
* @param {Boolean} allowSharePermission Asserts whether the reshare permission is available
* @param {Boolean} hasShareJail Asserts whether the share jail is available backend side
* @param {Array} spaces A list of spaces the current user has access to
*/
export function aggregateResourceShares(
shares,
incomingShares = false,
allowSharePermission,
hasShareJail
hasShareJail,
spaces = []
): Resource[] {
shares.sort((a, b) => a.path.localeCompare(b.path))
if (spaces.length) {
shares = addMatchingSpaceToShares(shares, spaces)
}
if (incomingShares) {
shares = addSharedWithToShares(shares)
return orderBy(shares, ['file_target', 'permissions'], ['asc', 'desc']).map((share) =>
Expand Down Expand Up @@ -210,14 +215,27 @@ function addSharedWithToShares(shares) {
return resources
}

function addMatchingSpaceToShares(shares, spaces) {
const resources = []
for (const share of shares) {
let matchingSpace
if (share.path === '/') {
const storageId = extractStorageId(share.item_source)
matchingSpace = spaces.find((s) => s.id === storageId && s.driveType === 'project')
}
resources.push({ ...share, matchingSpace })
}
return resources
}

export function buildSharedResource(
share,
incomingShares = false,
allowSharePermission = true,
hasShareJail = false
): Resource {
const isFolder = share.item_type === 'folder'
const resource: Resource = {
let resource: Resource = {
id: share.id,
fileId: share.item_source,
storageId: extractStorageId(share.item_source),
Expand Down Expand Up @@ -282,6 +300,10 @@ export function buildSharedResource(
resource.canDeny = () => SharePermissions.denied.enabled(share.permissions)
resource.getDomSelector = () => extractDomSelector(share.id)

if (share.matchingSpace) {
resource = { ...resource, ...share.matchingSpace }
}

return resource
}

Expand Down
2 changes: 1 addition & 1 deletion packages/web-app-files/src/mixins/actions/navigate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export default {
return false
}

if (!resources[0].isFolder) {
if (!resources[0].isFolder || resources[0].type === 'space') {
return false
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import {
useCapabilityShareJailEnabled
} from 'web-pkg/src/composables'
import { unref } from '@vue/composition-api'
import { clientService } from 'web-pkg/src/services'
import { configurationManager } from 'web-pkg/src/configuration'

export class FolderLoaderSharedViaLink implements FolderLoader {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
Expand Down Expand Up @@ -40,13 +42,23 @@ export class FolderLoaderSharedViaLink implements FolderLoader {
})

resources = resources.map((r) => r.shareInfo)
let spaces = []
if (store.getters.capabilities?.spaces?.enabled) {
const accessToken = store.getters['runtime/auth/accessToken']
const serverUrl = configurationManager.serverUrl
const graphClient = clientService.graphAuthenticated(serverUrl, accessToken)
// FIXME: Wait until spaces are loaded? We already load them in the runtime
yield store.dispatch('runtime/spaces/loadSpaces', { graphClient })
kulmann marked this conversation as resolved.
Show resolved Hide resolved
spaces = store.getters['runtime/spaces/spaces']
}

if (resources.length) {
resources = aggregateResourceShares(
resources,
false,
unref(hasResharing),
unref(hasShareJail)
unref(hasShareJail),
spaces
)
}

Expand Down
11 changes: 11 additions & 0 deletions packages/web-client/src/helpers/resource/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ export interface Resource {
type?: string
status?: number
spaceRoles?: any[]
spaceQuota?: any[]
spaceMemberIds?: any[]
spaceImageData?: any[]
spaceReadmeData?: any[]
mimeType?: string
isFolder?: boolean
sdate?: string
Expand All @@ -35,12 +39,19 @@ export interface Resource {
canBeDeleted?(): boolean
canBeRestored?(): boolean
canDeny?(): boolean
canEditDescription?(): boolean
canRestore?(): boolean
canDisable?(): boolean
canEditImage?(): boolean
canEditReadme?(): boolean

isReceivedShare?(): boolean
isMounted?(): boolean

getDomSelector?(): string

matchingSpace?: any

resourceOwner?: User
owner?: User[]
ownerDisplayName?: string
Expand Down