Skip to content

Commit

Permalink
Merge pull request #12002 from owncloud/fix/ocm-issues
Browse files Browse the repository at this point in the history
fix: multiple ocm issues
  • Loading branch information
JammingBen authored Dec 5, 2024
2 parents edd70d5 + cbbe96c commit ac1de91
Show file tree
Hide file tree
Showing 13 changed files with 101 additions and 30 deletions.
6 changes: 6 additions & 0 deletions changelog/unreleased/bugfix-ocm-share-editing
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Bugfix: OCM share editing

We've fixed a bug where OCM shares could be edited although the server does not support it.

https://github.com/owncloud/web/pull/12002
https://github.com/owncloud/web/issues/11991
6 changes: 6 additions & 0 deletions changelog/unreleased/bugfix-ocm-share-recipient-issuer
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Bugfix: OCM share recipient issuer

We've fixed a bug where the issuer for OCM shares was missing in the invite input field.

https://github.com/owncloud/web/pull/12002
https://github.com/owncloud/web/issues/11972
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
</li>
</oc-list>
<oc-list
v-if="canEditOrDelete"
v-if="canRemove"
class="collaborator-edit-dropdown-options-list collaborator-edit-dropdown-options-list-remove"
>
<li
Expand Down Expand Up @@ -91,7 +91,11 @@ export default defineComponent({
return ['user', 'group'].includes(value) || !value
}
},
canEditOrDelete: {
canEdit: {
type: Boolean,
required: true
},
canRemove: {
type: Boolean,
required: true
},
Expand Down Expand Up @@ -198,7 +202,7 @@ export default defineComponent({
})
}
if (this.canEditOrDelete && this.isExpirationSupported) {
if (this.canEdit && this.isExpirationSupported) {
result.push({
title: this.isExpirationDateSet
? this.$gettext('Edit expiration date')
Expand Down Expand Up @@ -254,7 +258,7 @@ export default defineComponent({
},
isRemoveExpirationPossible() {
return this.canEditOrDelete && this.isExpirationSupported && this.isExpirationDateSet
return this.canEdit && this.isExpirationSupported && this.isExpirationDateSet
}
},
methods: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@
class="files-collaborators-autocomplete-additionalInfo"
v-text="`${additionalInfo}`"
/>
<div
v-if="externalIssuer"
class="files-collaborators-autocomplete-externalIssuer"
v-text="`${externalIssuer}`"
/>
</div>
</div>
</template>
Expand All @@ -56,7 +61,14 @@ export default {
return props.item.mail || props.item.onPremisesSamAccountName
})
return { additionalInfo }
const externalIssuer = computed(() => {
if (props.item.shareType === ShareTypes.remote.value) {
return props.item.identities?.[0]?.issuer
}
return ''
})
return { additionalInfo, externalIssuer }
},
computed: {
shareType() {
Expand Down Expand Up @@ -87,7 +99,8 @@ export default {
</script>

<style lang="scss">
.files-collaborators-autocomplete-additionalInfo {
.files-collaborators-autocomplete-additionalInfo,
.files-collaborators-autocomplete-externalIssuer {
font-size: var(--oc-font-size-small);
}
</style>
Original file line number Diff line number Diff line change
Expand Up @@ -295,11 +295,14 @@ export default defineComponent({
})
})
onMounted(async () => {
const setInitialSelectedRole = () => {
selectedRole.value = unref(isExternalShareRoleType)
? unref(availableExternalRoles)[0]
: unref(availableInternalRoles)[0]
}
onMounted(async () => {
setInitialSelectedRole()
await nextTick()
markInstance.value = new Mark('.mark-element')
})
Expand Down Expand Up @@ -479,6 +482,7 @@ export default defineComponent({
}
}
focusShareInput()
setInitialSelectedRole()
}
const focusShareInput = () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<script lang="ts">
import { avatarUrl } from '../../../../../helpers/user'
import { CollaboratorAutoCompleteItem, ShareTypes } from '@ownclouders/web-client'
import { defineComponent, PropType } from 'vue'
import { computed, defineComponent, PropType } from 'vue'
import { Recipient } from '@ownclouders/design-system/helpers'
import { useCapabilityStore, useConfigStore } from '@ownclouders/web-pkg'
import { storeToRefs } from 'pinia'
Expand All @@ -37,22 +37,35 @@ export default defineComponent({
default: null
}
},
setup() {
setup(props) {
const capabilityStore = useCapabilityStore()
const capabilityRefs = storeToRefs(capabilityStore)
const configStore = useConfigStore()
const { serverUrl } = storeToRefs(configStore)
const externalIssuer = computed(() => {
if (props.recipient.shareType === ShareTypes.remote.value) {
return props.recipient.identities?.[0]?.issuer
}
return ''
})
return {
serverUrl,
userProfilePicture: capabilityRefs.sharingUserProfilePicture
userProfilePicture: capabilityRefs.sharingUserProfilePicture,
externalIssuer
}
},
data(): { formattedRecipient: Recipient } {
let name = this.recipient.displayName
if (this.externalIssuer) {
name += ` (${this.externalIssuer})`
}
return {
formattedRecipient: {
name: this.recipient.displayName,
name,
icon: this.getRecipientIcon(),
hasAvatar: this.recipient.shareType === ShareTypes.user.value,
isLoadingAvatar: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@
data-testid="collaborator-edit"
:expiration-date="share.expirationDateTime ? share.expirationDateTime : null"
:share-category="shareCategory"
:can-edit-or-delete="modifiable"
:can-edit="modifiable"
:can-remove="removable"
:is-share-denied="isShareDenied"
:is-locked="isLocked"
:deniable="deniable"
Expand Down Expand Up @@ -165,6 +166,10 @@ export default defineComponent({
type: Boolean,
default: false
},
removable: {
type: Boolean,
default: false
},
sharedParentRoute: {
type: Object as PropType<RouteLocationNamedRaw>,
default: null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
:resource-name="resource.name"
:deniable="isShareDeniable(collaborator)"
:modifiable="isShareModifiable(collaborator)"
:removable="isShareRemovable(collaborator)"
:is-share-denied="isShareDenied(collaborator)"
:shared-parent-route="getSharedParentRoute(collaborator)"
:is-locked="resource.locked"
Expand Down Expand Up @@ -438,6 +439,17 @@ export default defineComponent({
},
isShareModifiable(collaborator: CollaboratorShare) {
if (collaborator.indirect || collaborator.shareType === ShareTypes.remote.value) {
return false
}
if (isProjectSpaceResource(this.space) || isShareSpaceResource(this.space)) {
return this.space.canShare({ user: this.user })
}
return true
},
isShareRemovable(collaborator: CollaboratorShare) {
if (collaborator.indirect) {
return false
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
<collaborator-list-item
:share="collaborator"
:modifiable="isModifiable(collaborator)"
:removable="isModifiable(collaborator)"
:is-space-share="true"
@on-delete="deleteMemberConfirm(collaborator)"
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,22 @@ describe('EditDropdown', () => {
})
})
describe('remove share action', () => {
it('is being rendered when canEditOrDelete is true', () => {
const { wrapper } = getWrapper({ canEditOrDelete: true })
it('is being rendered when canRemove is true', () => {
const { wrapper } = getWrapper({ canRemove: true })
expect(wrapper.find(selectors.removeShareSection).exists()).toBeTruthy()
})
it('is not being rendered when canEditOrDelete is false', () => {
const { wrapper } = getWrapper({ canEditOrDelete: false })
it('is not being rendered when canRemove is false', () => {
const { wrapper } = getWrapper({ canRemove: false })
expect(wrapper.find(selectors.removeShareSection).exists()).toBeFalsy()
})
})
describe('expiration date', () => {
it('is being rendered when canEditOrDelete is true', () => {
const { wrapper } = getWrapper({ canEditOrDelete: true })
it('is being rendered when canEdit is true', () => {
const { wrapper } = getWrapper({ canEdit: true })
expect(wrapper.find(selectors.expireDateMenuAction).exists()).toBeTruthy()
})
it('is not being rendered when canEditOrDelete is false', () => {
const { wrapper } = getWrapper({ canEditOrDelete: false })
it('is not being rendered when canEdit is false', () => {
const { wrapper } = getWrapper({ canEdit: false })
expect(wrapper.find(selectors.expireDateMenuAction).exists()).toBeFalsy()
})
})
Expand Down Expand Up @@ -71,7 +71,8 @@ function getWrapper(props: PartialComponentProps<typeof EditDropdown> = {}) {
return {
wrapper: shallowMount(EditDropdown, {
props: {
canEditOrDelete: true,
canEdit: true,
canRemove: true,
shareCategory: 'user',
accessDetails: [],
...props
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ exports[`Collaborator ListItem component > share inheritance indicators > show w
<div data-v-ccf14be2="" class="oc-flex oc-flex-middle oc-width-1-3 files-collaborators-collaborator-navigation">
<!--v-if-->
<oc-icon-stub data-v-ccf14be2="" name="folder-shared" fill-type="line" class="files-collaborators-collaborator-shared-via oc-mx-xs"></oc-icon-stub>
<edit-dropdown-stub data-v-ccf14be2="" accessdetails="[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]" sharecategory="user" caneditordelete="true" issharedenied="false" deniable="false" islocked="false" sharedparentroute="[object Object]" class="files-collaborators-collaborator-edit oc-ml-xs" data-testid="collaborator-edit"></edit-dropdown-stub>
<edit-dropdown-stub data-v-ccf14be2="" accessdetails="[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]" sharecategory="user" canedit="true" canremove="false" issharedenied="false" deniable="false" islocked="false" sharedparentroute="[object Object]" class="files-collaborators-collaborator-edit oc-ml-xs" data-testid="collaborator-edit"></edit-dropdown-stub>
</div>
</div>
</div>"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@ exports[`FileShares > collaborators list > renders sharedWithLabel and sharee li
<portal-target data-v-5d17c3fa="" name="app.files.sidebar.sharing.shared-with.top" slot-props="[object Object]" multiple="true"></portal-target>
<ul data-v-5d17c3fa="" id="files-collaborators-list" class="oc-list oc-list-divider oc-m-rm" aria-label="Share receivers">
<li data-v-5d17c3fa="">
<collaborator-list-item-stub data-v-5d17c3fa="" share="[object Object]" issharedenied="false" modifiable="true" resourcename="[Function]" deniable="false" islocked="[Function]" isspaceshare="false"></collaborator-list-item-stub>
<collaborator-list-item-stub data-v-5d17c3fa="" share="[object Object]" issharedenied="false" modifiable="true" removable="true" resourcename="[Function]" deniable="false" islocked="[Function]" isspaceshare="false"></collaborator-list-item-stub>
</li>
<li data-v-5d17c3fa="">
<collaborator-list-item-stub data-v-5d17c3fa="" share="[object Object]" issharedenied="false" modifiable="true" resourcename="[Function]" deniable="false" islocked="[Function]" isspaceshare="false"></collaborator-list-item-stub>
<collaborator-list-item-stub data-v-5d17c3fa="" share="[object Object]" issharedenied="false" modifiable="true" removable="true" resourcename="[Function]" deniable="false" islocked="[Function]" isspaceshare="false"></collaborator-list-item-stub>
</li>
<li data-v-5d17c3fa="">
<collaborator-list-item-stub data-v-5d17c3fa="" share="[object Object]" issharedenied="false" modifiable="true" resourcename="[Function]" deniable="false" islocked="[Function]" isspaceshare="false"></collaborator-list-item-stub>
<collaborator-list-item-stub data-v-5d17c3fa="" share="[object Object]" issharedenied="false" modifiable="true" removable="true" resourcename="[Function]" deniable="false" islocked="[Function]" isspaceshare="false"></collaborator-list-item-stub>
</li>
<li data-v-5d17c3fa="">
<collaborator-list-item-stub data-v-5d17c3fa="" share="[object Object]" issharedenied="false" modifiable="true" resourcename="[Function]" deniable="false" islocked="[Function]" isspaceshare="false"></collaborator-list-item-stub>
<collaborator-list-item-stub data-v-5d17c3fa="" share="[object Object]" issharedenied="false" modifiable="true" removable="true" resourcename="[Function]" deniable="false" islocked="[Function]" isspaceshare="false"></collaborator-list-item-stub>
</li>
<portal-target data-v-5d17c3fa="" name="app.files.sidebar.sharing.shared-with.bottom" slot-props="[object Object]" multiple="true"></portal-target>
</ul>
Expand Down Expand Up @@ -53,7 +53,7 @@ exports[`FileShares > current space > loads space members if a space is given an
<portal-target data-v-5d17c3fa="" name="app.files.sidebar.sharing.shared-with.top" slot-props="[object Object]" multiple="true"></portal-target>
<ul data-v-5d17c3fa="" id="files-collaborators-list" class="oc-list oc-list-divider oc-mb-l" aria-label="Share receivers">
<li data-v-5d17c3fa="">
<collaborator-list-item-stub data-v-5d17c3fa="" share="[object Object]" issharedenied="false" modifiable="false" resourcename="[Function]" deniable="false" islocked="[Function]" isspaceshare="false"></collaborator-list-item-stub>
<collaborator-list-item-stub data-v-5d17c3fa="" share="[object Object]" issharedenied="false" modifiable="false" removable="false" resourcename="[Function]" deniable="false" islocked="[Function]" isspaceshare="false"></collaborator-list-item-stub>
</li>
<portal-target data-v-5d17c3fa="" name="app.files.sidebar.sharing.shared-with.bottom" slot-props="[object Object]" multiple="true"></portal-target>
</ul>
Expand All @@ -63,10 +63,10 @@ exports[`FileShares > current space > loads space members if a space is given an
</div>
<ul data-v-5d17c3fa="" id="space-collaborators-list" class="oc-list oc-list-divider oc-overflow-hidden oc-m-rm" aria-label="Space members">
<li data-v-5d17c3fa="">
<collaborator-list-item-stub data-v-5d17c3fa="" share="[object Object]" issharedenied="false" modifiable="false" resourcename="[Function]" deniable="false" islocked="false" isspaceshare="true"></collaborator-list-item-stub>
<collaborator-list-item-stub data-v-5d17c3fa="" share="[object Object]" issharedenied="false" modifiable="false" removable="false" resourcename="[Function]" deniable="false" islocked="false" isspaceshare="true"></collaborator-list-item-stub>
</li>
<li data-v-5d17c3fa="">
<collaborator-list-item-stub data-v-5d17c3fa="" share="[object Object]" issharedenied="false" modifiable="false" resourcename="[Function]" deniable="false" islocked="false" isspaceshare="true"></collaborator-list-item-stub>
<collaborator-list-item-stub data-v-5d17c3fa="" share="[object Object]" issharedenied="false" modifiable="false" removable="false" resourcename="[Function]" deniable="false" islocked="false" isspaceshare="true"></collaborator-list-item-stub>
</li>
</ul>
<!--v-if-->
Expand Down
8 changes: 7 additions & 1 deletion packages/web-client/src/helpers/share/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
import { Identity, SharingLinkType, UnifiedRoleDefinition } from '../../graph/generated'
import {
Identity,
ObjectIdentity,
SharingLinkType,
UnifiedRoleDefinition
} from '../../graph/generated'
import { Resource } from '../resource'

export enum GraphSharePermission {
Expand Down Expand Up @@ -73,4 +78,5 @@ export interface CollaboratorAutoCompleteItem {
shareType: number
mail?: string
onPremisesSamAccountName?: string
identities?: ObjectIdentity[]
}

0 comments on commit ac1de91

Please sign in to comment.