Skip to content

Commit

Permalink
feat: add hotkey support for deleting rules and values
Browse files Browse the repository at this point in the history
  • Loading branch information
tiancihe authored and 何天赐 committed Dec 8, 2020
1 parent f0bba81 commit a596611
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
11 changes: 11 additions & 0 deletions biz/webui/htdocs/src/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -749,6 +749,17 @@ var Index = React.createClass({
self.importSessions(e);
e.preventDefault();
}

if (
(util.IS_MACOS && e.key === 'Backspace' && e.metaKey === true) ||
(!util.IS_MACOS && e.key === 'Delete')
) {
if (self.state.name === 'rules') {
self.removeRules();
} else if (self.state.name === 'values') {
self.removeValues();
}
}
});

function getKey(url) {
Expand Down
6 changes: 5 additions & 1 deletion biz/webui/htdocs/src/js/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ var dragTarget, dragOffset, dragCallback;
var logTempId = 0;
var LEVELS = ['fatal', 'error', 'warn', 'info', 'debug'];

var IS_MACOS = navigator.userAgent.indexOf('Macintosh') >= 0;

exports.IS_MACOS = IS_MACOS;

function noop(_) {
return _;
}
Expand Down Expand Up @@ -277,7 +281,7 @@ exports.getExtension = function(headers) {
}
type = type || getRawType(headers);
type = type.substring(type.indexOf('/') + 1).toLowerCase();
return /\w+/.test(type) ? '.' + RegExp['$&'] : '';
return /\w+/.test(type) ? '.' + RegExp['$&'] : '';
};

function getContentType(type) {
Expand Down

0 comments on commit a596611

Please sign in to comment.