Timothy Jaeryang Baek 2 周之前
父节点
当前提交
612a52d7bb
共有 1 个文件被更改,包括 19 次插入10 次删除
  1. 19 10
      src/lib/components/layout/SearchModal.svelte

+ 19 - 10
src/lib/components/layout/SearchModal.svelte

@@ -12,7 +12,7 @@
 	import calendar from 'dayjs/plugin/calendar';
 	import Loader from '../common/Loader.svelte';
 	import { createMessagesList } from '$lib/utils';
-	import { user } from '$lib/stores';
+	import { config, user } from '$lib/stores';
 	import Messages from '../chat/Messages.svelte';
 	import { goto } from '$app/navigation';
 	import PencilSquare from '../icons/PencilSquare.svelte';
@@ -31,15 +31,6 @@
 				onClose();
 			},
 			icon: PencilSquare
-		},
-		{
-			label: 'Create a new note',
-			onClick: async () => {
-				await goto('/notes');
-				show = false;
-				onClose();
-			},
-			icon: Note
 		}
 	];
 
@@ -234,6 +225,24 @@
 	};
 
 	onMount(() => {
+		actions = [
+			...actions,
+			...(($config?.features?.enable_notes ?? false) &&
+			($user?.role === 'admin' || ($user?.permissions?.features?.notes ?? true))
+				? [
+						{
+							label: 'Create a new note',
+							onClick: async () => {
+								await goto('/notes');
+								show = false;
+								onClose();
+							},
+							icon: Note
+						}
+					]
+				: [])
+		];
+
 		document.addEventListener('keydown', onKeyDown);
 	});