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
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 intl = useIntl()
useEffect(() => {
@ -108,6 +108,14 @@ export const FileExplorerContextMenu = (props: FileExplorerContextMenuProps) =>
copy(path, type)
_paq.push(['trackEvent', 'fileExplorer', 'contextMenu', 'copy'])
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':
paste(path, type)
_paq.push(['trackEvent', 'fileExplorer', 'contextMenu', 'paste'])

@ -409,6 +409,17 @@ export const FileExplorer = (props: FileExplorerProps) => {
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) => {
try {
props.dispatchMoveFile(src, dest)
@ -480,6 +491,8 @@ export const FileExplorer = (props: FileExplorerProps) => {
runScript={runScript}
copy={handleCopyClick}
paste={handlePasteClick}
copyFileName={handleCopyFileNameClick}
copyPath={handleCopyFilePathClick}
emit={emitContextMenuEvent}
pageX={state.focusContext.x}
pageY={state.focusContext.y}

@ -134,6 +134,8 @@ export interface FileExplorerContextMenuProps {
onMouseOver?: (...args) => void,
copy?: (path: 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 {

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

Loading…
Cancel
Save