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] Resharing for ocis #7086

Merged
merged 1 commit into from
Jul 6, 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
2 changes: 1 addition & 1 deletion .drone.env
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# The version of OCIS to use in pipelines that test against OCIS
OCIS_COMMITID=49541e6cc244f933e1d42b0462664eb6f1ab4ad4
OCIS_COMMITID=ee97594742b23550d1f35a1002a3d83700950622
OCIS_BRANCH=master
1 change: 1 addition & 0 deletions .drone.star
Original file line number Diff line number Diff line change
Expand Up @@ -2154,6 +2154,7 @@ def ocisService():
"STORAGE_USERS_DRIVER_OWNCLOUD_DATADIR": "/srv/app/tmp/ocis/owncloud/data",
"WEB_ASSET_PATH": "%s/dist" % dir["web"],
"WEB_UI_CONFIG": "/srv/config/drone/config-ocis.json",
"FRONTEND_ENABLE_RESHARING": "true",
fschade marked this conversation as resolved.
Show resolved Hide resolved
pascalwengerter marked this conversation as resolved.
Show resolved Hide resolved
},
"commands": [
"cd %s/ocis-build" % dir["base"],
Expand Down
7 changes: 7 additions & 0 deletions changelog/unreleased/enhancement-ocis-resharing
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Enhancement: Re-sharing for ocis

We've enhanced web to be able to re-share resources when using an ownCloud infinite scale backend. It now works for project and personal spaces as well as the sharing jail.
Besides that we also send roles, space-ref and path as separate values to the sharing api which simplifies the usage of it.

https://github.com/owncloud/web/pull/7086
fschade marked this conversation as resolved.
Show resolved Hide resolved
https://github.com/owncloud/web/issues/6894
6 changes: 5 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ services:
OCIS_JWT_SECRET: "${OCIS_JWT_SECRET:-some-ocis-jwt-secret}"
OCIS_MACHINE_AUTH_API_KEY: "${OCIS_MACHINE_AUTH_API_KEY:-some-ocis-machine-auth-api-key}"

# FRONTEND
FRONTEND_ENABLE_RESHARING: "true"

# WEB
WEB_UI_CONFIG: ${WEB_UI_CONFIG:-/web/config.json}
WEB_ASSET_PATH: ${WEB_ASSET_PATH:-/web/dist}
Expand All @@ -32,7 +35,7 @@ services:
IDP_LDAP_BIND_PASSWORD: "${IDP_LDAP_BIND_PASSWORD:-some-ldap-idp-password}"
IDP_IDENTIFIER_REGISTRATION_CONF: ${IDP_IDENTIFIER_REGISTRATION_CONF:-/web/identifier-registration.yml}

# Storage
# STORAGE
STORAGE_HOME_DRIVER: ${STORAGE_HOME_DRIVER:-ocis}
STORAGE_USERS_DRIVER: ${STORAGE_USERS_DRIVER:-ocis}
STORAGE_TRANSFER_SECRET: "${STORAGE_TRANSFER_SECRET:-some-ocis-transfer-secret}"
Expand All @@ -43,6 +46,7 @@ services:
AUTH_BASIC_LDAP_BIND_PASSWORD: "${AUTH_BASIC_LDAP_BIND_PASSWORD:-some-ldap-reva-password}"
GRAPH_LDAP_BIND_PASSWORD: "${GRAPH_LDAP_BIND_PASSWORD:-some-ldap-idm-password}"

# PROXY
PROXY_ENABLE_BASIC_AUTH: "${PROXY_ENABLE_BASIC_AUTH:-true}"
volumes:
- ./dev/docker/ocis.entrypoint.sh:/usr/bin/entrypoint
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,7 @@ export default defineComponent({

return {
sharedParentDir,
sharedParentRoute,
currentStorageId
sharedParentRoute
}
},

Expand Down Expand Up @@ -393,7 +392,7 @@ export default defineComponent({
client: this.$client,
path: this.file.path,
$gettext: this.$gettext,
...(this.currentStorageId && { storageId: this.currentStorageId })
storageId: this.file.fileId
fschade marked this conversation as resolved.
Show resolved Hide resolved
})
this.shareIndicators = getIndicators(this.file, this.sharesTree)
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,10 @@ import {
SpacePeopleShareRoles
} from '../../../../../helpers/share'
import { clientService } from 'web-pkg/src/services'
import { useCapabilityFilesSharingResharing } from 'web-pkg/src/composables'
import {
useCapabilityFilesSharingResharing,
useCapabilityShareJailEnabled
} from 'web-pkg/src/composables'
import {
shareInviteCollaboratorHelp,
shareInviteCollaboratorHelpCern,
Expand Down Expand Up @@ -122,7 +125,8 @@ export default {

setup() {
return {
hasResharing: useCapabilityFilesSharingResharing()
hasResharing: useCapabilityFilesSharingResharing(),
hasShareJail: useCapabilityShareJailEnabled()
}
},

Expand Down Expand Up @@ -186,9 +190,6 @@ export default {
return this.$gettext('Invite')
},

currentStorageId() {
return this.$route.params.storageId
},
resourceIsSpace() {
return this.highlightedFile.type === 'space'
},
Expand Down Expand Up @@ -326,24 +327,24 @@ export default {
this.selectedRole.permissions(this.hasResharing || this.resourceIsSpace)
)

let storageId
if (this.resourceIsSpace) {
storageId = this.highlightedFile.id
} else if (this.currentStorageId) {
storageId = this.currentStorageId
let path = this.highlightedFile.path
// sharing a share root from the share jail -> use resource name as path
if (this.hasShareJail && path === '/') {
path = `/${this.highlightedFile.name}`
}

this.addShare({
client: this.$client,
graphClient: this.graphClient,
path: this.highlightedFile.path,
path,
$gettext: this.$gettext,
shareWith: collaborator.value.shareWith,
displayName: collaborator.label,
shareType: collaborator.value.shareType,
permissions: bitmask,
role: this.selectedRole,
expirationDate: this.expirationDate,
storageId
storageId: this.highlightedFile.fileId || this.highlightedFile.id
fschade marked this conversation as resolved.
Show resolved Hide resolved
})
})
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,8 @@ export default {
graphClient: this.graphClient,
share: this.share,
permissions: bitmask,
expirationDate: expirationDate || ''
expirationDate: expirationDate || '',
role
})
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ import {
PeopleShareRoles,
SharePermissions,
ShareRole,
ShareTypes,
SpacePeopleShareRoles
} from '../../../../helpers/share'
import * as uuid from 'uuid'
Expand Down Expand Up @@ -157,11 +156,8 @@ export default {
return this.allowSharePermission && this.resource.canShare()
},
share() {
const userShares = this.sharesTree[this.resource.path]?.filter((s) =>
ShareTypes.containsAnyValue(ShareTypes.individuals, [s.shareType])
)

return userShares?.length ? userShares[0] : undefined
// the root share has an empty key in the shares tree. That's the reason why we retrieve the share by an empty key here
return this.sharesTree['']?.find((s) => s.incoming)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But that's only true if we are in the share jail, right? For oc10 the old behaviour should be correct...

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i just checked it again, it's the same behavior for classic too

Bildschirmfoto 2022-07-06 um 12 04 31

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still have questions:

  1. What if you have a group share and a user share (both incoming shares) for the same folder? Picking any incoming shares is not sufficient then, right?
  2. Still don't get why it would be sufficient in any case to check the incoming shares of the root node. What if the share is mounted in a deeply nested folder? E.g. you have Shares/the-world as default mount path for shares in oc10. Or you move a mounted share to another mount point.

},
allowCustomSharing() {
return this.capabilities?.files_sharing?.allow_custom
Expand Down
73 changes: 49 additions & 24 deletions packages/web-app-files/src/components/SideBar/Shares/FileLinks.vue
Original file line number Diff line number Diff line change
Expand Up @@ -110,17 +110,23 @@ import { dirname } from 'path'
import { defineComponent } from '@vue/composition-api'
import { DateTime } from 'luxon'
import { mapGetters, mapActions, mapState } from 'vuex'
import { useStore, useCapabilitySpacesEnabled } from 'web-pkg/src/composables'
import {
useStore,
useCapabilitySpacesEnabled,
useCapabilityShareJailEnabled,
useCapabilityFilesSharingResharing
} from 'web-pkg/src/composables'
import { clientService } from 'web-pkg/src/services'
import mixins from '../../../mixins'
import { shareViaLinkHelp, shareViaIndirectLinkHelp } from '../../../helpers/contextualHelpers'
import { getParentPaths } from '../../../helpers/path'
import { ShareTypes, LinkShareRoles, SharePermissions } from '../../../helpers/share'
import { cloneStateObject } from '../../../helpers/store'
import { showQuickLinkPasswordModal } from '../../../quickActions'
import CreateQuickLink from './Links/CreateQuickLink.vue'
import DetailsAndEdit from './Links/DetailsAndEdit.vue'
import NameAndCopy from './Links/NameAndCopy.vue'
import CreateQuickLink from './Links/CreateQuickLink.vue'
import { isLocationSpacesActive } from '../../../router'

export default defineComponent({
name: 'FileLinks',
Expand All @@ -144,6 +150,8 @@ export default defineComponent({
return {
graphClient,
hasSpaces: useCapabilitySpacesEnabled(),
hasShareJail: useCapabilityShareJailEnabled(),
fschade marked this conversation as resolved.
Show resolved Hide resolved
hasResharing: useCapabilityFilesSharingResharing(),
indirectLinkListCollapsed,
linkListCollapsed
}
Expand Down Expand Up @@ -180,6 +188,11 @@ export default defineComponent({
return this.currentFileOutgoingLinks.find((link) => link.quicklink === true)
},

share() {
// the root share has an empty key in the shares tree. That's the reason why we retrieve the share by an empty key here
return this.sharesTree['']?.find((s) => s.incoming)
},

expirationDate() {
const expireDate = this.capabilities.files_sharing.public.expire_date

Expand Down Expand Up @@ -211,6 +224,14 @@ export default defineComponent({
},

availableRoleOptions() {
if (this.highlightedFile.isReceivedShare() && this.canCreatePublicLinks && this.share) {
return LinkShareRoles.filterByBitmask(
parseInt(this.share.permissions),
this.highlightedFile.isFolder,
this.capabilities.files_sharing?.public?.can_edit
)
}

const roles = LinkShareRoles.list(
this.highlightedFile.isFolder,
this.capabilities.files_sharing?.public?.can_edit
Expand Down Expand Up @@ -244,6 +265,15 @@ export default defineComponent({
},

canCreatePublicLinks() {
if (this.highlightedFile.isReceivedShare() && !this.hasResharing) {
return false
}

const isShareJail = isLocationSpacesActive(this.$router, 'files-spaces-share')
if (isShareJail && !this.hasResharing) {
return false
}

return this.highlightedFile.canShare({ user: this.user })
},

Expand Down Expand Up @@ -333,28 +363,12 @@ export default defineComponent({
if (this.resourceIsSpace) {
return this.highlightedFile.id
}

return this.$route.params.storageId || null
}
},
watch: {
highlightedFile(newItem, oldItem) {
fschade marked this conversation as resolved.
Show resolved Hide resolved
if (oldItem !== newItem) {
this.reloadLinks()
}
}
},
mounted() {
this.reloadLinks()
},

methods: {
...mapActions('Files', [
'addLink',
'updateLink',
'removeLink',
'loadSharesTree',
'loadCurrentFileOutgoingShares'
]),
...mapActions('Files', ['addLink', 'updateLink', 'removeLink']),
...mapActions(['showMessage', 'createModal', 'hideModal']),

toggleLinkListCollapsed() {
Expand Down Expand Up @@ -485,18 +499,24 @@ export default defineComponent({
permissions: link.permissions,
quicklink: link.quicklink,
name: link.name,
spaceRef: this.highlightedFile.fileId,
...(this.currentStorageId && {
storageId: this.currentStorageId,
spaceRef: `${this.currentStorageId}${this.highlightedFile.path}`
storageId: this.currentStorageId
})
}
},

async createLink({ params, onError = (e) => {} }) {
let path = this.highlightedFile.path
// sharing a share root from the share jail -> use resource name as path
if (this.hasShareJail && path === '/') {
path = `/${this.highlightedFile.name}`
}
await this.addLink({
path: this.highlightedFile.path,
path,
client: this.$client,
$gettext: this.$gettext,
storageId: this.highlightedFile.fileId || this.highlightedFile.id,
params
}).catch((e) => {
onError(e)
Expand Down Expand Up @@ -555,12 +575,17 @@ export default defineComponent({

async deleteLink({ client, share, resource }) {
this.hideModal()
let path = resource.path
// sharing a share root from the share jail -> use resource name as path
if (this.hasShareJail && path === '/') {
path = `/${resource.name}`
}
// removeLink currently fetches all shares from the backend in order to reload the shares indicators
// TODO: Check if to-removed link is last link share and only reload if it's the last link
await this.removeLink({
client,
share,
resource,
path,
...(this.currentStorageId && { storageId: this.currentStorageId })
})
.then(
Expand Down
Loading