Skip to content

Commit

Permalink
Merge pull request #360 from sp2mbn/future/keyboard-shortcuts-for-Acc…
Browse files Browse the repository at this point in the history
…ept-Revert

Keyboard shortcuts for 'Accept/Revert url/test' buttons
  • Loading branch information
tkaik authored Jan 23, 2019
2 parents 75bc334 + 01d2484 commit 3b85fa4
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 38 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ All notable changes to AET will be documented in this file.
- [PR-338](https://github.com/Cognifide/aet/pull/338) Enable creating new dbs by default
- [PR-345](https://github.com/Cognifide/aet/pull/345) Deprecate AET maven plugin
- [PR-301](https://github.com/Cognifide/aet/pull/301) New versions of virtualization tools used with new AET cookbook
- [PR-360](https://github.com/Cognifide/aet/pull/360) Keyboard shortcuts for 'Accept/Revert url/test' buttons ([#317](https://github.com/Cognifide/aet/issues/317))

## Version 2.1.6

Expand Down
5 changes: 4 additions & 1 deletion documentation/src/main/wiki/SuiteReportFeatures.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ Blue version means that it is a rebased version of previous suite - this is also
* use **[** / **]** to navigate between test's urls
* press **m** to show/hide layout mask (when available)
* press **** / **** to navigate between url's tabs
* press **a** for accepting suite/test/url
* press **r** for reverting suite/test/url
* **shift** modifier that will define that the specific opened test case should be accepted/reverted (shift + A - accepts opened test case ; shift + R - reverts opened test case )

#### Rerun

Expand All @@ -76,4 +79,4 @@ Or just one url:
![Url rerun](assets/suiteReport/rerun-url.png)

After scheduling task from the report progress bar will be presented.
When the task is finished, result will be presented on the report.
When the task is finished, result will be presented on the report.
Original file line number Diff line number Diff line change
Expand Up @@ -29,45 +29,41 @@ define(['angularAMD', 'userSettingsService'], function (angularAMD) {

function linkFunc(scope) {

/*
code 37 - arrow left
code 39 - arrow right
code 69 - e
code 77 - m
code 81 - q
code 219 - [
code 221 - ]
*/

var shortcuts = {
'37': function () {
goToTab('prev');
},
'39': function () {
goToTab('next');
'ArrowLeft': goToTab,
'ArrowRight': goToTab,
'e': toggleErrors,
'm': toggleMask,
'q': toggleAll,
'[': function () {
scope.traverseTree('up');
},
'69': function () {
toggleErrors();
']': function () {
scope.traverseTree('down');
},
'77': function () {
toggleMask();
'a': function () {
clickById('#accept-test');
},
'81': function () {
toggleAll();
'r': function () {
clickById('#revert-test');
},
'219': function () {
scope.traverseTree('up');
'A': function (event) {
if (!event.ctrlKey) {} {
clickById('#accept-test-case');
}
},
'221': function () {
scope.traverseTree('down');
'R': function (event) {
if (!event.ctrlKey) {} {
clickById('#revert-test-case');
}
}
};

$(document).on('keydown', function (e) {
if ($('body').hasClass('modal-open')) {
if ($('body').hasClass('modal-open') || $(e.target).hasClass('search-input')) {
return true;
} else if (shortcuts[e.keyCode]) {
shortcuts[e.keyCode]();
} else if (shortcuts[e.key]) {
shortcuts[e.key](e);
}
});

Expand All @@ -86,11 +82,15 @@ define(['angularAMD', 'userSettingsService'], function (angularAMD) {
}
};

function goToTab(direction) {
function clickById(id) {
$(id).click();
}

function goToTab(event) {
var $tabs = $('.test-tabs'),
$active = $tabs.find('.active');

if (direction === 'prev') {
if (event.key === 'ArrowLeft') {
$active.prev().find('a').click();
} else {
$active.next().find('a').click();
Expand Down Expand Up @@ -251,7 +251,7 @@ define(['angularAMD', 'userSettingsService'], function (angularAMD) {
var $nextTestTabs = $('.nav-tabs').children();
$nextTestTabs.each(function() {
if($(this).text().replace(/\s/g, '') === currentTabLabel) {
$(this).find('a').click();
$(this).find('a').click();
currentTabLabel = null;
}
});
Expand All @@ -260,15 +260,15 @@ define(['angularAMD', 'userSettingsService'], function (angularAMD) {
//MutationObserver fires a callback every time something changes on the page
//and here it's used to click a tab before the page is actually rendered to get rid of flickering effect
var mutationObserver = new MutationObserver(callback);

function callback(mutList) {
function findElement(element) {
if($(element.target).hasClass('nav-tabs')) {
clickOnTab();
return true;
}
}
mutList.find(findElement);
mutList.find(findElement);
}

mutationObserver.observe(document, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@
</div>
</div>
<div class="toolbar-btns pull-right" data-ng-if=" !case.usesCrossSuitePattern ">
<div class="button button-small js-test-rebase button-blue" ng-click="urlView.acceptCase(case)"
<div id="accept-test-case" class="button button-small js-test-rebase button-blue" ng-click="urlView.acceptCase(case)"
ng-if="case.showAcceptButton">
<i class="icon icon-rebase"></i>
Accept test case
</div>
<div class="button button-small js-test-rebase button-red" ng-click="urlView.revertCase(case)"
<div id="revert-test-case" class="button button-small js-test-rebase button-red" ng-click="urlView.revertCase(case)"
ng-if="case.showRevertButton">
<i class="icon icon-unrebase"></i>
Revert test case
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,13 +138,13 @@ <h5 ng-if="toolbarBottom.viewMode == 'url'">
Accept {{toolbarBottom.viewMode}}
</span>

<span class="button js-rebase-suite button-blue"
<span id="accept-test" class="button js-rebase-suite button-blue"
data-ng-if="toolbarBottom.showAcceptButton()"
data-ng-click="toolbarBottom.updatePatterns()"></i>
Accept {{toolbarBottom.viewMode}}
</span>

<span class="button js-rebase-suite button-red"
<span id="revert-test" class="button js-rebase-suite button-red"
data-ng-if="toolbarBottom.showRevertButton()"
data-ng-click="toolbarBottom.revertAcceptedPatterns()">
<i class="fas {{theme.statusClasses['unrebased']}}"></i>
Expand Down
3 changes: 3 additions & 0 deletions report/src/main/webapp/report.html
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ <h4 class="modal-title">Handful keyboard shortcuts</h4>
available)
</li>
<li>press <span class="label label-info">← / →</span> to navigate between url's tabs</li>
<li>press <span class="label label-info">a</span> for accepting suite/test/url</li>
<li>press <span class="label label-info">r</span> for reverting suite/test/url</li>
<li><span class="label label-info">shift</span> modifier that will define that the specific opened test case should be accepted/reverted (shift + A - accepts opened test case ; shift + R - reverts opened test case)</li>
</ul>
</div>
</div>
Expand Down

0 comments on commit 3b85fa4

Please sign in to comment.