diff --git a/HELP.md b/HELP.md index a0f8becf..ca426c84 100644 --- a/HELP.md +++ b/HELP.md @@ -80,6 +80,7 @@ Cloud Commander supports command line parameters: | `--prefix` | set url prefix | `--port` | set port number | `--progress` | show progress of file operations +| `--confirm-copy` | confirm copy | `--html-dialogs` | use html dialogs | `--open` | open web browser when server started | `--name` | set tab name in web browser @@ -97,6 +98,7 @@ Cloud Commander supports command line parameters: | `--no-name` | set empty tab name in web browser | `--no-one-panel-mode` | unset one panel mode | `--no-progress` | do not show progress of file operations +| `--no-confirm-copy` | do not confirm copy | `--no-html-dialogs` | do not use html dialogs | `--no-contact` | disable contact | `--no-config-dialog` | disable config dialog @@ -363,6 +365,7 @@ Here is description of options: "root" : "/", /* root directory */ "prefix" : "", /* url prefix */ "progress" : true, /* show progress of file operations */ + "confirmCopy" : true, /* confirm copy */ "htmlDialogs" : true, /* use html dialogs */ "onePanelMode" : false, /* set one panel mode */ "contact" : true, /* enable contact */ @@ -391,6 +394,7 @@ Some config options can be overridden with `environment variables` such: - `CLOUDCMD_ROOT` - set root directory - `CLOUDCMD_ONE_PANEL_MODE` - set one panel mode - `CLOUDCMD_VIM` - enable vim hot keys +- `CLOUDCMD_CONFIRM_COPY` - confirm copy Menu --------------- diff --git a/app.json b/app.json index c9c2a4a4..2ee3916f 100644 --- a/app.json +++ b/app.json @@ -81,6 +81,11 @@ "description": "enable vim hot keys", "value": "false", "required": false + }, + "CLOUDCMD_CONFIRM_COPY": { + "description": "confirm copy", + "value": "true", + "required": false } } } diff --git a/bin/cloudcmd.js b/bin/cloudcmd.js index a3ebce51..937cb583 100755 --- a/bin/cloudcmd.js +++ b/bin/cloudcmd.js @@ -43,6 +43,7 @@ const args = require('minimist')(argv.slice(2), { 'contact', 'terminal', 'one-panel-mode', + 'confirm-copy', 'html-dialogs', 'show-config', 'vim', @@ -65,9 +66,10 @@ const args = require('minimist')(argv.slice(2), { contact : choose(env.bool('contact'), config('contact')), terminal : choose(env.bool('terminal'), config('terminal')), - 'terminal-path': env('terminal_path') || config('terminalPath'), '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')), + 'confirm-copy': choose(env.bool('confirm_copy'), config('confirmCopy')), 'html-dialogs': config('htmlDialogs'), 'vim': choose(env.bool('vim'), config('vim')), }, @@ -116,6 +118,7 @@ function main() { config('root', args.root); config('vim', args.vim); config('htmlDialogs', args['html-dialogs']); + config('confirmCopy', args['confirm-copy']); config('onePanelMode', args['one-panel-mode']); config('configDialog', args['config-dialog']); diff --git a/client/modules/operation/index.js b/client/modules/operation/index.js index 6d50f57f..b11e5416 100644 --- a/client/modules/operation/index.js +++ b/client/modules/operation/index.js @@ -38,6 +38,7 @@ function OperationProto(operation, data) { const Info = DOM.CurrentInfo; const showLoad = Images.show.load.bind(null, 'top'); const Operation = this; + const processFiles = currify(_processFiles); function init() { showLoad(); @@ -278,13 +279,13 @@ function OperationProto(operation, data) { } }; - this.copy = (data) => { - processFiles(data, copyFn, message('Copy')); - }; + this.copy = processFiles(copyFn, { + type: 'copy', + }); - this.move = (data) => { - processFiles(data, moveFn, message('Rename/Move')); - }; + this.move = processFiles(moveFn, { + type: 'move' + }); this.delete = () => { promptDelete(); @@ -398,17 +399,17 @@ function OperationProto(operation, data) { * @param data * @param operation */ - function processFiles(data, operation, message) { - var name, selFiles, files, - panel, - shouldAsk, - sameName, - ok, - - from = '', - to = '', - - names = []; + function _processFiles(operation, options, data) { + let name, selFiles, files; + let panel; + let shouldAsk; + let sameName; + let ok; + + let from = ''; + let to = ''; + + let names = []; if (data) { from = data.from; @@ -435,8 +436,14 @@ function OperationProto(operation, data) { if (name === '..') return Dialog.alert.noFiles(TITLE); - if (shouldAsk) - return message(to, names).then(ask); + const {type} = options; + + if (shouldAsk && config(type)) { + const isCopy = type === 'copy'; + const title = isCopy ? 'Copy' : 'Rename/Move'; + + return message(title, to, names).then(ask); + } ask(to); @@ -543,24 +550,22 @@ function OperationProto(operation, data) { }); } - function message(msg) { - return (to, names) => { - const n = names.length; - const name = names[0]; - - msg += ' '; - - if (names.length > 1) - msg += n + ' file(s)'; - else - msg += '"' + name + '"'; - - msg += ' to'; - - const cancel = false; - - return Dialog.prompt(TITLE, msg, to, {cancel}); - }; + function message(msg, to, names) { + const n = names.length; + const name = names[0]; + + msg += ' '; + + if (names.length > 1) + msg += n + ' file(s)'; + else + msg += '"' + name + '"'; + + msg += ' to'; + + const cancel = false; + + return Dialog.prompt(TITLE, msg, to, {cancel}); } function load(callback) { diff --git a/json/config.json b/json/config.json index dbdb36eb..332fbd79 100644 --- a/json/config.json +++ b/json/config.json @@ -22,6 +22,7 @@ "progress": true, "htmlDialogs": true, "contact": true, + "confirmCopy": true, "configDialog": true, "onePanelMode": false, "console": true, diff --git a/json/help.json b/json/help.json index 8c1f27af..e74075a7 100644 --- a/json/help.json +++ b/json/help.json @@ -14,6 +14,7 @@ "--prefix ": "set url prefix", "--port ": "set port number", "--progress ": "show progress of file operations", + "--confirm-copy ": "confirm copy", "--html-dialogs ": "use html dialogs", "--open ": "open web browser when server started", "--name ": "set tab name in web browser", @@ -31,6 +32,7 @@ "--no-name ": "set default tab name in web browser", "--no-one-panel-mode ": "unset one panel mode", "--no-progress ": "do not show progress of file operations", + "--no-confirm-copy ": "do not confirm copy", "--no-html-dialogs ": "do not use html dialogs", "--no-config-dialog ": "disable config dialog", "--no-console ": "disable console", diff --git a/man/cloudcmd.1 b/man/cloudcmd.1 index 831a8778..286fcc70 100644 --- a/man/cloudcmd.1 +++ b/man/cloudcmd.1 @@ -37,6 +37,7 @@ programs in browser from any computer, mobile or tablet device. --prefix set url prefix --port set port number --progress show progress of file operations + --confirm-copy confirm copy --html-dialogs use html dialogs --open open web browser when server started --name set tab name in web browser @@ -54,6 +55,7 @@ programs in browser from any computer, mobile or tablet device. --no-name set default tab name in web browser --no-one-panel-mode unset one panel mode --no-progress do not show progress of file operations + --no-confirm-copy do not confirm copy --no-html-dialogs do not use html dialogs --no-contact disable contact --no-config-dialog disable config dialog diff --git a/tmpl/config.hbs b/tmpl/config.hbs index 02f49b39..cce7f912 100644 --- a/tmpl/config.hbs +++ b/tmpl/config.hbs @@ -128,6 +128,12 @@ value="{{ port }}" placeholder="Port" class="form-control"> + +