From 33647a906e718d41d511377780ce6316e8874f65 Mon Sep 17 00:00:00 2001 From: Edwin Date: Wed, 12 Jul 2023 16:01:07 +0800 Subject: [PATCH] Add file empty tips for the file editor component --- .../gpt-runner-web/client/public/locales/de.json | 3 ++- .../gpt-runner-web/client/public/locales/en.json | 3 ++- .../gpt-runner-web/client/public/locales/ja.json | 3 ++- .../client/public/locales/zh_CN.json | 3 ++- .../client/public/locales/zh_Hant.json | 3 ++- .../components/file-editor/file-editor.styles.ts | 14 ++++++++++++++ .../pages/chat/components/file-editor/index.tsx | 12 +++++++----- 7 files changed, 31 insertions(+), 10 deletions(-) diff --git a/packages/gpt-runner-web/client/public/locales/de.json b/packages/gpt-runner-web/client/public/locales/de.json index c94dfd2..1139ba6 100644 --- a/packages/gpt-runner-web/client/public/locales/de.json +++ b/packages/gpt-runner-web/client/public/locales/de.json @@ -7,6 +7,7 @@ "tab_settings": "Einstellungen", "tab_about": "Über", "tab_file_editor": "Editor", + "file_empty_tips": "Bitte wählen Sie eine Datei zum Bearbeiten aus", "continue_inputting_prompt": "Bitte weitermachen", "copy_btn": "Kopieren", "insert_btn": "Einfügen", @@ -97,4 +98,4 @@ "file_editor_forgot_save_tips_title": "Möchten Sie die Änderungen an {{fileName}} speichern?", "file_editor_forgot_save_tips_content": "Ihre Änderungen gehen verloren, wenn Sie sie nicht speichern." } -} \ No newline at end of file +} diff --git a/packages/gpt-runner-web/client/public/locales/en.json b/packages/gpt-runner-web/client/public/locales/en.json index c7cd5ff..34b5007 100644 --- a/packages/gpt-runner-web/client/public/locales/en.json +++ b/packages/gpt-runner-web/client/public/locales/en.json @@ -7,6 +7,7 @@ "tab_settings": "Settings", "tab_about": "About", "tab_file_editor": "Editor", + "file_empty_tips": "Please select a file to edit", "continue_inputting_prompt": "Please continue", "copy_btn": "Copy", "insert_btn": "Insert", @@ -97,4 +98,4 @@ "file_editor_forgot_save_tips_title": "Do you want to save changes to {{fileName}}?", "file_editor_forgot_save_tips_content": "Your changes will be lost if you don't save them." } -} \ No newline at end of file +} diff --git a/packages/gpt-runner-web/client/public/locales/ja.json b/packages/gpt-runner-web/client/public/locales/ja.json index d533ecd..7738c90 100644 --- a/packages/gpt-runner-web/client/public/locales/ja.json +++ b/packages/gpt-runner-web/client/public/locales/ja.json @@ -7,6 +7,7 @@ "tab_settings": "設定", "tab_about": "情報", "tab_file_editor": "エディター", + "file_empty_tips": "編集するファイルを選択してください", "continue_inputting_prompt": "続けてください", "copy_btn": "コピー", "insert_btn": "挿入", @@ -97,4 +98,4 @@ "file_editor_forgot_save_tips_title": "変更を{{fileName}}に保存しますか?", "file_editor_forgot_save_tips_content": "保存しない場合、変更は失われます。" } -} \ No newline at end of file +} diff --git a/packages/gpt-runner-web/client/public/locales/zh_CN.json b/packages/gpt-runner-web/client/public/locales/zh_CN.json index c51cd4e..db00a32 100644 --- a/packages/gpt-runner-web/client/public/locales/zh_CN.json +++ b/packages/gpt-runner-web/client/public/locales/zh_CN.json @@ -7,6 +7,7 @@ "tab_settings": "设置", "tab_about": "关于", "tab_file_editor": "编辑器", + "file_empty_tips": "请选择要编辑的文件", "continue_inputting_prompt": "请继续", "copy_btn": "复制", "insert_btn": "插入", @@ -97,4 +98,4 @@ "file_editor_forgot_save_tips_title": "你想要保存对{{fileName}}的更改吗?", "file_editor_forgot_save_tips_content": "如果你不保存,你的改动将会丢失." } -} \ No newline at end of file +} diff --git a/packages/gpt-runner-web/client/public/locales/zh_Hant.json b/packages/gpt-runner-web/client/public/locales/zh_Hant.json index 9972b77..9df82a8 100644 --- a/packages/gpt-runner-web/client/public/locales/zh_Hant.json +++ b/packages/gpt-runner-web/client/public/locales/zh_Hant.json @@ -7,6 +7,7 @@ "tab_settings": "設定", "tab_about": "關於", "tab_file_editor": "編輯器", + "file_empty_tips": "請選擇要編輯的檔案", "continue_inputting_prompt": "請繼續", "copy_btn": "複製", "insert_btn": "插入", @@ -97,4 +98,4 @@ "file_editor_forgot_save_tips_title": "你想要保存對{{fileName}}的更改嗎?", "file_editor_forgot_save_tips_content": "如果你不保存,你的改動將會丟失." } -} \ No newline at end of file +} diff --git a/packages/gpt-runner-web/client/src/pages/chat/components/file-editor/file-editor.styles.ts b/packages/gpt-runner-web/client/src/pages/chat/components/file-editor/file-editor.styles.ts index dc3d013..f8b6d75 100644 --- a/packages/gpt-runner-web/client/src/pages/chat/components/file-editor/file-editor.styles.ts +++ b/packages/gpt-runner-web/client/src/pages/chat/components/file-editor/file-editor.styles.ts @@ -6,3 +6,17 @@ export const FileEditorWrapper = styled.div` height: 100%; overflow: hidden; ` + +export const EmptyEditorWrapper = styled.div` + width: 100%; + height: 100%; + display: flex; + align-items: center; + justify-content: center; + font-size: 1.5rem; + font-weight: bold; + background-color: var(--panel-view-background); + color: var(--foreground); + user-select: text; + text-align: center; +` diff --git a/packages/gpt-runner-web/client/src/pages/chat/components/file-editor/index.tsx b/packages/gpt-runner-web/client/src/pages/chat/components/file-editor/index.tsx index cfd6289..ee5df4a 100644 --- a/packages/gpt-runner-web/client/src/pages/chat/components/file-editor/index.tsx +++ b/packages/gpt-runner-web/client/src/pages/chat/components/file-editor/index.tsx @@ -10,7 +10,7 @@ import { PanelTab } from '../../../../components/panel-tab' import type { FileEditorItem } from '../../../../store/zustand/file-editor/file-editor-item' import { useElementSizeRealTime } from '../../../../hooks/use-element-size-real-time.hook' import { saveFileContent } from '../../../../networks/editor' -import { FileEditorWrapper } from './file-editor.styles' +import { EmptyEditorWrapper, FileEditorWrapper } from './file-editor.styles' import { FileEditorTabLabel } from './components/file-editor-tab-label' import { FileContentEditor } from './components/file-content-editor' @@ -38,6 +38,7 @@ export const FileEditor: FC = memo((props) => { updateFileEditorItem, removeFileEditorItem, } = useFileEditorStore() + console.log('fileEditorItems', fileEditorItems) const [isLoading, setIsLoading] = useState(false) const { mutate: saveFileToRemote, isLoading: saveFileLoading } = useMutation({ mutationFn: (params: SaveFileContentReqParams) => saveFileContent(params), @@ -75,7 +76,7 @@ export const FileEditor: FC = memo((props) => { fileName, dirPath, } - + // If user open the same name file, we need to show parent path if (fileName) { const count = fileNameMap.get(fileName) || 0 fileNameMap.set(fileName, count + 1) @@ -149,8 +150,8 @@ export const FileEditor: FC = memo((props) => { return {isLoading && } - - { @@ -167,7 +168,8 @@ export const FileEditor: FC = memo((props) => { tabItemStyles={{ padding: 0, }} - /> + />) + : {t('chat_page.file_empty_tips')}} })