From f43f09ab006a50ca29b3e3d19567d8538390708f Mon Sep 17 00:00:00 2001 From: Joseph Izang Date: Thu, 11 Jan 2024 13:50:57 +0100 Subject: [PATCH 01/15] add icon hover component --- .../components/file-explorer-hovericons.tsx | 100 ++++++++++++++++++ 1 file changed, 100 insertions(+) create mode 100644 libs/remix-ui/workspace/src/lib/components/file-explorer-hovericons.tsx diff --git a/libs/remix-ui/workspace/src/lib/components/file-explorer-hovericons.tsx b/libs/remix-ui/workspace/src/lib/components/file-explorer-hovericons.tsx new file mode 100644 index 0000000000..61485287b4 --- /dev/null +++ b/libs/remix-ui/workspace/src/lib/components/file-explorer-hovericons.tsx @@ -0,0 +1,100 @@ +import React, { useState } from 'react' +import { CustomTooltip } from '@remix-ui/helper' +import { FormattedMessage } from 'react-intl' +import { ROOT_PATH } from '../utils/constants' + +export type FileHoverIconsProps = { + hover: boolean + isEditable: boolean + file: any + handleNewFolderOp: any + handleNewFileOp: any + renamePathOp: any + deletePathOp: any +} + +export function FileHoverIcons(props: FileHoverIconsProps) { + + return ( + <> + {(props.hover && !props.isEditable) &&
+ { + props.file.isDirectory ? ( + <> + } + tooltipId={`filePanel.edit.${props.file.path}`} + tooltipClasses="text-nowrap" + > + { + e.stopPropagation() + console.log(props) + await props.handleNewFolderOp(props.file.path) + console.log('clicked on folder icon') + }} + > + + } + tooltipId={`fileExplorer.edit.${props.file.path}`} + tooltipClasses="text-nowrap" + > + { + e.stopPropagation() + await props.handleNewFileOp(props.file.path) + console.log('clicked on file icon') + }} + > + + + ) : null + } + } + tooltipId={`fileExplorer.edit.${props.file.path}`} + tooltipClasses="text-nowrap" + > + { + e.stopPropagation() + console.log(props) + console.log(e) + await props.renamePathOp(props.file.path, props.file.type) + console.log('clicked on edit icon') + }} + > + + } + tooltipId={`fileExplorer.edit.${props.file.path}`} + tooltipClasses="text-nowrap" + > + { + e.stopPropagation() + console.log(props) + console.log(e) + console.log('clicked on trash icon') + await props.deletePathOp(props.file.path) + }} + > + +
+ } + + ) +} From 2c28bbff48b7b87bb5f2972be678977bca802b70 Mon Sep 17 00:00:00 2001 From: Joseph Izang Date: Wed, 31 Jan 2024 13:26:12 +0100 Subject: [PATCH 02/15] add hovericons component --- .../src/lib/components/file-explorer-hovericons.tsx | 12 ++++++------ .../workspace/src/lib/components/flat-tree.tsx | 5 ++++- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/libs/remix-ui/workspace/src/lib/components/file-explorer-hovericons.tsx b/libs/remix-ui/workspace/src/lib/components/file-explorer-hovericons.tsx index 61485287b4..49b4584ca1 100644 --- a/libs/remix-ui/workspace/src/lib/components/file-explorer-hovericons.tsx +++ b/libs/remix-ui/workspace/src/lib/components/file-explorer-hovericons.tsx @@ -4,13 +4,13 @@ import { FormattedMessage } from 'react-intl' import { ROOT_PATH } from '../utils/constants' export type FileHoverIconsProps = { - hover: boolean - isEditable: boolean + hover?: boolean + isEditable?: boolean file: any - handleNewFolderOp: any - handleNewFileOp: any - renamePathOp: any - deletePathOp: any + handleNewFolderOp?: any + handleNewFileOp?: any + renamePathOp?: any + deletePathOp?: any } export function FileHoverIcons(props: FileHoverIconsProps) { diff --git a/libs/remix-ui/workspace/src/lib/components/flat-tree.tsx b/libs/remix-ui/workspace/src/lib/components/flat-tree.tsx index f86cd2873c..a96f514a86 100644 --- a/libs/remix-ui/workspace/src/lib/components/flat-tree.tsx +++ b/libs/remix-ui/workspace/src/lib/components/flat-tree.tsx @@ -7,6 +7,7 @@ import { FlatTreeItemInput } from './flat-tree-item-input'; import { FlatTreeDrop } from './flat-tree-drop'; import { getEventTarget } from '../utils/getEventTarget'; import { fileDecoration, FileDecorationIcons } from '@remix-ui/file-decorators'; +import { FileHoverIcons } from './file-explorer-hovericons'; export default function useOnScreen(ref: RefObject) { @@ -209,7 +210,9 @@ export const FlatTree = (props: FlatTreeProps) => { {file.name} - {getFileStateIcons(file)} +
+
{getFileStateIcons(file)} +
} From d0598e2d73a1da6548f1dfcec7470c8b44b6f60a Mon Sep 17 00:00:00 2001 From: Joseph Izang Date: Thu, 1 Feb 2024 12:39:58 +0100 Subject: [PATCH 03/15] add props, make icons visible. --- .../components/file-explorer-hovericons.tsx | 100 +++++++++--------- .../src/lib/components/file-explorer.tsx | 7 +- .../src/lib/components/flat-tree-drop.tsx | 6 +- .../src/lib/components/flat-tree.tsx | 11 +- .../workspace/src/lib/remix-ui-workspace.tsx | 15 +-- .../remix-ui/workspace/src/lib/types/index.ts | 1 + 6 files changed, 76 insertions(+), 64 deletions(-) diff --git a/libs/remix-ui/workspace/src/lib/components/file-explorer-hovericons.tsx b/libs/remix-ui/workspace/src/lib/components/file-explorer-hovericons.tsx index 49b4584ca1..70d3c47e78 100644 --- a/libs/remix-ui/workspace/src/lib/components/file-explorer-hovericons.tsx +++ b/libs/remix-ui/workspace/src/lib/components/file-explorer-hovericons.tsx @@ -17,82 +17,82 @@ export function FileHoverIcons(props: FileHoverIconsProps) { return ( <> - {(props.hover && !props.isEditable) &&
+ {(!props.hover && !props.isEditable) &&
{ props.file.isDirectory ? ( <> - } tooltipId={`filePanel.edit.${props.file.path}`} tooltipClasses="text-nowrap" - > - { - e.stopPropagation() - console.log(props) - await props.handleNewFolderOp(props.file.path) - console.log('clicked on folder icon') - }} - > - - */} + { + e.stopPropagation() + console.log(props) + await props.handleNewFolderOp(props.file.path) + console.log('clicked on folder icon') + }} + > + {/* */} + {/* } tooltipId={`fileExplorer.edit.${props.file.path}`} tooltipClasses="text-nowrap" - > - { - e.stopPropagation() - await props.handleNewFileOp(props.file.path) - console.log('clicked on file icon') - }} - > - + > */} + { + e.stopPropagation() + await props.handleNewFileOp(props.file.path) + console.log('clicked on file icon') + }} + > + {/* */} ) : null } - } tooltipId={`fileExplorer.edit.${props.file.path}`} tooltipClasses="text-nowrap" - > - { - e.stopPropagation() - console.log(props) - console.log(e) - await props.renamePathOp(props.file.path, props.file.type) - console.log('clicked on edit icon') - }} - > - - */} + { + e.stopPropagation() + console.log(props) + console.log(e) + await props.renamePathOp(props.file.path, props.file.type) + console.log('clicked on edit icon') + }} + > + {/* */} + {/* } tooltipId={`fileExplorer.edit.${props.file.path}`} tooltipClasses="text-nowrap" - > - { - e.stopPropagation() - console.log(props) - console.log(e) - console.log('clicked on trash icon') - await props.deletePathOp(props.file.path) - }} - > - + > */} + { + e.stopPropagation() + console.log(props) + console.log(e) + console.log('clicked on trash icon') + await props.deletePathOp(props.file.path) + }} + > + {/* */}
} diff --git a/libs/remix-ui/workspace/src/lib/components/file-explorer.tsx b/libs/remix-ui/workspace/src/lib/components/file-explorer.tsx index 39e20428d4..9eca0e4c7d 100644 --- a/libs/remix-ui/workspace/src/lib/components/file-explorer.tsx +++ b/libs/remix-ui/workspace/src/lib/components/file-explorer.tsx @@ -1,4 +1,4 @@ -import React, { useEffect, useState, useRef, SyntheticEvent, useTransition } from 'react' // eslint-disable-line +import React, { useEffect, useState, useRef, SyntheticEvent } from 'react' // eslint-disable-line import { useIntl } from 'react-intl' import { TreeView } from '@remix-ui/tree-view' // eslint-disable-line import { FileExplorerMenu } from './file-explorer-menu' // eslint-disable-line @@ -27,12 +27,13 @@ export const FileExplorer = (props: FileExplorerProps) => { handleContextMenu, handleNewFileInput, handleNewFolderInput, + deletePath, uploadFile, uploadFolder, fileState } = props const [state, setState] = useState(workspaceState) - const [isPending, startTransition] = useTransition(); + // const [isPending, startTransition] = useTransition(); const treeRef = useRef(null) useEffect(() => { @@ -404,6 +405,8 @@ export const FileExplorer = (props: FileExplorerProps) => { moveFile={handleFileMove} moveFolder={handleFolderMove} handleClickFolder={handleClickFolder} + createNewFile={handleNewFileInput} + createNewFolder={handleNewFolderInput} />
diff --git a/libs/remix-ui/workspace/src/lib/components/flat-tree-drop.tsx b/libs/remix-ui/workspace/src/lib/components/flat-tree-drop.tsx index e1d7fc72c5..de02b36084 100644 --- a/libs/remix-ui/workspace/src/lib/components/flat-tree-drop.tsx +++ b/libs/remix-ui/workspace/src/lib/components/flat-tree-drop.tsx @@ -1,4 +1,4 @@ -import React, { SyntheticEvent, startTransition, useEffect, useRef, useState } from 'react' +import React, { SyntheticEvent, useEffect, useRef, useState } from 'react' import { FileType } from '../types' import { getEventTarget } from '../utils/getEventTarget' import { extractParentFromKey } from '@remix-ui/helper' @@ -36,7 +36,7 @@ export const FlatTreeDrop = (props: FlatTreeDropProps) => { setFolderToOpen(null) } if (dragDestination && dragDestination.isDirectory && !expandPath.includes(dragDestination.path) && folderToOpen !== dragDestination.path && props.handleClickFolder) { - + setFolderToOpen(dragDestination.path) timer && clearTimeout(timer) setTimer( @@ -84,4 +84,4 @@ export const FlatTreeDrop = (props: FlatTreeDropProps) => { onDrop={onDrop} onDragOver={onDragOver} className="d-flex h-100" >{props.children}) -} \ No newline at end of file +} diff --git a/libs/remix-ui/workspace/src/lib/components/flat-tree.tsx b/libs/remix-ui/workspace/src/lib/components/flat-tree.tsx index a96f514a86..16d76c9bc2 100644 --- a/libs/remix-ui/workspace/src/lib/components/flat-tree.tsx +++ b/libs/remix-ui/workspace/src/lib/components/flat-tree.tsx @@ -8,6 +8,7 @@ import { FlatTreeDrop } from './flat-tree-drop'; import { getEventTarget } from '../utils/getEventTarget'; import { fileDecoration, FileDecorationIcons } from '@remix-ui/file-decorators'; import { FileHoverIcons } from './file-explorer-hovericons'; +import { deletePath } from '../actions'; export default function useOnScreen(ref: RefObject) { @@ -37,6 +38,10 @@ interface FlatTreeProps { moveFile: (dest: string, src: string) => void moveFolder: (dest: string, src: string) => void fileState: fileDecoration[] + createNewFile?: any + createNewFolder?: any + deletePath?: (path: string | string[]) => void | Promise + renamePath?: (path: string, newName: string) => void | Promise } let mouseTimer: any = { @@ -45,7 +50,7 @@ let mouseTimer: any = { } export const FlatTree = (props: FlatTreeProps) => { - const { files, flatTree, expandPath, focusEdit, editModeOff, handleTreeClick, moveFile, moveFolder, fileState, focusElement, handleClickFolder } = props + const { files, flatTree, expandPath, focusEdit, editModeOff, handleTreeClick, moveFile, moveFolder, fileState, focusElement, handleClickFolder, deletePath, renamePath } = props const [hover, setHover] = useState('') const [mouseOverTarget, setMouseOverTarget] = useState<{ path: string, @@ -211,7 +216,9 @@ export const FlatTree = (props: FlatTreeProps) => {
-
{getFileStateIcons(file)} +
+ +
{getFileStateIcons(file)}
} diff --git a/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx b/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx index 400aa1de2c..c9785841e5 100644 --- a/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx +++ b/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx @@ -796,7 +796,7 @@ export function Workspace() { +