Skip to content

Commit

Permalink
feat: Add Space Template Menu Item Extension - MEED-7669 - Meeds-io/M…
Browse files Browse the repository at this point in the history
…IPs#165 (#241)

This change will allow to edit Space Template Navigation through the
Site Navigation Editor.
  • Loading branch information
boubaker committed Oct 29, 2024
1 parent 9c7b9b5 commit 02f94fb
Show file tree
Hide file tree
Showing 8 changed files with 161 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@
import org.exoplatform.commons.exception.ObjectNotFoundException;
import org.exoplatform.commons.utils.ExpressionUtil;
import org.exoplatform.portal.application.PortalRequestHandler;
import org.exoplatform.portal.application.PortalTemplateRequestHandler;
import org.exoplatform.portal.config.model.PortalConfig;
import org.exoplatform.portal.mop.SiteKey;
import org.exoplatform.portal.mop.SiteType;
import org.exoplatform.portal.mop.State;
import org.exoplatform.portal.mop.Visibility;
import org.exoplatform.portal.mop.navigation.NodeContext;
Expand Down Expand Up @@ -297,11 +300,19 @@ public String getNodeUri(NodeData node) {
Router router = webController.getRouter();

Map<QualifiedName, String> params = new HashMap<>();
params.put(WebAppController.HANDLER_PARAM, "portal"); // PortalRequestHandler.NAME
params.put(PortalRequestHandler.REQUEST_SITE_NAME, siteKey.getName());
params.put(PortalRequestHandler.REQUEST_SITE_TYPE, siteKey.getTypeName());
params.put(PortalRequestHandler.REQUEST_PATH, uriBuilder.toString().replaceFirst("/", ""));
params.put(PortalRequestHandler.LANG, Locale.ENGLISH.toLanguageTag());
if (siteKey.getType() == SiteType.GROUP_TEMPLATE) {
PortalConfig portalConfig = layoutService.getPortalConfig(siteKey);
params.put(WebAppController.HANDLER_PARAM, PortalTemplateRequestHandler.HANDLER_NAME);
params.put(PortalTemplateRequestHandler.REQUEST_SITE_ID, (portalConfig.getStorageId().split("_"))[1]);
params.put(PortalTemplateRequestHandler.REQUEST_PATH, uriBuilder.toString().replaceFirst("/", ""));
params.put(PortalTemplateRequestHandler.LANG, Locale.ENGLISH.toLanguageTag());
} else {
params.put(WebAppController.HANDLER_PARAM, PortalRequestHandler.HANDLER_NAME);
params.put(PortalRequestHandler.REQUEST_SITE_NAME, siteKey.getName());
params.put(PortalRequestHandler.REQUEST_SITE_TYPE, siteKey.getTypeName());
params.put(PortalRequestHandler.REQUEST_PATH, uriBuilder.toString().replaceFirst("/", ""));
params.put(PortalRequestHandler.LANG, Locale.ENGLISH.toLanguageTag());
}
return router.render(params).replace("/en", "").replace("?lang=en", "").replace("&lang=en", "");
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
siteManagement.label.portal=Site
siteManagement.label.group=Site of group
siteManagement.label.group_template=Group Template
siteManagement.label.navigation=Navigation
siteManagement.label.delete=Delete
siteManagement.label.cancel=Cancel
Expand Down
41 changes: 40 additions & 1 deletion layout-webapp/src/main/webapp/WEB-INF/gatein-resources.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,13 @@
<css-path>/skin/css/editor.css</css-path>
</portlet-skin>

<portlet-skin>
<application-name>social</application-name>
<portlet-name>SpaceTemplateManagement</portlet-name>
<skin-name>Enterprise</skin-name>
<css-path>/skin/css/siteNavigation.css</css-path>
</portlet-skin>

<module>
<name>commonLayoutComponents</name>
<script>
Expand Down Expand Up @@ -73,7 +80,7 @@
</module>

<module>
<name>ManageSpacesExtension</name>
<name>LayoutManageSpacesExtension</name>
<load-group>ManageSpaceGRP</load-group>
<script>
<path>/js/siteNavigation.bundle.js</path>
Expand Down Expand Up @@ -104,6 +111,38 @@
</depends>
</module>

<module>
<name>LayoutSpaceTemplateManagementExtension</name>
<load-group>SpaceTemplateManagement</load-group>
<script>
<path>/js/siteNavigation.bundle.js</path>
</script>
<depends>
<module>extensionRegistry</module>
</depends>
<depends>
<module>eXoVueI18n</module>
</depends>
<depends>
<module>vue</module>
</depends>
<depends>
<module>vuetify</module>
</depends>
<depends>
<module>commonVueComponents</module>
</depends>
<depends>
<module>commonLayoutComponents</module>
</depends>
<depends>
<module>translationField</module>
</depends>
<depends>
<module>fontIcons</module>
</depends>
</module>

<portlet>
<name>SiteNavigation</name>
<module>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
<span
:title="siteName"
class="font-weight-bold text-truncate">
{{ siteName }}
{{ label }}
</span>
<v-spacer v-if="!$refs.siteNavigationDrawer?.expand" />
<v-btn
Expand Down Expand Up @@ -77,6 +77,7 @@ export default {
siteName: null,
siteType: null,
siteId: null,
siteLabel: null,
includeGlobal: false,
loading: false,
filter: 'ALL',
Expand Down Expand Up @@ -104,7 +105,10 @@ export default {
},
isMetaSite() {
return this.site?.metaSite;
}
},
label() {
return this.siteLabel || this.siteName;
},
},
watch: {
filter() {
Expand All @@ -121,6 +125,7 @@ export default {
open(event) {
this.siteName = event?.siteName || eXo.env.portal.spaceDisplayName || eXo.env.portal.siteKeyName;
this.siteType = event?.siteType || eXo.env.portal.siteKeyType;
this.siteLabel = event?.siteLabel;
this.siteId = event?.siteId || eXo.env.portal.siteId;
this.includeGlobal = event?.includeGlobal || false;
this.getNavigationNodes();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@
</v-footer>
</v-card>
</template>

<script>
export default {
props: {
Expand All @@ -69,7 +68,7 @@ export default {
},
siteTypeLabel() {
return this.$t(`siteManagement.label.${this.site.siteType.toLowerCase()}`) ;
}
},
},
methods: {
openSiteNavigationDrawer() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
<!--
This file is part of the Meeds project (https://meeds.io/).
Copyright (C) 2020 - 2024 Meeds Association [email protected]
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-->
<template>
<v-tooltip v-if="spaceTemplate.layout" :disabled="!spaceTemplate.system" bottom>
<template #activator="{ on, attrs }">
<div
v-on="on"
v-bind="attrs">
<v-list-item
:disabled="spaceTemplate.system"
dense
@click="openSiteNavigationDrawer">
<v-icon
:class="spaceTemplate.system && 'disabled--text'"
size="13">
fa-columns
</v-icon>
<v-list-item-title class="ps-2">
<span :class="spaceTemplate.system && 'disabled--text'">{{ $t('spaceTemplate.label.editLayout') }}</span>
</v-list-item-title>
</v-list-item>
</div>
</template>
<span>{{ $t('spaceTemplate.label.system.noEditLayout') }}</span>
</v-tooltip>
</template>
<script>
export default {
props: {
spaceTemplate: {
type: Object,
default: null,
},
},
data: () => ({
site: null,
}),
beforeDestroy() {
this.$emit('loading', false);
},
methods: {
async openSiteNavigationDrawer() {
this.$emit('loading', true);
try {
if (!this.site) {
this.site = await this.$siteService.getSite('group_template', this.spaceTemplate?.layout, {
expandNavigations: false,
});
}
document.dispatchEvent(new CustomEvent('open-site-navigation-drawer',{detail: {
siteName: this.site.name,
siteType: this.site.siteType,
siteId: this.site.siteId,
siteLabel: this.spaceTemplate?.name,
includeGlobal: false,
}}));
} finally {
this.$emit('loading', false);
}
},
},
};
</script>
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,13 @@
import SiteNavigation from './components/SiteNavigation.vue';
import SiteNavigationButton from './components/SiteNavigationButton.vue';
import SiteNavigationDrawersActions from './components/SiteNavigationDrawersActions.vue';
import SpaceTemplateEditLayoutSpaceMenuItem from './components/SpaceTemplateEditLayoutSpaceMenuItem.vue';

const components = {
'site-navigation': SiteNavigation,
'site-navigation-button': SiteNavigationButton,
'site-navigation-drawers-actions': SiteNavigationDrawersActions
'site-navigation-drawers-actions': SiteNavigationDrawersActions,
'site-navigation-space-template-manage-layout': SpaceTemplateEditLayoutSpaceMenuItem,
};

for (const key in components) {
Expand Down
12 changes: 12 additions & 0 deletions layout-webapp/src/main/webapp/vue-app/site-navigation/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,18 @@ extensionRegistry.registerComponent('manageSpaceDrawers', 'manage-space-drawers'
rank: 20,
});

extensionRegistry.registerComponent('space-templates', 'space-templates-drawers', {
id: 'manage-space-drawers',
vueComponent: Vue.options.components['site-navigation-drawers-actions'],
rank: 10,
});

extensionRegistry.registerExtension('space-templates', 'space-templates-item-action', {
rank: 25,
name: 'manage-layout',
componentName: 'site-navigation-space-template-manage-layout',
});

const appId = 'siteNavigation';

//getting language of the PLF
Expand Down

0 comments on commit 02f94fb

Please sign in to comment.