feature(cloudcmd) deprecate --one-panel-mode in favour --one-file-panel

This commit is contained in:
coderaiser 2018-04-10 11:45:52 +03:00
parent 697df5846f
commit 9963577a65
13 changed files with 94 additions and 37 deletions

22
HELP.md
View file

@ -85,7 +85,9 @@ Cloud Commander supports command line parameters:
| `--html-dialogs` | use html dialogs
| `--open` | open web browser when server started
| `--name` | set tab name in web browser
| `--one-panel-mode` | set one panel mode
| `--one-panel-mode` | show one file panel (**deprecated**: use `--one-file-panel` instead)
| `--one-file-panel` | show one file panel
| `--keys-panel` | show keys panel
| `--contact` | enable contact
| `--config-dialog` | enable config dialog
| `--console` | enable console
@ -93,7 +95,6 @@ Cloud Commander supports command line parameters:
| `--terminal` | enable terminal
| `--terminal-path` | set terminal path
| `--vim` | enable vim hot keys
| `--keys-panel` | show keys panel
| `--columns` | set visible columns
| `--cache` | enable cache
| `--no-server` | do not start server
@ -101,7 +102,9 @@ Cloud Commander supports command line parameters:
| `--no-online` | load scripts from local server
| `--no-open` | do not open web browser when server started
| `--no-name` | set empty tab name in web browser
| `--no-one-panel-mode` | unset one panel mode
| `--no-one-file-panel` | show two file panels
| `--no-one-panel-mode` | show two file panels (**deprecated**: use `--no-one-file-panel` instead)
| `--no-keys-panel` | hide keys panel
| `--no-progress` | do not show progress of file operations
| `--no-confirm-copy` | do not confirm copy
| `--no-confirm-move` | do not confirm move
@ -112,7 +115,6 @@ Cloud Commander supports command line parameters:
| `--no-sync-console-path` | do not sync console path
| `--no-terminal` | disable terminal
| `--no-vim` | disable vim hot keys
| `--no-keys-panel` | hide keys panel
| `--no-columns` | set visible default columns
| `--no-cache` | disable cache
@ -368,6 +370,8 @@ Here is description of options:
"online" : true, /* load js files from cdn or local path */
"open" : false /* open web browser when server started */
"cache" : true, /* enable cache */
"onePanelMode" : false, /* show one file panel (deprecated) */
"oneFilePanel" : false, /* show one file panel */
"keysPanel" : true, /* show classic panel with buttons of keys */
"port" : 8000, /* http port */
"ip" : null, /* ip or null(default) */
@ -378,7 +382,6 @@ Here is description of options:
"confirmMove" : true, /* confirm move */
"htmlDialogs" : true, /* use html dialogs */
"showConfig" : false, /* show config at startap */
"onePanelMode" : false, /* set one panel mode */
"contact" : true, /* enable contact */
"configDialog" : true, /* enable config dialog */
"console" : true, /* enable console */
@ -405,11 +408,12 @@ Some config options can be overridden with `environment variables` such:
- `CLOUDCMD_TERMINAL_PATH` - set terminal path
- `CLOUDCMD_CONFIG_DIALOG` - enable config dialog
- `CLOUDCMD_KEYS_PANEL` - show keys panel
- `CLOUDCMD_ONE_PANEL_MODE` - show one file panel (**deprecated**: use `CLOUDCMD_ONE_FILE_PANEL` instead)
- `CLOUDCMD_ONE_FILE_PANEL` - show one file panel
- `CLOUDCMD_AUTH` - enable authentication
- `CLOUDCMD_USERNAME` - set username
- `CLOUDCMD_PASSWORD` - set password
- `CLOUDCMD_ROOT` - set root directory
- `CLOUDCMD_ONE_PANEL_MODE` - set one panel mode
- `CLOUDCMD_VIM` - enable vim hot keys
- `CLOUDCMD_CONFIRM_COPY` - confirm copy
- `CLOUDCMD_CONFIRM_MOVE` - confirm move
@ -445,12 +449,12 @@ Right mouse click button shows context menu with items:
| `F9` | open
| `Esc` | close
One panel mode
One file panel
---------------
Cloud Commander could work in one panel mode when screen size can not accommodate second panel or via `--one-panel-mode` options flag.
Cloud Commander can work in one panel mode when screen size can not accommodate second panel or via `--one-file-panel` options flag.
It could happen when mobile device, tablet or small window size used to work with file manager.
![One panel mode](/img/screen/one-panel-mode.png "One panel mode")
![One file panel](/img/screen/one-file-panel.png "One file panel")
Using as Middleware
---------------

