pull/5370/head
filip mertens 2 years ago committed by lianahus
parent 981db607c6
commit 8f6addd08f
  1. 8
      apps/remix-ide/src/app/panels/file-panel.js
  2. 2
      libs/remix-ui/home-tab/src/lib/components/homeTabFile.tsx
  3. 6
      libs/remix-ui/workspace/src/lib/actions/events.ts

@ -30,7 +30,7 @@ const { SlitherHandle } = require('../files/slither-handle.js')
const profile = { const profile = {
name: 'filePanel', name: 'filePanel',
displayName: 'File explorer', 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'], events: ['setWorkspace', 'workspaceRenamed', 'workspaceDeleted', 'workspaceCreated'],
icon: 'assets/img/fileManager.webp', icon: 'assets/img/fileManager.webp',
description: 'Remix IDE file explorer', description: 'Remix IDE file explorer',
@ -184,10 +184,14 @@ module.exports = class Filepanel extends ViewPlugin {
if (workspace.name !== " - connect to localhost - ") { if (workspace.name !== " - connect to localhost - ") {
localStorage.setItem('currentWorkspace', workspace.name) localStorage.setItem('currentWorkspace', workspace.name)
} }
this.emit('setWorkspace', workspace)
if (this.currentWorkspaceMetadata.name !== current) { if (this.currentWorkspaceMetadata.name !== current) {
this.saveRecent(workspace) this.saveRecent(workspace)
} }
this.emit('setWorkspace', workspace)
}
switchToWorkspace(workspaceName) {
this.emit('switchToWorkspace', workspaceName)
} }
workspaceRenamed (oldName, workspaceName) { workspaceRenamed (oldName, workspaceName) {

@ -165,7 +165,7 @@ function HomeTabFile({plugin}: HomeTabFileProps) {
const handleSwichToRecentWorkspace = async (e, workspaceName) => { const handleSwichToRecentWorkspace = async (e, workspaceName) => {
e.preventDefault(); 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.'); console.log('The link was clicked.');
} }

@ -3,7 +3,7 @@ import { extractParentFromKey } from '@remix-ui/helper'
import React from 'react' import React from 'react'
import { action, WorkspaceTemplate } from '../types' import { action, WorkspaceTemplate } from '../types'
import { ROOT_PATH } from '../utils/constants' 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' import { addInputField, createWorkspace, deleteWorkspace, fetchWorkspaceDirectory, renameWorkspace, switchToWorkspace, uploadFile } from './workspace'
const LOCALHOST = ' - connect to localhost - ' const LOCALHOST = ' - connect to localhost - '
@ -40,6 +40,10 @@ export const listenOnPluginEvents = (filePanelPlugin) => {
uploadFile(target, dir, cb) uploadFile(target, dir, cb)
}) })
plugin.on('filePanel', 'switchToWorkspace', async (workspace) => {
await switchToWorkspace(workspace.name)
})
plugin.on('fileDecorator', 'fileDecoratorsChanged', async (items: fileDecoration[]) => { plugin.on('fileDecorator', 'fileDecoratorsChanged', async (items: fileDecoration[]) => {
setFileDecorators(items) setFileDecorators(items)
}) })

Loading…
Cancel
Save