much better interaction on levels keys with tabs

This commit is contained in:
Peter Cottle 2013-10-26 12:46:19 -07:00
parent 12e921a781
commit c522722513
4 changed files with 56 additions and 2 deletions

View file

@ -685,6 +685,13 @@ var commandConfig = {
var refspecParts = firstArg.split(':');
source = refspecParts[0];
destination = validateBranchName(engine, refspecParts[1]);
if (source === "" && !engine.origin.refs[options.destination]) {
throw new GitError({
msg: intl.todo(
'cannot delete branch ' + options.destination + ' which doesnt exist'
)
});
}
} else {
if (firstArg) {
// we are using this arg as destination AND source. the dest branch

View file

@ -1193,7 +1193,7 @@ GitEngine.prototype.fetchCore = function(sourceDestPairs, options) {
}, this);
chain = chain.then(_.bind(function() {
// update all the destinations
// update all the destinations
_.each(sourceDestPairs, function(pair) {
var ours = this.refs[pair.destination];
var theirCommitID = this.origin.getCommitFromRef(pair.source).get('id');

View file

@ -89,6 +89,10 @@ var LevelDropdownView = ContainedBase.extend({
if (id === this.JSON.selectedTab) {
return;
}
this.updateTabTo(id);
},
updateTabTo: function(id) {
this.JSON.selectedTab = id;
this.render();
if (this.selectedID) {
@ -119,7 +123,24 @@ var LevelDropdownView = ContainedBase.extend({
leftOrRight: function(delta) {
this.deselectIconByID(this.selectedID);
this.selectedIndex = this.wrapIndex(this.selectedIndex + delta, this.getCurrentSequence());
var index = this.selectedIndex + delta;
var sequence = this.getCurrentSequence();
var tabs = this.JSON.tabs;
// switch tabs now if needed / possible
if (index >= sequence.length &&
this.getTabIndex() + 1 < tabs.length) {
this.switchToTabIndex(this.getTabIndex() + 1);
this.selectedIndex = 0;
} else if (index < 0 &&
this.getTabIndex() - 1 >= 0) {
this.switchToTabIndex(this.getTabIndex() - 1);
this.selectedIndex = 0;
} else {
this.selectedIndex = this.wrapIndex(
this.selectedIndex + delta, this.getCurrentSequence()
);
}
this.updateSelectedIcon();
},
@ -168,6 +189,18 @@ var LevelDropdownView = ContainedBase.extend({
this.selectedSequence = undefined;
},
getTabIndex: function() {
var ids = _.map(this.JSON.tabs, function(tab) {
return tab.id;
});
return ids.indexOf(this.JSON.selectedTab);
},
switchToTabIndex: function(index) {
var tabID = this.JSON.tabs[index].id;
this.updateTabTo(tabID);
},
wrapIndex: function(index, arr) {
index = (index >= arr.length) ? 0 : index;
index = (index < 0) ? arr.length - 1 : index;