View file

@ -57,6 +57,11 @@
"value": "false",
"required": false
},
"CLOUDCMD_ONE_FILE_PANEL": {
"description": "show one file panel",
"value": "false",
"required": false
},
"CLOUDCMD_KEYS_PANEL": {
"description": "show keys panel",
"value": "true",
@ -88,6 +93,11 @@
"required": false
},
"CLOUDCMD_ONE_PANEL_MODE": {
"description": "set one panel mode (deprecated use CLOUDCMD_ONE_FILE_PANEL)",
"value": "false",
"required": false
},
"CLOUDCMD_ONE_FILE_PANEL": {
"description": "set one panel mode",
"value": "false",
"required": false

View file

@ -2,6 +2,9 @@
'use strict';
const util = require('util');
const noop = () => {};
const Info = require('../package');
const DIR_SERVER = '../server/';
@ -45,6 +48,7 @@ const args = require('minimist')(argv.slice(2), {
'sync-console-path',
'contact',
'terminal',
'one-file-panel',
'one-panel-mode',
'confirm-copy',
'confirm-move',
@ -75,7 +79,8 @@ const args = require('minimist')(argv.slice(2), {
'sync-console-path': choose(env.bool('sync_console_path'), config('syncConsolePath')),
'config-dialog': choose(env.bool('config_dialog'), config('configDialog')),
'terminal-path': env('terminal_path') || config('terminalPath'),
'one-panel-mode': choose(env.bool('one_panel_mode'), config('onePanelMode')),
'one-file-panel': choose(env.bool('one_file_panel'), config('onePanelMode')),
'one-panel-mode': '',
'confirm-copy': choose(env.bool('confirm_copy'), config('confirmCopy')),
'confirm-move': choose(env.bool('confirm_move'), config('confirmMove')),
'html-dialogs': config('htmlDialogs'),
@ -133,10 +138,27 @@ function main() {
config('htmlDialogs', args['html-dialogs']);
config('confirmCopy', args['confirm-copy']);
config('confirmMove', args['confirm-move']);
config('onePanelMode', args['one-panel-mode']);
config('onePanelMode', args['one-file-panel']);
config('oneFilePanel', args['one-file-panel']);
config('configDialog', args['config-dialog']);
config('keysPanel', args['keys-panel']);
if (args['one-panel-mode']) {
util.deprecate(noop, `cloudcmd --one-panel-mode: deprecated, use --one-file-panel instead`, 'DP0001')();
config('oneFilePanel', true);
config('onePanelMode', true);
} else if (typeof args['one-panel-mode'] === 'boolean') {
util.deprecate(noop, `cloudcmd --no-one-panel-mode: deprecated, use --no-one-file-panel instead`, 'DP0001')();
config('oneFilePanel', false);
config('onePanelMode', false);
}
if (typeof env.bool('one_panel_mode') === 'boolean') {
util.deprecate(noop, `CLOUDCMD_ONE_PANEL_MODE deprecated, use CLOUDCMD_ONE_FILE_PANEL instead`, 'DP0001')();
config('oneFilePanel', env.bool('one_panel_mode'));
config('onePanelMode', env.bool('one_panel_mode'));
}
readConfig(args.config);
const options = {

View file

Before

Width:  |  Height:  |  Size: 26 KiB

After

Width:  |  Height:  |  Size: 26 KiB

Before After
Before After

View file

@ -26,6 +26,7 @@
"confirmMove": true,
"configDialog": true,
"onePanelMode": false,
"oneFilePanel": false,
"console": true,
"syncConsolePath": false,
"terminal": false,

View file

@ -19,7 +19,9 @@
"--html-dialogs ": "use html dialogs",
"--open ": "open web browser when server started",
"--name ": "set tab name in web browser",
"--one-panel-mode ": "set one panel mode",
"--one-panel-mode ": "show one file panel (deprecated use --one-file-panel instead)",
"--one-file-panel ": "show one file panel",
"--keys-panel ": "show keys panel",
"--config-dialog ": "enable config dialog",
"--console ": "enable console",
"--sync-console-path ": "sync console path",
@ -28,14 +30,15 @@
"--terminal-path ": "set terminal path",
"--vim ": "enable vim hot keys",
"--columns ": "set visible columns",
"--keys-panel ": "show keys panel",
"--cache ": "enable cache",
"--no-server ": "do not start server",
"--no-auth ": "disable authorization",
"--no-online ": "load scripts from local server",
"--no-open ": "do not open web browser when server started",
"--no-name ": "set default tab name in web browser",
"--no-one-panel-mode ": "unset one panel mode",
"--no-one-panel ": "show two file panels",
"--no-keys-panel ": "hide keys panel",
"--no-one-file-panel ": "show two file panels",
"--no-progress ": "do not show progress of file operations",
"--no-confirm-copy ": "do not confirm copy",
"--no-confirm-move ": "do not confirm move",
@ -46,7 +49,6 @@
"--no-contact ": "disable contact",
"--no-terminal ": "disable terminal",
"--no-vim ": "disable vim hot keys",
"--no-keys-panel ": "hide keys panel",
"--no-columns ": "set default visible columns",
"--no-cache ": "disable cache"
}

View file

@ -42,23 +42,25 @@ programs in browser from any computer, mobile or tablet device.
--html-dialogs use html dialogs
--open open web browser when server started
--name set tab name in web browser
--one-panel-mode set one panel mode
--one-panele-mode show one file panel (deprecated use --one-file-panel instead)
--one-file-panele show one file panel
--keys-panel show keys panel
--contact enable contact
--config-dialog enable config dialog
--console enable console
--sync-console-path sync console path
--sync-console-path sync console path
--terminal enable terminal
--terminal-path set terminal path
--vim enable vim hot keys
--columns set visible columns
--keys-panel show keys panel
--cache enable cache
--no-auth disable authorization
--no-server do not start server
--no-online load scripts from local server
--no-open do not open web browser when server started
--no-name set default tab name in web browser
--no-one-panel-mode unset one panel mode
--no-one-file-panel show two file panels
--no-keys-panel hide keys panel
--no-progress do not show progress of file operations
--no-confirm-copy do not confirm copy
--no-confirm-move do not confirm move
@ -70,7 +72,6 @@ programs in browser from any computer, mobile or tablet device.
--no-terminal disable terminal
--no-vim disable vim hot keys
--no-columns set visible default columns
--no-keys-panel hide keys panel
--no-cache disable cache
.SH RESOURCES AND DOCUMENTATION

View file

@ -4,6 +4,8 @@ const DIR = __dirname + '/';
const DIR_ROOT = DIR + '../';
const DIR_COMMON = DIR + '../common/';
const util = require('util');
const cloudfunc = require(DIR_COMMON + 'cloudfunc');
const authentication = require(DIR + 'auth');
const config = require(DIR + 'config');
@ -37,6 +39,14 @@ const clean = (a) => a.filter(notEmpty);
const isDev = process.env.NODE_ENV === 'development';
const deprecateOnePanelMode = (value) => {
const noop = () => {};
util.deprecate(noop, 'onePanelMode is deprecated, use oneFilePanel instead', 'DP0001')();
config('oneFilePanel', value);
};
module.exports = (params) => {
const p = params || {};
const options = p.config || {};
@ -50,7 +60,11 @@ module.exports = (params) => {
keys.forEach((name) => {
const value = options[name];
if (/root|editor|packer|columns/.test(name))
if (name === 'onePanelMode')
deprecateOnePanelMode();
else if (name === 'oneFilePanel')
config('onePanelMode', value);
else if (/root|editor|packer|columns/.test(name))
validate[name](value);
config(name, value);

View file

@ -7,6 +7,9 @@ module.exports = parse;
module.exports.bool = (name) => {
const value = parse(name);
if (value === 'true')
return true;
if (value === 'false')
return false;

View file

@ -41,7 +41,7 @@ module.exports._getIndexPath = getIndexPath;
* additional processing of index file
*/
function indexProcessing(options) {
const isOnePanel = config('onePanelMode');
const oneFilePanel = config('onePanelMode');
const noContact = !config('contact');
const noConfig = !config('configDialog');
const noConsole = !config('console');
@ -53,7 +53,7 @@ function indexProcessing(options) {
if (!config('keysPanel'))
data = hideKeysPanel(data);
if (isOnePanel)
if (oneFilePanel)
data = data
.replace('icon-move', 'icon-move none')
.replace('icon-copy', 'icon-copy none');
@ -77,11 +77,11 @@ function indexProcessing(options) {
const left = rendy(Template.panel, {
side : 'left',
content : panel,
className : !isOnePanel ? '' : 'panel-single'
className : !oneFilePanel ? '' : 'panel-single'
});
let right = '';
if (!isOnePanel)
if (!oneFilePanel)
right = rendy(Template.panel, {
side : 'right',
content : panel,

View file

@ -19,18 +19,18 @@ test('env: big', (t) => {
t.end();
});
test('env: bool', (t) => {
test('env: bool: false', (t) => {
process.env.cloudcmd_terminal = 'false';
t.notOk(env.bool('terminal'), 'should return false');
t.equal(env.bool('terminal'), false, 'should return false');
delete process.env.cloudcmd_terminal;
t.end();
});
test('env: bool', (t) => {
test('env: bool: true', (t) => {
process.env.cloudcmd_terminal = 'true';
t.ok(env.bool('terminal'), 'should be true');
t.equal(env.bool('terminal'), true, 'should be true');
delete process.env.cloudcmd_terminal;
t.end();

View file

@ -113,7 +113,7 @@ test('cloudcmd: route: buttons: no contact', async (t) => {
test('cloudcmd: route: buttons: one panel mode: move', async (t) => {
const config = {
onePanelMode: true
oneFilePanel: true
};
const {port, done} = await connect({config});
@ -127,7 +127,7 @@ test('cloudcmd: route: buttons: one panel mode: move', async (t) => {
test('cloudcmd: route: buttons: one panel mode: move', async (t) => {
const config = {
onePanelMode: true
oneFilePanel: true
};
const {port, done} = await connect({config});

View file

@ -105,6 +105,12 @@
Cache
</label>
</li>
<li>
<label>
<input data-name="js-onePanelMode" type="checkbox" {{ onePanelMode }}>
One Panel Mode
</label>
</li>
<li>
<label>
<input data-name="js-keysPanel" type="checkbox" {{ keysPanel }}>
@ -162,12 +168,6 @@
HTML Dialogs
</label>
</li>
<li>
<label>
<input data-name="js-onePanelMode" type="checkbox" {{ onePanelMode }}>
One Panel Mode
</label>
</li>
<li>
<label>
<input data-name="js-syncConsolePath" type="checkbox" {{ syncConsolePath }}>