From 1034c657ea83dff5ee0cf0698cdbc869fe1aebc6 Mon Sep 17 00:00:00 2001 From: bunsenstraat Date: Thu, 4 Jan 2024 09:12:41 +0100 Subject: [PATCH] win fixes --- apps/remixdesktop/package.json | 2 +- apps/remixdesktop/src/plugins/fsPlugin.ts | 22 ++++++++++----- .../workspace/src/lib/actions/index.ts | 4 --- .../workspace/src/lib/actions/workspace.ts | 27 ++++++++++++------- .../components/electron-workspace-name.tsx | 20 +++++++------- .../src/lib/providers/FileSystemProvider.tsx | 2 +- 6 files changed, 46 insertions(+), 31 deletions(-) diff --git a/apps/remixdesktop/package.json b/apps/remixdesktop/package.json index 84ff63537c..3654146639 100644 --- a/apps/remixdesktop/package.json +++ b/apps/remixdesktop/package.json @@ -1,6 +1,6 @@ { "name": "remixdesktop", - "version": "0.0.2-Alpha", + "version": "0.0.3-Alpha", "main": "build/main.js", "license": "MIT", "type": "commonjs", diff --git a/apps/remixdesktop/src/plugins/fsPlugin.ts b/apps/remixdesktop/src/plugins/fsPlugin.ts index d2da626d3b..14437e8218 100644 --- a/apps/remixdesktop/src/plugins/fsPlugin.ts +++ b/apps/remixdesktop/src/plugins/fsPlugin.ts @@ -21,6 +21,10 @@ const convertPathToPosix = (pathName: string): string => { return pathName.split(path.sep).join(path.posix.sep) } +const convertPathToLocalFileSystem = (pathName: string): string => { + return pathName.split(path.posix.sep).join(path.sep) +} + const getBaseName = (pathName: string): string => { return path.basename(pathName) } @@ -207,14 +211,15 @@ class FSPluginClient extends ElectronBasePluginClient { } async getWorkingDir(): Promise { - return this.workingDir + return convertPathToPosix(this.workingDir) } async watch(): Promise { try { - this.off('filePanel' as any, 'expandPathChanged') + if(this.events && this.events.eventNames().includes('[filePanel] expandPathChanged')) { + this.off('filePanel' as any, 'expandPathChanged') + } this.on('filePanel' as any, 'expandPathChanged', async (paths: string[]) => { - //console.log('expandPathChanged', paths) this.expandedPaths = ['.', ...paths] // add root //console.log(Object.keys(this.watchers)) paths = paths.map((path) => this.fixPath(path)) @@ -332,7 +337,9 @@ class FSPluginClient extends ElectronBasePluginClient { async getRecentFolders(): Promise { const config = await this.call('electronconfig' as any, 'readConfig') - return config.recentFolders || [] + let folders: string[] = config.recentFolders || [] + folders = folders.map((f: string) => convertPathToPosix(f)) + return folders } async removeRecentFolder(path: string): Promise { @@ -398,8 +405,9 @@ class FSPluginClient extends ElectronBasePluginClient { await this.call('fileManager', 'closeAllFiles') } - async revealInExplorer(action: customAction): Promise { - shell.showItemInFolder(this.fixPath(action.path[0])) + async revealInExplorer(action: customAction, isAbsolutePath: boolean = false): Promise { + let path = isAbsolutePath? action.path[0] : this.fixPath(action.path[0]) + shell.showItemInFolder(convertPathToLocalFileSystem(path)) } async openInVSCode(action: customAction): Promise { @@ -412,6 +420,8 @@ class FSPluginClient extends ElectronBasePluginClient { if (path.startsWith('/')) { path = path.slice(1) } + + } path = this.workingDir + (!this.workingDir.endsWith('/') ? '/' : '') + path return path diff --git a/libs/remix-ui/workspace/src/lib/actions/index.ts b/libs/remix-ui/workspace/src/lib/actions/index.ts index 5cf8d02166..7e0053b3f4 100644 --- a/libs/remix-ui/workspace/src/lib/actions/index.ts +++ b/libs/remix-ui/workspace/src/lib/actions/index.ts @@ -124,10 +124,6 @@ export const initWorkspace = (filePanelPlugin) => async (reducerDispatch: React. plugin.call('notification', 'toast', `opening ${params.opendir}...`) await plugin.call('fs', 'setWorkingDir', params.opendir) } - - plugin.on('fs', 'workingDirChanged', async (dir) => { - dispatch(setCurrentLocalFilePath(dir)) - }) const currentPath = await plugin.call('fs', 'getWorkingDir') dispatch(setCurrentLocalFilePath(currentPath)) plugin.setWorkspace({ name: 'electron', isLocalhost: false }) diff --git a/libs/remix-ui/workspace/src/lib/actions/workspace.ts b/libs/remix-ui/workspace/src/lib/actions/workspace.ts index 2b36578ac8..a41e991a94 100644 --- a/libs/remix-ui/workspace/src/lib/actions/workspace.ts +++ b/libs/remix-ui/workspace/src/lib/actions/workspace.ts @@ -28,6 +28,7 @@ import { setGitConfig, setElectronRecentFolders, setCurrentWorkspaceHasGitSubmodules, + setCurrentLocalFilePath, } from './payload' import { addSlash, checkSlash, checkSpecialChars } from '@remix-ui/helper' @@ -86,7 +87,9 @@ export const setPlugin = (filePanelPlugin, reducerDispatch) => { await checkGit() } }) - plugin.on('fs', 'workingDirChanged', async (path: string) => { + plugin.on('fs', 'workingDirChanged', async (dir: string) => { + console.log('workingDirChanged', dir) + dispatch(setCurrentLocalFilePath(dir)) await checkGit() }) checkGit() @@ -368,7 +371,6 @@ export const fetchWorkspaceDirectory = async (path: string) => { provider.resolveDirectory(path, (error, fileTree: FileTree) => { if (error) { reject(error) - console.error(error) } resolve(fileTree) }) @@ -546,11 +548,13 @@ export const uploadFolder = async (target, targetFolder: string, cb?: (err: Erro } export const getWorkspaces = async (): Promise<{ name: string; isGitRepo: boolean; hasGitSubmodules: boolean; branches?: { remote: any; name: string }[]; currentBranch?: string }[]> | undefined => { + console.log('getWorkspaces') try { const workspaces: { name: string; isGitRepo: boolean; hasGitSubmodules: boolean; branches?: { remote: any; name: string }[]; currentBranch?: string }[] = await new Promise((resolve, reject) => { const workspacesPath = plugin.fileProviders.workspace.workspacesPath - + console.log('workspacesPath', workspacesPath) plugin.fileProviders.browser.resolveDirectory('/' + workspacesPath, (error, items) => { + if (error) { return reject(error) } @@ -584,6 +588,7 @@ export const getWorkspaces = async (): Promise<{ name: string; isGitRepo: boolea ).then((workspacesList) => resolve(workspacesList)) }) }) + console.log('workspaces', workspaces) await plugin.setWorkspaces(workspaces) return workspaces } catch (e) {} @@ -652,13 +657,15 @@ export const cloneRepository = async (url: string) => { } export const checkGit = async () => { - const isGitRepo = await plugin.fileManager.isGitRepo() - const hasGitSubmodule = await plugin.fileManager.hasGitSubmodules() - dispatch(setCurrentWorkspaceIsGitRepo(isGitRepo)) - dispatch(setCurrentWorkspaceHasGitSubmodules(hasGitSubmodule)) - await refreshBranches() - const currentBranch = await plugin.call('dGitProvider', 'currentbranch') - dispatch(setCurrentWorkspaceCurrentBranch(currentBranch)) + try { + const isGitRepo = await plugin.fileManager.isGitRepo() + const hasGitSubmodule = await plugin.fileManager.hasGitSubmodules() + dispatch(setCurrentWorkspaceIsGitRepo(isGitRepo)) + dispatch(setCurrentWorkspaceHasGitSubmodules(hasGitSubmodule)) + await refreshBranches() + const currentBranch = await plugin.call('dGitProvider', 'currentbranch') + dispatch(setCurrentWorkspaceCurrentBranch(currentBranch)) + } catch (e) {} } export const getRepositoryTitle = async (url: string) => { diff --git a/libs/remix-ui/workspace/src/lib/components/electron-workspace-name.tsx b/libs/remix-ui/workspace/src/lib/components/electron-workspace-name.tsx index 1e25c5dcd1..96f59a16fe 100644 --- a/libs/remix-ui/workspace/src/lib/components/electron-workspace-name.tsx +++ b/libs/remix-ui/workspace/src/lib/components/electron-workspace-name.tsx @@ -1,5 +1,7 @@ import { CustomTooltip } from "@remix-ui/helper" -import React, { MouseEventHandler, useContext, useEffect, useState } from "react" +import React from "react" +import path from 'path' + interface ElectronWorkspaceNameProps { path: string @@ -7,29 +9,29 @@ interface ElectronWorkspaceNameProps { } export const ElectronWorkspaceName = (props: ElectronWorkspaceNameProps) => { - const { path } = props + const { path: dir } = props - const parsePath = (path: string) => { - const pathArray = path.split('/') + const parsePath = () => { + const pathArray = dir.split(path.posix.sep) return pathArray[pathArray.length - 1] } const openInExplorer = () => { props.plugin.call('fs', 'revealInExplorer', { - path - }) + path: [dir] + }, true) } return ( - (path === undefined || path === '') ? <> : + (dir === undefined || dir === '') ? <> :
-
{parsePath(path)}
+
{parsePath()}
{ try { await fetchWorkspaceDirectory(path) } catch (err) { - console.error(err) + console.warn(err) } }