Skip to content

πŸ“š The open-source, offline-first Notion, Obsidian & Confluence alternative. Advanced Markdown, multi-tenant teams, OIDC/SSO, and local S3 backups. Deploy in one command.

Disable no doc ressource

Smaug6739ab888e7f5dad
diff --git a/frontend/components/AppSelect.vue b/frontend/components/AppSelect.vue
index c94af9a2..14b20879 100644
--- a/frontend/components/AppSelect.vue
+++ b/frontend/components/AppSelect.vue
@@ -7,7 +7,7 @@
<input type="text" v-model="search" placeholder="Search..." class="search-input" ref="searchInput" @blur="handleBlur" @keydown="handleKeyDown" />
<div class="dropdown">
<ul>
- <AppSelectNode v-for="item in filteredItems" :key="item.id" :node="item" :level="0" @select="handleSelect" />
+ <AppSelectNode v-for="item in filteredItems" :key="item.id" :node="item" :level="0" @select="handleSelect" :disabled="disabled" />
</ul>
</div>
</div>
@@ -22,6 +22,7 @@ const props = defineProps<{
placeholder?: string;
modelValue?: string | number;
size?: string;
+ disabled?: (i: ANode) => boolean;
}>();
const selectedId = ref<string | number>(props.modelValue || '');
diff --git a/frontend/components/AppSelectNode.vue b/frontend/components/AppSelectNode.vue
index 8b983d0f..1d58928c 100644
--- a/frontend/components/AppSelectNode.vue
+++ b/frontend/components/AppSelectNode.vue
@@ -1,10 +1,10 @@
<template>
<li>
- <button class="tree-node" :style="{ paddingLeft: `${level * 20 + 12}px`, fontWeight: node.childrens?.length ? 700 : 400 }" @click.stop="select">
+ <button class="tree-node" :style="{ paddingLeft: `${level * 20 + 12}px`, fontWeight: node.childrens?.length ? 700 : 400 }" @click.stop="select" :disabled="disabled && disabled(node)">
{{ node.label }}
</button>
<ul v-if="node.childrens?.length">
- <AppSelectNode v-for="child in node.childrens" :key="child.id" :node="child" :level="level + 1" @select="$emit('select', $event)" />
+ <AppSelectNode v-for="child in node.childrens" :key="child.id" :node="child" :level="level + 1" @select="$emit('select', $event)" :disabled="disabled" />
</ul>
</li>
</template>
@@ -13,11 +13,13 @@
const props = defineProps<{
node: ANode;
level: number;
+ disabled?: (i: ANode) => boolean;
}>();
const emit = defineEmits(['select']);
function select() {
+ if (props.disabled && props.disabled(props.node)) return;
emit('select', props.node);
}
</script>
@@ -45,4 +47,8 @@ li {
margin: 0;
padding: 0;
}
+button[disabled] {
+ cursor: not-allowed;
+ opacity: 0.5;
+}
</style>
diff --git a/frontend/pages/dashboard/cdn/[id]/index.vue b/frontend/pages/dashboard/cdn/[id]/index.vue
index 1dd51817..fbec2299 100644
--- a/frontend/pages/dashboard/cdn/[id]/index.vue
+++ b/frontend/pages/dashboard/cdn/[id]/index.vue
@@ -18,7 +18,7 @@
<label>Name</label>
<input type="text" v-model="ressource.filename" id="name" required />
<label style="display: flex; align-items: center">Parent <AppHint text="To organize your uploads" /></label>
- <AppSelect v-model="ressource.parent_id" :items="tree" placeholder="Select a ressource parent" />
+ <AppSelect v-model="ressource.parent_id" :items="tree" :disabled="(i) => (i as Item).data?.type !== 'document'" placeholder="Select a ressource parent" />
<label>Type</label>
<input type="text" :value="ressource.filetype" id="id" disabled />
<label>Original path</label>