From 04b226a86dce60ca4f45ce66668283f74a4e5b0c Mon Sep 17 00:00:00 2001 From: warpdesign Date: Thu, 2 May 2019 11:10:24 +0200 Subject: [PATCH] FIXED: in Windows 'C:' resolved to app folder instead of 'C:\', fixes #30 FIXED: one more selection problem (Windows) IMPROVED: do not show "empty" placeholder when file table is empty because cache is loading ADDED: new FS.displaypath() that returns path to display in tab/tab title REMOVED: FTP samples from path tooltip since FTP plugin is disabled for now --- README.md | 2 +- src/components/FileTable.tsx | 12 ++++++++---- src/components/TabList.tsx | 5 ++++- src/components/Toolbar.tsx | 17 ++--------------- src/services/Fs.ts | 1 + src/services/plugins/FsFtp.ts | 8 ++++++++ src/services/plugins/FsGeneric.ts | 8 ++++++++ src/services/plugins/FsLocal.ts | 17 +++++++++++------ src/services/plugins/FsSimpleFtp.ts | 8 ++++++++ 9 files changed, 51 insertions(+), 27 deletions(-) diff --git a/README.md b/README.md index 80f44774..c306093e 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,7 @@ This will build a development package. In order to run in locally without having to create a native executable, you can then type: ```shell -npx electron ./dist/main.js +npx electron ./build/main.js ``` ## Building binary packages diff --git a/src/components/FileTable.tsx b/src/components/FileTable.tsx index d82281b4..9d1b3d15 100644 --- a/src/components/FileTable.tsx +++ b/src/components/FileTable.tsx @@ -245,14 +245,18 @@ export class FileTableClass extends React.Component { _noRowsRenderer = () => { const { t } = this.injected; - return (
{t('COMMON.EMPTY_FOLDER')}
); + // we don't want to show empty + loader at the same time + if (this.cache.status !== 'busy') { + return (
{t('COMMON.EMPTY_FOLDER')}
); + } else { + return (
); + } } private updateNodes(files: File[]) { - // we want to keep selected files when updating the cache - const keepSelection = files.length && this.state.path === files[0].dir; + // reselect previously selected file in case of reload/change tab + const keepSelection = !!this.cache.selected.length; console.log('got files', files.length); - // console.time('building nodes'); const nodes = this.buildNodes(files, keepSelection); this.updateState(nodes, keepSelection); } diff --git a/src/components/TabList.tsx b/src/components/TabList.tsx index 65a7c24c..35dd539f 100644 --- a/src/components/TabList.tsx +++ b/src/components/TabList.tsx @@ -54,8 +54,11 @@ class TabListClass extends React.Component { { caches.map((cache, index) => { const closeIcon = cache.isVisible && caches.length > 1 && ; + const path = cache.path; + const tabInfo = cache.getFS().displaypath(path); + console.log('**tab', tabInfo); return ( - + ) }) } diff --git a/src/components/Toolbar.tsx b/src/components/Toolbar.tsx index c26c5400..8a4a4bb6 100644 --- a/src/components/Toolbar.tsx +++ b/src/components/Toolbar.tsx @@ -382,25 +382,13 @@ export class ToolbarClass extends React.Component {

{t('TOOLTIP.PATH.TITLE2')}

  • {localExample}/
  • -
  • {t('TOOLTIP.PATH.FTP1')}
  • -
  • {t('TOOLTIP.PATH.FTP2')}
  • + {/*
  • {t('TOOLTIP.PATH.FTP1')}
  • +
  • {t('TOOLTIP.PATH.FTP2')}
  • */}
) } - testStat = () => { - const { appState, viewState } = this.injected; - const fileCache = viewState.getVisibleCache(); - - if (appState.getActiveCache() === fileCache && fileCache.selected.length) { - const file = fileCache.selected[0]; - const path = fileCache.getAPI().join(file.dir, file.fullname); - debugger; - fileCache.exists(path); - } - } - public render() { const { status, path, isOpen, isDeleteOpen, isTooltipOpen } = this.state; const { viewState } = this.injected; @@ -418,7 +406,6 @@ export class ToolbarClass extends React.Component { return ( - {/* */} }> diff --git a/src/services/Fs.ts b/src/services/Fs.ts index be901e6b..bdfbbe37 100644 --- a/src/services/Fs.ts +++ b/src/services/Fs.ts @@ -28,6 +28,7 @@ export interface Fs { canread(str: string): boolean; serverpart(str: string): string; credentials(str: string): ICredentials; + displaypath(str: string): { fullPath: string, shortPath: string }; name: string; description: string; icon: string; diff --git a/src/services/plugins/FsFtp.ts b/src/services/plugins/FsFtp.ts index 8d683555..ced65d0f 100644 --- a/src/services/plugins/FsFtp.ts +++ b/src/services/plugins/FsFtp.ts @@ -773,5 +773,13 @@ export const FsFtp: Fs = { user: info.username }; }, + displaypath(str: string) { + const info = new URL(str); + const split = info.pathname.split('/'); + return { + fullPath: str, + shortPath: split.slice(-1)[0] || '/' + }; + }, API: FtpAPI } diff --git a/src/services/plugins/FsGeneric.ts b/src/services/plugins/FsGeneric.ts index 64456874..7a4d4d2b 100644 --- a/src/services/plugins/FsGeneric.ts +++ b/src/services/plugins/FsGeneric.ts @@ -151,5 +151,13 @@ export const FsGeneric: Fs = { port: 0 }; }, + displaypath(str: string) { + return { + // full path, display in the tab's tooltip + fullPath: str, + // short path, as displayed in the tab + shortPath: str + }; + }, API: GenericApi } diff --git a/src/services/plugins/FsLocal.ts b/src/services/plugins/FsLocal.ts index e255a3a5..5828e112 100644 --- a/src/services/plugins/FsLocal.ts +++ b/src/services/plugins/FsLocal.ts @@ -1,17 +1,17 @@ import { FsApi, File, ICredentials, Fs, Parent, filetype } from '../Fs'; import * as fs from 'fs'; import * as path from 'path'; -import * as process from 'process'; import * as mkdir from 'mkdirp'; import * as del from 'del'; import { size } from '../../utils/size'; import { throttle } from '../../utils/throttle'; const { Transform } = require('stream'); -import { isWin } from '../../utils/platform'; -import { LocalWatch, WatcherCB } from './LocalWatch'; +import { isWin, lineEnding } from '../../utils/platform'; +import { LocalWatch } from './LocalWatch'; const invalidDirChars = isWin && /[\*:<>\?|"]+/ig || /^[\.]+[\/]+(.)*$/ig; const invalidFileChars = isWin && /[\*:<>\?|"]+/ig || /\//; +const SEP = path.sep; // Since nodeJS will translate unix like paths to windows path, when running under Windows // we accept Windows style paths (eg. C:\foo...) and unix paths (eg. /foo or ./foo) @@ -336,7 +336,7 @@ class LocalApi implements FsApi { } sanityze(path: string) { - return path; + return isWin ? (path.match(/\\$/) ? path : path + '\\') : path; } on(event: string, cb: (data: any) => void): void { @@ -361,8 +361,6 @@ export const FsLocal: Fs = { return !!str.match(localStart); }, serverpart(str: string): string { - // const server = str.replace(/^ftp\:\/\//, ''); - // return server.split('/')[0]; return 'local'; }, credentials(str: string): ICredentials { @@ -372,5 +370,12 @@ export const FsLocal: Fs = { port: 0 }; }, + displaypath(str: string) { + const split = str.split(SEP); + return { + fullPath: str, + shortPath: split.slice(-1)[0] || str + }; + }, API: LocalApi } diff --git a/src/services/plugins/FsSimpleFtp.ts b/src/services/plugins/FsSimpleFtp.ts index 84b83842..65e2d502 100644 --- a/src/services/plugins/FsSimpleFtp.ts +++ b/src/services/plugins/FsSimpleFtp.ts @@ -464,5 +464,13 @@ export const FsSimpleFtp: Fs = { user: info.username }; }, + displaypath(str: string) { + const info = new URL(str); + const split = info.pathname.split('/'); + return { + fullPath: str, + shortPath: split.slice(-1)[0] || '/' + }; + }, API: SimpleFtpApi }