Просмотр исходного кода

Show Knowledge Assistant in Sidebar

Shun Miyazawa 1 год назад
Родитель
Сommit
3db8fc04f8

+ 1 - 0
apps/app/public/static/locales/en_US/translation.json

@@ -152,6 +152,7 @@
   "Page Tree": "Page Tree",
   "Bookmarks": "Bookmarks",
   "In-App Notification": "Notifications",
+  "Knowledge Assistant": "Knowledge Assistant",
   "original_path": "Original path",
   "new_path": "New path",
   "duplicated_path": "Duplicated path",

+ 1 - 0
apps/app/public/static/locales/fr_FR/translation.json

@@ -152,6 +152,7 @@
   "Page Tree": "Arbre",
   "Bookmarks": "Favoris",
   "In-App Notification": "Notifications",
+  "Knowledge Assistant": "Assistant de Connaissance",
   "original_path": "Chemin originel",
   "new_path": "Nouveau chemin",
   "duplicated_path": "Chemin dupliqué",

+ 1 - 0
apps/app/public/static/locales/ja_JP/translation.json

@@ -153,6 +153,7 @@
   "Page Tree": "ページツリー",
   "Bookmarks": "ブックマーク",
   "In-App Notification": "通知",
+  "Knowledge Assistant": "ナレッジアシスタント",
   "original_path": "元のパス",
   "new_path": "新しいパス",
   "duplicated_path": "重複したパス",

+ 1 - 0
apps/app/public/static/locales/zh_CN/translation.json

@@ -158,6 +158,7 @@
   "Page Tree": "页面树",
   "Bookmarks": "书签",
   "In-App Notification": "通知",
+  "Knowledge Assistant": "知识助手",
   "original_path": "Original path",
   "new_path": "New path",
   "duplicated_path": "Duplicated path",

+ 3 - 0
apps/app/src/client/components/Sidebar/SidebarContents.tsx

@@ -1,5 +1,6 @@
 import React, { memo, useMemo } from 'react';
 
+import { KnowledgeAssistant } from '~/features/openai/client/components/Sidebar/KnowledgeAssistant';
 import { SidebarContentsType } from '~/interfaces/ui';
 import { useCollapsedContentsOpened, useCurrentSidebarContents, useSidebarMode } from '~/stores/ui';
 
@@ -32,6 +33,8 @@ export const SidebarContents = memo(() => {
         return Bookmarks;
       case SidebarContentsType.NOTIFICATION:
         return InAppNotification;
+      case SidebarContentsType.KNOWNLEDGE_ASSISTANT:
+        return KnowledgeAssistant;
       default:
         return PageTree;
     }

+ 6 - 2
apps/app/src/client/components/Sidebar/SidebarNav/PrimaryItem.tsx

@@ -22,6 +22,7 @@ export type PrimaryItemProps = {
   label: string,
   iconName: string,
   sidebarMode: SidebarMode,
+  isCustomIcon?: boolean,
   badgeContents?: number,
   onHover?: (contents: SidebarContentsType) => void,
   onClick?: () => void,
@@ -29,7 +30,7 @@ export type PrimaryItemProps = {
 
 export const PrimaryItem = (props: PrimaryItemProps): JSX.Element => {
   const {
-    contents, label, iconName, sidebarMode, badgeContents,
+    contents, label, iconName, sidebarMode, badgeContents, isCustomIcon,
     onClick, onHover,
   } = props;
 
@@ -80,7 +81,10 @@ export const PrimaryItem = (props: PrimaryItemProps): JSX.Element => {
           { badgeContents != null && (
             <span className="position-absolute badge rounded-pill bg-primary">{badgeContents}</span>
           )}
-          <span className="material-symbols-outlined">{iconName}</span>
+          { isCustomIcon
+            ? (<span className="growi-custom-icons fs-4 align-middle lh-1">{iconName}</span>)
+            : (<span className="material-symbols-outlined">{iconName}</span>)
+          }
         </div>
       </button>
       {

+ 8 - 0
apps/app/src/client/components/Sidebar/SidebarNav/PrimaryItems.tsx

@@ -35,6 +35,14 @@ export const PrimaryItems = memo((props: Props) => {
       <PrimaryItem sidebarMode={sidebarMode} contents={SidebarContentsType.BOOKMARKS} label="Bookmarks" iconName="bookmarks" onHover={onItemHover} />
       <PrimaryItem sidebarMode={sidebarMode} contents={SidebarContentsType.TAG} label="Tags" iconName="local_offer" onHover={onItemHover} />
       <PrimaryItemForNotification sidebarMode={sidebarMode} onHover={onItemHover} />
+      <PrimaryItem
+        sidebarMode={sidebarMode}
+        contents={SidebarContentsType.KNOWNLEDGE_ASSISTANT}
+        label="Knowledge Assistant"
+        iconName="knowledge_assistant"
+        isCustomIcon
+        onHover={onItemHover}
+      />
     </div>
   );
 });

+ 20 - 0
apps/app/src/features/openai/client/components/Sidebar/KnowledgeAssistant.tsx

@@ -0,0 +1,20 @@
+import React, { Suspense, useState } from 'react';
+
+import dynamic from 'next/dynamic';
+import { useTranslation } from 'react-i18next';
+
+import ItemsTreeContentSkeleton from '~/client/components/ItemsTree/ItemsTreeContentSkeleton';
+
+export const KnowledgeAssistant = (): JSX.Element => {
+  const { t } = useTranslation();
+
+  return (
+    <div className="px-3">
+      <div className="grw-sidebar-content-header py-4 d-flex">
+        <h3 className="fs-6 fw-bold mb-0">
+          {t('Knowledge Assistant')}
+        </h3>
+      </div>
+    </div>
+  );
+};

+ 1 - 0
apps/app/src/interfaces/ui.ts

@@ -15,6 +15,7 @@ export const SidebarContentsType = {
   TAG: 'tag',
   BOOKMARKS: 'bookmarks',
   NOTIFICATION: 'notification',
+  KNOWNLEDGE_ASSISTANT: 'knowledgeAssistant',
 } as const;
 export const AllSidebarContentsType = Object.values(SidebarContentsType);
 export type SidebarContentsType = typeof SidebarContentsType[keyof typeof SidebarContentsType];