From 8379a4a9bff7a3c250c13d90488a8e8a1e0f44c5 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Tue, 16 Oct 2018 13:12:55 +0300 Subject: [PATCH] feature(config) add ability to remove auth change from config with help of --config-auth flag --- .yaspellerrc | 1 + HELP.md | 4 ++++ app.json | 5 +++++ bin/cloudcmd.js | 3 +++ client/modules/config.js | 20 +++++++++++--------- json/config.json | 1 + json/help.json | 2 ++ now.json | 3 ++- tmpl/config.hbs | 6 +++--- 9 files changed, 32 insertions(+), 13 deletions(-) diff --git a/.yaspellerrc b/.yaspellerrc index 559f677f..582fabab 100644 --- a/.yaspellerrc +++ b/.yaspellerrc @@ -26,6 +26,7 @@ "Termux", "Zalitok", "WebSocket", + "auth", "cd", "cloudcmd", "coderaiser", diff --git a/HELP.md b/HELP.md index 39f70b05..1f37ee16 100644 --- a/HELP.md +++ b/HELP.md @@ -91,6 +91,7 @@ Cloud Commander supports command line parameters: | `--keys-panel` | show keys panel | `--contact` | enable contact | `--config-dialog` | enable config dialog +| `--config-auth` | enable auth change in config dialog | `--console` | enable console | `--sync-console-path` | sync console path | `--terminal` | enable terminal @@ -118,6 +119,7 @@ Cloud Commander supports command line parameters: | `--no-confirm-copy` | do not confirm copy | `--no-confirm-move` | do not confirm move | `--no-config-dialog` | disable config dialog +| `--no-config-auth` | disable auth change in config dialog | `--no-console` | disable console | `--no-sync-console-path` | do not sync console path | `--no-contact` | disable contact @@ -397,6 +399,7 @@ Here is description of options: "showFileName" : false /* do not show file name in view and edit */ "contact" : true, /* enable contact */ "configDialog" : true, /* enable config dialog */ + "configAuth" : true, /* enable auth change in config dialog */ "console" : true, /* enable console */ "syncConsolePath" : false /* do not sync console path */ "terminal" : false, /* disable terminal */ @@ -425,6 +428,7 @@ Some config options can be overridden with `environment variables` such: - `CLOUDCMD_COLUMNS` - set visible columns - `CLOUDCMD_CONTACT` - enable contact - `CLOUDCMD_CONFIG_DIALOG` - enable config dialog +- `CLOUDCMD_CONFIG_AUTH` - enable auth change in config dialog - `CLOUDCMD_CONSOLE` - enable console - `CLOUDCMD_SYNC_CONSOLE_PATH` - sync console path - `CLOUDCMD_TERMINAL` - enable terminal diff --git a/app.json b/app.json index 16d00e8e..9072f44d 100644 --- a/app.json +++ b/app.json @@ -32,6 +32,11 @@ "value": "false", "required": false }, + "CLOUDCMD_CONFIG_AUTH": { + "description": "disable auth change in config dialog", + "value": "false", + "required": false + }, "CLOUDCMD_CONSOLE": { "description": "enable console", "value": "true", diff --git a/bin/cloudcmd.js b/bin/cloudcmd.js index 6a0b0571..85e2f1d4 100755 --- a/bin/cloudcmd.js +++ b/bin/cloudcmd.js @@ -52,6 +52,7 @@ const args = require('minimist')(argv.slice(2), { 'open', 'progress', 'config-dialog', + 'config-auth', 'console', 'sync-console-path', 'contact', @@ -99,6 +100,7 @@ const args = require('minimist')(argv.slice(2), { 'show-file-name': choose(env.bool('show_file_name'), config('showFileName')), 'sync-console-path': choose(env.bool('sync_console_path'), config('syncConsolePath')), 'config-dialog': choose(env.bool('config_dialog'), config('configDialog')), + 'config-auth': choose(env.bool('config_auth'), config('configAuth')), 'terminal-path': env('terminal_path') || config('terminalPath'), 'terminal-command': env('terminal_command') || config('terminalCommand'), 'terminal-auto-restart': choose(env.bool('terminal_auto_restart'), config('terminalAutoRestart')), @@ -162,6 +164,7 @@ function main() { config('confirmMove', args['confirm-move']); config('oneFilePanel', args['one-file-panel']); config('configDialog', args['config-dialog']); + config('configAuth', args['config-auth']); config('keysPanel', args['keys-panel']); config('export', args.export); config('exportToken', args['export-token']); diff --git a/client/modules/config.js b/client/modules/config.js index 30c9c6c6..909e8573 100644 --- a/client/modules/config.js +++ b/client/modules/config.js @@ -137,16 +137,18 @@ function fillTemplate(error, template) { if (error) return alert('Could not load config!'); - const obj = input.convert(config); + const { + editor, + packer, + columns, + configAuth, + ...obj + } = input.convert(config); - obj[obj.editor + '-selected'] = 'selected'; - delete obj.editor; - - obj[obj.packer + '-selected'] = 'selected'; - delete obj.packer; - - obj[obj.columns + '-selected'] = 'selected'; - delete obj.columns; + obj[editor + '-selected'] = 'selected'; + obj[packer + '-selected'] = 'selected'; + obj[columns + '-selected'] = 'selected'; + obj.configAuth = configAuth ? '' : 'hidden'; const innerHTML = rendy(Template, obj); diff --git a/json/config.json b/json/config.json index 5e865fc8..100d8ed0 100644 --- a/json/config.json +++ b/json/config.json @@ -22,6 +22,7 @@ "confirmCopy": true, "confirmMove": true, "configDialog": true, + "configAuth": true, "oneFilePanel": false, "console": true, "syncConsolePath": false, diff --git a/json/help.json b/json/help.json index 68b7df3a..1b43e60c 100644 --- a/json/help.json +++ b/json/help.json @@ -22,6 +22,7 @@ "--one-file-panel ": "show one file panel", "--keys-panel ": "show keys panel", "--config-dialog ": "enable config dialog", + "--config-auth ": "enable auth change in config dialog", "--console ": "enable console", "--sync-console-path ": "sync console path", "--contact ": "enable contact", @@ -50,6 +51,7 @@ "--no-confirm-copy ": "do not confirm copy", "--no-confirm-move ": "do not confirm move", "--no-config-dialog ": "disable config dialog", + "--no-config-auth ": "disable auth change in config dialog", "--no-console ": "disable console", "--no-sync-console-path ": "do not sync console path", "--no-contact ": "disable contact", diff --git a/now.json b/now.json index 38aabd89..c6fa74f9 100644 --- a/now.json +++ b/now.json @@ -2,7 +2,8 @@ "type": "npm", "alias": "cloudcmd", "env": { - "cloudcmd_config_dialog": "false", + "cloudcmd_config_dialog": "true", + "cloudcmd_config_auth": "false", "cloudcmd_terminal": "true", "cloudcmd_terminal_path": "gritty", "cloudcmd_import": "true", diff --git a/tmpl/config.hbs b/tmpl/config.hbs index 8acaa429..742c2b24 100644 --- a/tmpl/config.hbs +++ b/tmpl/config.hbs @@ -1,11 +1,11 @@