LianaHus-patch-7
bunsenstraat 11 months ago
parent 03731199ee
commit d71afc9e8c
  1. 2
      apps/remixdesktop/package.json
  2. 22
      apps/remixdesktop/src/plugins/fsPlugin.ts
  3. 4
      libs/remix-ui/workspace/src/lib/actions/index.ts
  4. 27
      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", "name": "remixdesktop",
"version": "0.0.2-Alpha", "version": "0.0.3-Alpha",
"main": "build/main.js", "main": "build/main.js",
"license": "MIT", "license": "MIT",
"type": "commonjs", "type": "commonjs",

@ -21,6 +21,10 @@ const convertPathToPosix = (pathName: string): string => {
return pathName.split(path.sep).join(path.posix.sep) 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 => { const getBaseName = (pathName: string): string => {
return path.basename(pathName) return path.basename(pathName)
} }
@ -207,14 +211,15 @@ class FSPluginClient extends ElectronBasePluginClient {
} }
async getWorkingDir(): Promise<string> { async getWorkingDir(): Promise<string> {
return this.workingDir return convertPathToPosix(this.workingDir)
} }
async watch(): Promise<void> { async watch(): Promise<void> {
try { 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[]) => { this.on('filePanel' as any, 'expandPathChanged', async (paths: string[]) => {
//console.log('expandPathChanged', paths)
this.expandedPaths = ['.', ...paths] // add root this.expandedPaths = ['.', ...paths] // add root
//console.log(Object.keys(this.watchers)) //console.log(Object.keys(this.watchers))
paths = paths.map((path) => this.fixPath(path)) paths = paths.map((path) => this.fixPath(path))
@ -332,7 +337,9 @@ class FSPluginClient extends ElectronBasePluginClient {
async getRecentFolders(): Promise<string[]> { async getRecentFolders(): Promise<string[]> {
const config = await this.call('electronconfig' as any, 'readConfig') 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> { async removeRecentFolder(path: string): Promise<void> {
@ -398,8 +405,9 @@ class FSPluginClient extends ElectronBasePluginClient {
await this.call('fileManager', 'closeAllFiles') await this.call('fileManager', 'closeAllFiles')
} }
async revealInExplorer(action: customAction): Promise<void> { async revealInExplorer(action: customAction, isAbsolutePath: boolean = false): Promise<void> {
shell.showItemInFolder(this.fixPath(action.path[0])) let path = isAbsolutePath? action.path[0] : this.fixPath(action.path[0])
shell.showItemInFolder(convertPathToLocalFileSystem(path))
} }
async openInVSCode(action: customAction): Promise<void> { async openInVSCode(action: customAction): Promise<void> {
@ -412,6 +420,8 @@ class FSPluginClient extends ElectronBasePluginClient {
if (path.startsWith('/')) { if (path.startsWith('/')) {
path = path.slice(1) path = path.slice(1)
} }
} }
path = this.workingDir + (!this.workingDir.endsWith('/') ? '/' : '') + path path = this.workingDir + (!this.workingDir.endsWith('/') ? '/' : '') + path
return path return path

@ -124,10 +124,6 @@ export const initWorkspace = (filePanelPlugin) => async (reducerDispatch: React.
plugin.call('notification', 'toast', `opening ${params.opendir}...`) plugin.call('notification', 'toast', `opening ${params.opendir}...`)
await plugin.call('fs', 'setWorkingDir', 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') const currentPath = await plugin.call('fs', 'getWorkingDir')
dispatch(setCurrentLocalFilePath(currentPath)) dispatch(setCurrentLocalFilePath(currentPath))
plugin.setWorkspace({ name: 'electron', isLocalhost: false }) plugin.setWorkspace({ name: 'electron', isLocalhost: false })

@ -28,6 +28,7 @@ import {
setGitConfig, setGitConfig,
setElectronRecentFolders, setElectronRecentFolders,
setCurrentWorkspaceHasGitSubmodules, setCurrentWorkspaceHasGitSubmodules,
setCurrentLocalFilePath,
} from './payload' } from './payload'
import { addSlash, checkSlash, checkSpecialChars } from '@remix-ui/helper' import { addSlash, checkSlash, checkSpecialChars } from '@remix-ui/helper'
@ -86,7 +87,9 @@ export const setPlugin = (filePanelPlugin, reducerDispatch) => {
await checkGit() 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() await checkGit()
}) })
checkGit() checkGit()
@ -368,7 +371,6 @@ export const fetchWorkspaceDirectory = async (path: string) => {
provider.resolveDirectory(path, (error, fileTree: FileTree) => { provider.resolveDirectory(path, (error, fileTree: FileTree) => {
if (error) { if (error) {
reject(error) reject(error)
console.error(error)
} }
resolve(fileTree) 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 => { export const getWorkspaces = async (): Promise<{ name: string; isGitRepo: boolean; hasGitSubmodules: boolean; branches?: { remote: any; name: string }[]; currentBranch?: string }[]> | undefined => {
console.log('getWorkspaces')
try { try {
const workspaces: { name: string; isGitRepo: boolean; hasGitSubmodules: boolean; branches?: { remote: any; name: string }[]; currentBranch?: string }[] = await new Promise((resolve, reject) => { 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 const workspacesPath = plugin.fileProviders.workspace.workspacesPath
console.log('workspacesPath', workspacesPath)
plugin.fileProviders.browser.resolveDirectory('/' + workspacesPath, (error, items) => { plugin.fileProviders.browser.resolveDirectory('/' + workspacesPath, (error, items) => {
if (error) { if (error) {
return reject(error) return reject(error)
} }
@ -584,6 +588,7 @@ export const getWorkspaces = async (): Promise<{ name: string; isGitRepo: boolea
).then((workspacesList) => resolve(workspacesList)) ).then((workspacesList) => resolve(workspacesList))
}) })
}) })
console.log('workspaces', workspaces)
await plugin.setWorkspaces(workspaces) await plugin.setWorkspaces(workspaces)
return workspaces return workspaces
} catch (e) {} } catch (e) {}
@ -652,13 +657,15 @@ export const cloneRepository = async (url: string) => {
} }
export const checkGit = async () => { export const checkGit = async () => {
const isGitRepo = await plugin.fileManager.isGitRepo() try {
const hasGitSubmodule = await plugin.fileManager.hasGitSubmodules() const isGitRepo = await plugin.fileManager.isGitRepo()
dispatch(setCurrentWorkspaceIsGitRepo(isGitRepo)) const hasGitSubmodule = await plugin.fileManager.hasGitSubmodules()
dispatch(setCurrentWorkspaceHasGitSubmodules(hasGitSubmodule)) dispatch(setCurrentWorkspaceIsGitRepo(isGitRepo))
await refreshBranches() dispatch(setCurrentWorkspaceHasGitSubmodules(hasGitSubmodule))
const currentBranch = await plugin.call('dGitProvider', 'currentbranch') await refreshBranches()
dispatch(setCurrentWorkspaceCurrentBranch(currentBranch)) const currentBranch = await plugin.call('dGitProvider', 'currentbranch')
dispatch(setCurrentWorkspaceCurrentBranch(currentBranch))
} catch (e) {}
} }
export const getRepositoryTitle = async (url: string) => { export const getRepositoryTitle = async (url: string) => {

@ -1,5 +1,7 @@
import { CustomTooltip } from "@remix-ui/helper" import { CustomTooltip } from "@remix-ui/helper"
import React, { MouseEventHandler, useContext, useEffect, useState } from "react" import React from "react"
import path from 'path'
interface ElectronWorkspaceNameProps { interface ElectronWorkspaceNameProps {
path: string path: string
@ -7,29 +9,29 @@ interface ElectronWorkspaceNameProps {
} }
export const ElectronWorkspaceName = (props: ElectronWorkspaceNameProps) => { export const ElectronWorkspaceName = (props: ElectronWorkspaceNameProps) => {
const { path } = props const { path: dir } = props
const parsePath = (path: string) => { const parsePath = () => {
const pathArray = path.split('/') const pathArray = dir.split(path.posix.sep)
return pathArray[pathArray.length - 1] return pathArray[pathArray.length - 1]
} }
const openInExplorer = () => { const openInExplorer = () => {
props.plugin.call('fs', 'revealInExplorer', { props.plugin.call('fs', 'revealInExplorer', {
path path: [dir]
}) }, true)
} }
return ( return (
(path === undefined || path === '') ? <></> : (dir === undefined || dir === '') ? <></> :
<div className="d-flex align-items-baseline"> <div className="d-flex align-items-baseline">
<CustomTooltip <CustomTooltip
placement="top" placement="top"
tooltipId="workspace-name" tooltipId="workspace-name"
tooltipClasses="text-nowrap" tooltipClasses="text-nowrap"
tooltipText={path} tooltipText={dir}
> >
<div>{parsePath(path)}</div> <div>{parsePath()}</div>
</CustomTooltip> </CustomTooltip>
<CustomTooltip <CustomTooltip
placement="top" placement="top"

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

Loading…
Cancel
Save