-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Saved status #812
base: main
Are you sure you want to change the base?
Saved status #812
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,7 @@ | ||
import { | ||
import React, { | ||
useCallback, | ||
useContext, | ||
useMemo, | ||
useState, | ||
} from 'react'; | ||
useMemo } from 'react'; | ||
import { | ||
FileId, | ||
FileTree, | ||
|
@@ -29,28 +27,17 @@ import { Listing } from './Listing'; | |
import { useDragAndDrop } from './useDragAndDrop'; | ||
import './styles.scss'; | ||
|
||
// TODO turn this UI back on when we are actually detecting | ||
// the connection status. | ||
// See https://github.com/vizhub-core/vzcode/issues/456 | ||
const enableConnectionStatus = true; | ||
|
||
export const VZSidebar = ({ | ||
createFileTooltipText = 'New File', | ||
createDirTooltipText = 'New Directory', | ||
openSettingsTooltipText = 'Open Settings', | ||
openKeyboardShortcuts = 'Keyboard Shortcuts', | ||
reportBugTooltipText = 'Report Bug', | ||
searchToolTipText = 'Search', | ||
filesToolTipText = 'Files', | ||
}: { | ||
createFileTooltipText?: string; | ||
createDirTooltipText?: string; | ||
openSettingsTooltipText?: string; | ||
reportBugTooltipText?: string; | ||
openKeyboardShortcuts?: string; | ||
searchToolTipText?: string; | ||
filesToolTipText?: string; | ||
}) => { | ||
createFileTooltipText = 'New File', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please run |
||
createDirTooltipText = 'New Directory', | ||
openSettingsTooltipText = 'Open Settings', | ||
openKeyboardShortcuts = 'Keyboard Shortcuts', | ||
reportBugTooltipText = 'Report Bug', | ||
searchToolTipText = 'Search', | ||
filesToolTipText = 'Files', | ||
}) => { | ||
const { | ||
files, | ||
openTab, | ||
|
@@ -64,15 +51,18 @@ export const VZSidebar = ({ | |
sidebarRef, | ||
enableAutoFollow, | ||
toggleAutoFollow, | ||
savingStatus, | ||
} = useContext(VZCodeContext); | ||
|
||
const fileTree = useMemo( | ||
() => (files ? sortFileTree(getFileTree(files)) : null), | ||
[files], | ||
); | ||
|
||
const handleQuestionMarkClick = useCallback(() => { | ||
setIsDocOpen(true); | ||
}, []); | ||
|
||
const handleSettingsClick = useCallback(() => { | ||
setIsSettingsOpen(true); | ||
}, []); | ||
|
@@ -81,23 +71,20 @@ export const VZSidebar = ({ | |
SplitPaneResizeContext, | ||
); | ||
|
||
// On single-click, open the file in a transient tab. | ||
const handleFileClick = useCallback( | ||
(fileId: FileId) => { | ||
openTab({ fileId, isTransient: true }); | ||
}, | ||
[openTab], | ||
); | ||
|
||
// On double-click, open the file in a persistent tab. | ||
const handleFileDoubleClick = useCallback( | ||
(fileId: FileId) => { | ||
openTab({ fileId, isTransient: false }); | ||
}, | ||
[openTab], | ||
); | ||
|
||
// True if files exist. | ||
const filesExist = | ||
fileTree && | ||
fileTree.children && | ||
|
@@ -225,7 +212,6 @@ export const VZSidebar = ({ | |
</i> | ||
</OverlayTrigger> | ||
|
||
{/*Directory Rename*/} | ||
<OverlayTrigger | ||
placement="right" | ||
overlay={ | ||
|
@@ -242,7 +228,6 @@ export const VZSidebar = ({ | |
</i> | ||
</OverlayTrigger> | ||
|
||
{/*Toggle Follow*/} | ||
<OverlayTrigger | ||
placement="right" | ||
overlay={ | ||
|
@@ -310,14 +295,19 @@ export const VZSidebar = ({ | |
</div> | ||
|
||
{enableConnectionStatus && ( | ||
<div className="connection-status"> | ||
{connected ? 'Connected' : 'Connection Lost'} | ||
<div className="connection"> | ||
<div | ||
className={`connection-status-indicator ${ | ||
connected ? 'connected' : 'disconnected' | ||
}`} | ||
/> | ||
<div className="status-bar"> | ||
<div className="connection-status"> | ||
{connected ? 'Connected' : 'Connection Lost'} | ||
<div className="connection"> | ||
<div | ||
className={`connection-status-indicator ${ | ||
connected ? 'connected' : 'disconnected' | ||
}`} | ||
/> | ||
</div> | ||
</div> | ||
<div className="saving-status"> | ||
{savingStatus} | ||
</div> | ||
</div> | ||
)} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// DRAFT: DO NOT USE | ||
// Some file handling component | ||
// import { useContext } from 'react'; | ||
// import { VZCodeContext } from '../VZCodeContext'; | ||
// | ||
// const FileEditor = () => { | ||
// const { saveChanges } = useContext(VZCodeContext); | ||
// | ||
// const handleFileChange = (newContent) => { | ||
// // Handle file content change logic... | ||
// saveChanges(); // Trigger saving process | ||
// }; | ||
// | ||
// return ( | ||
// <div className="file-editor"> | ||
// <textarea | ||
// value={useContext} | ||
// onChange={saveChanges} | ||
// className="file-editor-textarea" | ||
// /> | ||
// </div> | ||
// ); | ||
// }; | ||
// | ||
// export default FileEditor; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
where
useSavingStatus
is pretty much the same asusePending
from the old example.