Fix dropdown for file whose diff is not displayable

Summary: The current behavior is that, when the dropdown menu is clicked for a binary file, it navigates to the current revision page directly without showing the dropdown meu. The fix is to do nothing when there is no file displayed.

Test Plan:
- checked a diff with binary file
- checked a diff with normal files

Reviewers: vrana, epriestley

Reviewed By: epriestley

CC: epriestley, aran

Differential Revision: https://secure.phabricator.com/D2801
This commit is contained in:
Jason Ge
2012-06-19 15:56:42 -07:00
parent d277908842
commit 0c088a695c
2 changed files with 131 additions and 25 deletions

View File

@@ -101,12 +101,22 @@ JX.behavior('differential-dropdown-menus', function(config) {
reveal_item.setName('Entire File Shown');
}
var diff = JX.DOM.find(JX.$(data.containerID),
var diffs = JX.DOM.scry(JX.$(data.containerID),
'table', 'differential-diff');
if (JX.Stratcom.getData(diff).hidden) {
visible_item.setName('Expand File');
if (diffs.length > 1) {
JX.$E(
'More than one node with sigil "differential-diff" was found in "'+
data.containerID+'."');
} else if (diffs.length == 1) {
diff = diffs[0];
if (JX.Stratcom.getData(diff).hidden) {
visible_item.setName('Expand File');
} else {
visible_item.setName('Collapse File');
}
} else {
visible_item.setName('Collapse File');
// Do nothing when there is no diff shown in the table. For example,
// the file is binary.
}
});
}