Skip to content

Commit

Permalink
use ocis storageId whenever possible
Browse files Browse the repository at this point in the history
use roles whenever possible
use fileId for public link sharing
fix indirect sharing-indicators behavior
fix retrieving of shares from shares tree
fix reshare permissions on share roots
fix sharesTree errors for links, take parent permissions into account
add ocis resharing env var to docker compose config
load indicators in share jail when resharing is enabled
make use of resharing composable
refactor share loading out of link and share panel component into parent component to load the data only once
cleanup expected failures & acceptance tests
add gherkin debug helpers
bump sdk
bump ocis
  • Loading branch information
fschade committed Jul 6, 2022
1 parent 67458fc commit 28dabe3
Show file tree
Hide file tree
Showing 34 changed files with 505 additions and 276 deletions.
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",
},
"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
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
})
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
})
})
)
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)
},
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(),
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) {
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

0 comments on commit 28dabe3

Please sign in to comment.