bug5712: fixed the premium indicator under the user icon in header area. Was only shown in home area before. Now it is active everywhere.

This commit is contained in:
Udo Wessels
2022-05-09 20:47:38 +02:00
parent 92382cb9d6
commit e17859bd34
16 changed files with 89 additions and 45 deletions
@@ -162,8 +162,7 @@
.user_menu_button.loggedin.open {
background-image: resourceUrl('loggedinOpen');
}
.user_menu_button span.premium {
display: none;
.user_menu_premium {
position: absolute;
bottom: -2px;
left: 50%;
@@ -94,7 +94,6 @@ public class Header extends Composite implements HeaderConstants {
@UiField Element centerMenuPanel;
@UiField Anchor usermenu;
@UiField ImageElement logoImage;
@UiField Element usermenuPremium;
private static final HyperlinkImpl HYPERLINK_IMPL = GWT.create(HyperlinkImpl.class);
private final List<Anchor> links;
@@ -104,10 +103,10 @@ public class Header extends Composite implements HeaderConstants {
private final PlaceNavigation<SolutionsPlace> solutionsNavigation;
private final PlaceNavigation<SubscriptionPlace> subscriptionsNavigation;
private final AuthenticationMenuView authenticationMenuView;
interface HeaderUiBinder extends UiBinder<Widget, Header> {
}
/**
* Contains the logic for the dynamic hamburger menu on top of the page.
* @author Georg Herdt
@@ -265,6 +264,8 @@ public class Header extends Composite implements HeaderConstants {
eventsPageLink.setHref(eventsNavigation.getTargetUrl());
solutionsPageLink.setHref(solutionsNavigation.getTargetUrl());
subscriptionsPageLink.setHref(subscriptionsNavigation.getTargetUrl());
authenticationMenuView = new AuthenticationMenuViewImpl(usermenu, HeaderResources.INSTANCE.css().loggedin(),
HeaderResources.INSTANCE.css().open(), HeaderResources.INSTANCE.css().user_menu_premium());
// make the Admin link visible only for signed-in users
adminConsolePageLink.getElement().getStyle().setDisplay(Display.NONE);
// initially hide admin console, data mining and strategy simulator in hamburger menu
@@ -346,11 +347,7 @@ public class Header extends Composite implements HeaderConstants {
}
menuItemVisibilityHandler.refreshVisibilityDeferred();
if (authContext.hasPermission(authContext.getCurrentUser(), UserActions.BE_PREMIUM)) {
usermenuPremium.getStyle().setDisplay(Display.BLOCK);
} else {
usermenuPremium.getStyle().setDisplay(Display.NONE);
}
authenticationMenuView.showPremium(authContext.hasPermission(authContext.getCurrentUser(), UserActions.BE_PREMIUM));
});
searchText.getElement().setAttribute("placeholder", StringMessages.INSTANCE.headerSearchPlaceholder());
searchText.addFocusHandler((focusEvent) -> menuItemVisibilityHandler.refreshVisibility(370));
@@ -371,7 +368,6 @@ public class Header extends Composite implements HeaderConstants {
updateActiveLink(event.getNewPlace());
}
});
authenticationMenuView = new AuthenticationMenuViewImpl(usermenu, HeaderResources.INSTANCE.css().loggedin(), HeaderResources.INSTANCE.css().open());
if (!ClientConfiguration.getInstance().isBrandingActive()) {
logoImage.getStyle().setDisplay(Display.NONE);
logoImage.setTitle(StringMessages.INSTANCE.sapSailingAnalytics());
@@ -76,9 +76,7 @@
<g:TextBox ui:field="searchText" styleName="{local_res.css.search_textfield}" />
<g:Button ui:field="searchButton" styleName="{res.mainCss.button} {res.mainCss.buttonsearch} {local_res.css.search_button}" />
</span>
<g:Anchor addStyleNames="{local_res.css.sitenavigation_link} {local_res.css.user_menu_button}" ui:field="usermenu">
<span ui:field="usermenuPremium" class="{local_res.css.premium}"><ui:text from='{i18n.premium}' /></span>
</g:Anchor>
<g:Anchor addStyleNames="{local_res.css.sitenavigation_link} {local_res.css.user_menu_button}" ui:field="usermenu"/>
<div id="usrMngmtFlyover" />
<!-- -->
</nav>
@@ -49,7 +49,7 @@ public interface HeaderResources extends AuthenticationResources {
String header_navigation_icon();
String header_navigation_iconactive();
String subscriptions();
String premium();
String user_menu_premium();
String premium_feature();
String premium_hint();
}
@@ -8,7 +8,6 @@ import java.util.List;
import java.util.Map;
import com.google.gwt.activity.shared.AbstractActivity;
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.shared.EventBus;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.rpc.AsyncCallback;
@@ -288,7 +288,9 @@ public class RaceBoardPanel
}
}
}
this.userManagementMenuView = new AuthenticationMenuViewImpl(new Anchor(), mainCss.usermanagement_loggedin(), mainCss.usermanagement_open());
this.userManagementMenuView = new AuthenticationMenuViewImpl(new Anchor(), mainCss.usermanagement_loggedin(),
mainCss.usermanagement_open(), mainCss.user_menu_premium());
this.userManagementMenuView.asWidget().setStyleName(mainCss.usermanagement_icon());
timeRangeWithZoomModel = new TimeRangeWithZoomModel();
final CompetitorColorProvider colorProvider = new CompetitorColorProviderImpl(selectedRaceIdentifier, competitorsAndTheirBoats);
@@ -7,25 +7,21 @@ import com.sap.sse.security.ui.authentication.generic.resource.AuthenticationRes
public interface RaceBoardResources extends CommonSharedResources, AuthenticationResources {
public static final RaceBoardResources INSTANCE = GWT.create(RaceBoardResources.class);
@Source({CommonSharedResources.RESET, CommonSharedResources.MAIN, "raceboard-main.gss"})
RaceBoardMainCss mainCss();
@Source({CommonSharedResources.MEDIA, "raceboard-media.gss"})
RaceBoardMediaCss mediaCss();
@Source({ CommonSharedResources.RESET, CommonSharedResources.MAIN, "raceboard-main.gss" })
RaceBoardMainCss mainCss();
@Source({ CommonSharedResources.MEDIA, "raceboard-media.gss" })
RaceBoardMediaCss mediaCss();
public interface RaceBoardMainCss extends CommonMainCss {
String button();
String buttonprimary();
String buttonprimaryoutlined();
String buttonarrowrightwhite();
String mainsection();
String mainsection_header();
String mainsection_header_title();
String usermanagement_icon();
String usermanagement_loggedin();
String usermanagement_view();
@@ -33,9 +29,9 @@ public interface RaceBoardResources extends CommonSharedResources, Authenticatio
String usermanagement_view_content();
String usermanagement_mobile();
String usermanagement_open();
String user_menu_premium();
}
public interface RaceBoardMediaCss extends CommonMediaCss {
}
}
@@ -46,3 +46,17 @@
.usermanagement_mobile .usermanagement_view_content {
width: 100%;
}
.user_menu_premium {
position: absolute;
bottom: -2px;
left: 50%;
transform: translate(-50%, 0%);
margin: 0;
padding: 0 3px;
font-size: 9px;
font-weight: bold;
color: #fff;
background: #efaa00;
line-height: 12px;
border-radius: 0.33em;
}
@@ -37,7 +37,8 @@ public class SAPHeaderWithAuthentication extends SAPHeader {
Anchor authenticationMenu = new Anchor();
authenticationMenu.addStyleName(res.css().usermanagement_icon());
rightWithAuthentication.add(authenticationMenu);
authenticationMenuView = new AuthenticationMenuViewImpl(authenticationMenu, res.css().usermanagement_loggedin(), res.css().usermanagement_open());
authenticationMenuView = new AuthenticationMenuViewImpl(authenticationMenu, res.css().usermanagement_loggedin(),
res.css().usermanagement_open(), res.css().user_menu_premium());
rightWrapper = new SimplePanel();
rightWrapper.addStyleName(res.css().header_right_extension());
rightWithAuthentication.add(rightWrapper);
@@ -48,9 +49,10 @@ public class SAPHeaderWithAuthentication extends SAPHeader {
public void addWidgetToRightSide(Widget widget) {
rightWrapper.add(widget);
}
/**
* @return the {@link AuthenticationMenuView} associated with the authentication control on the right side of the header.
* @return the {@link AuthenticationMenuView} associated with the authentication control on the right side of the
* header.
*/
public AuthenticationMenuView getAuthenticationMenuView() {
return authenticationMenuView;
@@ -4,23 +4,22 @@ import com.google.gwt.core.client.GWT;
import com.google.gwt.resources.client.CssResource;
import com.sap.sse.security.ui.authentication.generic.resource.AuthenticationResources;
public interface SAPHeaderWithAuthenticationResources extends AuthenticationResources {
public static final SAPHeaderWithAuthenticationResources INSTANCE = GWT.create(SAPHeaderWithAuthenticationResources.class);
public static final SAPHeaderWithAuthenticationResources INSTANCE = GWT
.create(SAPHeaderWithAuthenticationResources.class);
@Source("header-with-authentication.gss")
HeaderWithAuthenticationCss css();
public interface HeaderWithAuthenticationCss extends CssResource {
String header_right_wrapper();
String header_right_extension();
String fixed();
String usermanagement_icon();
String usermanagement_loggedin();
String usermanagement_view();
String usermanagement_open();
String user_menu_premium();
String languageSelector();
}
}
@@ -53,3 +53,17 @@
font-size: 100% !important;
font-weight: normal;
}
.user_menu_premium {
position: absolute;
bottom: -2px;
left: 50%;
transform: translate(-50%, 0%);
margin: 0;
padding: 0 3px;
font-size: 9px;
font-weight: bold;
color: #fff;
background: #efaa00;
line-height: 12px;
border-radius: 0.33em;
}
@@ -6,7 +6,7 @@ import com.google.gwt.user.client.ui.IsWidget;
* Interface for menu items, which interacting with a {@link FlyoutAuthenticationView}.
*/
public interface AuthenticationMenuView extends IsWidget {
/**
* Sets the {@link Presenter}.
*
@@ -14,7 +14,7 @@ public interface AuthenticationMenuView extends IsWidget {
* the {@link Presenter} to set
*/
void setPresenter(Presenter presenter);
/**
* Sets whether or not there is an authenticated user.
*
@@ -22,7 +22,7 @@ public interface AuthenticationMenuView extends IsWidget {
* <code>true</code> if there is an authenticated user, <code>false</code> otherwise
*/
void setAuthenticated(boolean authenticated);
/**
* Sets whether or not the {@link FlyoutAuthenticationView} is open/shown.
*
@@ -30,7 +30,15 @@ public interface AuthenticationMenuView extends IsWidget {
* <code>true</code> the {@link FlyoutAuthenticationView} is open, <code>false</code> otherwise
*/
void setOpen(boolean open);
/**
* Shows the premium indicator below the user icon.
*
* @param premium
* if premium is visible (active premium role) or not.
*/
void showPremium(boolean premium);
/**
* Presenter interface to toggle {@link FlyoutAuthenticationView}'s visibility.
*/
@@ -4,17 +4,20 @@ import com.google.gwt.debug.client.DebugInfo;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.ui.Anchor;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.Widget;
import com.sap.sse.security.ui.client.i18n.StringMessages;
/**
* Default implementation of {@link AuthenticationMenuView} based on an {@link Anchor} widget.
*/
public class AuthenticationMenuViewImpl implements AuthenticationMenuView {
private Presenter presenter;
private final Anchor anchor;
private final String loggedInStyle;
private final String openStyle;
private final Label usermenuPremium;
/**
* Create a new {@link AuthenticationMenuViewImpl} instance with the given parameters.
@@ -26,7 +29,7 @@ public class AuthenticationMenuViewImpl implements AuthenticationMenuView {
* @param openStyle
* the style name to add to the widget, if the {@link FlyoutAuthenticationView} is open
*/
public AuthenticationMenuViewImpl(Anchor anchor, String loggedInStyle, String openStyle) {
public AuthenticationMenuViewImpl(Anchor anchor, String loggedInStyle, String openStyle, String premiumStyle) {
this.anchor = anchor;
this.loggedInStyle = loggedInStyle;
this.openStyle = openStyle;
@@ -37,6 +40,10 @@ public class AuthenticationMenuViewImpl implements AuthenticationMenuView {
}
});
this.anchor.ensureDebugId("authenticationMenu");
usermenuPremium = new Label(StringMessages.INSTANCE.premium());
usermenuPremium.addStyleName(premiumStyle);
usermenuPremium.setVisible(false);
this.anchor.getElement().appendChild(usermenuPremium.getElement());
}
@Override
@@ -54,13 +61,18 @@ public class AuthenticationMenuViewImpl implements AuthenticationMenuView {
anchor.setStyleName(loggedInStyle, authenticated);
setDebugDataAttribute("data-auth", authenticated);
}
@Override
public void setOpen(boolean open) {
anchor.setStyleName(openStyle, open);
setDebugDataAttribute("data-open", open);
}
@Override
public void showPremium(boolean premium) {
usermenuPremium.setVisible(premium);
}
private void setDebugDataAttribute(String name, boolean value) {
if (DebugInfo.isDebugIdEnabled()) {
anchor.getElement().setAttribute(name, String.valueOf(value));
@@ -1,6 +1,7 @@
package com.sap.sse.security.ui.authentication.view;
import com.google.web.bindery.event.shared.EventBus;
import com.sap.sse.security.shared.impl.SecuredSecurityTypes.UserActions;
import com.sap.sse.security.ui.authentication.AuthenticationContextEvent;
import com.sap.sse.security.ui.authentication.AuthenticationPlaceManagementController;
import com.sap.sse.security.ui.authentication.AuthenticationRequestEvent;
@@ -55,9 +56,11 @@ public class FlyoutAuthenticationPresenter implements AuthenticationMenuView.Pre
@Override
public void onUserChangeEvent(AuthenticationContextEvent event) {
authenticationMenuView.setAuthenticated(event.getCtx().isLoggedIn());
authenticationMenuView.showPremium(event.getCtx().hasPermission(event.getCtx().getCurrentUser(), UserActions.BE_PREMIUM));
}
});
authenticationMenuView.setAuthenticated(initialAuthentication.isLoggedIn());
authenticationMenuView.showPremium(initialAuthentication.hasPermission(initialAuthentication.getCurrentUser(), UserActions.BE_PREMIUM));
}
public void showRegister() {
@@ -206,6 +206,7 @@ public interface StringMessages extends com.sap.sse.gwt.client.StringMessages {
String selectSubscriptionPlan();
String features();
String premiumFeature();
String premium();
String price();
String pleaseSubscribeToUse();
String pleaseSubscribeToUseSpecific(String actionName);
@@ -213,6 +213,7 @@ premiumFeatureListDescription=Compare all the features provided in the FREE or P
selectSubscriptionPlan=Please select a subscription plan to subscribe to.
features=Features
premiumFeature=Premium-Feature
premium=Premium
price=Price
pleaseSubscribeToUse=You do not have permission to use this feature. Consider Subscribing.
pleaseSubscribeToUseSpecific=You do not have permission to use the feature "{0}". Consider acquiring a subscription plan.