LianaHus-patch-7
bunsenstraat 11 months ago
parent 03731199ee
commit d71afc9e8c
  1. 2
      apps/remixdesktop/package.json
  2. 20
      apps/remixdesktop/src/plugins/fsPlugin.ts
  3. 4
      libs/remix-ui/workspace/src/lib/actions/index.ts
  4. 13
      libs/remix-ui/workspace/src/lib/actions/workspace.ts
  5. 20
      libs/remix-ui/workspace/src/lib/components/electron-workspace-name.tsx
  6. 2
      libs/remix-ui/workspace/src/lib/providers/FileSystemProvider.tsx

@ -1,6 +1,6 @@
{
"name": "remixdesktop",
"version": "0.0.2-Alpha",
"version": "0.0.3-Alpha",
"main": "build/main.js",
"license": "MIT",
"type": "commonjs",

@ -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<string> {
return this.workingDir
return convertPathToPosix(this.workingDir)
}
async watch(): Promise<void> {
try {
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<string[]> {
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<void> {
@ -398,8 +405,9 @@ class FSPluginClient extends ElectronBasePluginClient {
await this.call('fileManager', 'closeAllFiles')
}
async revealInExplorer(action: customAction): Promise<void> {
shell.showItemInFolder(this.fixPath(action.path[0]))
async revealInExplorer(action: customAction, isAbsolutePath: boolean = false): Promise<void> {
let path = isAbsolutePath? action.path[0] : this.fixPath(action.path[0])
shell.showItemInFolder(convertPathToLocalFileSystem(path))
}
async openInVSCode(action: customAction): Promise<void> {
@ -412,6 +420,8 @@ class FSPluginClient extends ElectronBasePluginClient {
if (path.startsWith('/')) {
path = path.slice(1)
}
}
path = this.workingDir + (!this.workingDir.endsWith('/') ? '/' : '') + path
return path

@ -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 })

@ -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,6 +657,7 @@ export const cloneRepository = async (url: string) => {
}
export const checkGit = async () => {
try {
const isGitRepo = await plugin.fileManager.isGitRepo()
const hasGitSubmodule = await plugin.fileManager.hasGitSubmodules()
dispatch(setCurrentWorkspaceIsGitRepo(isGitRepo))
@ -659,6 +665,7 @@ export const checkGit = async () => {
await refreshBranches()
const currentBranch = await plugin.call('dGitProvider', 'currentbranch')
dispatch(setCurrentWorkspaceCurrentBranch(currentBranch))
} catch (e) {}
}
export const getRepositoryTitle = async (url: string) => {

@ -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 === '') ? <></> :
<div className="d-flex align-items-baseline">
<CustomTooltip
placement="top"
tooltipId="workspace-name"
tooltipClasses="text-nowrap"
tooltipText={path}
tooltipText={dir}
>
<div>{parsePath(path)}</div>
<div>{parsePath()}</div>
</CustomTooltip>
<CustomTooltip
placement="top"

@ -96,7 +96,7 @@ export const FileSystemProvider = (props: WorkspaceProps) => {
try {
await fetchWorkspaceDirectory(path)
} catch (err) {
console.error(err)
console.warn(err)
}
}

Loading…
Cancel
Save