Skip to content

Commit

Permalink
feature(cloudcmd) only user menu on f2
Browse files Browse the repository at this point in the history
  • Loading branch information
coderaiser committed Aug 14, 2019
1 parent a61eb22 commit a8e679b
Show file tree
Hide file tree
Showing 7 changed files with 4 additions and 51 deletions.
3 changes: 1 addition & 2 deletions HELP.md
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ Hot keys
|Key |Operation
|:----------------------|:--------------------------------------------
| `F1` | help
| `F2` | rename or show `user menu`
| `F2` | show `user menu`
| `F3` | view, change directory
| `Shift + F3` | view as markdown
| `F4` | edit
Expand Down Expand Up @@ -466,7 +466,6 @@ Some config options can be overridden with environment variables, such as:

### User Menu

You can enable `user menu` with help of a flag `--user-menu` (bear in mind that file rename using `F2` will be disabled, but you can use `Shift` + `F6` or `F2` + `F2`).
When you press `F2` Cloud Commander will read a file `.cloudcmd.menu.js` by walking up parent directories, if can't read it will try to read `~/.cloudcmd.menu.js`.

Let's consider example `user menu` works file:
Expand Down
5 changes: 1 addition & 4 deletions client/key/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,10 +195,7 @@ function KeyProto() {
break;

case Key.F2:
if (CloudCmd.config('userMenu'))
return CloudCmd.UserMenu.show();

DOM.renameCurrent(current);
CloudCmd.UserMenu.show();
break;

case Key.F3:
Expand Down
5 changes: 1 addition & 4 deletions client/listeners/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,7 @@ module.exports.initKeysPanel = () => {
};

function initF2() {
if (CloudCmd.config('userMenu'))
return CloudCmd.UserMenu.show();

return DOM.renameCurrent();
CloudCmd.UserMenu.show();
}

const getPanel = (side) => {
Expand Down
1 change: 0 additions & 1 deletion html/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
<div class="fm">{{ fm }}</div>
<div id="js-keyspanel" class="keyspanel">
<button id=f1 class="cmd-button reduce-text icon-help" title="Help" >F1</button>
<button id=f2 class="cmd-button reduce-text icon-rename" title="Rename" >F2</button>
<button id=f2 class="cmd-button reduce-text icon-user-menu" title="User Menu" >F2</button>
<button id=f3 class="cmd-button reduce-text icon-view" title="View" >F3</button>
<button id=f4 class="cmd-button reduce-text icon-edit " title="Edit" >F4</button>
Expand Down
3 changes: 1 addition & 2 deletions json/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
"importListen": false,
"log": true,
"dropbox": false,
"dropboxToken": "",
"userMenu": false
"dropboxToken": ""
}

8 changes: 0 additions & 8 deletions server/route.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ function indexProcessing(config, options) {
const noConfig = !config('configDialog');
const noConsole = !config('console');
const noTerminal = !config('terminal');
const noUserMenu = !config('userMenu');
const {panel} = options;

let {data} = options;
Expand Down Expand Up @@ -140,13 +139,6 @@ function indexProcessing(config, options) {
data = data
.replace('icon-terminal', 'icon-terminal none');

if (noUserMenu)
data = data
.replace('icon-user-menu', 'icon-user-menu none');
else
data = data
.replace('icon-rename', 'icon-rename none');

const left = rendy(Template.panel, {
side : 'left',
content : panel,
Expand Down
30 changes: 0 additions & 30 deletions server/route.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,36 +40,6 @@ test('cloudcmd: route: buttons: no console', async (t) => {
t.end();
});

test('cloudcmd: route: buttons: user menu: disabled', async (t) => {
const options = {
config: {
userMenu: false,
},
};

const {body} = await request.get('/', {
options,
});

t.ok(/icon-user-menu none/.test(body), 'should hide console');
t.end();
});

test('cloudcmd: route: buttons: user menu: enabled', async (t) => {
const options = {
config: {
userMenu: true,
},
};

const {body} = await request.get('/', {
options,
});

t.ok(/icon-rename none/.test(body), 'should hide console');
t.end();
});

test('cloudcmd: route: buttons: console', async (t) => {
const config = {
console: true,
Expand Down

0 comments on commit a8e679b

Please sign in to comment.