Minor cleanups for current user popup panel
Wrap the two links (Settings, Sign-Out) into a single div and supply a min-width of 175px. This prevents them from collapsing in an odd two line display when there is no avatar present. Remove the div altogether when viewing another user's popup panel, rather than just hiding the links. This makes the DOM slightly smaller for the common case of viewing someone else's information. Change-Id: I96c3e37ef8799b8b86a56e3a8b4a960860b2373a
This commit is contained in:
@@ -16,8 +16,8 @@ package com.google.gerrit.client;
|
|||||||
|
|
||||||
import com.google.gerrit.client.account.AccountInfo;
|
import com.google.gerrit.client.account.AccountInfo;
|
||||||
import com.google.gerrit.client.ui.InlineHyperlink;
|
import com.google.gerrit.client.ui.InlineHyperlink;
|
||||||
import com.google.gerrit.common.PageLinks;
|
|
||||||
import com.google.gwt.core.client.GWT;
|
import com.google.gwt.core.client.GWT;
|
||||||
|
import com.google.gwt.dom.client.Element;
|
||||||
import com.google.gwt.uibinder.client.UiBinder;
|
import com.google.gwt.uibinder.client.UiBinder;
|
||||||
import com.google.gwt.uibinder.client.UiField;
|
import com.google.gwt.uibinder.client.UiField;
|
||||||
import com.google.gwt.user.client.ui.Anchor;
|
import com.google.gwt.user.client.ui.Anchor;
|
||||||
@@ -26,32 +26,21 @@ import com.google.gwt.user.client.ui.Widget;
|
|||||||
import com.google.gwtexpui.user.client.PluginSafePopupPanel;
|
import com.google.gwtexpui.user.client.PluginSafePopupPanel;
|
||||||
|
|
||||||
public class UserPopupPanel extends PluginSafePopupPanel {
|
public class UserPopupPanel extends PluginSafePopupPanel {
|
||||||
interface Binder extends UiBinder<Widget, UserPopupPanel> {
|
interface Binder extends UiBinder<Widget, UserPopupPanel> {}
|
||||||
}
|
|
||||||
|
|
||||||
private static final Binder binder = GWT.create(Binder.class);
|
private static final Binder binder = GWT.create(Binder.class);
|
||||||
|
|
||||||
@UiField(provided = true)
|
@UiField(provided = true) AvatarImage avatar;
|
||||||
AvatarImage avatar;
|
@UiField Label userName;
|
||||||
@UiField
|
@UiField Label userEmail;
|
||||||
Label userName;
|
@UiField Element userLinks;
|
||||||
@UiField
|
@UiField Anchor logout;
|
||||||
Label userEmail;
|
@UiField InlineHyperlink settings;
|
||||||
@UiField
|
|
||||||
Anchor logout;
|
|
||||||
@UiField
|
|
||||||
InlineHyperlink settings;
|
|
||||||
|
|
||||||
public UserPopupPanel(AccountInfo account, boolean canLogOut,
|
public UserPopupPanel(AccountInfo account, boolean canLogOut,
|
||||||
boolean showSettingsLink) {
|
boolean showSettingsLink) {
|
||||||
super(/* auto hide */true, /* modal */false);
|
super(/* auto hide */true, /* modal */false);
|
||||||
avatar = new AvatarImage(account, 100, false);
|
avatar = new AvatarImage(account, 100, false);
|
||||||
setWidget(binder.createAndBindUi(this));
|
setWidget(binder.createAndBindUi(this));
|
||||||
// We must show and then hide this popup so that it is part of the DOM.
|
|
||||||
// Otherwise the image does not get any events. Calling hide() would
|
|
||||||
// remove it from the DOM so we use setVisible(false) instead.
|
|
||||||
show();
|
|
||||||
setVisible(false);
|
|
||||||
setStyleName(Gerrit.RESOURCES.css().userInfoPopup());
|
setStyleName(Gerrit.RESOURCES.css().userInfoPopup());
|
||||||
if (account.name() != null) {
|
if (account.name() != null) {
|
||||||
userName.setText(account.name());
|
userName.setText(account.name());
|
||||||
@@ -59,15 +48,24 @@ public class UserPopupPanel extends PluginSafePopupPanel {
|
|||||||
if (account.email() != null) {
|
if (account.email() != null) {
|
||||||
userEmail.setText(account.email());
|
userEmail.setText(account.email());
|
||||||
}
|
}
|
||||||
|
if (showSettingsLink) {
|
||||||
if (canLogOut) {
|
if (canLogOut) {
|
||||||
logout.setHref(Gerrit.selfRedirect("/logout"));
|
logout.setHref(Gerrit.selfRedirect("/logout"));
|
||||||
} else {
|
} else {
|
||||||
logout.setVisible(false);
|
logout.setVisible(false);
|
||||||
}
|
}
|
||||||
if (showSettingsLink) {
|
|
||||||
settings.setTargetHistoryToken(PageLinks.SETTINGS);
|
|
||||||
} else {
|
} else {
|
||||||
settings.setVisible(false);
|
settings.removeFromParent();
|
||||||
|
settings = null;
|
||||||
|
userLinks.removeFromParent();
|
||||||
|
userLinks = null;
|
||||||
|
logout = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// We must show and then hide this popup so that it is part of the DOM.
|
||||||
|
// Otherwise the image does not get any events. Calling hide() would
|
||||||
|
// remove it from the DOM so we use setVisible(false) instead.
|
||||||
|
show();
|
||||||
|
setVisible(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,6 +36,9 @@ limitations under the License.
|
|||||||
.userName {
|
.userName {
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
|
.userLinks {
|
||||||
|
min-width: 175px;
|
||||||
|
}
|
||||||
.email {
|
.email {
|
||||||
padding-bottom: 6px;
|
padding-bottom: 6px;
|
||||||
}
|
}
|
||||||
@@ -52,11 +55,13 @@ limitations under the License.
|
|||||||
<g:Label ui:field='userName' styleName="{style.userName}" />
|
<g:Label ui:field='userName' styleName="{style.userName}" />
|
||||||
<g:Label ui:field='userEmail' styleName="{style.email}" />
|
<g:Label ui:field='userEmail' styleName="{style.email}" />
|
||||||
</td></tr></table>
|
</td></tr></table>
|
||||||
<u:InlineHyperlink ui:field='settings'>
|
<div ui:field='userLinks' class='{style.userLinks}'>
|
||||||
|
<u:InlineHyperlink ui:field='settings' targetHistoryToken='/settings/'>
|
||||||
<ui:msg>Settings</ui:msg>
|
<ui:msg>Settings</ui:msg>
|
||||||
</u:InlineHyperlink>
|
</u:InlineHyperlink>
|
||||||
<g:Anchor ui:field='logout' styleName="{style.logout}">
|
<g:Anchor ui:field='logout' styleName="{style.logout}">
|
||||||
<ui:text from='{constants.menuSignOut}' />
|
<ui:text from='{constants.menuSignOut}' />
|
||||||
</g:Anchor>
|
</g:Anchor>
|
||||||
|
</div>
|
||||||
</g:HTMLPanel>
|
</g:HTMLPanel>
|
||||||
</ui:UiBinder>
|
</ui:UiBinder>
|
||||||
Reference in New Issue
Block a user