Skip to content

Commit

Permalink
FIXED: in Windows 'C:' resolved to app folder instead of 'C:\', fixes #…
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
warpdesign committed May 2, 2019
1 parent 4de0906 commit 04b226a
Show file tree
Hide file tree
Showing 9 changed files with 51 additions and 27 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 8 additions & 4 deletions src/components/FileTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -245,14 +245,18 @@ export class FileTableClass extends React.Component<IProps, IState> {
_noRowsRenderer = () => {
const { t } = this.injected;

return (<div className="empty"><Icon icon="tick-circle" iconSize={40} />{t('COMMON.EMPTY_FOLDER')}</div>);
// we don't want to show empty + loader at the same time
if (this.cache.status !== 'busy') {
return (<div className="empty"><Icon icon="tick-circle" iconSize={40} />{t('COMMON.EMPTY_FOLDER')}</div>);
} else {
return (<div />);
}
}

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);
}
Expand Down
5 changes: 4 additions & 1 deletion src/components/TabList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,11 @@ class TabListClass extends React.Component<InjectedProps> {
{
caches.map((cache, index) => {
const closeIcon = cache.isVisible && caches.length > 1 && <Icon iconSize={12} htmlTitle={t('TABS.CLOSE')} className="closetab" intent="warning" onClick={this.closeTab.bind(this, index)} icon="cross"></Icon>;
const path = cache.path;
const tabInfo = cache.getFS().displaypath(path);
console.log('**tab', tabInfo);
return (
<Button key={"" + viewId + index} onClick={this.selectTab.bind(this, index)} title={cache.path} intent={cache.isVisible ? "primary" : "none"} rightIcon={closeIcon}>{cache.path.split('/').slice(-1)[0]}</Button>
<Button key={"" + viewId + index} onClick={this.selectTab.bind(this, index)} title={tabInfo.fullPath} intent={cache.isVisible ? "primary" : "none"} rightIcon={closeIcon}>{tabInfo.shortPath}</Button>
)
})
}
Expand Down
17 changes: 2 additions & 15 deletions src/components/Toolbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -382,25 +382,13 @@ export class ToolbarClass extends React.Component<IProps, PathInputState> {
<p>{t('TOOLTIP.PATH.TITLE2')}</p>
<ul>
<li>{localExample}/</li>
<li>{t('TOOLTIP.PATH.FTP1')}</li>
<li>{t('TOOLTIP.PATH.FTP2')}</li>
{/* <li>{t('TOOLTIP.PATH.FTP1')}</li>
<li>{t('TOOLTIP.PATH.FTP2')}</li> */}
</ul>
</div>
)
}

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;
Expand All @@ -418,7 +406,6 @@ export class ToolbarClass extends React.Component<IProps, PathInputState> {
return (
<ControlGroup>
<ButtonGroup style={{ minWidth: 120 }}>
{/* <Button text="stat" onClick={this.testStat}></Button> */}
<Button data-cy-backward disabled={!canGoBackward} onClick={this.onBackward} rightIcon="chevron-left"></Button>
<Button data-cy-forward disabled={!canGoForward} onClick={this.onForward} rightIcon="chevron-right"></Button>
<Popover content={<FileMenu selectedItems={selected} onFileAction={this.onFileAction} />}>
Expand Down
1 change: 1 addition & 0 deletions src/services/Fs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 8 additions & 0 deletions src/services/plugins/FsFtp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
8 changes: 8 additions & 0 deletions src/services/plugins/FsGeneric.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
17 changes: 11 additions & 6 deletions src/services/plugins/FsLocal.ts
Original file line number Diff line number Diff line change
@@ -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)
Expand Down Expand Up @@ -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 {
Expand All @@ -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 {
Expand All @@ -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
}
8 changes: 8 additions & 0 deletions src/services/plugins/FsSimpleFtp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

0 comments on commit 04b226a

Please sign in to comment.