Skip to content

Commit

Permalink
feat: Add Portlet Images - MEED-7071 - Meeds-io/meeds#2154
Browse files Browse the repository at this point in the history
  • Loading branch information
boubaker committed Jun 14, 2024
1 parent 359374f commit c58822b
Show file tree
Hide file tree
Showing 27 changed files with 70 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ protected void saveIllustration(long pageTemplateId, String imagePath) {
uploadResource.setStatus(UploadResource.UPLOADED_STATUS);
uploadResource.setStoreLocation(resource.getPath());
UploadedAttachmentDetail uploadedAttachmentDetail = new UploadedAttachmentDetail(uploadResource);
attachmentService.deleteAttachments(PageTemplateAttachmentPlugin.OBJECT_TYPE, String.valueOf(pageTemplateId));
attachmentService.saveAttachment(uploadedAttachmentDetail,
PageTemplateAttachmentPlugin.OBJECT_TYPE,
String.valueOf(pageTemplateId),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,7 @@ protected void saveIllustration(long portletInstanceId, String imagePath) {
uploadResource.setStatus(UploadResource.UPLOADED_STATUS);
uploadResource.setStoreLocation(resource.getPath());
UploadedAttachmentDetail uploadedAttachmentDetail = new UploadedAttachmentDetail(uploadResource);
attachmentService.deleteAttachments(PortletInstanceAttachmentPlugin.OBJECT_TYPE, String.valueOf(portletInstanceId));
attachmentService.saveAttachment(uploadedAttachmentDetail,
PortletInstanceAttachmentPlugin.OBJECT_TYPE,
String.valueOf(portletInstanceId),
Expand Down
57 changes: 23 additions & 34 deletions layout-service/src/main/resources/portlet-instances.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"descriptions":{
"en":"layout.portletInstance.MembersPortlet.description"
},
"illustrationPath":"war:/../skin/DefaultSkin/portletIcons/MembersPortlet.png",
"illustrationPath":"war:/../images/portlets/member.webp",
"preferences":[

],
Expand All @@ -29,7 +29,7 @@
"descriptions":{
"en":"layout.portletInstance.SpaceSettingPortlet.description"
},
"illustrationPath":"war:/../skin/DefaultSkin/portletIcons/SpaceSettingPortlet.png",
"illustrationPath":"war:/../images/portlets/settings.webp",
"preferences":[

],
Expand All @@ -48,7 +48,7 @@
"descriptions":{
"en":"layout.portletInstance.Image.description"
},
"illustrationPath":"war:/../skin/DefaultSkin/portletIcons/Image.png",
"illustrationPath":"war:/../images/portlets/image.webp",
"preferences":[

],
Expand All @@ -67,7 +67,7 @@
"descriptions":{
"en":"layout.portletInstance.Links.description"
},
"illustrationPath":"war:/../skin/DefaultSkin/portletIcons/Links.png",
"illustrationPath":"war:/../images/portlets/links.webp",
"preferences":[

],
Expand All @@ -86,7 +86,7 @@
"descriptions":{
"en":"layout.portletInstance.ExternalSpacesList.description"
},
"illustrationPath":"war:/../skin/DefaultSkin/portletIcons/ExternalSpacesList.png",
"illustrationPath":"war:/../images/portlets/spacesList.webp",
"preferences":[

],
Expand All @@ -105,6 +105,7 @@
"descriptions":{
"en":"layout.portletInstance.GettingStarted.description"
},
"illustrationPath":"war:/../images/portlets/gettingStarted.webp",
"permissions":[
"*:/platform/administrators",
"*:/platform/web-contributors"
Expand All @@ -121,7 +122,7 @@
"descriptions":{
"en":"layout.portletInstance.SpaceBannerPortlet.description"
},
"illustrationPath":"war:/../skin/DefaultSkin/portletIcons/SpaceMenuPortlet.png",
"illustrationPath":"war:/../images/portlets/spaceBanner.webp",
"preferences":[

],
Expand All @@ -140,7 +141,7 @@
"descriptions":{
"en":"layout.portletInstance.WhoIsOnLinePortlet.description"
},
"illustrationPath":"war:/../skin/DefaultSkin/portletIcons/WhoIsOnLinePortlet.png",
"illustrationPath":"war:/../images/portlets/whosOnline.webp",
"preferences":[

],
Expand All @@ -159,7 +160,7 @@
"descriptions":{
"en":"layout.portletInstance.PeopleOverview.description"
},
"illustrationPath":"war:/../skin/DefaultSkin/portletIcons/PeopleOverview.png",
"illustrationPath":"war:/../images/portlets/peopleOverview.webp",
"preferences":[

],
Expand All @@ -178,7 +179,7 @@
"descriptions":{
"en":"layout.portletInstance.SpaceActivityStreamPortlet.description"
},
"illustrationPath":"war:/../skin/DefaultSkin/portletIcons/SpaceActivityStreamPortlet.png",
"illustrationPath":"war:/../images/portlets/spaceStream.webp",
"preferences":[

],
Expand All @@ -197,7 +198,7 @@
"descriptions":{
"en":"layout.portletInstance.SpacesOverview.description"
},
"illustrationPath":"war:/../skin/DefaultSkin/portletIcons/SpacesOverview.png",
"illustrationPath":"war:/../images/portlets/spacesOverview.webp",
"preferences":[

],
Expand All @@ -217,7 +218,7 @@
"descriptions":{
"en":"layout.portletInstance.SuggestionsPeopleAndSpace.description"
},
"illustrationPath":"war:/../skin/DefaultSkin/portletIcons/SuggestionsPeopleAndSpace.png",
"illustrationPath":"war:/../images/portlets/suggestionsSpacesPeople.webp",
"preferences":[

],
Expand All @@ -237,7 +238,7 @@
"descriptions":{
"en":"layout.portletInstance.UserActivityStreamPortlet.description"
},
"illustrationPath":"war:/../skin/DefaultSkin/portletIcons/SpaceActivityStreamPortlet.png",
"illustrationPath":"war:/../images/portlets/userActivityStream.webp",
"preferences":[

],
Expand All @@ -257,7 +258,7 @@
"descriptions":{
"en":"layout.portletInstance.SpaceInfos.description"
},
"illustrationPath":"war:/../skin/DefaultSkin/portletIcons/SpaceInfos.png",
"illustrationPath":"war:/../images/portlets/SpaceInfos.webp",
"preferences":[

],
Expand Down Expand Up @@ -286,26 +287,6 @@
],
"system":true
},
{
"nameId":"VerticalMenu",
"categoryNameId":"navigation",
"portletName":"VerticalMenu",
"names":{
"en":"layout.portletInstance.VerticalMenu.name"
},
"descriptions":{
"en":"layout.portletInstance.VerticalMenu.description"
},
"illustrationPath":"war:/../skin/DefaultSkin/portletIcons/VerticalMenu.png",
"preferences":[

],
"permissions":[
"*:/platform/administrators",
"*:/platform/web-contributors"
],
"system":true
},
{
"nameId":"Breadcrumb",
"categoryNameId":"navigation",
Expand All @@ -316,7 +297,7 @@
"descriptions":{
"en":"layout.portletInstance.Breadcrumb.description"
},
"illustrationPath":"war:/../skin/DefaultSkin/portletIcons/Breadcrumb.png",
"illustrationPath":"war:/../images/portlets/siteBreadcrumb.webp",
"preferences":[

],
Expand All @@ -336,6 +317,7 @@
"descriptions":{
"en":"layout.portletInstance.GeneralSettings.description"
},
"illustrationPath":"war:/../images/portlets/generalSettings.webp",
"permissions":[
"*:/platform/administrators",
"*:/platform/web-contributors"
Expand All @@ -352,6 +334,7 @@
"descriptions":{
"en":"layout.portletInstance.UserSettingLanguage.description"
},
"illustrationPath":"war:/../images/portlets/userLanguageSettings.webp",
"permissions":[
"*:/platform/administrators",
"*:/platform/web-contributors"
Expand All @@ -368,6 +351,7 @@
"descriptions":{
"en":"layout.portletInstance.UserSettingNotifications.description"
},
"illustrationPath":"war:/../images/portlets/userNotificationsSettings.webp",
"permissions":[
"*:/platform/administrators",
"*:/platform/web-contributors"
Expand All @@ -384,6 +368,7 @@
"descriptions":{
"en":"layout.portletInstance.UserSettingSecurity.description"
},
"illustrationPath":"war:/../images/portlets/userSecuritySettings.webp",
"permissions":[
"*:/platform/administrators",
"*:/platform/web-contributors"
Expand All @@ -400,6 +385,7 @@
"descriptions":{
"en":"layout.portletInstance.ProfileAboutMe.description"
},
"illustrationPath":"war:/../images/portlets/profileAboutMe.webp",
"permissions":[
"*:/platform/administrators",
"*:/platform/web-contributors"
Expand All @@ -416,6 +402,7 @@
"descriptions":{
"en":"layout.portletInstance.ProfileContactInformation.description"
},
"illustrationPath":"war:/../images/portlets/profileContactInformations.webp",
"permissions":[
"*:/platform/administrators",
"*:/platform/web-contributors"
Expand All @@ -432,6 +419,7 @@
"descriptions":{
"en":"layout.portletInstance.ProfileHeader.description"
},
"illustrationPath":"war:/../images/portlets/profileHeader.webp",
"permissions":[
"*:/platform/administrators",
"*:/platform/web-contributors"
Expand All @@ -448,6 +436,7 @@
"descriptions":{
"en":"layout.portletInstance.ProfileWorkExperience.description"
},
"illustrationPath":"war:/../images/portlets/profileWorkExperiences.webp",
"permissions":[
"*:/platform/administrators",
"*:/platform/web-contributors"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,23 @@ public void getPageLayout() throws IllegalAccessException, ObjectNotFoundExcepti
assertEquals(page, pageLayoutService.getPageLayout(PAGE_KEY, TEST_USER));
}

@SuppressWarnings("unchecked")
@Test
public void getPageApplicationLayout() throws IllegalAccessException, ObjectNotFoundException {
assertThrows(ObjectNotFoundException.class, () -> pageLayoutService.getPageApplicationLayout(PAGE_KEY, 2l, TEST_USER));
when(layoutService.getPage(PAGE_KEY)).thenReturn(page);
assertThrows(IllegalAccessException.class, () -> pageLayoutService.getPageApplicationLayout(PAGE_KEY, 2l, TEST_USER));
when(aclService.canViewPage(PAGE_KEY, TEST_USER)).thenReturn(true);
assertThrows(ObjectNotFoundException.class, () -> pageLayoutService.getPageApplicationLayout(PAGE_KEY, 2l, TEST_USER));

Container container = mock(Container.class);
when(page.getChildren()).thenReturn(new ArrayList<>(Collections.singleton(container)));
Application<Portlet> application = mock(Application.class);
when(application.getStorageId()).thenReturn("2");
when(container.getChildren()).thenReturn(new ArrayList<>(Collections.singleton(application)));
assertNotNull(pageLayoutService.getPageApplicationLayout(PAGE_KEY, 2l, TEST_USER));
}

@SuppressWarnings("unchecked")
@Test
public void getPageLayoutWithDynamicContainer() {
Expand Down Expand Up @@ -226,6 +243,34 @@ public void createPage() {
verify(page).setEditPermission(argThat(permission -> permission.equals(pageEditPermission)));
}

@Test
@SneakyThrows
public void createPageWithLink() {
PageCreateModel pageModel = mock(PageCreateModel.class);
when(pageModel.getPageSiteType()).thenReturn(SITE_KEY.getTypeName());
when(pageModel.getPageSiteName()).thenReturn(SITE_KEY.getName());
when(pageModel.getPageType()).thenReturn(PageType.LINK.name());
when(pageModel.getLink()).thenReturn("#link");
when(pageModel.getPageName()).thenReturn(PAGE_KEY.getName());

String pageTitle = "pageTitle";
when(pageModel.getPageTitle()).thenReturn(pageTitle);
String sitePermission = "site permission";
when(portalConfig.getAccessPermissions()).thenReturn(new String[] { sitePermission });
String siteEditPermission = "site edit permission";
when(portalConfig.getEditPermission()).thenReturn(siteEditPermission);
when(layoutService.getPortalConfig(SITE_KEY)).thenReturn(portalConfig);
when(aclService.canEditNavigation(SITE_KEY, TEST_USER)).thenReturn(true);

pageLayoutService.createPage(pageModel, TEST_USER);
verify(layoutService).save(any(PageContext.class),
argThat(p -> p.getAccessPermissions()[0].equals(sitePermission)
&& p.getEditPermission().equals(siteEditPermission)
&& p.getLink().equals(pageModel.getLink())
&& p.getType().equals(PageType.LINK.name())
&& p.getTitle().equals(pageTitle)));
}

@Test
public void clonePage() throws IllegalAccessException, ObjectNotFoundException {
assertThrows(ObjectNotFoundException.class, () -> pageLayoutService.clonePage(PAGE_KEY, TEST_USER));
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 comments on commit c58822b

Please sign in to comment.