Make 'u' go up to the last change listing

Rather than hard code 'u' from a change page to your dashboard, make
it return to the last major listing of changes you were viewing.
This makes it a whole lot easier to navigate through all changes
that you have starred, or have drafts on, or that are in a particular
query result.

Change-Id: I04c5569125633b4e68eb2a93d2bd313a1b632209
Signed-off-by: Shawn O. Pearce <sop@google.com>
This commit is contained in:
Shawn O. Pearce
2010-08-19 17:40:53 -07:00
parent 4f0d56acd7
commit 38347820a4
8 changed files with 45 additions and 77 deletions

View File

@@ -16,6 +16,7 @@ package com.google.gerrit.client;
import com.google.gerrit.client.auth.openid.OpenIdSignInDialog;
import com.google.gerrit.client.auth.userpass.UserPassSignInDialog;
import com.google.gerrit.client.changes.ChangeListScreen;
import com.google.gerrit.client.rpc.GerritCallback;
import com.google.gerrit.client.ui.LinkMenuBar;
import com.google.gerrit.client.ui.LinkMenuItem;
@@ -81,6 +82,8 @@ public class Gerrit implements EntryPoint {
private static final Dispatcher dispatcher = new Dispatcher();
private static ViewSite<Screen> body;
private static String lastChangeListToken;
static {
SYSTEM_SVC = GWT.create(SystemInfoService.class);
JsonUtil.bind(SYSTEM_SVC, "rpc/SystemInfoService");
@@ -91,6 +94,16 @@ public class Gerrit implements EntryPoint {
Window.Location.reload();
}
public static void displayLastChangeList() {
if (lastChangeListToken != null) {
display(lastChangeListToken);
} else if (isSignedIn()) {
display(PageLinks.MINE);
} else {
display(PageLinks.toChangeQuery("status:open"));
}
}
/**
* Load the screen at the given location, displaying when ready.
* <p>
@@ -365,6 +378,11 @@ public class Gerrit implements EntryPoint {
dispatchHistoryHooks(token);
}
}
if (view instanceof ChangeListScreen) {
lastChangeListToken = token;
}
super.onShowView(view);
view.onShowView();
}

View File

@@ -25,7 +25,7 @@ import com.google.gerrit.common.data.AccountInfo;
import com.google.gerrit.reviewdb.Account;
public class AccountDashboardScreen extends Screen {
public class AccountDashboardScreen extends Screen implements ChangeListScreen {
private final Account.Id ownerId;
private ChangeTable table;
private ChangeTable.Section byOwner;

View File

@@ -46,7 +46,7 @@ public interface ChangeConstants extends Constants {
String changeTableStar();
String changeTablePagePrev();
String changeTablePageNext();
String upToDashboard();
String upToChangeList();
String expandCollapseDependencies();
String previousPatchSet();
String nextPatchSet();

View File

@@ -26,7 +26,7 @@ changeTableOpen = Open change
changeTableStar = Star (or unstar) change
changeTablePagePrev = Previous page of changes
changeTablePageNext = Next page of changes
upToDashboard = Up to dashboard
upToChangeList = Up to change list
expandCollapseDependencies = Expands / Collapses dependencies section
previousPatchSet = Previous patch set
nextPatchSet = Next patch set

View File

@@ -0,0 +1,18 @@
// Copyright (C) 2010 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.gerrit.client.changes;
public interface ChangeListScreen {
}

View File

@@ -22,7 +22,6 @@ import com.google.gerrit.client.ui.ExpandAllCommand;
import com.google.gerrit.client.ui.LinkMenuBar;
import com.google.gerrit.client.ui.NeedsSignInKeyCommand;
import com.google.gerrit.client.ui.Screen;
import com.google.gerrit.common.PageLinks;
import com.google.gerrit.common.data.AccountInfo;
import com.google.gerrit.common.data.AccountInfoCache;
import com.google.gerrit.common.data.ChangeDetail;
@@ -145,7 +144,7 @@ public class ChangeScreen extends Screen {
keysNavigation = new KeyCommandSet(Gerrit.C.sectionNavigation());
keysAction = new KeyCommandSet(Gerrit.C.sectionActions());
keysNavigation.add(new DashboardKeyCommand(0, 'u', Util.C.upToDashboard()));
keysNavigation.add(new UpToListKeyCommand(0, 'u', Util.C.upToChangeList()));
keysNavigation.add(new ExpandCollapseDependencySectionKeyCommand(0, 'd', Util.C.expandCollapseDependencies()));
if (Gerrit.isSignedIn()) {
@@ -346,18 +345,14 @@ public class ChangeScreen extends Screen {
});
}
public class DashboardKeyCommand extends KeyCommand {
public DashboardKeyCommand(int mask, char key, String help) {
public class UpToListKeyCommand extends KeyCommand {
public UpToListKeyCommand(int mask, char key, String help) {
super(mask, key, help);
}
@Override
public void onKeyPress(final KeyPressEvent event) {
if (Gerrit.isSignedIn()) {
Gerrit.display(PageLinks.MINE);
} else {
Gerrit.display(PageLinks.toChangeQuery("status:open"));
}
Gerrit.displayLastChangeList();
}
}

View File

@@ -1,64 +0,0 @@
// Copyright (C) 2008 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.gerrit.client.changes;
import com.google.gerrit.client.rpc.ScreenLoadCallback;
import com.google.gerrit.client.ui.AccountScreen;
import com.google.gerrit.common.data.SingleListChangeInfo;
import com.google.gwt.user.client.rpc.AsyncCallback;
public abstract class MineSingleListScreen extends AccountScreen {
private final String anchor;
private ChangeTable table;
private ChangeTable.Section drafts;
protected MineSingleListScreen(final String historyToken) {
anchor = historyToken;
}
@Override
protected void onInitUI() {
super.onInitUI();
table = new ChangeTable();
drafts = new ChangeTable.Section();
table.addSection(drafts);
table.setSavePointerId(anchor);
add(table);
}
@Override
public void registerKeys() {
super.registerKeys();
table.setRegisterKeys(true);
}
protected AsyncCallback<SingleListChangeInfo> loadCallback() {
return new ScreenLoadCallback<SingleListChangeInfo>(this) {
@Override
protected void preDisplay(final SingleListChangeInfo result) {
display(result);
}
};
}
private void display(final SingleListChangeInfo result) {
table.setAccountInfoCache(result.getAccounts());
drafts.display(result.getChanges());
table.finishDisplay();
}
}

View File

@@ -24,7 +24,8 @@ import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwtorm.client.KeyUtil;
public class QueryScreen extends PagedSingleListScreen {
public class QueryScreen extends PagedSingleListScreen implements
ChangeListScreen {
public static QueryScreen forQuery(String query) {
return forQuery(query, PageLinks.TOP);
}