Skip to content

Commit

Permalink
feat: Save Sites Display Order when Saving Sidebar - MEED-7902 - Meed…
Browse files Browse the repository at this point in the history
…s-io/MIPs#159 (#4238)

This change will allow to change display order index of sites when
changing it in Sidebar configuration.
  • Loading branch information
boubaker authored and exo-swf committed Dec 6, 2024
1 parent ccaf98a commit 47e4083
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@
import jakarta.annotation.PostConstruct;

@Component
public class NavigationConfigurationSiteDisplayListener
implements ListenerBase<NavigationConfiguration, NavigationConfiguration> {
public class NavigationConfigurationSiteDisplayListener implements ListenerBase<NavigationConfiguration, NavigationConfiguration> {

@Autowired
private ListenerService listenerService;
Expand Down Expand Up @@ -77,8 +76,11 @@ public void onEvent(Event<NavigationConfiguration, NavigationConfiguration> even

newSiteNames.forEach(siteName -> {
PortalConfig site = layoutService.getPortalConfig(SiteKey.portal(siteName));
if (site != null && !site.isDisplayed()) {
int displayOrder = newSiteNames.indexOf(siteName) + 1;
if (site != null
&& (!site.isDisplayed() || site.getDisplayOrder() != displayOrder)) {
site.setDisplayed(true);
site.setDisplayOrder(displayOrder);
layoutService.save(site);
}
});
Expand Down
13 changes: 5 additions & 8 deletions webapp/src/main/webapp/WEB-INF/jsp/portlet/platformSettings.jsp
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
<%@ page import="org.exoplatform.container.ExoContainerContext"%>
<%@ page import="org.exoplatform.portal.config.UserPortalConfigService" %>
<%@ page import="org.exoplatform.portal.application.PortalRequestContext" %>
<%@ page import="org.exoplatform.portal.mop.service.LayoutService" %>
<%@ page import="org.exoplatform.portal.config.model.PortalConfig" %>
<%@ page import="org.exoplatform.web.application.RequestContext" %>
<%@ page import="org.exoplatform.commons.utils.CommonsUtils" %>
<%
PortalRequestContext requestContext = ((PortalRequestContext) RequestContext.getCurrentInstance());
PortalConfig administrationSite = CommonsUtils.getService(LayoutService.class).getPortalConfig("PORTAL", "administration");
String path = CommonsUtils.getService(UserPortalConfigService.class).computePortalSitePath("administration", requestContext.getRequest());
String path = ExoContainerContext.getService(UserPortalConfigService.class)
.getDefaultSitePath("administration", request.getRemoteUser());
if (path != null) {
%>
<% if (administrationSite != null && !administrationSite.isDisplayed() && path != null) { %>
<div class="VuetifyApp">
<div data-app="true"
class="v-application v-application--is-ltr theme--light"
Expand All @@ -22,7 +19,7 @@
</a>
</div>
<script type="text/javascript">
require(['PORTLET/social/PlatformSettings'], app => app.init(`<%=path%>`));
require(['PORTLET/social/PlatformSettings'], app => app.init());
</script>
</div>
</div>
Expand Down
4 changes: 2 additions & 2 deletions webapp/src/main/webapp/WEB-INF/jsp/portlet/sidebar.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<%@page import="io.meeds.social.space.template.service.SpaceTemplateService"%>
<%@page import="org.exoplatform.social.webui.Utils"%>
<%
PortalRequestContext rcontext = (PortalRequestContext) PortalRequestContext.getCurrentInstance();
PortalRequestContext rcontext = (PortalRequestContext) PortalRequestContext.getCurrentInstance();
UserPortalConfigService portalConfigService = ExoContainerContext.getService(UserPortalConfigService.class);
NavigationConfigurationService navigationConfigurationService = ExoContainerContext.getService(NavigationConfigurationService.class);
Expand All @@ -37,7 +37,7 @@
} else {
defaultUserPath = portalConfigService.getUserHomePage(request.getRemoteUser());
if (defaultUserPath == null) {
defaultUserPath = portalConfigService.computePortalPath(rcontext.getRequest());
defaultUserPath = portalConfigService.getDefaultPath(request.getRemoteUser());
}
}
if (defaultUserPath == null) {
Expand Down
32 changes: 16 additions & 16 deletions webapp/src/main/webapp/WEB-INF/jsp/portlet/topbarLogo.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
<%@ page import="org.exoplatform.social.core.identity.provider.OrganizationIdentityProvider" %>
<%@ page import="java.util.Optional" %>
<%
String spaceId = null;
String spaceId = null;
String portalPath = null;
String titleClass = "";
String imageClass = "";
Expand Down Expand Up @@ -64,13 +64,13 @@
portalPath = "/portal/public";
} else {
if (sidebarConfiguration.isAllowUserCustomHome()) {
portalPath = portalConfigService.getUserHomePage(request.getRemoteUser());
portalPath = portalConfigService.getUserHomePage(request.getRemoteUser());
}
if (portalPath == null) {
portalPath = portalConfigService.computePortalPath(requestContext.getRequest());
if (portalPath == null) {
portalPath = defaultHomePath;
}
portalPath = portalConfigService.getDefaultPath(request.getRemoteUser());
if (portalPath == null) {
portalPath = defaultHomePath;
}
}
}
titleClass = "company";
Expand All @@ -95,10 +95,10 @@
membersNumber = space.getMembers().length;
spaceDescription = Optional.ofNullable(space.getDescription()).orElse("");
if (authenticatedUser != null) {
for(String username : space.getManagers()) {
Profile profile = identityManager.getOrCreateIdentity(OrganizationIdentityProvider.NAME, username).getProfile();
managers.add(profile);
}
for(String username : space.getManagers()) {
Profile profile = identityManager.getOrCreateIdentity(OrganizationIdentityProvider.NAME, username).getProfile();
managers.add(profile);
}
}
}
Expand All @@ -108,8 +108,8 @@
boolean displaySiteName = topbarConfiguration.isDisplaySiteName();
SidebarMode sidebarMode = sidebarConfiguration.getUserMode();
SidebarItem sidebarItem = space == null ? sidebarConfiguration.getItems().stream().filter(item -> item.getUrl() != null
&& item.getType() == SidebarItemType.SITE
&& requestContext.getRequest().getRequestURI().toString().startsWith(item.getUrl()))
&& item.getType() == SidebarItemType.SITE
&& requestContext.getRequest().getRequestURI().toString().startsWith(item.getUrl()))
.findFirst()
.orElse(null)
: null;
Expand All @@ -118,10 +118,10 @@
&& StringUtils.equals(sidebarItem.getProperties().get(AbstractLayoutSidebarPlugin.SITE_EXPAND_PAGES_PROP_NAME), "true")
&& CollectionUtils.isNotEmpty(sidebarItem.getItems())) {
sidebarItem = sidebarItem.getItems().stream().filter(item -> item.getUrl() != null
&& item.getType() == SidebarItemType.PAGE
&& requestContext.getRequest().getRequestURI().toString().startsWith(item.getUrl()))
.findFirst()
.orElse(null);
&& item.getType() == SidebarItemType.PAGE
&& requestContext.getRequest().getRequestURI().toString().startsWith(item.getUrl()))
.findFirst()
.orElse(null);
isSitePage = true;
}
%>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<v-tooltip bottom>
<template #activator="{ on, attrs }">
<v-btn
:href="$root.url"
:aria-label="$t('platformSettings.label.openAdministration')"
href="/portal/administration"
target="_blank"
class="mx-2"
icon
Expand Down
5 changes: 1 addition & 4 deletions webapp/src/main/webapp/vue-apps/platform-settings/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,9 @@ const appId = 'platformSettings';
const lang = window?.eXo?.env?.portal?.language || 'en';
const i18NUrl = `/social/i18n/locale.portlet.PlatformSettings?lang=${lang}`;

export function init(url) {
export function init() {
exoi18n.loadLanguageAsync(lang, i18NUrl).then(i18n => {
Vue.createApp({
data: {
url,
},
mounted() {
this.$root.$applicationLoaded();
},
Expand Down

0 comments on commit 47e4083

Please sign in to comment.