Skip to content

Commit

Permalink
feat: Implement left navigation level 1 for sites - EXO-65477 - Meeds…
Browse files Browse the repository at this point in the history
  • Loading branch information
GouadriaHanen authored and IlhemEssaadi committed Sep 4, 2023
1 parent 61de30d commit 63ecf7f
Show file tree
Hide file tree
Showing 10 changed files with 345 additions and 3 deletions.
46 changes: 46 additions & 0 deletions webapp/portlet/src/main/webapp/vue-apps/common/js/SitesService.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* This file is part of the Meeds project (https://meeds.io/).
*
* Copyright (C) 2023 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.
*/

export function retrieveSites(siteType, displayed, allSites, excludedSiteName, expandNavigations, filterByPermission) {

const formData = new FormData();
if (siteType) {
formData.append('siteType', siteType);
}
formData.append('displayed', displayed);
formData.append('allSites', allSites);
formData.append('filterByPermission', filterByPermission);
if (excludedSiteName) {
formData.append('excludedSiteName', excludedSiteName);
}
formData.append('expandNavigations', expandNavigations);
const params = new URLSearchParams(formData).toString();

return fetch(`${eXo.env.portal.context}/${eXo.env.portal.rest}/v1/sitesManagement?${params}`, {
method: 'GET',
credentials: 'include',
}).then(resp => {
if (resp?.ok) {
return resp.json();
} else {
throw new Error('error while retrieving sites');
}
});
}
4 changes: 4 additions & 0 deletions webapp/portlet/src/main/webapp/vue-apps/common/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import * as brandingService from './js/brandingService.js';
import * as navigationService from '../common/js/NavigationService.js';
import * as profileSettingsService from '../common/js/ProfileSettingsService.js';
import * as profileLabelService from '../common/js/ProfileLabelService.js';
import * as sitesService from './js/SitesService.js';

// get overrided components if exists
if (extensionRegistry) {
Expand Down Expand Up @@ -88,6 +89,9 @@ window.Object.defineProperty(Vue.prototype, '$profileLabelService', {
window.Object.defineProperty(Vue.prototype, '$navigationService', {
value: navigationService,
});
window.Object.defineProperty(Vue.prototype, '$sitesService', {
value: sitesService,
});

if (eXo.env.portal.userIdentityId) {
window.Object.defineProperty(Vue.prototype, '$currentUserIdentity', {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
:second-level="secondLevel"
:has-administration-navigations="hasAdministrationNavigations"
:site-navigations="siteNavigations"
:sites="sites"
:recent-spaces="recentSpaces"
:opened-space="space"
:sticky-allowed="stickyAllowed"
Expand All @@ -73,6 +74,7 @@
:second-level="secondLevel"
:has-administration-navigations="hasAdministrationNavigations"
:site-navigations="siteNavigations"
:sites="sites"
:recent-spaces="recentSpaces"
:opened-space="space"
:sticky-allowed="stickyAllowed"
Expand Down Expand Up @@ -113,6 +115,7 @@ export default {
space: null,
administrationNavigations: null,
siteNavigations: null,
sites: [],
initStep: 0,
recentSpaces: null,
limit: 7,
Expand Down Expand Up @@ -225,6 +228,7 @@ export default {
methods: {
init() {
return Promise.all([
this.retrieveSites(),
this.retrieveSiteNavigations(),
this.retrieveAdministrationNavigations(),
this.retrieveRecentSpaces(),
Expand Down Expand Up @@ -301,8 +305,16 @@ export default {
window.setTimeout(() => document.dispatchEvent(new CustomEvent('drawerClosed')), 200);
},
retrieveSiteNavigations() {
return this.$navigationService.getNavigations(eXo.env.portal.portalName, 'portal', 'children', this.visibility)
.then(data => this.siteNavigations = data || []);
if (!eXo.env.portal.newLeftNavigationDrawer) {
return this.$navigationService.getNavigations(eXo.env.portal.portalName, 'portal', 'children', this.visibility)
.then(data => this.siteNavigations = data || []);
}
},
retrieveSites(){
if (eXo.env.portal.newLeftNavigationDrawer) {
return this.$sitesService.retrieveSites('PORTAL', true, false, 'global', true, true)
.then(data => this.sites = data || []);
}
},
retrieveAdministrationNavigations() {
return this.$navigationService.getNavigations(null, 'group', null, this.visibility)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@
class="overflow-y-overlay overflow-x-hidden flex-grow-1 flex-shrink-1 pt-5"
flat
tile>
<site-hamburger-navigation :navigations="siteNavigations" />
<sites-hamburger v-if="newLeftNavigationDrawerEnabled" :sites="sites" />
<site-hamburger-navigation v-else :navigations="siteNavigations" />
<spaces-hamburger-navigation
:recent-spaces="recentSpaces"
:recent-spaces-drawer-opened="recentSpacesDrawerOpened"
Expand Down Expand Up @@ -91,6 +92,10 @@ export default {
type: Array,
default: null,
},
sites: {
type: Array,
default: () => [],
},
recentSpaces: {
type: Array,
default: null,
Expand All @@ -112,6 +117,9 @@ export default {
default: null,
},
},
data: () => ({
newLeftNavigationDrawerEnabled: eXo.env.portal.newLeftNavigationDrawer,
}),
computed: {
levelsOpened() {
return this.secondLevelDrawer || this.thirdLevelDrawer;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<!--
This file is part of the Meeds project (https://meeds.io/).
Copyright (C) 2020 - 2023 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-list-item :href="uri" class="ps-0">
<v-list-item-icon class="flex align-center flex-grow-0 my-2">
<v-icon v-if="siteRootNode.icon"> {{ icon }}</v-icon>
<i v-else :class="iconClass"></i>
</v-list-item-icon>
<v-list-item-content>
<v-list-item-title
class="subtitle-2"
v-text="site.displayName" />
</v-list-item-content>
</v-list-item>
</template>

<script>
export default {
props: {
site: {
type: Object,
default: null
}
},
data: () => ({
BASE_SITE_URI: `${eXo.env.portal.context}/${eXo.env.portal.portalName}/`,
}),
computed: {
uri() {
return this.site?.siteNavigations && this.site?.siteNavigations[0]?.uri && this.site?.siteNavigations[0].pageLink && this.urlVerify(this.site?.siteNavigations[0].pageLink) || `/portal/${this.site.name}/${this.site?.siteNavigations[0].uri}`;
},
icon() {
return `fas ${this.site?.siteNavigations && this.site?.siteNavigations[0]?.icon}`;
},
siteRootNode() {
return this.site?.siteNavigations && this.site?.siteNavigations[0];
},
iconClass() {
const capitilizedName = `${this.siteRootNode.name[0].toUpperCase()}${this.siteRootNode.name.slice(1)}`;
return `uiIcon uiIconFile uiIconToolbarNavItem uiIcon${capitilizedName} icon${capitilizedName} ${this.siteRootNode.icon}`;
}
},
methods: {
urlVerify(url) {
if (!url.match(/^(https?:\/\/|javascript:|\/portal\/)/)) {
url = `//${url}`;
}
return url;
},
}
};
</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<!--
This file is part of the Meeds project (https://meeds.io/).
Copyright (C) 2020 - 2023 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-list
dense
min-width="90%"
class="pb-0">
<v-list-item
v-for="site in sites"
:key="site.name"
link>
<site-hamburger-item
v-if="!site.defaultSite"
:site="site" />
<site-hamburger-navigation-list v-else :navigations="site.siteNavigations" />
</v-list-item>
</v-list>
</template>

<script>
export default {
props: {
sites: {
type: Array,
default: () => []
}
}
};
</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<!--
This file is part of the Meeds project (https://meeds.io/).
Copyright (C) 2020 - 2023 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-list-item
:href="uri"
:target="target"
class="ps-0">
<v-list-item-icon class-name="flex align-center flex-grow-0">
<v-icon v-if="navigation.icon"> {{ icon }}</v-icon>
<i v-else :class="iconClass"></i>
</v-list-item-icon>
<v-list-item-content>
<v-list-item-title
class-name="subtitle-2"
v-text="navigation.label" />
</v-list-item-content>
</v-list-item>
</template>
<script>
export default {
props: {
navigation: {
type: Object,
default: null
}
},
computed: {
uri() {
return this.navigation?.pageLink && this.urlVerify(this.navigation.pageLink) || `/portal/${this.navigation.siteKey.name}/${this.navigation.uri}`;
},
target() {
return this.navigation?.target === 'SAME_TAB' && '_self' || '_blank';
},
icon() {
return `fas ${this.navigation?.icon}`;
},
iconClass() {
const capitilizedName = `${this.navigation.name[0].toUpperCase()}${this.navigation.name.slice(1)}`;
return `uiIcon uiIconFile uiIconToolbarNavItem uiIcon${capitilizedName} icon${capitilizedName} ${this.navigation.icon}`;
}
},
methods: {
urlVerify(url) {
if (!url.match(/^(https?:\/\/|javascript:|\/portal\/)/)) {
url = `//${url}`;
}
return url;
},
}
};
</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<!--
This file is part of the Meeds project (https://meeds.io/).
Copyright (C) 2020 - 2023 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-main class="ps-0">
<v-list-item
v-for="navigation in navigations"
:key="navigation.name"
dense
class="pb-0 ps-0">
<site-hamburger-navigation-item
:navigation="navigation" />
</v-list-item>
</v-main>
</template>
<script>
export default {
props: {
navigations: {
type: Array,
default: () => []
}
}
};
</script>
Loading

0 comments on commit 63ecf7f

Please sign in to comment.