Download file option

pull/3314/head
Aniket-Engg 2 years ago committed by Aniket
parent e8b7f0cdd0
commit 7145be4e13
  1. 6
      libs/remix-ui/workspace/src/lib/components/file-explorer-context-menu.tsx
  2. 6
      libs/remix-ui/workspace/src/lib/components/file-explorer.tsx
  3. 1
      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, copyFileName, copyPath, paste, runScript, emit, pageX, pageY, path, type, focus, ...otherProps } = props const { actions, createNewFile, createNewFolder, deletePath, renamePath, downloadPath, 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(() => {
@ -88,6 +88,10 @@ export const FileExplorerContextMenu = (props: FileExplorerContextMenuProps) =>
deletePath(getPath()) deletePath(getPath())
_paq.push(['trackEvent', 'fileExplorer', 'contextMenu', 'delete']) _paq.push(['trackEvent', 'fileExplorer', 'contextMenu', 'delete'])
break break
case 'Download':
downloadPath(path)
_paq.push(['trackEvent', 'fileExplorer', 'contextMenu', 'download'])
break
case 'Push changes to gist': case 'Push changes to gist':
_paq.push(['trackEvent', 'fileExplorer', 'contextMenu', 'pushToChangesoGist']) _paq.push(['trackEvent', 'fileExplorer', 'contextMenu', 'pushToChangesoGist'])
pushChangesToGist(path, type) pushChangesToGist(path, type)

@ -12,6 +12,7 @@ import { checkSpecialChars, extractNameFromKey, extractParentFromKey, joinPath }
import { FileRender } from './file-render' import { FileRender } from './file-render'
import { Drag } from "@remix-ui/drag-n-drop" import { Drag } from "@remix-ui/drag-n-drop"
import { ROOT_PATH } from '../utils/constants' import { ROOT_PATH } from '../utils/constants'
import { saveAs } from 'file-saver'
export const FileExplorer = (props: FileExplorerProps) => { export const FileExplorer = (props: FileExplorerProps) => {
const { name, contextMenuItems, removedContextMenuItems, files, fileState } = props const { name, contextMenuItems, removedContextMenuItems, files, fileState } = props
@ -174,6 +175,10 @@ export const FileExplorer = (props: FileExplorerProps) => {
} }
} }
const downloadPath = (path: string) => {
console.log('downloadPath', path)
}
const uploadFile = (target) => { const uploadFile = (target) => {
const parentFolder = getFocusedFolder() const parentFolder = getFocusedFolder()
const expandPath = [...new Set([...props.expandPath, parentFolder])] const expandPath = [...new Set([...props.expandPath, parentFolder])]
@ -488,6 +493,7 @@ export const FileExplorer = (props: FileExplorerProps) => {
createNewFile={handleNewFileInput} createNewFile={handleNewFileInput}
createNewFolder={handleNewFolderInput} createNewFolder={handleNewFolderInput}
deletePath={deletePath} deletePath={deletePath}
downloadPath={downloadPath}
renamePath={editModeOn} renamePath={editModeOn}
runScript={runScript} runScript={runScript}
copy={handleCopyClick} copy={handleCopyClick}

@ -127,6 +127,7 @@ export interface FileExplorerContextMenuProps {
createNewFolder: (parentFolder?: string) => void, createNewFolder: (parentFolder?: string) => void,
deletePath: (path: string | string[]) => void, deletePath: (path: string | string[]) => void,
renamePath: (path: string, type: string) => void, renamePath: (path: string, type: string) => void,
downloadPath: (path: string) => void,
hideContextMenu: () => void, hideContextMenu: () => void,
publishToGist?: (path?: string, type?: string) => void, publishToGist?: (path?: string, type?: string) => void,
pushChangesToGist?: (path?: string, type?: string) => void, pushChangesToGist?: (path?: string, type?: string) => void,

@ -24,6 +24,12 @@ export const contextMenuActions: MenuItems = [{
type: ['file', 'folder', 'gist'], type: ['file', 'folder', 'gist'],
multiselect: false, multiselect: false,
label: '' label: ''
},{
id: 'download',
name: 'Download',
type: ['file'],
multiselect: false,
label: ''
}, { }, {
id: 'run', id: 'run',
name: 'Run', name: 'Run',

Loading…
Cancel
Save