π The open-source, offline-first Notion, Obsidian & Confluence alternative. Advanced Markdown, multi-tenant teams, OIDC/SSO, and local S3 backups. Deploy in one command.
Vue dockergolangkanbanknowledge-baseknowledge-managementmarkdownnote-takingnotesnotes-appnotionnuxtnuxtjsoffline-firstoidcpwaselfhostedssovuevuejswiki
New organization for modal options
Smaug6739354a29113065
diff --git a/frontend/app/components/CommandCenter/index.vue b/frontend/app/components/CommandCenter/index.vueindex 619e7807..af9217fb 100644--- a/frontend/app/components/CommandCenter/index.vue+++ b/frontend/app/components/CommandCenter/index.vue@@ -81,7 +81,7 @@ onMounted(() => {router.push('/dashboard/cdn');} else if ((e.ctrlKey || e.metaKey) && e.altKey && e.key.toLowerCase() === 'n') {e.preventDefault();- useModal().add(new Modal(shallowRef(CreateCategoryModal), { role: 1 }));+ useModal().add(new Modal(shallowRef(CreateCategoryModal), { props: { role: 1 } }));} else if (e.key === 'Escape' && isOpen.value) {closeSearch();} else if ((e.key === 'ArrowRight' || e.key === 'ArrowLeft') && isOpen.value) {diff --git a/frontend/app/components/DocumentCard.vue b/frontend/app/components/DocumentCard.vueindex 1d6a085e..c1708347 100644--- a/frontend/app/components/DocumentCard.vue+++ b/frontend/app/components/DocumentCard.vue@@ -40,7 +40,7 @@ const props = defineProps<{ document: Document }>();const categoriesStore = useCategoriesStore();const category = computed(() => categoriesStore.getById(props.document.category || ''));const user = useUserStore().user;-const deleteDoc = () => useModal().add(new Modal(shallowRef(DeleteDocumentModal), { documentId: props.document.id }));+const deleteDoc = () => useModal().add(new Modal(shallowRef(DeleteDocumentModal), { props: { documentId: props.document.id } }));</script><style scoped lang="scss">diff --git a/frontend/app/components/DocumentLine.vue b/frontend/app/components/DocumentLine.vueindex a8a08aae..369f5af5 100644--- a/frontend/app/components/DocumentLine.vue+++ b/frontend/app/components/DocumentLine.vue@@ -31,7 +31,7 @@ const props = defineProps<{ document: Document }>();const categoriesStore = useCategoriesStore();const category = computed(() => categoriesStore.getById(props.document.category || ''));const user = useUserStore().user;-const deleteDoc = () => useModal().add(new Modal(shallowRef(DeleteDocumentModal), { documentId: props.document.id }));+const deleteDoc = () => useModal().add(new Modal(shallowRef(DeleteDocumentModal), { props: { documentId: props.document.id } }));</script><style scoped lang="scss">diff --git a/frontend/app/components/MarkdownEditor/LazyMarkdownEditor.vue b/frontend/app/components/MarkdownEditor/LazyMarkdownEditor.vueindex bc256a61..7b49a537 100644--- a/frontend/app/components/MarkdownEditor/LazyMarkdownEditor.vue+++ b/frontend/app/components/MarkdownEditor/LazyMarkdownEditor.vue@@ -134,7 +134,7 @@ function insertText(text: string) {}function openColorModal() {const modalManager = useModal();- modalManager.add(new Modal(shallowRef(ColorPickerModal), { onColorSelect: handleColorSelect }, () => {}, false));+ modalManager.add(new Modal(shallowRef(ColorPickerModal), { props: { onColorSelect: handleColorSelect } }));}function handleColorSelect(color: string) {@@ -143,12 +143,12 @@ function handleColorSelect(color: string) {function openImageSelector() {const modalManager = useModal();- modalManager.add(new Modal(shallowRef(ImageSelectorModal), { onImageSelect: handleImageSelect }, () => {}, true));+ modalManager.add(new Modal(shallowRef(ImageSelectorModal), { props: { onImageSelect: handleImageSelect }, size: 'large' }));}function openGridOrganization() {const modalManager = useModal();- modalManager.add(new Modal(shallowRef(GridOrganizationModal), { onGridSelect: handleGridSelect }, () => {}, false));+ modalManager.add(new Modal(shallowRef(GridOrganizationModal), { props: { onGridSelect: handleGridSelect } }));}function handleImageSelect(imageUrl: string, altText: string) {diff --git a/frontend/app/components/MarkdownEditor/Toolbar.vue b/frontend/app/components/MarkdownEditor/Toolbar.vueindex dba710f1..63ac2976 100644--- a/frontend/app/components/MarkdownEditor/Toolbar.vue+++ b/frontend/app/components/MarkdownEditor/Toolbar.vue@@ -38,7 +38,7 @@ const localValue = computed({const emitAction = (action: string) => emit('execute-action', action);-const openModal = () => useModal().add(new Modal(shallowRef(ModalSyntax), {}, () => {}, true));+const openModal = () => useModal().add(new Modal(shallowRef(ModalSyntax), { size: 'large' }));const categories = new TreeStructure(useSidebarTree().categories.value).generateTree().filter(i => i.data.type === 'category' && i.data.role == 2);diff --git a/frontend/app/components/ModalManager.vue b/frontend/app/components/ModalManager.vueindex 100d61f0..ca5773f2 100644--- a/frontend/app/components/ModalManager.vue+++ b/frontend/app/components/ModalManager.vue@@ -6,7 +6,7 @@<button class="close-btn" @click="modalManager.close(modal)"><Icon name="close" :big="true" /></button>- <component :is="modal.component" v-bind="modal.props" class="modal" :class="modal.big ? 'big' : ''" @close="modalManager.close(modal)" />+ <component :is="modal.component" v-bind="modal.options.props" class="modal" :class="modal.options.size" @close="modalManager.close(modal)" /></div></div></TransitionGroup>@@ -47,6 +47,10 @@ const modals = modalManager.modals;max-width: 1115px;}+.modal-container:has(> .small) {+ max-width: 600px;+}+.modal-overlay {position: absolute;z-index: 1;diff --git a/frontend/app/components/Sidebar/Sidebar.vue b/frontend/app/components/Sidebar/Sidebar.vueindex f8f29852..c91240f3 100644--- a/frontend/app/components/Sidebar/Sidebar.vue+++ b/frontend/app/components/Sidebar/Sidebar.vue@@ -73,7 +73,7 @@ const handleClickOutside = (e: MouseEvent) => {};const newCategory = () => {onClick();- useModal().add(new Modal(shallowRef(NewCategoryModal), { role: 1 }));+ useModal().add(new Modal(shallowRef(NewCategoryModal), { props: { role: 1 } }));};const onClick = () => {if (isMobile()) isOpened.value = false;diff --git a/frontend/app/components/Sidebar/SidebarWorkspaces.vue b/frontend/app/components/Sidebar/SidebarWorkspaces.vueindex 10bd6e04..b3d1e045 100644--- a/frontend/app/components/Sidebar/SidebarWorkspaces.vue+++ b/frontend/app/components/Sidebar/SidebarWorkspaces.vue@@ -57,7 +57,7 @@ const handleClickOutside = (event: MouseEvent) => {};onMounted(() => document.addEventListener('click', handleClickOutside));onBeforeUnmount(() => document.removeEventListener('click', handleClickOutside));-const create_workspace = (_: MouseEvent) => useModal().add(new Modal(shallowRef(NewCategoryModal), { role: 2 }));+const create_workspace = (_: MouseEvent) => useModal().add(new Modal(shallowRef(NewCategoryModal), { props: { role: 2 } }));</script><style scoped lang="scss">diff --git a/frontend/app/composables/ModalBus.ts b/frontend/app/composables/ModalBus.tsindex 2a9e446c..ebbdf66d 100644--- a/frontend/app/composables/ModalBus.ts+++ b/frontend/app/composables/ModalBus.ts@@ -9,7 +9,7 @@ function close(modal: Modal) {const index = modals.value.indexOf(modal);if (index !== -1) {modals.value.splice(index, 1);- modal.onClose();+ modal.options.onClose?.();}}@@ -21,6 +21,19 @@ export function useModal() {};}+interface ModalOptions {+ onClose?: () => void;+ size?: 'small' | 'medium' | 'large';+ props?: object;+}+export class Modal {- constructor(public component: object, public props: object = {}, public onClose: () => void = () => {}, public big: boolean = false) {}+ constructor(+ public component: object,+ public options: ModalOptions = {+ onClose: () => {},+ size: 'medium',+ props: {},+ },+ ) {}}diff --git a/frontend/app/pages/dashboard/categories/[id]/edit.vue b/frontend/app/pages/dashboard/categories/[id]/edit.vueindex f83e2b05..ba527012 100644--- a/frontend/app/pages/dashboard/categories/[id]/edit.vue+++ b/frontend/app/pages/dashboard/categories/[id]/edit.vue@@ -5,22 +5,22 @@<div class="form-row"><div class="form-column"><label>ID</label>- <input id="id" v-model="category.id" type="text" disabled >+ <input id="id" v-model="category.id" type="text" disabled /></div><div class="form-column"><label for="order">Order</label>- <input id="order" v-model.number="category.order" type="number" >+ <input id="order" v-model.number="category.order" type="number" /></div></div><label>Name</label>- <input id="name" v-model="category.name" type="text" required >+ <input id="name" v-model="category.name" type="text" required /><label>Role</label><select v-model="category.role"><option :value="1">Category</option><option :value="2">Workspace</option></select><label style="display: flex; align-items: center">Icon <AppHint text="SVG supported" /></label>- <textarea v-model="category.icon" type="text" rows="5"/>+ <textarea v-model="category.icon" type="text" rows="5" /><label>Parent</label><AppSelect v-model="category.parent_id" :items="categoriesItem" placeholder="Select a category parent" />@@ -57,7 +57,7 @@ const updateCategory = async () => {.catch(e => useNotifications().add({ type: 'error', title: 'Error', message: e }));};const deleteCategory = async () => {- useModal().add(new Modal(shallowRef(DeleteModal), { categoryId: category.value?.id || '' }));+ useModal().add(new Modal(shallowRef(DeleteModal), { props: { categoryId: category.value?.id || '' } }));};</script>diff --git a/frontend/app/pages/dashboard/categories/index.vue b/frontend/app/pages/dashboard/categories/index.vueindex 81c908c6..ef9fa34a 100644--- a/frontend/app/pages/dashboard/categories/index.vue+++ b/frontend/app/pages/dashboard/categories/index.vue@@ -9,7 +9,11 @@</div></header><div style="padding-bottom: 10px">- <input v-model="filter" placeholder="Search for workspace..." style="width: 50%; padding: 8px; border: 1px solid var(--border-color); border-radius: 4px" />+ <input+ v-model="filter"+ placeholder="Search for workspace..."+ style="width: 50%; padding: 8px; border: 1px solid var(--border-color); border-radius: 4px"+ /></div><div v-for="workspace in filteredItems" :key="workspace.id" class="workspace"><h3 class="wp-name">@@ -35,15 +39,15 @@ const filteredItems = computed(() => {return filterRecursive<Item<Category>>(tree.value, filter);});-const createWorkspace = () => useModal().add(new Modal(shallowRef(CreateCategoryModal), { role: 2 }));-const createCategory = () => useModal().add(new Modal(shallowRef(CreateCategoryModal), { role: 1 }));+const createWorkspace = () => useModal().add(new Modal(shallowRef(CreateCategoryModal), { props: { role: 2 } }));+const createCategory = () => useModal().add(new Modal(shallowRef(CreateCategoryModal), { props: { role: 1 } }));function editNode(node: Item) {useRouter().push('/dashboard/categories/' + node.id + '/edit');}function deleteNode(node: Item) {- useModal().add(new Modal(shallowRef(DeleteCategoryModal), { categoryId: node.id }));+ useModal().add(new Modal(shallowRef(DeleteCategoryModal), { props: { categoryId: node.id } }));}</script>diff --git a/frontend/app/pages/dashboard/cdn/[id]/index.vue b/frontend/app/pages/dashboard/cdn/[id]/index.vueindex 4a61a983..5cb2bf03 100644--- a/frontend/app/pages/dashboard/cdn/[id]/index.vue+++ b/frontend/app/pages/dashboard/cdn/[id]/index.vue@@ -8,32 +8,39 @@<div class="form-row"><div class="form-column"><label>ID</label>- <input id="id" type="text" :value="ressource.id" disabled >+ <input id="id" type="text" :value="ressource.id" disabled /></div><div class="form-column"><label>Size</label>- <input id="size" type="text" :value="readableFileSize(ressource.filesize)" disabled >+ <input id="size" type="text" :value="readableFileSize(ressource.filesize)" disabled /></div></div><label>Name</label>- <input id="name" v-model="ressource.filename" type="text" required >+ <input id="name" v-model="ressource.filename" type="text" required /><label style="display: flex; align-items: center">Parent <AppHint text="To organize your uploads" /></label><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 id="id" type="text" :value="ressource.filetype" disabled >+ <input id="id" type="text" :value="ressource.filetype" disabled /><label>Original path</label>- <input id="original_path" type="text" :value="ressource.original_path" disabled >+ <input id="original_path" type="text" :value="ressource.original_path" disabled /><label>Path</label>- <input id="path" type="text" :value="ressource.transformed_path" disabled >+ <input id="path" type="text" :value="ressource.transformed_path" disabled /><p style="overflow-wrap: break-word">- Ressource: <a :href="`${CDN}/${ressource.author_id}/${ressource.transformed_path || ressource.original_path}`" target="_blank">{{ `${CDN}/${ressource.author_id}/${ressource.transformed_path || ressource.original_path}` }}</a>+ Ressource:+ <a :href="`${CDN}/${ressource.author_id}/${ressource.transformed_path || ressource.original_path}`" target="_blank">{{+ `${CDN}/${ressource.author_id}/${ressource.transformed_path || ressource.original_path}`+ }}</a></p><div style="display: flex; justify-content: flex-end"><AppButton type="primary" class="btn primary" @click="updateCategory">Update</AppButton></div><h4>Preview</h4><div class="preview">- <img v-if="ressource.filetype.startsWith('image/')" :src="`${CDN}/${ressource.author_id}/${ressource.transformed_path || ressource.original_path}`" alt="Preview" >+ <img+ v-if="ressource.filetype.startsWith('image/')"+ :src="`${CDN}/${ressource.author_id}/${ressource.transformed_path || ressource.original_path}`"+ alt="Preview"+ /><p v-else>Preview not available for this file type.</p></div><h4>Danger</h4>@@ -70,7 +77,7 @@ const updateCategory = async () => {.catch(e => useNotifications().add({ type: 'error', title: 'Error', message: e }));};const showDeleteModal = () => {- useModal().add(new Modal(shallowRef(DeleteRessourceModal), { ressourceId: ressource.value?.id }));+ useModal().add(new Modal(shallowRef(DeleteRessourceModal), { props: { ressourceId: ressource.value?.id } }));};</script>diff --git a/frontend/app/pages/dashboard/cdn/index.vue b/frontend/app/pages/dashboard/cdn/index.vueindex 63cf6110..49b39b20 100644--- a/frontend/app/pages/dashboard/cdn/index.vue+++ b/frontend/app/pages/dashboard/cdn/index.vue@@ -83,7 +83,7 @@ const rows: ComputedRef<Field[]> = computed(() =>);const deleteRessource = async (id: string) => {- useModal().add(new Modal(shallowRef(DeleteRessourceModal), { ressourceId: id }));+ useModal().add(new Modal(shallowRef(DeleteRessourceModal), { props: { ressourceId: id } }));};</script>