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
8 changes: 7 additions & 1 deletion packages/web-app-files/src/components/Spaces/SpaceHeader.vue
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
is-read-only
:current-content="markdownContent"
/>
<div class="markdown-container-edit ml-2">
<div v-if="isEditReadmeVisible" class="markdown-container-edit ml-2">
<oc-button
type="router-link"
size="small"
Expand Down Expand Up @@ -122,6 +122,7 @@ import {
useLoadPreview,
useResourcesStore,
useSharesStore,
useSpaceActionsEditReadmeContent,
useSpacesStore
} from '@opencloud-eu/web-pkg'
import SpaceContextActions from './SpaceContextActions.vue'
Expand All @@ -146,6 +147,11 @@ const { loadPreview } = useLoadPreview()
const spacesStore = useSpacesStore()
const sharesStore = useSharesStore()
const { imagesLoading, readmesLoading } = storeToRefs(spacesStore)
const { actions: editReadmeContentActions } = useSpaceActionsEditReadmeContent()

const isEditReadmeVisible = computed(() =>
unref(editReadmeContentActions)[0].isVisible({ resources: [space] })
)
Comment on lines +152 to +154
Copy link

Copilot AI Sep 11, 2025

Choose a reason for hiding this comment

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

Accessing array index [0] without checking if the array has elements could cause a runtime error. Consider adding a safety check or using optional chaining.

Suggested change
const isEditReadmeVisible = computed(() =>
unref(editReadmeContentActions)[0].isVisible({ resources: [space] })
)
const isEditReadmeVisible = computed(() => {
const actions = unref(editReadmeContentActions);
return actions.length > 0 ? actions[0].isVisible({ resources: [space] }) : false;
})

Copilot uses AI. Check for mistakes.

const isMobileWidth = inject<Ref<boolean>>('isMobileWidth')

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ const getSpaceMock = (spaceImageData: DriveItem = undefined) =>
name: 'space',
description: '',
spaceReadmeData: undefined,
canEditReadme: () => true,
spaceImageData
})

Expand Down