Move backup button to file-explorer

pull/5370/head
David Disu 3 years ago committed by yann300
parent cae31221bc
commit d8d1ed8a9f
  1. 11
      libs/remix-ui/home-tab/src/lib/remix-ui-home-tab.tsx
  2. 6
      libs/remix-ui/workspace/src/lib/actions/index.ts
  3. 3
      libs/remix-ui/workspace/src/lib/contexts/index.ts
  4. 9
      libs/remix-ui/workspace/src/lib/providers/FileSystemProvider.tsx
  5. 18
      libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx

@ -176,13 +176,6 @@ export const RemixUiHomeTab = (props: RemixUiHomeTabProps) => {
plugin.verticalIcons.select('pluginManager') plugin.verticalIcons.select('pluginManager')
} }
const restoreBackupZip = async () => {
await plugin.appManager.activatePlugin(['restorebackupzip'])
await plugin.call('mainPanel', 'showContent', 'restorebackupzip')
plugin.verticalIcons.select('restorebackupzip')
_paq.push(['trackEvent', 'pluginManager', 'userActivate', 'restorebackupzip'])
}
const showFullMessage = (title: string, loadItem: string, examples: Array<string>) => { const showFullMessage = (title: string, loadItem: string, examples: Array<string>) => {
setState(prevState => { setState(prevState => {
return { ...prevState, showModalDialog: true, modalInfo: { title: title, loadItem: loadItem, examples: examples } } return { ...prevState, showModalDialog: true, modalInfo: { title: title, loadItem: loadItem, examples: examples } }
@ -295,10 +288,6 @@ export const RemixUiHomeTab = (props: RemixUiHomeTabProps) => {
<i className="mr-1 far fa-hdd"></i> <i className="mr-1 far fa-hdd"></i>
<label className="ml-1 remixui_home_text" onClick={() => connectToLocalhost()}>Connect to Localhost</label> <label className="ml-1 remixui_home_text" onClick={() => connectToLocalhost()}>Connect to Localhost</label>
</p> </p>
<p className="mb-1">
<i className="mr-1 far fa-upload"></i>
<label className="ml-1 remixui_home_text" onClick={() => restoreBackupZip()}>Restore Backup</label>
</p>
<p className="mt-3 mb-0"><label>LOAD FROM:</label></p> <p className="mt-3 mb-0"><label>LOAD FROM:</label></p>
<div className="btn-group"> <div className="btn-group">
<button className="btn mr-1 btn-secondary" data-id="landingPageImportFromGistButton" onClick={() => importFromGist()}>Gist</button> <button className="btn mr-1 btn-secondary" data-id="landingPageImportFromGistButton" onClick={() => importFromGist()}>Gist</button>

@ -297,6 +297,12 @@ export const handleDownloadFiles = async () => {
} }
} }
export const restoreBackupZip = async () => {
await plugin.appManager.activatePlugin(['restorebackupzip'])
plugin.verticalIcons.select('restorebackupzip')
_paq.push(['trackEvent', 'pluginManager', 'userActivate', 'restorebackupzip'])
}
const packageGistFiles = async (directory) => { const packageGistFiles = async (directory) => {
const workspaceProvider = plugin.fileProviders.workspace const workspaceProvider = plugin.fileProviders.workspace
const isFile = await workspaceProvider.isFile(directory) const isFile = await workspaceProvider.isFile(directory)

@ -28,5 +28,6 @@ export const FileSystemContext = createContext<{
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>,
dispatchHandleDownloadFiles: () => Promise<void> dispatchHandleDownloadFiles: () => Promise<void>,
dispatchHandleRestoreBackup: () => Promise<void>
}>(null) }>(null)

@ -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, emitContextMenuEvent, handleClickFile, handleExpandPath, addInputField, createWorkspace, fetchWorkspaceDirectory, renameWorkspace, switchToWorkspace, uploadFile, handleDownloadFiles } from '../actions' import { initWorkspace, fetchDirectory, removeInputField, deleteWorkspace, clearPopUp, publishToGist, createNewFile, setFocusElement, createNewFolder, deletePath, renamePath, copyFile, copyFolder, runScript, emitContextMenuEvent, handleClickFile, handleExpandPath, addInputField, createWorkspace, fetchWorkspaceDirectory, renameWorkspace, switchToWorkspace, uploadFile, handleDownloadFiles, restoreBackupZip } 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'
@ -119,6 +119,10 @@ export const FileSystemProvider = (props: WorkspaceProps) => {
await handleDownloadFiles() await handleDownloadFiles()
} }
const dispatchHandleRestoreBackup = async () => {
await restoreBackupZip()
}
useEffect(() => { useEffect(() => {
dispatchInitWorkspace() dispatchInitWorkspace()
}, []) }, [])
@ -219,7 +223,8 @@ export const FileSystemProvider = (props: WorkspaceProps) => {
dispatchEmitContextMenuEvent, dispatchEmitContextMenuEvent,
dispatchHandleClickFile, dispatchHandleClickFile,
dispatchHandleExpandPath, dispatchHandleExpandPath,
dispatchHandleDownloadFiles dispatchHandleDownloadFiles,
dispatchHandleRestoreBackup
} }
return ( return (
<FileSystemContext.Provider value={value}> <FileSystemContext.Provider value={value}>

@ -58,6 +58,14 @@ export function Workspace () {
} }
} }
const restoreBackup = async () => {
try {
await global.dispatchHandleRestoreBackup()
} catch (e) {
console.error(e)
}
}
const onFinishRenameWorkspace = async () => { const onFinishRenameWorkspace = async () => {
if (workspaceRenameInput.current === undefined) return if (workspaceRenameInput.current === undefined) return
// @ts-ignore: Object is possibly 'null'. // @ts-ignore: Object is possibly 'null'.
@ -178,6 +186,16 @@ export function Workspace () {
className='far fa-download remixui_menuicon' className='far fa-download remixui_menuicon'
title='Download Workspaces'> title='Download Workspaces'>
</span> </span>
<span
id='workspacesRestore'
data-id='workspacesRestore'
onClick={(e) => {
e.stopPropagation()
restoreBackup()
}}
className='far fa-upload remixui_menuicon'
title='Restore Workspaces Backup'>
</span>
</span> </span>
<select id="workspacesSelect" value={currentWorkspace} data-id="workspacesSelect" onChange={(e) => switchWorkspace(e.target.value)} className="form-control custom-select"> <select id="workspacesSelect" value={currentWorkspace} data-id="workspacesSelect" onChange={(e) => switchWorkspace(e.target.value)} className="form-control custom-select">
{ {

Loading…
Cancel
Save