Skip to content
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
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { isLocationSpacesActive } from '../../../router'
import { usePreviewService } from '../../previewService'
import { useClientService } from '../../clientService'
import { useLoadingService } from '../../loadingService'
import { useRouter } from '../../router'
Expand All @@ -8,14 +7,14 @@ import { computed } from 'vue'
import { FileAction, FileActionOptions } from '../types'
import { useModals, useUserStore } from '../../piniaStores'
import SpaceImageModal from '../../../components/Spaces/SpaceImageModal.vue'
import { isProjectSpaceResource } from '@opencloud-eu/web-client'

export const useFileActionsSetImage = () => {
const userStore = useUserStore()
const router = useRouter()
const { $gettext } = useGettext()
const clientService = useClientService()
const loadingService = useLoadingService()
const previewService = usePreviewService()
const { dispatchModal } = useModals()

const handler = async ({ space, resources }: FileActionOptions) => {
Expand Down Expand Up @@ -56,7 +55,9 @@ export const useFileActionsSetImage = () => {
if (!space) {
return false
}

if (!isProjectSpaceResource(space)) {
return false
}
return space.canEditImage({ user: userStore.user })
},
class: 'oc-files-actions-set-space-image-trigger'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,15 @@ describe('setImage', () => {
}
})
})
it.each(['personal', 'share'])('should be false when space is of type %s', (driveType) => {
const space = mock<SpaceResource>({ canEditImage: () => true, driveType })

getWrapper({
setup: ({ actions }) => {
expect(unref(actions)[0].isVisible({ space, resources: [space] })).toBe(false)
}
})
})
})

describe('handler', () => {
Expand Down