Skip to content

Commit

Permalink
I18N-1334 - Hide the logout option from the user menu (#179)
Browse files Browse the repository at this point in the history
Hid the logout option from the user menu
  • Loading branch information
DarKhaos authored Oct 31, 2024
1 parent f13648f commit 1e764d6
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 6 deletions.
10 changes: 10 additions & 0 deletions webapp/src/main/java/com/box/l10n/mojito/react/ReactAppConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ public class ReactAppConfig {

String analyticsHtmlInclude;

boolean userMenuLogoutHidden;

public ReactAppConfig(ReactStaticAppConfig reactStaticAppConfig, ReactUser reactUser) {
this.reactStaticAppConfig = reactStaticAppConfig;
this.user = reactUser;
Expand Down Expand Up @@ -74,4 +76,12 @@ public void setContextPath(String contextPath) {
public void setAnalyticsHtmlInclude(String analyticsHtmlInclude) {
this.analyticsHtmlInclude = analyticsHtmlInclude;
}

public boolean isUserMenuLogoutHidden() {
return userMenuLogoutHidden;
}

public void setUserMenuLogoutHidden(boolean userMenuLogoutHidden) {
this.userMenuLogoutHidden = userMenuLogoutHidden;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ public class ReactAppController {
@Value("${l10n.webapp.analytics.html.include:}")
String analyticsHtmlInclude;

@Value("${l10n.webapp.user-menu.logout.hide:false}")
boolean userMenuLogoutHidden;

@Value("${server.contextPath:}")
String contextPath = "";

Expand Down Expand Up @@ -102,6 +105,7 @@ ResponseEntity<String> getIndex(
reactAppConfig.setCsrfToken(csrfTokenController.getCsrfToken(httpServletRequest));
reactAppConfig.setContextPath(contextPath);
reactAppConfig.setAnalyticsHtmlInclude(analyticsHtmlInclude);
reactAppConfig.setUserMenuLogoutHidden(this.userMenuLogoutHidden);

index.appConfig = objectMapper.writeValueAsStringUnchecked(reactAppConfig);
index.locale = reactAppConfig.locale;
Expand Down
14 changes: 8 additions & 6 deletions webapp/src/main/resources/public/js/components/header/Header.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,12 +133,14 @@ class Header extends React.Component {
<Glyphicon glyph="pencil"/> <FormattedMessage id="header.change-pw"/>
</MenuItem>

<MenuItem onSelect={this.logoutSelected}>
<form action={UrlHelper.getUrlWithContextPath("/logout")} method="post" ref="logoutForm">
<FormControl type="hidden" name="_csrf" value={this.props.appConfig.csrfToken}/>
<Glyphicon glyph="log-out"/> <FormattedMessage id="header.loggedInUser.logout"/>
</form>
</MenuItem>
{!APP_CONFIG.userMenuLogoutHidden && (
<MenuItem onSelect={this.logoutSelected}>
<form action={UrlHelper.getUrlWithContextPath("/logout")} method="post" ref="logoutForm">
<FormControl type="hidden" name="_csrf" value={this.props.appConfig.csrfToken}/>
<Glyphicon glyph="log-out"/> <FormattedMessage id="header.loggedInUser.logout"/>
</form>
</MenuItem>
)}
</NavDropdown>
</Nav>
<LocaleSelectorModal key="headerLocaleSelectorModal" show={this.state.showLocaleSelectorModal}
Expand Down

0 comments on commit 1e764d6

Please sign in to comment.