mirror of
https://github.com/serverless/serverless.git
synced 2026-01-25 15:07:39 +00:00
Add hotkeys to dash for select all, select none, select functions, and select endpoints.
This commit is contained in:
parent
1e9591073f
commit
b7fcf47811
@ -46,6 +46,8 @@ exports.quickHelp = function() {
|
||||
let text = '';
|
||||
text = text + 'Use the <up>, <down>, <pageup>, <pagedown>, <home>, and <end> keys to navigate.' + os.EOL;
|
||||
text = text + 'Press <enter> to select/deselect, or <space> to select/deselect and move down.' + os.EOL;
|
||||
text = text + 'Press <ctrl> + a to select all, and <ctrl> + d to deselect all.' + os.EOL;
|
||||
text = text + 'Press <ctrl> + f to select all functions, and <ctrl> + e to select all endpoints.' + os.EOL;
|
||||
text = text + 'Press <ctrl> + <enter> to immediately deploy selected.' + os.EOL;
|
||||
text = text + 'Press <escape> to cancel.' + os.EOL;
|
||||
|
||||
@ -312,6 +314,42 @@ exports.select = function(message, choices, multi, doneLabel) {
|
||||
return Select._render();
|
||||
};
|
||||
|
||||
// Select/delselect all choices.
|
||||
let selectChoicesAll = function(selected) {
|
||||
// Cycle through all choices.
|
||||
for(let i = 0; i < Select.state.choices.length; ++i)
|
||||
{
|
||||
// If the choice is not a spacer and not an action.
|
||||
if(!Select.state.choices[i].spacer && !Select.state.choices[i].action)
|
||||
// Mark the choice as the specified selected state.
|
||||
Select.state.choices[i].toggled = selected;
|
||||
}
|
||||
|
||||
// Render
|
||||
return Select._render();
|
||||
};
|
||||
|
||||
// Select all choices of a specific type.
|
||||
let selectChoicesAllType = function(type) {
|
||||
// Cycle through all choices.
|
||||
for(let i = 0; i < Select.state.choices.length; ++i)
|
||||
{
|
||||
// If the choice is not a spacer and not an action.
|
||||
if(!Select.state.choices[i].spacer && !Select.state.choices[i].action)
|
||||
{
|
||||
// If the choice type matches the specified type.
|
||||
if(Select.state.choices[i].type && Select.state.choices[i].type === type)
|
||||
{
|
||||
// Mark as selected.
|
||||
Select.state.choices[i].toggled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Render
|
||||
return Select._render();
|
||||
};
|
||||
|
||||
if( !key ) return Select._render;
|
||||
|
||||
// Handle ctrl + c.
|
||||
@ -331,7 +369,18 @@ exports.select = function(message, choices, multi, doneLabel) {
|
||||
selectStateDown();
|
||||
} else if (key.name == 'pagedown') {
|
||||
selectStateDown(4);
|
||||
} else if (key.name == 'return' || key.name == 'space' || key.name == 'escape' || key.name == 'enter') {
|
||||
} else if (key.ctrl && key.name == 'a') {
|
||||
selectChoicesAll(true);
|
||||
} else if (key.ctrl && key.name == 'd') {
|
||||
selectChoicesAll(false);
|
||||
} else if (key.ctrl && key.name == 'e') {
|
||||
selectChoicesAllType('endpoint');
|
||||
} else if (key.ctrl && key.name == 'f') {
|
||||
selectChoicesAllType('function');
|
||||
} else if (key.name == 'return' ||
|
||||
key.name == 'space' ||
|
||||
key.name == 'escape' ||
|
||||
key.name == 'enter') {
|
||||
|
||||
// Check if "cancel" option, "done" option or ctrl was pressed.
|
||||
if (Select.state.choices[Select.state.index - 1].action
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user