ChangeScreen2: Make project settings gear icon a proper hyperlink
Wrapping the icon in an <a href> tag allows users to ctrl-click the icon to open the settings page in a new tab, instead of replacing the current change. If the user clicks in the tab, the icon still consumes the event so the standard delayed updating token process is used for navigation. Change-Id: I0c68d3ac7a65ac9885056c83c51d2bfc9ada0533
This commit is contained in:
parent
3e019db390
commit
8398359816
@ -43,6 +43,7 @@ import com.google.gerrit.client.rpc.ScreenLoadCallback;
|
||||
import com.google.gerrit.client.ui.BranchLink;
|
||||
import com.google.gerrit.client.ui.ChangeLink;
|
||||
import com.google.gerrit.client.ui.CommentLinkProcessor;
|
||||
import com.google.gerrit.client.ui.Hyperlink;
|
||||
import com.google.gerrit.client.ui.InlineHyperlink;
|
||||
import com.google.gerrit.client.ui.Screen;
|
||||
import com.google.gerrit.client.ui.UserActivityMonitor;
|
||||
@ -56,6 +57,7 @@ import com.google.gerrit.reviewdb.client.Project.SubmitType;
|
||||
import com.google.gwt.core.client.GWT;
|
||||
import com.google.gwt.core.client.JsArray;
|
||||
import com.google.gwt.core.client.JsArrayString;
|
||||
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.dom.client.SelectElement;
|
||||
@ -70,6 +72,7 @@ import com.google.gwt.uibinder.client.UiBinder;
|
||||
import com.google.gwt.uibinder.client.UiField;
|
||||
import com.google.gwt.uibinder.client.UiHandler;
|
||||
import com.google.gwt.user.client.DOM;
|
||||
import com.google.gwt.user.client.Event;
|
||||
import com.google.gwt.user.client.EventListener;
|
||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||
import com.google.gwt.user.client.ui.Anchor;
|
||||
@ -140,6 +143,7 @@ public class ChangeScreen2 extends Screen {
|
||||
@UiField InlineHyperlink ownerLink;
|
||||
@UiField Element statusText;
|
||||
@UiField Image projectSettings;
|
||||
@UiField AnchorElement projectSettingsLink;
|
||||
@UiField InlineHyperlink projectDashboard;
|
||||
@UiField InlineHyperlink branchLink;
|
||||
@UiField Element strategy;
|
||||
@ -356,11 +360,16 @@ public class ChangeScreen2 extends Screen {
|
||||
}
|
||||
|
||||
private void initProjectLinks(final ChangeInfo info) {
|
||||
projectSettingsLink.setHref(
|
||||
"#" + PageLinks.toProject(info.project_name_key()));
|
||||
projectSettings.addDomHandler(new ClickHandler() {
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
Gerrit.display(
|
||||
PageLinks.toProject(info.project_name_key()));
|
||||
if (Hyperlink.impl.handleAsClick((Event) event.getNativeEvent())) {
|
||||
event.stopPropagation();
|
||||
event.preventDefault();
|
||||
Gerrit.display(PageLinks.toProject(info.project_name_key()));
|
||||
}
|
||||
}
|
||||
}, ClickEvent.getType());
|
||||
projectDashboard.setText(info.project());
|
||||
|
@ -386,13 +386,15 @@ limitations under the License.
|
||||
title='Go to project dashboard'>
|
||||
<ui:attribute name='title'/>
|
||||
</x:InlineHyperlink>
|
||||
<g:Image
|
||||
ui:field='projectSettings'
|
||||
resource='{ico.gear}'
|
||||
styleName='{style.projectSettings}'
|
||||
title='Go to project settings'>
|
||||
<ui:attribute name='title'/>
|
||||
</g:Image>
|
||||
<a ui:field='projectSettingsLink'
|
||||
class='{style.projectSettings}'>
|
||||
<g:Image
|
||||
ui:field='projectSettings'
|
||||
resource='{ico.gear}'
|
||||
title='Go to project settings'>
|
||||
<ui:attribute name='title'/>
|
||||
</g:Image>
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
@ -23,7 +23,7 @@ import com.google.gwt.user.client.ui.impl.HyperlinkImpl;
|
||||
|
||||
/** Standard GWT hyperlink with late updating of the token. */
|
||||
public class Hyperlink extends com.google.gwt.user.client.ui.Hyperlink {
|
||||
static final HyperlinkImpl impl = GWT.create(HyperlinkImpl.class);
|
||||
public static final HyperlinkImpl impl = GWT.create(HyperlinkImpl.class);
|
||||
|
||||
/** Initialize a default hyperlink with no target and no text. */
|
||||
public Hyperlink() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user