add runAFterCompilation menu item

auto_exec
yann300 3 years ago
parent e5ddf164c6
commit 437a4cb4e7
  1. 4
      libs/remix-ui/workspace/src/lib/actions/index.ts
  2. 6
      libs/remix-ui/workspace/src/lib/components/file-explorer-context-menu.tsx
  3. 9
      libs/remix-ui/workspace/src/lib/components/file-explorer.tsx
  4. 1
      libs/remix-ui/workspace/src/lib/contexts/index.ts
  5. 7
      libs/remix-ui/workspace/src/lib/providers/FileSystemProvider.tsx
  6. 2
      libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx
  7. 2
      libs/remix-ui/workspace/src/lib/types/index.ts
  8. 6
      libs/remix-ui/workspace/src/lib/utils/index.ts

@ -267,6 +267,10 @@ export const runScriptWithMocha = async (path: string) => {
})
}
export const runAfterCompilation = async (path: string) => {
plugin.call('config', 'setAppParameter', 'live-script', path)
}
export const emitContextMenuEvent = async (cmd: customAction) => {
await plugin.call(cmd.id, cmd.name, cmd)
}

@ -12,7 +12,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, runScriptWithMocha, emit, pageX, pageY, path, type, focus, ...otherProps } = props
const { actions, createNewFile, createNewFolder, deletePath, renamePath, hideContextMenu, pushChangesToGist, publishFileToGist, publishFolderToGist, copy, paste, runScript, runScriptWithMocha, runAfterCompilation, emit, pageX, pageY, path, type, focus, ...otherProps } = props
const contextMenuRef = useRef(null)
useEffect(() => {
contextMenuRef.current.focus()
@ -102,6 +102,10 @@ export const FileExplorerContextMenu = (props: FileExplorerContextMenuProps) =>
_paq.push(['trackEvent', 'fileExplorer', 'runScriptWithMocha'])
runScriptWithMocha(path)
break
case 'Run after compilation':
_paq.push(['trackEvent', 'fileExplorer', 'runAfterCompilation'])
runAfterCompilation(path)
break
case 'Copy':
copy(path, type)
break

@ -229,6 +229,14 @@ export const FileExplorer = (props: FileExplorerProps) => {
}
}
const runAfterCompilation = async (path: string) => {
try {
props.dispatchRunAfterCompilation(path)
} catch (error) {
props.toast('Run script with Mocha failed')
}
}
const emitContextMenuEvent = (cmd: customAction) => {
try {
props.dispatchEmitContextMenuEvent(cmd)
@ -463,6 +471,7 @@ export const FileExplorer = (props: FileExplorerProps) => {
renamePath={editModeOn}
runScript={runScript}
runScriptWithMocha={runScriptWithMocha}
runAfterCompilation={runAfterCompilation}
copy={handleCopyClick}
paste={handlePasteClick}
emit={emitContextMenuEvent}

@ -26,6 +26,7 @@ export const FileSystemContext = createContext<{
dispatchCopyFolder: (src: string, dest: string) => Promise<void>,
dispatchRunScript: (path: string) => Promise<void>,
dispatchRunScriptWithMocha: (path: string) => Promise<void>,
dispatchRunAfterCompilation: (path: string) => Promise<void>,
dispatchEmitContextMenuEvent: (cmd: customAction) => Promise<void>,
dispatchHandleClickFile: (path: string, type: 'file' | 'folder' | 'gist') => Promise<void>
dispatchHandleExpandPath: (paths: string[]) => Promise<void>

@ -5,7 +5,7 @@ import { Toaster } from '@remix-ui/toaster' // eslint-disable-line
// eslint-disable-next-line @typescript-eslint/no-unused-vars
import { FileSystemContext } from '../contexts'
import { browserReducer, browserInitialState } from '../reducers/workspace'
import { initWorkspace, fetchDirectory, removeInputField, deleteWorkspace, clearPopUp, publishToGist, createNewFile, setFocusElement, createNewFolder, deletePath, renamePath, copyFile, copyFolder, runScript, runScriptWithMocha, emitContextMenuEvent, handleClickFile, handleExpandPath, addInputField, createWorkspace, fetchWorkspaceDirectory, renameWorkspace, switchToWorkspace, uploadFile } from '../actions'
import { initWorkspace, fetchDirectory, removeInputField, deleteWorkspace, clearPopUp, publishToGist, createNewFile, setFocusElement, createNewFolder, deletePath, renamePath, copyFile, copyFolder, runScript, runScriptWithMocha, runAfterCompilation, emitContextMenuEvent, handleClickFile, handleExpandPath, addInputField, createWorkspace, fetchWorkspaceDirectory, renameWorkspace, switchToWorkspace, uploadFile } from '../actions'
import { Modal, WorkspaceProps } from '../types'
// eslint-disable-next-line @typescript-eslint/no-unused-vars
import { Workspace } from '../remix-ui-workspace'
@ -107,6 +107,10 @@ export const FileSystemProvider = (props: WorkspaceProps) => {
await runScriptWithMocha(path)
}
const dispatchRunAfterCompilation = async (path: string) => {
await runAfterCompilation(path)
}
const dispatchEmitContextMenuEvent = async (cmd: customAction) => {
await emitContextMenuEvent(cmd)
}
@ -217,6 +221,7 @@ export const FileSystemProvider = (props: WorkspaceProps) => {
dispatchCopyFolder,
dispatchRunScript,
dispatchRunScriptWithMocha,
dispatchRunAfterCompilation,
dispatchEmitContextMenuEvent,
dispatchHandleClickFile,
dispatchHandleExpandPath

@ -199,6 +199,7 @@ export function Workspace () {
dispatchPublishToGist={global.dispatchPublishToGist}
dispatchRunScript={global.dispatchRunScript}
dispatchRunScriptWithMocha={global.dispatchRunScriptWithMocha}
dispatchRunAfterCompilation={global.dispatchRunAfterCompilation}
dispatchEmitContextMenuEvent={global.dispatchEmitContextMenuEvent}
dispatchHandleClickFile={global.dispatchHandleClickFile}
dispatchSetFocusElement={global.dispatchSetFocusElement}
@ -235,6 +236,7 @@ export function Workspace () {
dispatchPublishToGist={global.dispatchPublishToGist}
dispatchRunScript={global.dispatchRunScript}
dispatchRunScriptWithMocha={global.dispatchRunScriptWithMocha}
dispatchRunAfterCompilation={global.dispatchRunAfterCompilation}
dispatchEmitContextMenuEvent={global.dispatchEmitContextMenuEvent}
dispatchHandleClickFile={global.dispatchHandleClickFile}
dispatchSetFocusElement={global.dispatchSetFocusElement}

@ -88,6 +88,7 @@ export interface FileExplorerProps {
dispatchCopyFolder: (src: string, dest: string) => Promise<void>,
dispatchRunScript: (path: string) => Promise<void>,
dispatchRunScriptWithMocha: (path: string) => Promise<void>,
dispatchRunAfterCompilation: (path: string) => Promise<void>,
dispatchPublishToGist: (path?: string, type?: string) => Promise<void>,
dispatchEmitContextMenuEvent: (cmd: customAction) => Promise<void>,
dispatchHandleClickFile: (path: string, type: 'file' | 'folder' | 'gist') => Promise<void>,
@ -119,6 +120,7 @@ export interface FileExplorerContextMenuProps {
publishFileToGist?: (path?: string, type?: string) => void,
runScript?: (path: string) => void,
runScriptWithMocha?: (path: string) => void,
runAfterCompilation?: (path: string) => void,
emit?: (cmd: customAction) => void,
pageX: number,
pageY: number,

@ -36,6 +36,12 @@ export const contextMenuActions: MenuItems = [{
extension: ['.js'],
multiselect: false,
label: ''
}, {
id: 'runAfterCompilation',
name: 'Run after compilation',
extension: ['.js'],
multiselect: false,
label: ''
}, {
id: 'pushChangesToGist',
name: 'Push changes to gist',

Loading…
Cancel
Save