Skip to content

Commit

Permalink
Merge pull request #6619 from owncloud/resharing_capability
Browse files Browse the repository at this point in the history
  • Loading branch information
kulmann authored Mar 18, 2022
2 parents b121eae + 403a128 commit 35fbae0
Show file tree
Hide file tree
Showing 27 changed files with 207 additions and 53 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
:share-id="share.id"
:existing-permissions="share.customPermissions"
:existing-role="share.role"
:allow-share-permission="!isOcis || isSpace"
:allow-share-permission="hasResharing || isSpace"
class="files-collaborators-collaborator-role"
@optionChange="shareRoleChanged"
/>
Expand Down Expand Up @@ -94,6 +94,7 @@ import EditDropdown from './EditDropdown.vue'
import RoleDropdown from '../RoleDropdown.vue'
import { SharePermissions, ShareTypes } from '../../../../helpers/share'
import { clientService } from 'web-pkg/src/services'
import { useCapabilityFilesSharingResharing } from 'web-pkg/src/composables'
export default {
name: 'ListItem',
Expand All @@ -112,9 +113,14 @@ export default {
default: false
}
},
setup() {
return {
hasResharing: useCapabilityFilesSharingResharing()
}
},
computed: {
...mapGetters('Files', ['highlightedFile']),
...mapGetters(['isOcis', 'getToken', 'configuration']),
...mapGetters(['getToken', 'configuration']),
...mapState(['user']),
shareType() {
Expand Down Expand Up @@ -264,7 +270,7 @@ export default {
const bitmask = role.hasCustomPermissions
? SharePermissions.permissionsToBitmask(permissions)
: SharePermissions.permissionsToBitmask(
role.permissions(!this.isOcis || this.shareType === ShareTypes.space)
role.permissions(this.hasResharing || this.shareType === ShareTypes.space)
)
this.changeShare({
client: this.$client,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
<div class="oc-flex oc-flex-middle oc-flex-between oc-mb-l">
<role-dropdown
:resource="highlightedFile"
:allow-share-permission="!isOcis || resourceIsSpace"
:allow-share-permission="hasResharing || resourceIsSpace"
@optionChange="collaboratorRoleChanged"
/>
<expiration-datepicker
Expand Down Expand Up @@ -87,6 +87,7 @@ import {
SpacePeopleShareRoles
} from '../../../../helpers/share'
import { clientService } from 'web-pkg/src/services'
import { useCapabilityFilesSharingResharing } from 'web-pkg/src/composables'
export default {
name: 'InviteCollaboratorForm',
Expand All @@ -96,6 +97,11 @@ export default {
RecipientContainer,
ExpirationDatepicker
},
setup() {
return {
hasResharing: useCapabilityFilesSharingResharing()
}
},
data() {
return {
autocompleteResults: [],
Expand All @@ -111,7 +117,7 @@ export default {
},
computed: {
...mapGetters('Files', ['currentFileOutgoingCollaborators', 'highlightedFile']),
...mapGetters(['configuration', 'isOcis', 'getToken', 'user']),
...mapGetters(['configuration', 'getToken', 'user']),
inviteDescriptionMessage() {
return this.$gettext('Add new person by name, email or federation IDs')
Expand Down Expand Up @@ -252,7 +258,7 @@ export default {
const bitmask = this.selectedRole.hasCustomPermissions
? SharePermissions.permissionsToBitmask(this.customPermissions)
: SharePermissions.permissionsToBitmask(
this.selectedRole.permissions(!this.isOcis || this.resourceIsSpace)
this.selectedRole.permissions(this.hasResharing || this.resourceIsSpace)
)
let storageId
Expand Down
11 changes: 8 additions & 3 deletions packages/web-app-files/src/mixins/actions/acceptShare.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
import { triggerShareAction } from '../../helpers/share/triggerShareAction'

import { mapActions, mapGetters, mapMutations } from 'vuex'
import { mapActions, mapMutations } from 'vuex'
import PQueue from 'p-queue'
import { ShareStatus } from '../../helpers/share'
import { isLocationSharesActive } from '../../router'
import { useCapabilityFilesSharingResharing } from 'web-pkg/src/composables'

export default {
computed: {
...mapGetters(['isOcis']),
setup() {
return {
hasResharing: useCapabilityFilesSharingResharing()
}
},
$_acceptShare_items() {
return [
{
Expand Down Expand Up @@ -50,7 +55,7 @@ export default {
const share = await triggerShareAction(
resource,
ShareStatus.accepted,
!this.isOcis,
this.hasResharing,
this.$client
)
if (share) {
Expand Down
11 changes: 8 additions & 3 deletions packages/web-app-files/src/mixins/actions/declineShare.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
import { triggerShareAction } from '../../helpers/share/triggerShareAction'
import { isLocationSharesActive } from '../../router'
import { mapActions, mapGetters, mapMutations } from 'vuex'
import { mapActions, mapMutations } from 'vuex'
import PQueue from 'p-queue'
import { ShareStatus } from '../../helpers/share'
import { useCapabilityFilesSharingResharing } from 'web-pkg/src/composables'

export default {
setup() {
return {
hasResharing: useCapabilityFilesSharingResharing()
}
},
computed: {
...mapGetters(['isOcis']),
$_declineShare_items() {
return [
{
Expand Down Expand Up @@ -49,7 +54,7 @@ export default {
const share = await triggerShareAction(
resource,
ShareStatus.declined,
!this.isOcis,
this.hasResharing,
this.$client
)
if (share) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import Router from 'vue-router'
import { useTask } from 'vue-concurrency'
import { isLocationSharesActive } from '../../router'
import { aggregateResourceShares } from '../../helpers/resources'
import { useCapabilityFilesSharingResharing } from 'web-pkg/src/composables'
import { unref } from '@vue/composition-api'

export class FolderLoaderSharedViaLink implements FolderLoader {
public isEnabled(router: Router): boolean {
Expand All @@ -15,6 +17,8 @@ export class FolderLoaderSharedViaLink implements FolderLoader {
clientService: { owncloudSdk: client }
} = context

const hasResharing = useCapabilityFilesSharingResharing(store)

return useTask(function* (signal1, signal2) {
store.commit('Files/CLEAR_CURRENT_FILES_LIST')

Expand All @@ -28,14 +32,13 @@ export class FolderLoaderSharedViaLink implements FolderLoader {
resources = resources.ocs.data

if (resources.length) {
const isOcis = store.getters.isOcis
const configuration = store.getters.configuration
const getToken = store.getters.getToken

resources = aggregateResourceShares(
resources,
false,
!isOcis,
unref(hasResharing),
configuration.server,
getToken
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import Router from 'vue-router'
import { useTask } from 'vue-concurrency'
import { aggregateResourceShares } from '../../helpers/resources'
import { isLocationSharesActive } from '../../router'
import { useCapabilityFilesSharingResharing } from 'web-pkg/src/composables'
import { unref } from '@vue/composition-api'

export class FolderLoaderSharedWithMe implements FolderLoader {
public isEnabled(router: Router): boolean {
Expand All @@ -15,6 +17,8 @@ export class FolderLoaderSharedWithMe implements FolderLoader {
clientService: { owncloudSdk: client }
} = context

const hasResharing = useCapabilityFilesSharingResharing(store)

return useTask(function* (signal1, signal2) {
store.commit('Files/CLEAR_CURRENT_FILES_LIST')

Expand All @@ -28,14 +32,13 @@ export class FolderLoaderSharedWithMe implements FolderLoader {
resources = resources.ocs.data

if (resources.length) {
const isOcis = store.getters.isOcis
const configuration = store.getters.configuration
const getToken = store.getters.getToken

resources = aggregateResourceShares(
resources,
true,
!isOcis,
unref(hasResharing),
configuration.server,
getToken
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import Router from 'vue-router'
import { useTask } from 'vue-concurrency'
import { isLocationSharesActive } from '../../router'
import { aggregateResourceShares } from '../../helpers/resources'
import { useCapabilityFilesSharingResharing } from 'web-pkg/src/composables'
import { unref } from '@vue/composition-api'

export class FolderLoaderSharedWithOthers implements FolderLoader {
public isEnabled(router: Router): boolean {
Expand All @@ -15,6 +17,8 @@ export class FolderLoaderSharedWithOthers implements FolderLoader {
clientService: { owncloudSdk: client }
} = context

const hasResharing = useCapabilityFilesSharingResharing(store)

return useTask(function* (signal1, signal2) {
store.commit('Files/CLEAR_CURRENT_FILES_LIST')

Expand All @@ -28,14 +32,13 @@ export class FolderLoaderSharedWithOthers implements FolderLoader {
resources = resources.ocs.data

if (resources.length) {
const isOcis = store.getters.isOcis
const configuration = store.getters.configuration
const getToken = store.getters.getToken

resources = aggregateResourceShares(
resources,
false,
!isOcis,
unref(hasResharing),
configuration.server,
getToken
)
Expand Down
27 changes: 18 additions & 9 deletions packages/web-app-files/src/store/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ import { avatarUrl } from '../helpers/user'
import { has } from 'lodash-es'
import { ShareTypes, SpacePeopleShareRoles } from '../helpers/share'
import { sortSpaceMembers } from '../helpers/space'
import get from 'lodash-es/get'

const allowSharePermissions = (getters) => {
return get(getters, `capabilities.files_sharing.resharing`, true)
}

export default {
updateFileProgress({ commit }, progress) {
Expand Down Expand Up @@ -205,7 +210,7 @@ export default {
return buildShare(
element.shareInfo,
context.getters.highlightedFile,
!context.rootGetters.isOcis
allowSharePermissions(context.rootGetters)
)
})
)
Expand Down Expand Up @@ -234,7 +239,7 @@ export default {
return buildCollaboratorShare(
element.shareInfo,
context.getters.highlightedFile,
!context.rootGetters.isOcis
allowSharePermissions(context.rootGetters)
)
})
)
Expand Down Expand Up @@ -300,7 +305,7 @@ export default {
const share = buildCollaboratorShare(
updatedShare.shareInfo,
getters.highlightedFile,
!rootGetters.isOcis
allowSharePermissions(rootGetters)
)
commit('CURRENT_FILE_OUTGOING_SHARES_UPDATE', share)
resolve(share)
Expand Down Expand Up @@ -336,7 +341,7 @@ export default {
buildCollaboratorShare(
share.shareInfo,
context.getters.highlightedFile,
!context.rootGetters.isOcis
allowSharePermissions(context.rootGetters)
)
)
context.dispatch('updateCurrentFileShareTypes')
Expand Down Expand Up @@ -415,7 +420,7 @@ export default {
buildCollaboratorShare(
share.shareInfo,
context.getters.highlightedFile,
!context.rootGetters.isOcis
allowSharePermissions(context.rootGetters)
)
)
context.dispatch('updateCurrentFileShareTypes')
Expand Down Expand Up @@ -516,7 +521,11 @@ export default {
.then((data) => {
data.forEach((element) => {
sharesTree[queryPath].push({
...buildShare(element.shareInfo, { type: 'folder' }, !context.rootGetters.isOcis),
...buildShare(
element.shareInfo,
{ type: 'folder' },
allowSharePermissions(context.rootGetters)
),
outgoing: true,
indirect: true
})
Expand All @@ -540,7 +549,7 @@ export default {
...buildCollaboratorShare(
element.shareInfo,
{ type: 'folder' },
!context.rootGetters.isOcis
allowSharePermissions(context.rootGetters)
),
incoming: true,
indirect: true
Expand Down Expand Up @@ -583,7 +592,7 @@ export default {
client.shares
.shareFileWithLink(path, params)
.then((data) => {
const link = buildShare(data.shareInfo, null, !context.rootGetters.isOcis)
const link = buildShare(data.shareInfo, null, allowSharePermissions(context.rootGetters))
context.commit('CURRENT_FILE_OUTGOING_SHARES_ADD', link)
context.dispatch('updateCurrentFileShareTypes')
context.dispatch('loadIndicators', { client, currentFolder: path })
Expand All @@ -599,7 +608,7 @@ export default {
client.shares
.updateShare(id, params)
.then((data) => {
const link = buildShare(data.shareInfo, null, !context.rootGetters.isOcis)
const link = buildShare(data.shareInfo, null, allowSharePermissions(context.rootGetters))
context.commit('CURRENT_FILE_OUTGOING_SHARES_UPDATE', link)
resolve(link)
})
Expand Down
2 changes: 1 addition & 1 deletion packages/web-app-files/src/views/shares/SharedWithMe.vue
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ export default {
computed: {
...mapGetters('Files', ['selectedFiles']),
...mapGetters(['isOcis', 'configuration', 'getToken']),
...mapGetters(['configuration', 'getToken']),
...mapState('Files/sidebar', { sidebarClosed: 'closed' }),
// pending shares
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export default {
...mapState(['app']),
...mapState('Files', ['files']),
...mapGetters('Files', ['highlightedFile', 'selectedFiles', 'totalFilesCount']),
...mapGetters(['isOcis', 'configuration', 'getToken', 'user']),
...mapGetters(['configuration', 'getToken', 'user']),
...mapState('Files/sidebar', { sidebarClosed: 'closed' }),
selected: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,6 @@ function createWrapper({
state: {
user: Users.alice
},
getters: {
isOcis: () => false
},
modules: {
Files: {
namespaced: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,6 @@ const storeOptions = (data) => {
configuration: jest.fn(() => ({
server: 'http://example.com/'
})),
isOcis: () => false,
user: () => user,
capabilities: () => {
return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ function getWrapper({ selectedCollaborators = [], storageId, highlightedFile = f
}
},
getters: {
isOcis: () => true,
getToken: jest.fn(() => 'GFwHKXdsMgoFwt'),
configuration: jest.fn(() => ({
server: 'http://example.com/'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ const storeOptions = (avatarsEnabled) => {
}
},
getters: {
isOcis: () => false,
user: () => user,
getToken: () => '',
capabilities: () => {
Expand Down
Loading

0 comments on commit 35fbae0

Please sign in to comment.