diff --git a/apps/remix-ide/src/app/panels/file-panel.js b/apps/remix-ide/src/app/panels/file-panel.js index a4336a0c2a..bfda205ce0 100644 --- a/apps/remix-ide/src/app/panels/file-panel.js +++ b/apps/remix-ide/src/app/panels/file-panel.js @@ -30,7 +30,7 @@ const { SlitherHandle } = require('../files/slither-handle.js') const profile = { name: 'filePanel', displayName: 'File explorer', - methods: ['createNewFile', 'uploadFile', 'getCurrentWorkspace', 'getAvailableWorkspaceName', 'getWorkspaces', 'createWorkspace', 'setWorkspace', 'registerContextMenuItem', 'renameWorkspace', 'deleteWorkspace'], + methods: ['createNewFile', 'uploadFile', 'getCurrentWorkspace', 'getAvailableWorkspaceName', 'getWorkspaces', 'createWorkspace', 'switchToWorkspace', 'setWorkspace', 'registerContextMenuItem', 'renameWorkspace', 'deleteWorkspace'], events: ['setWorkspace', 'workspaceRenamed', 'workspaceDeleted', 'workspaceCreated'], icon: 'assets/img/fileManager.webp', description: 'Remix IDE file explorer', @@ -184,10 +184,14 @@ module.exports = class Filepanel extends ViewPlugin { if (workspace.name !== " - connect to localhost - ") { localStorage.setItem('currentWorkspace', workspace.name) } - this.emit('setWorkspace', workspace) if (this.currentWorkspaceMetadata.name !== current) { this.saveRecent(workspace) } + this.emit('setWorkspace', workspace) + } + + switchToWorkspace(workspaceName) { + this.emit('switchToWorkspace', workspaceName) } workspaceRenamed (oldName, workspaceName) { diff --git a/libs/remix-ui/home-tab/src/lib/components/homeTabFile.tsx b/libs/remix-ui/home-tab/src/lib/components/homeTabFile.tsx index fdcba77dee..b9046cf574 100644 --- a/libs/remix-ui/home-tab/src/lib/components/homeTabFile.tsx +++ b/libs/remix-ui/home-tab/src/lib/components/homeTabFile.tsx @@ -165,7 +165,7 @@ function HomeTabFile({plugin}: HomeTabFileProps) { const handleSwichToRecentWorkspace = async (e, workspaceName) => { e.preventDefault(); - await plugin.call('filePanel', 'setWorkspace', { name: workspaceName, isLocalhost: false }) + await plugin.call('filePanel', 'switchToWorkspace', { name: workspaceName, isLocalhost: false }) console.log('The link was clicked.'); } diff --git a/libs/remix-ui/workspace/src/lib/actions/events.ts b/libs/remix-ui/workspace/src/lib/actions/events.ts index 5c9b03141c..7481f2faec 100644 --- a/libs/remix-ui/workspace/src/lib/actions/events.ts +++ b/libs/remix-ui/workspace/src/lib/actions/events.ts @@ -3,7 +3,7 @@ import { extractParentFromKey } from '@remix-ui/helper' import React from 'react' import { action, WorkspaceTemplate } from '../types' import { ROOT_PATH } from '../utils/constants' -import { displayNotification, displayPopUp, fileAddedSuccess, fileRemovedSuccess, fileRenamedSuccess, folderAddedSuccess, loadLocalhostError, loadLocalhostRequest, loadLocalhostSuccess, removeContextMenuItem, removeFocus, rootFolderChangedSuccess, setContextMenuItem, setMode, setReadOnlyMode, setFileDecorationSuccess } from './payload' +import { displayNotification, displayPopUp, fileAddedSuccess, fileRemovedSuccess, fileRenamedSuccess, folderAddedSuccess, loadLocalhostError, loadLocalhostRequest, loadLocalhostSuccess, removeContextMenuItem, removeFocus, rootFolderChangedSuccess, setContextMenuItem, setMode, setReadOnlyMode, setFileDecorationSuccess, setCurrentWorkspace } from './payload' import { addInputField, createWorkspace, deleteWorkspace, fetchWorkspaceDirectory, renameWorkspace, switchToWorkspace, uploadFile } from './workspace' const LOCALHOST = ' - connect to localhost - ' @@ -40,6 +40,10 @@ export const listenOnPluginEvents = (filePanelPlugin) => { uploadFile(target, dir, cb) }) + plugin.on('filePanel', 'switchToWorkspace', async (workspace) => { + await switchToWorkspace(workspace.name) + }) + plugin.on('fileDecorator', 'fileDecoratorsChanged', async (items: fileDecoration[]) => { setFileDecorators(items) })