Skip to content

Commit

Permalink
feat: Add Access Button in Public Site Top bar - MEED-2820 - Meeds-io…
Browse files Browse the repository at this point in the history
…/meeds#1236 (#3136)

Prior to this change, When logged in AND accessing the public site, then
it is not possible to access the platform unless you have the link
somewhere referenced. This change will introduce a new button to the
user when logged in. By clicking on button, the aggregated default site
opens in a new tab.
  • Loading branch information
boubaker committed Nov 7, 2023
1 parent eea8236 commit 4e0a384
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -809,7 +809,7 @@ Notification.alert.errorChangingSpaceMutingStatus=An error occurred while procee
publicAccess.login=Login
publicAccess.register=Sign up
publicAccess.access=Open
publicAccess.previewModeTooltip=Preview as visitor
publicAccess.previewModeTooltip=Preview the page as visitor
publicAccess.editModeTooltip=Get back to edit mode
publicAccess.makeSiteVisible=Make the site visible
generalSettings.publicSiteUpdatedSuccessfully=Public site visibility successfully updated
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<%@page import="org.exoplatform.social.core.identity.model.Identity"%>
<%@page import="org.exoplatform.social.webui.Utils"%>
<%@page import="io.meeds.portal.security.constant.UserRegistrationType"%>
<%@page import="org.exoplatform.container.ExoContainerContext"%>
<%@page import="io.meeds.portal.security.service.SecuritySettingService"%>
Expand All @@ -24,6 +26,8 @@
<%
SecuritySettingService securitySettingService = ExoContainerContext.getService(SecuritySettingService.class);
boolean canRegister = securitySettingService.getRegistrationType() == UserRegistrationType.OPEN;
Identity viewerIdentity = Utils.getViewerIdentity();
String avatarUrl = viewerIdentity == null ? "" : viewerIdentity.getProfile().getAvatarUrl();
%>
<div class="VuetifyApp">
<div data-app="true"
Expand All @@ -40,7 +44,7 @@
</div>
<% } %>
<script type="text/javascript">
require(['PORTLET/social-portlet/TopBarLogin'], app => app.init(<%=canRegister%>));
require(['PORTLET/social-portlet/TopBarLogin'], app => app.init('<%=avatarUrl%>', <%=canRegister%>));
</script>
</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@

-->
<template>
<v-app v-if="publicMode">
<div class="d-flex">
<v-app>
<div v-if="publicMode" class="d-flex">
<v-btn
v-if="$root.canRegister"
id="topBarRegisterButton"
Expand All @@ -41,6 +41,18 @@
<v-icon v-else size="16">fa-sign-in-alt</v-icon>
</v-btn>
</div>
<v-btn
v-else-if="authenticated"
id="topBarAccessButton"
href="/portal"
target="_blank"
class="primary"
outlined>
<v-avatar size="20" class="me-2">
<v-img :src="$root.avatarUrl" eager />
</v-avatar>
<span class="text-none">{{ $t('publicAccess.access') }}</span>
</v-btn>
</v-app>
</template>
<script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,12 @@ const lang = window.eXo?.env?.portal?.language || 'en';
const url = `${eXo.env.portal.context}/${eXo.env.portal.rest}/i18n/bundle/locale.portlet.Portlets-${lang}.json`;
const appId = 'topbarLogin';

export function init(canRegister) {
export function init(avatarUrl, canRegister) {
exoi18n.loadLanguageAsync(lang, url).then(i18n => {
// init Vue app when locale resources are ready
Vue.createApp({
data: {
avatarUrl,
canRegister,
},
template: `<top-bar-login id="${appId}" />`,
Expand Down

0 comments on commit 4e0a384

Please sign in to comment.