From ed74c5404db221b6781f93122c0565ca6c5c3fa6 Mon Sep 17 00:00:00 2001 From: LordMathis Date: Fri, 4 Oct 2024 21:44:15 +0200 Subject: [PATCH] Add no file selected text --- frontend/src/components/ContentView.js | 35 +++++++++--- frontend/src/components/MainContent.js | 76 +++----------------------- 2 files changed, 35 insertions(+), 76 deletions(-) diff --git a/frontend/src/components/ContentView.js b/frontend/src/components/ContentView.js index 952869d..4a5bc28 100644 --- a/frontend/src/components/ContentView.js +++ b/frontend/src/components/ContentView.js @@ -1,18 +1,35 @@ import React from 'react'; import Editor from './Editor'; import MarkdownPreview from './MarkdownPreview'; -import { getFileUrl } from '../services/api'; +import { Text } from '@geist-ui/core'; +import { getFileUrl, lookupFileByName } from '../services/api'; import { isImageFile } from '../utils/fileHelpers'; import { useFileContentContext } from '../contexts/FileContentContext'; +import { useUIStateContext } from '../contexts/UIStateContext'; +import { useSettings } from '../contexts/SettingsContext'; +import { useFileNavigation } from '../hooks/useFileNavigation'; -const ContentView = ({ - activeTab, - themeType, - onLinkClick, - lookupFileByName, -}) => { +const ContentView = () => { const { content, selectedFile, handleContentChange, handleSave } = useFileContentContext(); + const { activeTab } = useUIStateContext(); + const { settings } = useSettings(); + const { handleLinkClick } = useFileNavigation(); + + if (!selectedFile) { + return ( +
+ No file selected. +
+ ); + } if (isImageFile(selectedFile)) { return ( @@ -36,13 +53,13 @@ const ContentView = ({ onChange={handleContentChange} onSave={handleSave} filePath={selectedFile} - themeType={themeType} + themeType={settings.theme} /> ) : ( ); diff --git a/frontend/src/components/MainContent.js b/frontend/src/components/MainContent.js index e13adb5..4f51212 100644 --- a/frontend/src/components/MainContent.js +++ b/frontend/src/components/MainContent.js @@ -1,13 +1,5 @@ -// components/MainContent.js import React from 'react'; -import { - Grid, - Breadcrumbs, - Tabs, - Dot, - useTheme, - useToasts, -} from '@geist-ui/core'; +import { Grid, Breadcrumbs, Tabs, Dot } from '@geist-ui/core'; import { Code, Eye } from '@geist-ui/icons'; import FileTree from './FileTree'; import FileActions from './FileActions'; @@ -15,60 +7,19 @@ import ContentView from './ContentView'; import CreateFileModal from './modals/CreateFileModal'; import DeleteFileModal from './modals/DeleteFileModal'; import CommitMessageModal from './modals/CommitMessageModal'; -import { useFileListContext } from '../contexts/FileListContext'; import { useFileContentContext } from '../contexts/FileContentContext'; -import { useGitOperationsContext } from '../contexts/GitOperationsContext'; import { useUIStateContext } from '../contexts/UIStateContext'; -import { useFileNavigation } from '../hooks/useFileNavigation'; const MainContent = () => { - const { files } = useFileListContext(); const { selectedFile, hasUnsavedChanges } = useFileContentContext(); - const { pullLatestChanges } = useGitOperationsContext(); - const { - activeTab, - setActiveTab, - newFileModalVisible, - setNewFileModalVisible, - deleteFileModalVisible, - setDeleteFileModalVisible, - commitMessageModalVisible, - setCommitMessageModalVisible, - } = useUIStateContext(); - const { handleLinkClick } = useFileNavigation(); - const { type: themeType } = useTheme(); - const { setToast } = useToasts(); + const { activeTab, setActiveTab } = useUIStateContext(); const handleTabChange = (value) => { setActiveTab(value); }; - const handlePull = async () => { - try { - await pullLatestChanges(); - setToast({ text: 'Successfully pulled latest changes', type: 'success' }); - } catch (error) { - setToast({ - text: 'Failed to pull changes: ' + error.message, - type: 'error', - }); - } - }; - - const handleCreateFile = () => { - setNewFileModalVisible(true); - }; - - const handleDeleteFile = () => { - setDeleteFileModalVisible(true); - }; - - const handleCommitAndPush = () => { - setCommitMessageModalVisible(true); - }; - const renderBreadcrumbs = () => { - if (!selectedFile) return null; + if (!selectedFile) return
; const pathParts = selectedFile.split('/'); return (
@@ -89,13 +40,8 @@ const MainContent = () => {
- - + +
{
- +
- - - + + + ); };