Move backup button to file-explorer

auto_exec_v2
David Disu 3 years ago committed by yann300
parent 1351f46e8a
commit 7af49d0478
  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')
}
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>) => {
setState(prevState => {
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>
<label className="ml-1 remixui_home_text" onClick={() => connectToLocalhost()}>Connect to Localhost</label>
</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>
<div className="btn-group">
<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 workspaceProvider = plugin.fileProviders.workspace
const isFile = await workspaceProvider.isFile(directory)

@ -28,5 +28,6 @@ export const FileSystemContext = createContext<{
dispatchEmitContextMenuEvent: (cmd: customAction) => Promise<void>,
dispatchHandleClickFile: (path: string, type: 'file' | 'folder' | 'gist') => Promise<void>
dispatchHandleExpandPath: (paths: string[]) => Promise<void>,
dispatchHandleDownloadFiles: () => Promise<void>
dispatchHandleDownloadFiles: () => Promise<void>,
dispatchHandleRestoreBackup: () => Promise<void>
}>(null)

@ -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, 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'
// eslint-disable-next-line @typescript-eslint/no-unused-vars
import { Workspace } from '../remix-ui-workspace'
@ -119,6 +119,10 @@ export const FileSystemProvider = (props: WorkspaceProps) => {
await handleDownloadFiles()
}
const dispatchHandleRestoreBackup = async () => {
await restoreBackupZip()
}
useEffect(() => {
dispatchInitWorkspace()
}, [])
@ -219,7 +223,8 @@ export const FileSystemProvider = (props: WorkspaceProps) => {
dispatchEmitContextMenuEvent,
dispatchHandleClickFile,
dispatchHandleExpandPath,
dispatchHandleDownloadFiles
dispatchHandleDownloadFiles,
dispatchHandleRestoreBackup
}
return (
<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 () => {
if (workspaceRenameInput.current === undefined) return
// @ts-ignore: Object is possibly 'null'.
@ -178,6 +186,16 @@ export function Workspace () {
className='far fa-download remixui_menuicon'
title='Download Workspaces'>
</span>
<span
id='workspacesRestore'
data-id='workspacesRestore'
onClick={(e) => {
e.stopPropagation()
restoreBackup()
}}
className='far fa-upload remixui_menuicon'
title='Restore Workspaces Backup'>
</span>
</span>
<select id="workspacesSelect" value={currentWorkspace} data-id="workspacesSelect" onChange={(e) => switchWorkspace(e.target.value)} className="form-control custom-select">
{

Loading…
Cancel
Save