1- import { Layout , Model , IJsonModel , TabNode , Action , Actions } from 'flexlayout-react' ;
1+ import { Layout , Model , IJsonModel , TabNode , Action , Actions , ITabRenderValues } from 'flexlayout-react' ;
22import React , { useEffect } from 'react' ;
33import BlocklyEditor from '@components/blockly' ;
44import MonacoEditor from '@components/MonacoEditor' ;
55import XRPShell from '@components/xrpshell' ;
66import FolderIcon from '@assets/images/folder-24.png' ;
7- import i18n from '@/utils/i18n ' ;
7+ import ShellIcon from '@assets/images/shell.svg ' ;
88//import treeDaaJson from '@/utils/testdata';
99import AppMgr , { EventType , Themes } from '@/managers/appmgr' ;
1010import FolderTree from './folder-tree' ;
@@ -16,6 +16,7 @@ import EditorMgr, { EditorStore } from '@/managers/editormgr';
1616import { CreateEditorTab } from '@/utils/editorUtils' ;
1717import XRPDashboard from '@/components/dashboard/xrp-dashboard' ;
1818import AIChat from '@/components/chat/ai-chat' ;
19+ import { useTranslation } from 'react-i18next' ;
1920
2021/**
2122 * Layout-React's layout JSON to specify the XRPWeb's single page application's layout
@@ -40,7 +41,7 @@ const layout_json: IJsonModel = {
4041 {
4142 type : 'tab' ,
4243 id : Constants . FOLDER_TAB_ID ,
43- name : i18n . t ( 'folders' ) ,
44+ name : 'folders' ,
4445 component : 'folders' ,
4546 enableClose : false ,
4647 icon : FolderIcon ,
@@ -74,8 +75,8 @@ const layout_json: IJsonModel = {
7475 children : [
7576 {
7677 type : 'tab' ,
77- id : 'shellId' ,
78- name : i18n . t ( 'shell' ) ,
78+ id : Constants . SHELL_TAB_ID ,
79+ name : 'shell' ,
7980 component : 'xterm' ,
8081 enableClose : false ,
8182 } ,
@@ -139,6 +140,7 @@ function useOnceCall(cb: () => void, condition = true) {
139140 */
140141function XRPLayout ( { forwardedref } : XRPLayoutProps ) {
141142 const [ activeTab , setActiveTab ] = useLocalStorage ( StorageKeys . ACTIVETAB , '' ) ;
143+ const { t } = useTranslation ( ) ;
142144
143145 /**
144146 * changeTheme - set the system selected theme
@@ -268,7 +270,24 @@ function XRPLayout({ forwardedref }: XRPLayoutProps) {
268270 return action ;
269271 }
270272
271- return < Layout ref = { forwardedref } model = { model } factory = { factory } onAction = { handleActions } /> ;
273+ /**
274+ * onRenderTab - render the tab with custom functionality
275+ * @param node
276+ * @param renderValues
277+ * @returns
278+ */
279+ const onRenderTab = ( node : TabNode , renderValues : ITabRenderValues ) => {
280+ // Override the content to use the translated tab names
281+ if ( node . getId ( ) === Constants . FOLDER_TAB_ID ) {
282+ renderValues . leading = < img src = { FolderIcon } alt = "icon" style = { { width : '16px' , height : '16px' , marginRight : '16px' } } /> ;
283+ } else if ( node . getId ( ) === Constants . SHELL_TAB_ID ) {
284+ renderValues . leading = < img src = { ShellIcon } alt = "icon" style = { { width : '16px' , height : '16px' , marginRight : '0px' } } /> ;
285+ }
286+ renderValues . content = t ( node . getName ( ) ) ;
287+ return renderValues ;
288+ } ;
289+
290+ return < Layout ref = { forwardedref } model = { model } factory = { factory } onAction = { handleActions } onRenderTab = { onRenderTab } /> ;
272291}
273292
274293export default XRPLayout ;
0 commit comments