Bladeren bron

Add owner share scope label to translations and update AiAssistantManagementHome component

Shun Miyazawa 1 jaar geleden
bovenliggende
commit
8609f2da2f

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

@@ -515,6 +515,9 @@
       "publicOnly": "Public pages only"
     },
     "share_scope": {
+      "owner": {
+        "label": "{{username}} only"
+      },
       "publicOnly": {
         "label": "Public",
         "desc": "Shared with all users"

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

@@ -510,6 +510,7 @@
       "publicOnly": "Pages publiques uniquement"
     },
     "share_scope": {
+      "owner": "Seulement {{username}}",
       "publicOnly": {
         "label": "Public",
         "desc": "Partagé avec tous les utilisateurs"

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

@@ -548,6 +548,9 @@
       "publicOnly": "公開ページのみ"
     },
     "share_scope": {
+      "owner": {
+        "label": "{{username}} のみ"
+      },
       "publicOnly": {
         "label": "全体公開",
         "desc": "すべてのユーザーに共有されます"

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

@@ -504,6 +504,9 @@
       "publicOnly": "仅公开页面"
     },
     "share_scope": {
+      "owner": {
+        "label": "仅 {{ username }}"
+      },
       "publicOnly": {
         "label": "公开",
         "desc": "与所有用户共享"

+ 15 - 4
apps/app/src/features/openai/client/components/AiAssistant/AiAssistantManagementModal/AiAssistantManagementHome.tsx

@@ -1,23 +1,34 @@
-import React from 'react';
+import React, { useCallback } from 'react';
 
 import { useTranslation } from 'react-i18next';
 import {
   ModalHeader, ModalBody, ModalFooter, Input,
 } from 'reactstrap';
 
+import { AiAssistantShareScope } from '~/features/openai/interfaces/ai-assistant';
+import { useCurrentUser } from '~/stores-universal/context';
+
 import { useAiAssistantManagementModal, AiAssistantManagementModalPageMode } from '../../../stores/ai-assistant';
 
 type Props = {
   instruction: string;
+  shareScope: AiAssistantShareScope
 }
 
 export const AiAssistantManagementHome = (props: Props): JSX.Element => {
-  const { instruction } = props;
+  const { instruction, shareScope } = props;
 
   const { t } = useTranslation();
-
+  const { data: currentUser } = useCurrentUser();
   const { close: closeAiAssistantManagementModal, changePageMode } = useAiAssistantManagementModal();
 
+  const getShareScopeLabel = useCallback((shareScope: AiAssistantShareScope) => {
+    const baseLabel = `modal_ai_assistant.share_scope.${shareScope}.label`;
+    return shareScope === AiAssistantShareScope.OWNER
+      ? t(baseLabel, { username: currentUser?.username })
+      : t(baseLabel);
+  }, [currentUser?.username, t]);
+
   return (
     <>
       <ModalHeader tag="h4" toggle={closeAiAssistantManagementModal} className="pe-4">
@@ -59,7 +70,7 @@ export const AiAssistantManagementHome = (props: Props): JSX.Element => {
             >
               <span className="fw-normal">{t('modal_ai_assistant.page_mode_title.share')}</span>
               <div className="d-flex align-items-center text-secondary">
-                <span>UserNameのみ</span>
+                <span>{getShareScopeLabel(shareScope)}</span>
                 <span className="material-symbols-outlined ms-2 align-middle">chevron_right</span>
               </div>
             </button>

+ 1 - 0
apps/app/src/features/openai/client/components/AiAssistant/AiAssistantManagementModal/AiAssistantManagementModal.tsx

@@ -126,6 +126,7 @@ const AiAssistantManagementModalSubstance = (): JSX.Element => {
       <TabContent activeTab={pageMode}>
         <TabPane tabId={AiAssistantManagementModalPageMode.HOME}>
           <AiAssistantManagementHome
+            shareScope={selectedShareScope}
             instruction={instruction}
           />
         </TabPane>