fix file type and context menu string. add function signature to interface.

pull/5370/head
Joseph Izang 2 years ago committed by Aniket
parent 3e271d4c5d
commit 6a5757203b
  1. 10
      libs/remix-ui/workspace/src/lib/components/file-explorer-context-menu.tsx
  2. 13
      libs/remix-ui/workspace/src/lib/components/file-explorer.tsx
  3. 2
      libs/remix-ui/workspace/src/lib/types/index.ts
  4. 6
      libs/remix-ui/workspace/src/lib/utils/index.ts

@ -13,7 +13,7 @@ declare global {
const _paq = window._paq = window._paq || [] //eslint-disable-line const _paq = window._paq = window._paq || [] //eslint-disable-line
export const FileExplorerContextMenu = (props: FileExplorerContextMenuProps) => { export const FileExplorerContextMenu = (props: FileExplorerContextMenuProps) => {
const { actions, createNewFile, createNewFolder, deletePath, renamePath, hideContextMenu, pushChangesToGist, publishFileToGist, publishFolderToGist, copy, paste, runScript, emit, pageX, pageY, path, type, focus, ...otherProps } = props const { actions, createNewFile, createNewFolder, deletePath, renamePath, hideContextMenu, pushChangesToGist, publishFileToGist, publishFolderToGist, copy, copyFileName, copyPath, paste, runScript, emit, pageX, pageY, path, type, focus, ...otherProps } = props
const contextMenuRef = useRef(null) const contextMenuRef = useRef(null)
const intl = useIntl() const intl = useIntl()
useEffect(() => { useEffect(() => {
@ -108,6 +108,14 @@ export const FileExplorerContextMenu = (props: FileExplorerContextMenuProps) =>
copy(path, type) copy(path, type)
_paq.push(['trackEvent', 'fileExplorer', 'contextMenu', 'copy']) _paq.push(['trackEvent', 'fileExplorer', 'contextMenu', 'copy'])
break break
case 'Copy name':
copyFileName(path, type)
_paq.push(['trackEvent', 'fileExplorer', 'contextMenu', 'copy'])
break
case 'Copy path':
copyPath(path, type)
_paq.push(['trackEvent', 'fileExplorer', 'contextMenu', 'copy'])
break
case 'Paste': case 'Paste':
paste(path, type) paste(path, type)
_paq.push(['trackEvent', 'fileExplorer', 'contextMenu', 'paste']) _paq.push(['trackEvent', 'fileExplorer', 'contextMenu', 'paste'])

@ -409,6 +409,17 @@ export const FileExplorer = (props: FileExplorerProps) => {
props.dispatchHandleExpandPath(expandPath) props.dispatchHandleExpandPath(expandPath)
} }
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const handleCopyFileNameClick = (path: string, _type: string) => {
const fileName = extractNameFromKey(path)
navigator.clipboard.writeText(fileName)
}
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const handleCopyFilePathClick = (path: string, _type: string) => {
navigator.clipboard.writeText(path)
}
const handleFileMove = (dest: string, src: string) => { const handleFileMove = (dest: string, src: string) => {
try { try {
props.dispatchMoveFile(src, dest) props.dispatchMoveFile(src, dest)
@ -480,6 +491,8 @@ export const FileExplorer = (props: FileExplorerProps) => {
runScript={runScript} runScript={runScript}
copy={handleCopyClick} copy={handleCopyClick}
paste={handlePasteClick} paste={handlePasteClick}
copyFileName={handleCopyFileNameClick}
copyPath={handleCopyFilePathClick}
emit={emitContextMenuEvent} emit={emitContextMenuEvent}
pageX={state.focusContext.x} pageX={state.focusContext.x}
pageY={state.focusContext.y} pageY={state.focusContext.y}

@ -134,6 +134,8 @@ export interface FileExplorerContextMenuProps {
onMouseOver?: (...args) => void, onMouseOver?: (...args) => void,
copy?: (path: string, type: string) => void, copy?: (path: string, type: string) => void,
paste?: (destination: string, type: string) => void paste?: (destination: string, type: string) => void
copyFileName?: (path: string, type: string) => void
copyPath?: (path: string, type: string) => void
} }
export interface FileExplorerState { export interface FileExplorerState {

@ -56,14 +56,14 @@ export const contextMenuActions: MenuItems = [{
label: '' label: ''
}, { }, {
id: 'copyFileName', id: 'copyFileName',
name: 'Copy file name', name: 'Copy name',
type: ['file'], type: ['file'],
multiselect: false, multiselect: false,
label: '' label: ''
}, { }, {
id: 'copyFilePath', id: 'copyFilePath',
name: 'Copy file path', name: 'Copy path',
type: ['folder', 'file'], type: ['file'],
multiselect: false, multiselect: false,
label: '' label: ''
}, { }, {

Loading…
Cancel
Save