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) => { export const emitContextMenuEvent = async (cmd: customAction) => {
await plugin.call(cmd.id, cmd.name, cmd) await plugin.call(cmd.id, cmd.name, cmd)
} }

@ -12,7 +12,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, 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) const contextMenuRef = useRef(null)
useEffect(() => { useEffect(() => {
contextMenuRef.current.focus() contextMenuRef.current.focus()
@ -102,6 +102,10 @@ export const FileExplorerContextMenu = (props: FileExplorerContextMenuProps) =>
_paq.push(['trackEvent', 'fileExplorer', 'runScriptWithMocha']) _paq.push(['trackEvent', 'fileExplorer', 'runScriptWithMocha'])
runScriptWithMocha(path) runScriptWithMocha(path)
break break
case 'Run after compilation':
_paq.push(['trackEvent', 'fileExplorer', 'runAfterCompilation'])
runAfterCompilation(path)
break
case 'Copy': case 'Copy':
copy(path, type) copy(path, type)
break 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) => { const emitContextMenuEvent = (cmd: customAction) => {
try { try {
props.dispatchEmitContextMenuEvent(cmd) props.dispatchEmitContextMenuEvent(cmd)
@ -463,6 +471,7 @@ export const FileExplorer = (props: FileExplorerProps) => {
renamePath={editModeOn} renamePath={editModeOn}
runScript={runScript} runScript={runScript}
runScriptWithMocha={runScriptWithMocha} runScriptWithMocha={runScriptWithMocha}
runAfterCompilation={runAfterCompilation}
copy={handleCopyClick} copy={handleCopyClick}
paste={handlePasteClick} paste={handlePasteClick}
emit={emitContextMenuEvent} emit={emitContextMenuEvent}

@ -26,6 +26,7 @@ export const FileSystemContext = createContext<{
dispatchCopyFolder: (src: string, dest: string) => Promise<void>, dispatchCopyFolder: (src: string, dest: string) => Promise<void>,
dispatchRunScript: (path: string) => Promise<void>, dispatchRunScript: (path: string) => Promise<void>,
dispatchRunScriptWithMocha: (path: string) => Promise<void>, dispatchRunScriptWithMocha: (path: string) => Promise<void>,
dispatchRunAfterCompilation: (path: string) => Promise<void>,
dispatchEmitContextMenuEvent: (cmd: customAction) => Promise<void>, dispatchEmitContextMenuEvent: (cmd: customAction) => Promise<void>,
dispatchHandleClickFile: (path: string, type: 'file' | 'folder' | 'gist') => Promise<void> dispatchHandleClickFile: (path: string, type: 'file' | 'folder' | 'gist') => Promise<void>
dispatchHandleExpandPath: (paths: string[]) => 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 // eslint-disable-next-line @typescript-eslint/no-unused-vars
import { FileSystemContext } from '../contexts' import { FileSystemContext } from '../contexts'
import { browserReducer, browserInitialState } from '../reducers/workspace' 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' import { Modal, WorkspaceProps } from '../types'
// eslint-disable-next-line @typescript-eslint/no-unused-vars // eslint-disable-next-line @typescript-eslint/no-unused-vars
import { Workspace } from '../remix-ui-workspace' import { Workspace } from '../remix-ui-workspace'
@ -107,6 +107,10 @@ export const FileSystemProvider = (props: WorkspaceProps) => {
await runScriptWithMocha(path) await runScriptWithMocha(path)
} }
const dispatchRunAfterCompilation = async (path: string) => {
await runAfterCompilation(path)
}
const dispatchEmitContextMenuEvent = async (cmd: customAction) => { const dispatchEmitContextMenuEvent = async (cmd: customAction) => {
await emitContextMenuEvent(cmd) await emitContextMenuEvent(cmd)
} }
@ -217,6 +221,7 @@ export const FileSystemProvider = (props: WorkspaceProps) => {
dispatchCopyFolder, dispatchCopyFolder,
dispatchRunScript, dispatchRunScript,
dispatchRunScriptWithMocha, dispatchRunScriptWithMocha,
dispatchRunAfterCompilation,
dispatchEmitContextMenuEvent, dispatchEmitContextMenuEvent,
dispatchHandleClickFile, dispatchHandleClickFile,
dispatchHandleExpandPath dispatchHandleExpandPath

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

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

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

Loading…
Cancel
Save