ChangeScreen2: Add query icon for project

As on the old change screen the project link should link to the
project administration page and there should be a query icon to search
for changes on the project. Clicking on the query icon opens the
default dashboard of the project or if no default dashboard is defined
it queries for the open changes of the project.

This behaviour is consistent with the old change screen so that users
don't get confused.

Bug: issue 2075
Change-Id: I62f87466b60896ecb046e6053f8361405a5c4285
Signed-off-by: Edwin Kempin <edwin.kempin@sap.com>
This commit is contained in:
Edwin Kempin
2013-10-28 16:40:48 +01:00
parent ed31e1c2ad
commit a2b2a2703e
4 changed files with 32 additions and 8 deletions

View File

@@ -94,6 +94,10 @@ public class PageLinks {
return PROJECTS + name.get() + DASHBOARDS + id;
}
public static String toProjectDefaultDashboard(Project.NameKey name) {
return PROJECTS + name.get() + DASHBOARDS + "default";
}
public static String projectQuery(Project.NameKey proj) {
return op("project", proj.get());
}

View File

@@ -59,6 +59,7 @@ import com.google.gwt.dom.client.AnchorElement;
import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.NativeEvent;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.dom.client.KeyPressEvent;
import com.google.gwt.event.logical.shared.ValueChangeEvent;
import com.google.gwt.event.shared.HandlerRegistration;
@@ -72,6 +73,7 @@ import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.HTMLPanel;
import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.ToggleButton;
import com.google.gwtexpui.clippy.client.CopyableLabel;
import com.google.gwtexpui.globalkey.client.GlobalKey;
@@ -135,6 +137,7 @@ public class ChangeScreen2 extends Screen {
@UiField Element changeIdText;
@UiField Element ownerText;
@UiField Element statusText;
@UiField Image projectQuery;
@UiField InlineHyperlink projectLink;
@UiField InlineHyperlink branchLink;
@UiField Element submitActionText;
@@ -284,13 +287,17 @@ public class ChangeScreen2 extends Screen {
new DownloadAction(info, revision, style, headerLine, download);
}
private void initProjectLink(ChangeInfo info) {
private void initProjectLinks(final ChangeInfo info) {
projectQuery.addDomHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
Gerrit.display(
PageLinks.toProjectDefaultDashboard(info.project_name_key()));
}
}, ClickEvent.getType());
projectLink.setText(info.project());
projectLink.setTargetHistoryToken(
PageLinks.toChangeQuery(
PageLinks.projectQuery(
info.project_name_key(),
info.status())));
PageLinks.toProject(info.project_name_key()));
}
private void initBranchLink(ChangeInfo info) {
@@ -649,7 +656,7 @@ public class ChangeScreen2 extends Screen {
initIncludedInAction(info);
initRevisionsAction(info, revision);
initDownloadAction(info, revision);
initProjectLink(info);
initProjectLinks(info);
initBranchLink(info);
actions.display(info, revision);

View File

@@ -20,6 +20,7 @@ limitations under the License.
xmlns:g='urn:import:com.google.gwt.user.client.ui'
xmlns:x='urn:import:com.google.gerrit.client.ui'
xmlns:clippy='urn:import:com.google.gwtexpui.clippy.client'>
<ui:with field='ico' type='com.google.gerrit.client.GerritResources'/>
<ui:with field='res' type='com.google.gerrit.client.change.Resources'/>
<ui:style type='com.google.gerrit.client.change.ChangeScreen2.Style'>
@eval textColor com.google.gerrit.client.Gerrit.getTheme().textColor;
@@ -133,6 +134,11 @@ limitations under the License.
float: right;
}
.queryProject {
float: left;
cursor: pointer;
}
.infoColumn {
width: 440px;
padding-right: 10px;
@@ -317,8 +323,15 @@ limitations under the License.
</tr>
<tr>
<th><ui:msg>Project</ui:msg></th>
<td><x:InlineHyperlink ui:field='projectLink'
<td><g:Image
ui:field='projectQuery'
resource='{ico.queryIcon}'
styleName='{style.queryProject}'
title='Search for changes on this project'>
<ui:attribute name='title'/>
</g:Image>
<x:InlineHyperlink ui:field='projectLink'
title='Go to project'>
<ui:attribute name='title'/>
</x:InlineHyperlink>
</td>

View File

@@ -24,7 +24,7 @@ import com.google.gwt.user.client.ui.Image;
public class ProjectSearchLink extends InlineHyperlink {
public ProjectSearchLink(Project.NameKey projectName) {
super(" ", PageLinks.toProjectDashboard(projectName, "default"));
super(" ", PageLinks.toProjectDefaultDashboard(projectName));
setTitle(Util.C.projectListQueryLink());
final Image image = new Image(Gerrit.RESOURCES.queryIcon());
DOM.insertBefore(getElement(), image.getElement(),