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] Resolve internal/private links on shares #7769

Merged
merged 3 commits into from
Oct 12, 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
4 changes: 2 additions & 2 deletions changelog/unreleased/enhancement-internal-links
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Enhancement: Resolve internal links

Public links with the role "internal" can now be resolved.
Note: Internal links to shares can not be resolved as of now. This will follow in a subsequent PR.

https://github.com/owncloud/web/pull/7405
https://github.com/owncloud/web/issues/7304
https://github.com/owncloud/web/issues/6844
https://github.com/owncloud/web/pull/7405
https://github.com/owncloud/web/pull/7769
4 changes: 2 additions & 2 deletions changelog/unreleased/enhancement-private-links
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Enhancement: Resolve private links

Private links can now be resolved.
Note: Private links to shares in oCIS can not be resolved as of now. This will follow in a subsequent PR.

https://github.com/owncloud/web/pull/7405
https://github.com/owncloud/web/issues/7707
https://github.com/owncloud/web/pull/7405
https://github.com/owncloud/web/pull/7769
12 changes: 10 additions & 2 deletions packages/web-app-files/src/helpers/resource/resource.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
import { Resource } from 'web-client'
import fileExtensions from '../extensions/fileExtensions'

export const extractStorageId = (id?: string): string => {
const extractIdSegment = (id: string, index: number): string => {
if (!id || typeof id !== 'string') {
return ''
}
return id.indexOf('!') >= 0 ? id.split('!')[0] : ''
return id.indexOf('!') >= 0 ? id.split('!')[index] : ''
}

export const extractStorageId = (id?: string): string => {
return extractIdSegment(id, 0)
}

export const extractNodeId = (id?: string): string => {
return extractIdSegment(id, 1)
}

export const extractNameWithoutExtension = (resource?: Resource): string => {
Expand Down
10 changes: 8 additions & 2 deletions packages/web-app-files/src/helpers/resources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
spaceRoleManager,
spaceRoleViewer
} from 'web-client/src/helpers/share'
import { extractExtensionFromFile, extractStorageId } from './resource'
import { extractExtensionFromFile, extractNodeId, extractStorageId } from './resource'
import { buildWebDavSpacesPath, extractDomSelector } from 'web-client/src/helpers/resource'
import { Resource, SpaceResource, SHARE_JAIL_ID } from 'web-client/src/helpers'
import { urlJoin } from 'web-pkg/src/utils'
Expand Down Expand Up @@ -44,7 +44,7 @@ export function buildResource(resource): Resource {
}

const id = resource.fileInfo[DavProperty.FileId]
return {
const r = {
id,
fileId: id,
storageId: extractStorageId(id),
Expand Down Expand Up @@ -106,6 +106,12 @@ export function buildResource(resource): Resource {
},
getDomSelector: () => extractDomSelector(id)
}
Object.defineProperty(r, 'nodeId', {
get() {
return extractNodeId(this.id)
}
})
return r
}

export function buildWebDavPublicPath(publicLinkToken, path = '') {
Expand Down
1 change: 1 addition & 0 deletions packages/web-client/src/helpers/resource/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export interface Resource {
fileId?: string
parentFolderId?: string
storageId?: string
readonly nodeId?: string
name?: string
path: string
webDavPath?: string
Expand Down
10 changes: 9 additions & 1 deletion packages/web-client/src/helpers/space/functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { PublicSpaceResource, ShareSpaceResource, SpaceResource, SHARE_JAIL_ID }
import { DavProperty } from 'web-pkg/src/constants'
import { buildWebDavPublicPath } from 'files/src/helpers/resources'
import { urlJoin } from 'web-pkg/src/utils'
import { extractNodeId } from 'files/src/helpers/resource'

export function buildPublicSpaceResource(data): PublicSpaceResource {
const publicLinkPassword = data.publicLinkPassword
Expand Down Expand Up @@ -94,7 +95,7 @@ export function buildSpace(data): SpaceResource {
})
const webDavUrl = urlJoin(data.serverUrl, 'remote.php/dav', webDavPath)

return {
const s = {
id: data.id,
fileId: data.id,
storageId: data.id,
Expand Down Expand Up @@ -125,6 +126,7 @@ export function buildSpace(data): SpaceResource {
ownerDisplayName: '',
ownerId: data.owner?.user?.id,
disabled,
root: data.root,
spaceQuota: data.quota,
spaceRoles,
spaceImageData,
Expand Down Expand Up @@ -197,4 +199,10 @@ export function buildSpace(data): SpaceResource {
return urlJoin(this.webDavUrl, resource.path)
}
}
Object.defineProperty(s, 'nodeId', {
get() {
return extractNodeId(this.id)
}
})
return s
}
21 changes: 21 additions & 0 deletions packages/web-client/src/helpers/space/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,21 @@ import { Resource } from '../resource'

export const SHARE_JAIL_ID = 'a0ca6a90-a365-4782-871e-d44447bbc668'

export interface SpaceResourceRemoteItem {
id: string
name: string
}

export interface SpaceResourceRoot {
id: string
remoteItem: SpaceResourceRemoteItem
webDavUrl: string
}

export interface SpaceResource extends Resource {
disabled?: boolean
webDavUrl: string
root: SpaceResourceRoot
getWebDavUrl(resource: Resource): string
getDriveAliasAndItem(resource: Resource): string
}
Expand All @@ -39,6 +51,15 @@ export const isShareSpaceResource = (resource: Resource): resource is ShareSpace
return resource.driveType === 'share'
}

export interface MountPointSpaceResource extends SpaceResource {
__mountPointSpaceResource?: any
}
export const isMountPointSpaceResource = (
resource: Resource
): resource is MountPointSpaceResource => {
return resource.driveType === 'mountpoint'
}

export interface PublicSpaceResource extends SpaceResource {
publicLinkPassword?: string
publicLinkItemType?: string
Expand Down
131 changes: 0 additions & 131 deletions packages/web-runtime/src/pages/resolveFileLink.vue

This file was deleted.

Loading