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 sharesTree loading #7580

Merged
merged 17 commits into from
Sep 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
13 changes: 13 additions & 0 deletions changelog/unreleased/bugfix-shares-tree-loading
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Bugfix: Shares tree loading

We've improved loading of the shares tree:

* It now happens more globally in the sidebar component instead of in each sidebar panel.
* Shares won't be loaded for resources without a path anymore.

These changes massively improve the sidebar performance and fix several issues with (re-)share permissions.

https://github.com/owncloud/web/issues/7506
https://github.com/owncloud/web/issues/7593
https://github.com/owncloud/web/issues/7592
https://github.com/owncloud/web/pull/7580
JammingBen marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -352,39 +352,40 @@ export default defineComponent({
watch: {
file() {
this.loadData()
this.refreshShareDetailsTree()
},
sharesTree() {
// missing early return
this.sharedItem = null
this.shareIndicators = getIndicators(this.file, this.sharesTree)
const sharePathParentOrCurrent = this.getParentSharePath(this.file.path, this.sharesTree)
if (sharePathParentOrCurrent === null) {
return
}
const shares = this.sharesTree[sharePathParentOrCurrent]?.filter((s) =>
ShareTypes.containsAnyValue(
[...ShareTypes.individuals, ...ShareTypes.unauthenticated],
[s.shareType]
},
sharesTree: {
handler() {
// missing early return
this.sharedItem = null
this.shareIndicators = getIndicators(this.file, this.sharesTree)
JammingBen marked this conversation as resolved.
Show resolved Hide resolved
const sharePathParentOrCurrent = this.getParentSharePath(this.file.path, this.sharesTree)
if (sharePathParentOrCurrent === null) {
return
}
const shares = this.sharesTree[sharePathParentOrCurrent]?.filter((s) =>
ShareTypes.containsAnyValue(
[...ShareTypes.individuals, ...ShareTypes.unauthenticated],
[s.shareType]
)
)
)
if (shares.length === 0) {
return
}
if (shares.length === 0) {
return
}

this.sharedItem = shares[0]
this.sharedByName = this.sharedItem.owner?.name
this.sharedByDisplayName = this.sharedItem.owner?.displayName
if (this.sharedItem.owner?.additionalInfo) {
this.sharedByDisplayName += ' (' + this.sharedItem.owner.additionalInfo + ')'
}
this.sharedTime = this.sharedItem.stime
this.sharedParentDir = sharePathParentOrCurrent
this.sharedItem = shares[0]
kulmann marked this conversation as resolved.
Show resolved Hide resolved
this.sharedByName = this.sharedItem.owner?.name
this.sharedByDisplayName = this.sharedItem.owner?.displayName
if (this.sharedItem.owner?.additionalInfo) {
this.sharedByDisplayName += ' (' + this.sharedItem.owner.additionalInfo + ')'
}
this.sharedTime = this.sharedItem.stime
this.sharedParentDir = sharePathParentOrCurrent
},
immediate: true
}
},
mounted() {
this.loadData()
this.refreshShareDetailsTree()
},
asyncComputed: {
preview: {
Expand All @@ -405,16 +406,8 @@ export default defineComponent({
}
},
methods: {
...mapActions('Files', ['loadPreview', 'loadVersions', 'loadSharesTree']),
async refreshShareDetailsTree() {
await this.loadSharesTree({
client: this.$client,
path: this.file.path,
$gettext: this.$gettext,
storageId: this.file.fileId
})
this.shareIndicators = getIndicators(this.file, this.sharesTree)
},
...mapActions('Files', ['loadPreview', 'loadVersions']),

getParentSharePath(childPath, shares) {
let currentPath = childPath
if (!currentPath) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,13 +217,6 @@ export default defineComponent({
return this.$gettextInterpolate(translated, context)
},

shareExpirationText() {
kulmann marked this conversation as resolved.
Show resolved Hide resolved
const translated = this.$gettext('Expires %{ expiryDateRelative }')
return this.$gettextInterpolate(translated, {
expiryDateRelative: this.expirationDateRelative
})
},

screenreaderShareExpiration() {
const translated = this.$gettext('Share expires %{ expiryDateRelative } (%{ expiryDate })')
return this.$gettextInterpolate(translated, {
Expand Down Expand Up @@ -258,11 +251,6 @@ export default defineComponent({
return this.sharedParentRoute?.params?.item.split('/').pop()
},

shareDetailsHelperContent() {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fyi unused property.

return {
text: this.$gettext('Invite persons or groups to access this file or folder.')
}
},
editDropDownToggleId() {
return uuid.v4()
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ import { PropType } from '@vue/composition-api'
export default defineComponent({
name: 'RoleDropdown',
components: { RoleItem },
inject: ['incomingParentShare'],
props: {
resource: {
type: Object,
Expand Down Expand Up @@ -181,10 +182,6 @@ export default defineComponent({
resourceIsSharable() {
return this.allowSharePermission && this.resource.canShare()
},
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)
},
allowCustomSharing() {
return this.capabilities?.files_sharing?.allow_custom
},
Expand All @@ -193,9 +190,9 @@ export default defineComponent({
return SpacePeopleShareRoles.list()
}

if (this.share?.incoming && this.resourceIsSharable) {
if (this.incomingParentShare.value && this.resourceIsSharable) {
return PeopleShareRoles.filterByBitmask(
parseInt(this.share.permissions),
parseInt(this.incomingParentShare.value.permissions),
this.resource.isFolder,
this.allowSharePermission,
this.allowCustomSharing !== false
Expand All @@ -205,8 +202,10 @@ export default defineComponent({
return PeopleShareRoles.list(this.resource.isFolder, this.allowCustomSharing !== false)
},
availablePermissions() {
if (this.share?.incoming && this.resourceIsSharable) {
return SharePermissions.bitmaskToPermissions(parseInt(this.share.permissions))
if (this.incomingParentShare.value && this.resourceIsSharable) {
return SharePermissions.bitmaskToPermissions(
parseInt(this.incomingParentShare.value.permissions)
)
}
return this.customPermissionsRole.permissions(this.allowSharePermission)
},
Expand Down
13 changes: 3 additions & 10 deletions packages/web-app-files/src/components/SideBar/Shares/FileLinks.vue
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ export default defineComponent({
DetailsAndEdit,
NameAndCopy
},
inject: ['incomingParentShare'],
setup() {
const store = useStore()

Expand Down Expand Up @@ -182,11 +183,6 @@ 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 @@ -218,9 +214,9 @@ export default defineComponent({
},

availableRoleOptions() {
if (this.share?.incoming && this.canCreatePublicLinks) {
if (this.incomingParentShare.value && this.canCreatePublicLinks) {
return LinkShareRoles.filterByBitmask(
parseInt(this.share.permissions),
parseInt(this.incomingParentShare.value.permissions),
this.highlightedFile.isFolder,
this.hasPublicLinkEditing,
this.hasPublicLinkAliasSupport
Expand Down Expand Up @@ -323,9 +319,6 @@ export default defineComponent({
return []
}

// remove root entry
parentPaths.pop()

parentPaths.forEach((parentPath) => {
const shares = cloneStateObject(this.sharesTree[parentPath])
if (shares) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,38 +188,6 @@ export default {
return this.collaborators.length > 0
},

/**
kulmann marked this conversation as resolved.
Show resolved Hide resolved
* Returns all incoming shares, direct and indirect
*
* @return {Array.<Object>} list of incoming shares
*/
$_allIncomingShares() {
// direct incoming shares
const allShares = [...this.incomingShares]

// indirect incoming shares
const parentPaths = getParentPaths(this.highlightedFile.path, true)
if (parentPaths.length === 0) {
return []
}

// remove root entry
parentPaths.pop()

parentPaths.forEach((parentPath) => {
const shares = this.sharesTree[parentPath]
if (shares) {
shares.forEach((share) => {
if (share.incoming) {
allShares.push(share)
}
})
}
})

return allShares
},

collaborators() {
return [...this.currentFileOutgoingCollaborators, ...this.indirectOutgoingShares]
.sort(this.collaboratorsComparator)
Expand Down Expand Up @@ -260,9 +228,6 @@ export default {
return []
}

// remove root entry
parentPaths.pop()

parentPaths.forEach((parentPath) => {
const shares = this.sharesTree[parentPath]
if (shares) {
Expand Down Expand Up @@ -294,20 +259,6 @@ export default {
const translatedFolder = this.$gettext("You don't have permission to share this folder.")
return this.highlightedFile.type === 'file' ? translatedFile : translatedFolder
},

kulmann marked this conversation as resolved.
Show resolved Hide resolved
currentUsersPermissions() {
if (this.$_allIncomingShares.length > 0) {
let permissions = 0

for (const share of this.$_allIncomingShares) {
permissions |= share.permissions
}

return permissions
}

return null
},
currentUserIsMemberOfSpace() {
return this.currentSpace?.spaceMemberIds?.includes(this.user.uuid)
},
Expand Down
Loading