diff --git a/component/api/src/main/java/org/exoplatform/social/core/space/SpaceListAccess.java b/component/api/src/main/java/org/exoplatform/social/core/space/SpaceListAccess.java index 64846232db5..45fca4f1dda 100644 --- a/component/api/src/main/java/org/exoplatform/social/core/space/SpaceListAccess.java +++ b/component/api/src/main/java/org/exoplatform/social/core/space/SpaceListAccess.java @@ -18,7 +18,6 @@ import java.util.ArrayList; import java.util.List; -import java.util.stream.Collectors; import org.apache.commons.lang3.StringUtils; import org.exoplatform.commons.utils.ListAccess; @@ -261,7 +260,7 @@ public Space[] load(int offset, int limit) throws Exception, IllegalArgumentExce break; case PUBLIC_FILTER: listSpaces = spaceStorage.getPublicSpacesByFilter(this.userId, this.spaceFilter, offset, limit); break; - case PUBLIC_SUPER_USER: listSpaces = new ArrayList (); + case PUBLIC_SUPER_USER: listSpaces = new ArrayList<> (); break; case SETTING: listSpaces = spaceStorage.getEditableSpaces(this.userId, offset, limit); break; diff --git a/component/core/src/main/java/org/exoplatform/social/core/identity/ProfileFilterListAccess.java b/component/core/src/main/java/org/exoplatform/social/core/identity/ProfileFilterListAccess.java index f651de4b95f..6143f496e0c 100644 --- a/component/core/src/main/java/org/exoplatform/social/core/identity/ProfileFilterListAccess.java +++ b/component/core/src/main/java/org/exoplatform/social/core/identity/ProfileFilterListAccess.java @@ -173,7 +173,8 @@ public Identity[] load(int offset, int limit) throws Exception, IllegalArgumentE Iterator iterator = identities.iterator(); while (iterator.hasNext()) { Identity identity = iterator.next(); - if (identity.equals(profileFilter.getViewerIdentity())) { + if (identity == null || (profileFilter.getViewerIdentity() != null + && identity.getId().equals(profileFilter.getViewerIdentity().getId()))) { iterator.remove(); } } diff --git a/component/core/src/main/java/org/exoplatform/social/core/space/SpaceUtils.java b/component/core/src/main/java/org/exoplatform/social/core/space/SpaceUtils.java index 63e3d4a587f..45be03aa665 100644 --- a/component/core/src/main/java/org/exoplatform/social/core/space/SpaceUtils.java +++ b/component/core/src/main/java/org/exoplatform/social/core/space/SpaceUtils.java @@ -17,11 +17,8 @@ package org.exoplatform.social.core.space; import java.util.ArrayList; -import java.util.Arrays; import java.util.Collection; -import java.util.Collections; import java.util.Comparator; -import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Locale; @@ -441,6 +438,9 @@ public static void removePagesAndGroupNavigation(Space space) throws Exception { */ public static void changeAppPageTitle(UserNode spacePageNode, String newSpaceName) throws Exception { + if (spacePageNode == null || spacePageNode.getPageRef() == null) { + return; + } LayoutService layoutService = getLayoutService(); Page page = layoutService.getPage(spacePageNode.getPageRef().format()); diff --git a/component/service/src/main/java/io/meeds/social/link/rest/LinkRest.java b/component/service/src/main/java/io/meeds/social/link/rest/LinkRest.java index e90c6ddc675..23ae75f6ba7 100644 --- a/component/service/src/main/java/io/meeds/social/link/rest/LinkRest.java +++ b/component/service/src/main/java/io/meeds/social/link/rest/LinkRest.java @@ -49,7 +49,7 @@ import io.meeds.social.link.model.Link; import io.meeds.social.link.model.LinkSetting; import io.meeds.social.link.rest.model.LinkSettingRestEntity; -import io.meeds.social.link.rest.util.EntityBuilder; +import io.meeds.social.link.rest.util.LinkEntityBuilder; import io.meeds.social.link.service.LinkService; import io.swagger.v3.oas.annotations.Operation; @@ -130,8 +130,8 @@ public Response getLinkSetting( @ApiResponse(responseCode = "401", description = "Unauthorized"), }) public Response saveLinkSetting(LinkSettingRestEntity linkSettingEntity) { try { - LinkSetting linkSetting = EntityBuilder.toLinkSetting(linkSettingEntity); - List linksToSave = EntityBuilder.toLinks(linkSettingEntity); + LinkSetting linkSetting = LinkEntityBuilder.toLinkSetting(linkSettingEntity); + List linksToSave = LinkEntityBuilder.toLinks(linkSettingEntity); linkSetting = linkService.saveLinkSetting(linkSetting, linksToSave, RestUtils.getCurrentUserAclIdentity()); return Response.ok(getLinkSettingEntity(linkSetting, null)).build(); } catch (IllegalAccessException e) { @@ -190,7 +190,7 @@ public Response getLinkIcon( private LinkSettingRestEntity getLinkSettingEntity(LinkSetting linkSetting, String lang) { List links = linkService.getLinks(linkSetting.getName(), lang, true); - return EntityBuilder.build(linkSetting, links); + return LinkEntityBuilder.build(linkSetting, links); } } diff --git a/component/service/src/main/java/io/meeds/social/link/rest/util/EntityBuilder.java b/component/service/src/main/java/io/meeds/social/link/rest/util/LinkEntityBuilder.java similarity index 98% rename from component/service/src/main/java/io/meeds/social/link/rest/util/EntityBuilder.java rename to component/service/src/main/java/io/meeds/social/link/rest/util/LinkEntityBuilder.java index a66d3262092..430945eaf0b 100644 --- a/component/service/src/main/java/io/meeds/social/link/rest/util/EntityBuilder.java +++ b/component/service/src/main/java/io/meeds/social/link/rest/util/LinkEntityBuilder.java @@ -34,9 +34,9 @@ import io.meeds.social.link.rest.model.LinkRestEntity; import io.meeds.social.link.rest.model.LinkSettingRestEntity; -public class EntityBuilder { +public class LinkEntityBuilder { - private EntityBuilder() { + private LinkEntityBuilder() { // Utils class } diff --git a/component/service/src/main/java/org/exoplatform/social/rest/api/EntityBuilder.java b/component/service/src/main/java/org/exoplatform/social/rest/api/EntityBuilder.java index 7d25c7e4c72..a3329092f4b 100644 --- a/component/service/src/main/java/org/exoplatform/social/rest/api/EntityBuilder.java +++ b/component/service/src/main/java/org/exoplatform/social/rest/api/EntityBuilder.java @@ -453,7 +453,7 @@ public static ProfileEntity buildEntityProfile(Profile profile, String restPath, } } if (expandAttributes.contains(SETTINGS)) { - userEntity.setProperties(EntityBuilder.buildProperties(profile, canViewProperties)); + userEntity.setProperties(buildProperties(profile, canViewProperties)); } if (expandAttributes.contains(MANAGER) && profile.getProperty(MANAGER) != null) { buildListManagers(userEntity, profile, restPath); @@ -538,8 +538,8 @@ private static void buildManagedUsersCount(ProfileEntity userEntity) { } } + @SuppressWarnings("unchecked") private static void buildListManagers(ProfileEntity userEntity, Profile profile, String restPath) { - @SuppressWarnings("unchecked") ArrayList> userNames = new ArrayList<>(); if (profile.getProperty(MANAGER) instanceof List) { userNames = (ArrayList>) profile.getProperty(MANAGER); @@ -783,6 +783,31 @@ public static List buildEntityProfiles(String[] userNames, String re return userEntities; } + public static CollectionEntity buildEntityFromSpaces(List spaces, + String username, + int offset, + int limit, + String expand, + UriInfo uriInfo) { + List spaceInfos = new ArrayList<>(); + for (Space space : spaces) { + SpaceEntity spaceInfo = buildEntityFromSpace(space, username, uriInfo.getPath(), expand); + spaceInfos.add(spaceInfo.getDataEntity()); + } + CollectionEntity collectionSpace = new CollectionEntity(spaceInfos, SPACES_TYPE, offset, limit); + if (StringUtils.isNotBlank(expand) && Arrays.asList(StringUtils.split(expand, ",")).contains(RestProperties.UNREAD)) { + SpaceWebNotificationService spaceWebNotificationService = ExoContainerContext.getService(SpaceWebNotificationService.class); + Map unreadItemsPerSpace = spaceWebNotificationService.countUnreadItemsBySpace(username); + if (MapUtils.isNotEmpty(unreadItemsPerSpace)) { + collectionSpace.setUnreadPerSpace(unreadItemsPerSpace.entrySet() + .stream() + .collect(Collectors.toMap(e -> e.getKey().toString(), + Entry::getValue))); + } + } + return collectionSpace; + } + /** * Get a hash map from a space in order to build a json object for the rest * service @@ -800,7 +825,7 @@ public static SpaceEntity buildEntityFromSpace(Space space, String userId, Strin if (StringUtils.isNotBlank(userId)) { IdentityManager identityManager = getIdentityManager(); GroupSpaceBindingService groupSpaceBindingService = CommonsUtils.getService(GroupSpaceBindingService.class); - if (ArrayUtils.contains(space.getMembers(), userId) || spaceService.isSuperManager(userId)) { + if (spaceService.canViewSpace(space, userId)) { spaceEntity.setHref(RestUtils.getRestUrl(SPACES_TYPE, space.getId(), restPath)); Identity spaceIdentity = identityManager.getOrCreateIdentity(SpaceIdentityProvider.NAME, space.getPrettyName()); @@ -879,18 +904,6 @@ public static SpaceEntity buildEntityFromSpace(Space space, String userId, Strin spaceEntity.setIsFavorite(String.valueOf(isFavorite)); } - if (expandFields.contains(RestProperties.UNREAD)) { - Identity userIdentity = identityManager.getOrCreateUserIdentity(userId); - SpaceWebNotificationService spaceWebNotificationService = - ExoContainerContext.getService(SpaceWebNotificationService.class); - Map unreadItems = - spaceWebNotificationService.countUnreadItemsByApplication(Long.parseLong(userIdentity.getId()), - Long.parseLong(space.getId())); - if (MapUtils.isNotEmpty(unreadItems)) { - spaceEntity.setUnreadItems(unreadItems); - } - } - if (expandFields.contains(RestProperties.MUTED)) { UserSettingService userSettingService = ExoContainerContext.getService(UserSettingService.class); UserSetting userSetting = userSettingService.get(userId); @@ -910,6 +923,7 @@ public static SpaceEntity buildEntityFromSpace(Space space, String userId, Strin spaceEntity.setIsInvited(spaceService.isInvitedUser(space, userId)); spaceEntity.setIsMember(spaceService.isMember(space, userId)); spaceEntity.setCanEdit(canEdit); + spaceEntity.setCanRedactOnSpace(spaceService.canRedactOnSpace(space, getCurrentUserIdentity())); spaceEntity.setIsManager(isManager); spaceEntity.setIsRedactor(spaceService.isRedactor(space, userId)); spaceEntity.setIsPublisher(spaceService.isPublisher(space, userId)); @@ -918,7 +932,7 @@ public static SpaceEntity buildEntityFromSpace(Space space, String userId, Strin spaceEntity.setIsMember(spaceService.isMember(space, currentUserIdentity.getRemoteId())); } - PortalConfig portalConfig = getLayoutService().getPortalConfig(new SiteKey(GROUP, space.getGroupId())); + PortalConfig portalConfig = getLayoutService().getPortalConfig(new SiteKey(PortalConfig.GROUP_TYPE, space.getGroupId())); spaceEntity.setSiteId((portalConfig.getStorageId().split("_"))[1]); spaceEntity.setDisplayName(space.getDisplayName()); @@ -932,8 +946,19 @@ public static SpaceEntity buildEntityFromSpace(Space space, String userId, Strin spaceEntity.setAvatarUrl(space.getAvatarUrl()); spaceEntity.setBannerUrl(space.getBannerUrl()); spaceEntity.setVisibility(space.getVisibility()); - spaceEntity.setPublicSiteId(space.getPublicSiteId()); - spaceEntity.setPublicSiteVisibility(space.getPublicSiteVisibility()); + if (space.getPublicSiteId() > 0) { + PortalConfig publicPortalConfig = getLayoutService().getPortalConfig(space.getPublicSiteId()); + if (publicPortalConfig == null + || !getUserACL().hasAccessPermission(publicPortalConfig, getCurrentUserIdentity())) { + spaceEntity.setPublicSiteId(0l); + } else { + spaceEntity.setPublicSiteId(space.getPublicSiteId()); + spaceEntity.setPublicSiteVisibility(space.getPublicSiteVisibility()); + spaceEntity.setPublicSiteName(publicPortalConfig.getName()); + } + } else { + spaceEntity.setPublicSiteId(0l); + } spaceEntity.setSubscription(space.getRegistration()); spaceEntity.setMembersCount(space.getMembers() == null ? 0 : countUsers(space.getMembers())); spaceEntity.setManagersCount(space.getManagers() == null ? 0 : countUsers(space.getManagers())); @@ -1003,11 +1028,11 @@ private static DataEntity buildSpaceMembership(SpaceService spaceService, String restPath, String expand) { if (getMembershipTypePredicate(spaceService, membershipType).test(space, userId)) { - return EntityBuilder.buildSpaceMembershipEntity(space, - userId, - membershipType.getRole(), - restPath, - expand); + return buildSpaceMembershipEntity(space, + userId, + membershipType.getRole(), + restPath, + expand); } else { return null; // NOSONAR } @@ -1018,11 +1043,11 @@ private static List buildSpaceMemberships(Space space, String restPath, String expand) { return Arrays.stream(getUsersSupplier(space, membershipType).get()) - .map(user -> EntityBuilder.buildSpaceMembershipEntity(space, - user, - membershipType.getRole(), - restPath, - expand)) + .map(user -> buildSpaceMembershipEntity(space, + user, + membershipType.getRole(), + restPath, + expand)) .toList(); } @@ -1079,20 +1104,20 @@ private static BiPredicate getMembershipTypePredicate(SpaceServic * service * * @param space the provided space - * @param userId the user's remote id + * @param username the user's remote id * @param type membership type * @param restPath base REST path * @param expand which fields to expand from space * @return a hash map */ public static SpaceMembershipEntity buildEntityFromSpaceMembership(Space space, - String userId, + String username, String type, String restPath, String expand) { updateCachedEtagValue(getEtagValue(type)); - String id = space.getPrettyName() + ":" + userId + ":" + type; + String id = space.getPrettyName() + ":" + username + ":" + type; SpaceMembershipEntity spaceMembership = new SpaceMembershipEntity(id); spaceMembership.setHref(RestUtils.getRestUrl(SPACES_MEMBERSHIP_TYPE, id, restPath)); @@ -1105,16 +1130,17 @@ public static SpaceMembershipEntity buildEntityFromSpaceMembership(Space space, LinkEntity userEntity; if (expandFields.contains(USERS_TYPE)) { - Identity identity = getIdentityManager().getOrCreateUserIdentity(userId); + Identity identity = getIdentityManager().getOrCreateUserIdentity(username); Profile profile = identity == null ? null : identity.getProfile(); userEntity = profile == null ? null : new LinkEntity(buildEntityProfile(space, profile, restPath, expand)); } else { - userEntity = new LinkEntity(RestUtils.getRestUrl(USERS_TYPE, userId, restPath)); + userEntity = new LinkEntity(RestUtils.getRestUrl(USERS_TYPE, username, restPath)); } spaceMembership.setDataUser(userEntity); + spaceMembership.setUsername(username); if (expandFields.contains(CREATED_DATE)) { - Instant createdDate = getSpaceService().getSpaceMembershipDate(Long.parseLong(space.getId()), userId); + Instant createdDate = getSpaceService().getSpaceMembershipDate(Long.parseLong(space.getId()), username); if (createdDate != null && getSpaceService().canManageSpace(space, getCurrentUserName())) { spaceMembership.getDataEntity().put(CREATED_DATE, createdDate.toEpochMilli()); } @@ -1122,11 +1148,12 @@ public static SpaceMembershipEntity buildEntityFromSpaceMembership(Space space, LinkEntity spaceEntity; if (expandFields.contains(SPACES_TYPE)) { - spaceEntity = new LinkEntity(buildEntityFromSpace(space, userId, restPath, expand)); + spaceEntity = new LinkEntity(buildEntityFromSpace(space, username, restPath, expand)); } else { spaceEntity = new LinkEntity(RestUtils.getRestUrl(SPACES_TYPE, space.getId(), restPath)); } spaceMembership.setDataSpace(spaceEntity); + spaceMembership.setSpaceId(space.getId()); spaceMembership.setRole(type); switch (type) { @@ -1191,25 +1218,25 @@ public static ActivityEntity buildEntityFromActivity(ExoSocialActivity activity, LinkEntity commentLink; if (expandFields.contains(COMMENTS_TYPE)) { - List commentsEntity = EntityBuilder.buildEntityFromComment(activity, - authentiatedUser, - restPath, - "", - false, - RestUtils.DEFAULT_OFFSET, - RestUtils.DEFAULT_LIMIT); + List commentsEntity = buildEntityFromComment(activity, + authentiatedUser, + restPath, + "", + false, + RestUtils.DEFAULT_OFFSET, + RestUtils.DEFAULT_LIMIT); RealtimeListAccess listAccess = getActivityManager().getCommentsWithListAccess(activity, true); commentLink = new LinkEntity(commentsEntity); activityEntity.setCommentsCount(listAccess.getSize()); } else if (expandFields.contains(COMMENTS_PREVIEW_TYPE)) { - List commentsEntity = EntityBuilder.buildEntityFromComment(activity, - authentiatedUser, - restPath, - expand, - true, - 0, - COMMENTS_PREVIEW_LIMIT); + List commentsEntity = buildEntityFromComment(activity, + authentiatedUser, + restPath, + expand, + true, + 0, + COMMENTS_PREVIEW_LIMIT); RealtimeListAccess listAccess = getActivityManager().getCommentsWithListAccess(activity, true); commentLink = new LinkEntity(commentsEntity); @@ -1221,11 +1248,11 @@ public static ActivityEntity buildEntityFromActivity(ExoSocialActivity activity, activityEntity.setComments(commentLink); if (expandFields.contains(LIKES_TYPE)) { - List likesEntity = EntityBuilder.buildEntityFromLike(activity, - restPath, - "", - RestUtils.DEFAULT_OFFSET, - DEFAULT_LIKERS_LIMIT); + List likesEntity = buildEntityFromLike(activity, + restPath, + "", + RestUtils.DEFAULT_OFFSET, + DEFAULT_LIKERS_LIMIT); activityEntity.setLikes(new LinkEntity(likesEntity)); } else { activityEntity.setLikes(new LinkEntity(getLikesActivityRestUrl(activity.getId(), restPath))); @@ -1540,11 +1567,11 @@ public static List buildRelationshipEntities(List rela List infos = new ArrayList<>(); for (Relationship relationship : relationships) { // - infos.add(EntityBuilder.buildEntityRelationship(relationship, - uriInfo.getPath(), - RestUtils.getQueryParam(uriInfo, "expand"), - true) - .getDataEntity()); + infos.add(buildEntityRelationship(relationship, + uriInfo.getPath(), + RestUtils.getQueryParam(uriInfo, "expand"), + true) + .getDataEntity()); } return infos; } diff --git a/component/service/src/main/java/org/exoplatform/social/rest/entity/BaseEntity.java b/component/service/src/main/java/org/exoplatform/social/rest/entity/BaseEntity.java index af9d6b15de0..0dc2f141486 100644 --- a/component/service/src/main/java/org/exoplatform/social/rest/entity/BaseEntity.java +++ b/component/service/src/main/java/org/exoplatform/social/rest/entity/BaseEntity.java @@ -22,12 +22,28 @@ import org.apache.commons.lang3.StringUtils; import org.json.JSONObject; +import lombok.EqualsAndHashCode; +import lombok.EqualsAndHashCode.Exclude; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; + +@EqualsAndHashCode +@NoArgsConstructor public class BaseEntity implements Serializable { private static final long serialVersionUID = -7245526640639649852L; - private DataEntity dataEntity = new DataEntity(); - private long lastUpdatedTime; - public BaseEntity() { + private DataEntity dataEntity = new DataEntity(); + + @Exclude + @Getter + @Setter + private long lastUpdatedTime; + + public BaseEntity(String id) { + if (!StringUtils.isEmpty(id)) { + setId(id); + } } public BaseEntity setProperty(String name, Object value) { @@ -47,12 +63,6 @@ protected String getString(String name) { return String.valueOf(o); } - public BaseEntity(String id) { - if (!StringUtils.isEmpty(id)) { - setId(id); - } - } - public BaseEntity setId(String id) { setProperty("id", id); return this; @@ -66,7 +76,7 @@ public BaseEntity setHref(String href) { setProperty("href", href); return this; } - + public String getHref() { return (String) dataEntity.get("href"); } @@ -88,11 +98,4 @@ public JSONObject toJSONObject() { return new JSONObject(this); } - public void setLastUpdatedTime(long lastUpdatedTime) { - this.lastUpdatedTime = lastUpdatedTime; - } - - public long getLastUpdatedTime() { - return lastUpdatedTime; - } } diff --git a/component/service/src/main/java/org/exoplatform/social/rest/entity/CollectionEntity.java b/component/service/src/main/java/org/exoplatform/social/rest/entity/CollectionEntity.java index 9f40616400a..6633a3a86f1 100644 --- a/component/service/src/main/java/org/exoplatform/social/rest/entity/CollectionEntity.java +++ b/component/service/src/main/java/org/exoplatform/social/rest/entity/CollectionEntity.java @@ -23,9 +23,14 @@ import java.util.Map; import org.exoplatform.social.rest.api.RestUtils; + +import lombok.EqualsAndHashCode; + import org.json.JSONObject; +@EqualsAndHashCode(callSuper = true) public class CollectionEntity extends LinkedHashMap { + private static final long serialVersionUID = 5157400162426650346L; private final String key; diff --git a/component/service/src/main/java/org/exoplatform/social/rest/entity/DataEntity.java b/component/service/src/main/java/org/exoplatform/social/rest/entity/DataEntity.java index 91d008e996a..209c30ca2c9 100644 --- a/component/service/src/main/java/org/exoplatform/social/rest/entity/DataEntity.java +++ b/component/service/src/main/java/org/exoplatform/social/rest/entity/DataEntity.java @@ -22,11 +22,12 @@ import org.apache.commons.lang3.StringUtils; import org.json.JSONObject; +import lombok.EqualsAndHashCode; + +@EqualsAndHashCode(callSuper = true) public class DataEntity extends LinkedHashMap { - private static final long serialVersionUID = -7245526640639649852L; - public DataEntity() { - } + private static final long serialVersionUID = -7245526640639649852L; public DataEntity setProperty(String name, Object value) { if (value != null && StringUtils.isNotEmpty(String.valueOf(value))) { @@ -43,4 +44,5 @@ public String toString() { public JSONObject toJSONObject() { return new JSONObject(this); } + } diff --git a/component/service/src/main/java/org/exoplatform/social/rest/entity/SpaceEntity.java b/component/service/src/main/java/org/exoplatform/social/rest/entity/SpaceEntity.java index 134106c6e65..e4807105def 100644 --- a/component/service/src/main/java/org/exoplatform/social/rest/entity/SpaceEntity.java +++ b/component/service/src/main/java/org/exoplatform/social/rest/entity/SpaceEntity.java @@ -22,6 +22,9 @@ import org.exoplatform.social.core.identity.model.Identity; +import lombok.EqualsAndHashCode; + +@EqualsAndHashCode(callSuper = true) public class SpaceEntity extends BaseEntity { private static final long serialVersionUID = -5407676622915680099L; @@ -114,6 +117,15 @@ public Long getPublicSiteId() { return (Long) getProperty("publicSiteId"); } + public SpaceEntity setPublicSiteName(String publicSiteName) { + setProperty("publicSiteName", publicSiteName); + return this; + } + + public String getPublicSiteName() { + return (String) getProperty("publicSiteName"); + } + public SpaceEntity setPublicSiteVisibility(String publicSiteVisibility) { setProperty("publicSiteVisibility", publicSiteVisibility); return this; @@ -236,6 +248,15 @@ public Boolean getCanEdit() { return (Boolean) getProperty("canEdit"); } + public SpaceEntity setCanRedactOnSpace(boolean canRedactOnSpace) { + setProperty("canRedactOnSpace", canRedactOnSpace); + return this; + } + + public Boolean getCanRedactOnSpace() { + return (Boolean) getProperty("canRedactOnSpace"); + } + public SpaceEntity setCanEditNavigations(boolean canEditNavigations) { setProperty("canEditNavigations", canEditNavigations); return this; @@ -298,7 +319,7 @@ public SpaceEntity setPublishers(LinkEntity publishers) { public String getPublishers() { return getString("publishers"); } - + public SpaceEntity setPublishersCount(int publishersCount) { setProperty("publishersCount", publishersCount); return this; diff --git a/component/service/src/main/java/org/exoplatform/social/rest/entity/SpaceMembershipEntity.java b/component/service/src/main/java/org/exoplatform/social/rest/entity/SpaceMembershipEntity.java index 11bca370929..d261d276388 100644 --- a/component/service/src/main/java/org/exoplatform/social/rest/entity/SpaceMembershipEntity.java +++ b/component/service/src/main/java/org/exoplatform/social/rest/entity/SpaceMembershipEntity.java @@ -32,12 +32,12 @@ public SpaceMembershipEntity setDataUser(LinkEntity user) { return this; } - public void setUser(String user) { - setProperty("user", user); + public void setUsername(String username) { + setProperty("username", username); } - public String getUser() { - return getString("user"); + public String getUsername() { + return getString("username"); } public SpaceMembershipEntity setDataSpace(LinkEntity space) { @@ -45,12 +45,12 @@ public SpaceMembershipEntity setDataSpace(LinkEntity space) { return this; } - public void setSpace(String space) { - setProperty("space", space); + public void setSpaceId(String spaceId) { + setProperty("spaceId", spaceId); } - public String getSpace() { - return getString("space"); + public String getSpaceId() { + return getString("spaceId"); } public SpaceMembershipEntity setRole(String role) { diff --git a/component/service/src/main/java/org/exoplatform/social/rest/entity/SpaceMembershipUpdateEntity.java b/component/service/src/main/java/org/exoplatform/social/rest/entity/SpaceMembershipUpdateEntity.java new file mode 100644 index 00000000000..e931942ab9c --- /dev/null +++ b/component/service/src/main/java/org/exoplatform/social/rest/entity/SpaceMembershipUpdateEntity.java @@ -0,0 +1,35 @@ +/* + * This file is part of the Meeds project (https://meeds.io/). + * + * Copyright (C) 2020 - 2024 Meeds Association contact@meeds.io + * + * 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. + */ +package org.exoplatform.social.rest.entity; + +import lombok.Data; + +@Data +public class SpaceMembershipUpdateEntity { + + private String user; + + private String space; + + private String status; + + private String role; + +} diff --git a/component/service/src/main/java/org/exoplatform/social/rest/impl/space/SpaceRest.java b/component/service/src/main/java/org/exoplatform/social/rest/impl/space/SpaceRest.java index 56acbd3cd82..2d75a8d0533 100644 --- a/component/service/src/main/java/org/exoplatform/social/rest/impl/space/SpaceRest.java +++ b/component/service/src/main/java/org/exoplatform/social/rest/impl/space/SpaceRest.java @@ -20,16 +20,13 @@ import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; -import java.util.ArrayList; +import java.time.Instant; +import java.time.temporal.ChronoUnit; import java.util.Arrays; import java.util.Collections; import java.util.Date; import java.util.List; import java.util.Locale; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Objects; -import java.util.stream.Collectors; import javax.annotation.security.RolesAllowed; import javax.ws.rs.DELETE; @@ -48,17 +45,16 @@ import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Request; import javax.ws.rs.core.Response; +import javax.ws.rs.core.Response.ResponseBuilder; import javax.ws.rs.core.Response.Status; import javax.ws.rs.core.UriInfo; import org.apache.commons.collections.CollectionUtils; -import org.apache.commons.collections.MapUtils; import org.apache.commons.lang3.StringUtils; import org.exoplatform.commons.utils.CommonsUtils; import org.exoplatform.commons.utils.IOUtil; import org.exoplatform.commons.utils.ListAccess; -import org.exoplatform.container.ExoContainerContext; import org.exoplatform.container.PortalContainer; import org.exoplatform.deprecation.DeprecatedAPI; import org.exoplatform.portal.config.model.Page; @@ -89,9 +85,7 @@ import org.exoplatform.social.core.space.SpaceUtils; import org.exoplatform.social.core.space.model.Space; import org.exoplatform.social.core.space.spi.SpaceService; -import org.exoplatform.social.notification.service.SpaceWebNotificationService; import org.exoplatform.social.rest.api.EntityBuilder; -import org.exoplatform.social.rest.api.RestProperties; import org.exoplatform.social.rest.api.RestUtils; import org.exoplatform.social.rest.entity.ActivityEntity; import org.exoplatform.social.rest.entity.BaseEntity; @@ -106,6 +100,7 @@ import io.meeds.portal.security.constant.UserRegistrationType; import io.meeds.portal.security.service.SecuritySettingService; +import io.meeds.social.util.JsonUtils; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; @@ -142,8 +137,12 @@ public class SpaceRest implements ResourceContainer { private static final CacheControl CACHE_REVALIDATE_CONTROL = new CacheControl(); + public static final String PROFILE_DEFAULT_BANNER_URL = "/skin/images/banner/DefaultSpaceBanner.png"; + private static final Date DEFAULT_IMAGES_LAST_MODIFED = new Date(); + private static final long DEFAULT_IMAGES_HASH = DEFAULT_IMAGES_LAST_MODIFED.getTime(); + // 7 days private static final int CACHE_IN_SECONDS = 7 * 86400; @@ -161,6 +160,8 @@ public class SpaceRest implements ResourceContainer { private final ImageThumbnailService imageThumbnailService; + private byte[] defaultSpaceBanner = null; + private byte[] defaultSpaceAvatar = null; public SpaceRest(ActivityRest activityRestResourcesV1, @@ -281,36 +282,12 @@ public Response getSpaces( // NOSONAR } else { spaces = Collections.emptyList(); } - List spaceInfos = new ArrayList<>(); - for (Space space : spaces) { - SpaceEntity spaceInfo = EntityBuilder.buildEntityFromSpace(space, authenticatedUser, uriInfo.getPath(), expand); - spaceInfos.add(spaceInfo.getDataEntity()); - } - - CollectionEntity collectionSpace = new CollectionEntity(spaceInfos, EntityBuilder.SPACES_TYPE, offset, limit); + CollectionEntity collectionSpace = EntityBuilder.buildEntityFromSpaces(spaces, authenticatedUser, offset, limit, expand, uriInfo); if (returnSize) { collectionSpace.setSize(listAccess.getSize()); } - if (StringUtils.isNotBlank(expand) && Arrays.asList(StringUtils.split(expand, ",")).contains(RestProperties.UNREAD)) { - SpaceWebNotificationService spaceWebNotificationService = ExoContainerContext.getService(SpaceWebNotificationService.class); - Map unreadItemsPerSpace = spaceWebNotificationService.countUnreadItemsBySpace(authenticatedUser); - if (MapUtils.isNotEmpty(unreadItemsPerSpace)) { - collectionSpace.setUnreadPerSpace(unreadItemsPerSpace.entrySet() - .stream() - .collect(Collectors.toMap(e -> e.getKey().toString(), - Entry::getValue))); - } - } - - EntityTag eTag = new EntityTag(String.valueOf(Objects.hash(spaceInfos, - spaceFilter, - filterType, - offset, - limit, - returnSize, - expand, - authenticatedUser))); + EntityTag eTag = new EntityTag(String.valueOf(JsonUtils.toJsonString(collectionSpace).hashCode())); Response.ResponseBuilder builder = request.evaluatePreconditions(eTag); if (builder == null) { builder = EntityBuilder.getResponseBuilder(collectionSpace, uriInfo, RestUtils.getJsonMediaType(), Response.Status.OK); @@ -393,8 +370,9 @@ public Response createSpace( @ApiResponse(responseCode = "500", description = "Internal server error"), @ApiResponse(responseCode = "404", description = "Resource not found"), @ApiResponse(responseCode = "400", description = "Invalid query input") }) - public Response isSpaceContainsExternals(@Context - UriInfo uriInfo, + public Response isSpaceContainsExternals( + @Context + UriInfo uriInfo, @Context Request request, @Parameter(description = "Space Id", required = true) @@ -458,8 +436,9 @@ public Response getSpaceById( @ApiResponse(responseCode = "200", description = "Request fulfilled"), @ApiResponse(responseCode = "500", description = "Internal server error"), @ApiResponse(responseCode = "400", description = "Invalid query input") }) - public Response getSpaceByPrettyName(@Context - UriInfo uriInfo, + public Response getSpaceByPrettyName( + @Context + UriInfo uriInfo, @Context Request request, @Parameter(description = "Space id", required = true) @@ -487,8 +466,9 @@ public Response getSpaceByPrettyName(@Context @ApiResponse(responseCode = "200", description = "Request fulfilled"), @ApiResponse(responseCode = "500", description = "Internal server error"), @ApiResponse(responseCode = "400", description = "Invalid query input") }) - public Response getSpaceByGroupSuffix(@Context - UriInfo uriInfo, + public Response getSpaceByGroupSuffix( + @Context + UriInfo uriInfo, @Context Request request, @Parameter(description = "Space id", required = true) @@ -514,8 +494,9 @@ public Response getSpaceByGroupSuffix(@Context @ApiResponse(responseCode = "200", description = "Request fulfilled"), @ApiResponse(responseCode = "500", description = "Internal server error"), @ApiResponse(responseCode = "400", description = "Invalid query input") }) - public Response getSpaceByDisplayName(@Context - UriInfo uriInfo, + public Response getSpaceByDisplayName( + @Context + UriInfo uriInfo, @Context Request request, @Parameter(description = "Space id", required = true) @@ -542,8 +523,9 @@ public Response getSpaceByDisplayName(@Context @ApiResponse(responseCode = "500", description = "Internal server error"), @ApiResponse(responseCode = "400", description = "Invalid query input"), @ApiResponse(responseCode = "404", description = "Resource not found") }) - public Response getSpaceAvatarById(@Context - UriInfo uriInfo, + public Response getSpaceAvatarById( + @Context + UriInfo uriInfo, @Context Request request, @Parameter(description = "The value of lastModified parameter will determine whether the query should be cached by browser or not. If not set, no 'expires HTTP Header will be sent'") @@ -651,8 +633,9 @@ public Response getSpaceAvatarById(@Context @ApiResponse(responseCode = "500", description = "Internal server error"), @ApiResponse(responseCode = "400", description = "Invalid query input"), @ApiResponse(responseCode = "404", description = "Resource not found") }) - public Response getSpaceBannerById(@Context - UriInfo uriInfo, + public Response getSpaceBannerById( + @Context + UriInfo uriInfo, @Context Request request, @Parameter(description = "The value of lastModified parameter will determine whether the query should be cached by browser or not. If not set, no 'expires HTTP Header will be sent'") @@ -671,11 +654,12 @@ public Response getSpaceBannerById(@Context @QueryParam("r") String token) throws IOException { boolean isDefault = StringUtils.equals(LinkProvider.DEFAULT_IMAGE_REMOTE_ID, id); - if (isDefault) { - return Response.status(Status.NOT_FOUND).build(); - } + Identity identity = null; + Long lastUpdated = null; - if (RestUtils.isAnonymous() && !LinkProvider.isAttachmentTokenValid(token, + if (!isDefault + && RestUtils.isAnonymous() + && !LinkProvider.isAttachmentTokenValid(token, SpaceIdentityProvider.NAME, id, BannerAttachment.TYPE, @@ -684,39 +668,47 @@ public Response getSpaceBannerById(@Context return Response.status(Status.NOT_FOUND).build(); } - String authenticatedUser = RestUtils.getCurrentUser(); - Space space = byId ? spaceService.getSpaceById(id) : spaceService.getSpaceByPrettyName(id); - if (space == null - || (Space.HIDDEN.equals(space.getVisibility()) - && !spaceService.canViewSpace(space, authenticatedUser))) { - return Response.status(Status.NOT_FOUND).build(); - } - Identity identity = identityManager.getOrCreateIdentity(SpaceIdentityProvider.NAME, space.getPrettyName()); - // - Profile profile = identity.getProfile(); - Long lastUpdated = null; - if (profile != null) { - lastUpdated = profile.getBannerLastUpdated(); + if (!isDefault) { + String authenticatedUser = RestUtils.getCurrentUser(); + Space space = byId ? spaceService.getSpaceById(id) : spaceService.getSpaceByPrettyName(id); + if (space == null + || (Space.HIDDEN.equals(space.getVisibility()) + && !spaceService.canViewSpace(space, authenticatedUser))) { + return Response.status(Status.NOT_FOUND).build(); + } + identity = identityManager.getOrCreateIdentity(SpaceIdentityProvider.NAME, space.getPrettyName()); + // + Profile profile = identity.getProfile(); + if (profile != null) { + lastUpdated = profile.getBannerLastUpdated(); + } } EntityTag eTag = null; - if (lastUpdated != null) { + if (isDefault) { + eTag = new EntityTag(String.valueOf(DEFAULT_IMAGES_HASH)); + } else if (lastUpdated != null) { eTag = new EntityTag(Integer.toString(lastUpdated.hashCode())); } + // Response.ResponseBuilder builder = (eTag == null ? null : request.evaluatePreconditions(eTag)); if (builder == null) { - InputStream stream = identityManager.getBannerInputStream(identity); - if (stream == null) { - throw new WebApplicationException(Response.Status.NOT_FOUND); + if (isDefault) { + builder = getDefaultBannerBuilder(); + } else { + InputStream stream = identityManager.getBannerInputStream(identity); + if (stream == null) { + throw new WebApplicationException(Response.Status.NOT_FOUND); + } + /* + * As recommended in the the RFC1341 + * (https://www.w3.org/Protocols/rfc1341/4_Content-Type.html), we set the + * banner content-type to "image/png". So, its data would be recognized as + * "image" by the user-agent. + */ + builder = Response.ok(stream, "image/png"); + builder.tag(eTag); } - /* - * As recommended in the the RFC1341 - * (https://www.w3.org/Protocols/rfc1341/4_Content-Type.html), we set the - * banner content-type to "image/png". So, its data would be recognized as - * "image" by the user-agent. - */ - builder = Response.ok(stream, "image/png"); - builder.tag(eTag); } builder.cacheControl(CACHE_CONTROL); builder.lastModified(lastUpdated == null ? DEFAULT_IMAGES_LAST_MODIFED : new Date(lastUpdated)); @@ -840,8 +832,9 @@ public Response updateSpaceById( @ApiResponse(responseCode = "200", description = "Request fulfilled"), @ApiResponse(responseCode = "500", description = "Internal server error"), @ApiResponse(responseCode = "400", description = "Invalid query input") }) - public Response deleteSpaceById(@Context - UriInfo uriInfo, + public Response deleteSpaceById( + @Context + UriInfo uriInfo, @Parameter(description = "Space id", required = true) @PathParam("id") String id, @@ -919,7 +912,6 @@ public Response getSpaceMembers( throw new WebApplicationException(Response.Status.UNAUTHORIZED); } - long cacheTime = space.getCacheTime(); if (StringUtils.isBlank(role)) { role = SpaceMemberFilterListAccess.Type.MEMBER.name(); } @@ -952,14 +944,13 @@ public Response getSpaceMembers( collectionUser.setSize(spaceIdentitiesListAccess.getSize()); } - String eTagValue = String.valueOf(Objects.hash(collectionUser.hashCode(), authenticatedUser, expand)); - EntityTag eTag = new EntityTag(eTagValue); + EntityTag eTag = new EntityTag(String.valueOf(JsonUtils.toJsonString(collectionUser).hashCode())); Response.ResponseBuilder builder = request.evaluatePreconditions(eTag); if (builder == null) { builder = Response.ok(collectionUser, MediaType.APPLICATION_JSON); builder.tag(eTag); - builder.lastModified(new Date(cacheTime)); - builder.expires(new Date(cacheTime)); + builder.lastModified(new Date()); + builder.expires(Date.from(Instant.now().plus(7, ChronoUnit.DAYS))); } return builder.build(); } @@ -1338,19 +1329,34 @@ private Response buildSpaceResponse(Space space, String expand, UriInfo uriInfo, throw new WebApplicationException(Response.Status.UNAUTHORIZED); } - long cacheTime = space.getCacheTime(); - String eTagValue = String.valueOf(Objects.hash(cacheTime, authenticatedUser, expand)); - - EntityTag eTag = new EntityTag(eTagValue, true); + SpaceEntity spaceEntity = EntityBuilder.buildEntityFromSpace(space, authenticatedUser, uriInfo.getPath(), expand); + EntityTag eTag = new EntityTag(String.valueOf(spaceEntity.hashCode())); Response.ResponseBuilder builder = request.evaluatePreconditions(eTag); if (builder == null) { - SpaceEntity spaceEntity = EntityBuilder.buildEntityFromSpace(space, authenticatedUser, uriInfo.getPath(), expand); builder = Response.ok(spaceEntity.getDataEntity(), MediaType.APPLICATION_JSON); builder.tag(eTag); - builder.lastModified(new Date(cacheTime)); - builder.expires(new Date(cacheTime)); + builder.lastModified(new Date()); + builder.cacheControl(CACHE_REVALIDATE_CONTROL); } return builder.build(); } + private Response.ResponseBuilder getDefaultBannerBuilder() throws IOException { + if (defaultSpaceBanner == null) { + InputStream is = PortalContainer.getInstance().getPortalContext().getResourceAsStream(PROFILE_DEFAULT_BANNER_URL); + if (is == null) { + LOG.warn("Can't find default user banner file in location {}", PROFILE_DEFAULT_BANNER_URL); + defaultSpaceBanner = new byte[] {}; + } else { + defaultSpaceBanner = IOUtil.getStreamContentAsBytes(is); + } + } + + ResponseBuilder builder = Response.ok(new ByteArrayInputStream(defaultSpaceBanner), "image/png"); + builder.lastModified(DEFAULT_IMAGES_LAST_MODIFED); + EntityTag eTag = new EntityTag(String.valueOf(DEFAULT_IMAGES_HASH)); + builder.tag(eTag); + return builder; + } + } diff --git a/component/service/src/main/java/org/exoplatform/social/rest/impl/spacemembership/SpaceMembershipRest.java b/component/service/src/main/java/org/exoplatform/social/rest/impl/spacemembership/SpaceMembershipRest.java index 4c5de24c9fb..31a950852ac 100644 --- a/component/service/src/main/java/org/exoplatform/social/rest/impl/spacemembership/SpaceMembershipRest.java +++ b/component/service/src/main/java/org/exoplatform/social/rest/impl/spacemembership/SpaceMembershipRest.java @@ -50,7 +50,7 @@ import org.exoplatform.social.rest.api.RestUtils; import org.exoplatform.social.rest.entity.CollectionEntity; import org.exoplatform.social.rest.entity.DataEntity; -import org.exoplatform.social.rest.entity.SpaceMembershipEntity; +import org.exoplatform.social.rest.entity.SpaceMembershipUpdateEntity; import org.exoplatform.social.service.rest.api.VersionResources; import io.meeds.social.space.constant.SpaceMembershipStatus; @@ -73,11 +73,14 @@ public class SpaceMembershipRest implements ResourceContainer { private IdentityManager identityManager; public enum MembershipType { - PENDING(SpaceUtils.PENDING, SpaceMembershipStatus.PENDING), APPROVED(SpaceUtils.MEMBER, - SpaceMembershipStatus.MEMBER), IGNORED(SpaceUtils.IGNORED, SpaceMembershipStatus.IGNORED), INVITED( - SpaceUtils.INVITED, SpaceMembershipStatus.INVITED), MEMBER(SpaceUtils.MEMBER, SpaceMembershipStatus.MEMBER), MANAGER( - SpaceUtils.MANAGER, SpaceMembershipStatus.MANAGER), PUBLISHER(SpaceUtils.PUBLISHER, - SpaceMembershipStatus.PUBLISHER), REDACTOR(SpaceUtils.REDACTOR, SpaceMembershipStatus.REDACTOR); + PENDING(SpaceUtils.PENDING, SpaceMembershipStatus.PENDING), + APPROVED(SpaceUtils.MEMBER, SpaceMembershipStatus.MEMBER), + IGNORED(SpaceUtils.IGNORED, SpaceMembershipStatus.IGNORED), + INVITED(SpaceUtils.INVITED, SpaceMembershipStatus.INVITED), + MEMBER(SpaceUtils.MEMBER, SpaceMembershipStatus.MEMBER), + MANAGER(SpaceUtils.MANAGER, SpaceMembershipStatus.MANAGER), + PUBLISHER(SpaceUtils.PUBLISHER, SpaceMembershipStatus.PUBLISHER), + REDACTOR(SpaceUtils.REDACTOR, SpaceMembershipStatus.REDACTOR); @Getter private final SpaceMembershipStatus status; @@ -232,7 +235,7 @@ public Response addSpacesMemberships( "
\"user\": \"john\"," + "
\"space\": \"1552\"" + "
}", required = true) - SpaceMembershipEntity model) { + SpaceMembershipUpdateEntity model) { if (model == null) { throw new WebApplicationException(Response.Status.BAD_REQUEST); } @@ -357,7 +360,7 @@ public Response deleteSpaceMembershipById( "
\"user\": \"john\"," + "
\"space\": \"1552\"" + "
}", required = true) - SpaceMembershipEntity model) { + SpaceMembershipUpdateEntity model) { if (model == null) { throw new WebApplicationException(Response.Status.BAD_REQUEST); } diff --git a/component/service/src/test/java/org/exoplatform/social/rest/impl/space/SpaceRestResourcesTest.java b/component/service/src/test/java/org/exoplatform/social/rest/impl/space/SpaceRestResourcesTest.java index fbd35aa9651..73d2fe8b87c 100644 --- a/component/service/src/test/java/org/exoplatform/social/rest/impl/space/SpaceRestResourcesTest.java +++ b/component/service/src/test/java/org/exoplatform/social/rest/impl/space/SpaceRestResourcesTest.java @@ -494,7 +494,7 @@ public void testGetSpaceBannerForAnonymous() throws Exception { response = service("GET", getURLResource("spaces/" + LinkProvider.DEFAULT_IMAGE_REMOTE_ID + "/banner"), "", null, null); assertNotNull(response); - assertEquals(404, response.getStatus()); + assertEquals(200, response.getStatus()); space.setVisibility(Space.HIDDEN); space = spaceService.updateSpace(space); @@ -528,7 +528,7 @@ public void testGetSpaceBannerForAuthentiticatedUser() throws Exception { response = service("GET", getURLResource("spaces/" + LinkProvider.DEFAULT_IMAGE_REMOTE_ID + "/banner"), "", null, null); assertNotNull(response); - assertEquals(404, response.getStatus()); + assertEquals(200, response.getStatus()); space.setVisibility(Space.HIDDEN); space = spaceService.updateSpace(space); diff --git a/extension/war/src/main/webapp/WEB-INF/conf/social-extension/social/search-configuration.xml b/extension/war/src/main/webapp/WEB-INF/conf/social-extension/social/search-configuration.xml index 6b76c51b24f..cb0119dbada 100644 --- a/extension/war/src/main/webapp/WEB-INF/conf/social-extension/social/search-configuration.xml +++ b/extension/war/src/main/webapp/WEB-INF/conf/social-extension/social/search-configuration.xml @@ -105,9 +105,6 @@ SHARED/SpaceSearchResultCard - - social-portlet/SpaceSearch - locale.portlet.social.SpacesListApplication diff --git a/webapp/portlet/pom.xml b/webapp/portlet/pom.xml index f2e7906ceba..771a4fa81b7 100644 --- a/webapp/portlet/pom.xml +++ b/webapp/portlet/pom.xml @@ -113,14 +113,10 @@ portlet/SpaceInfos/Style.less portlet/SpaceMenu/Style.less portlet/SpacesAdministration/Style.less - portlet/SpaceSearch/Style.less - portlet/SpaceSettings/Style.less - portlet/SpacesList/Style.less portlet/SpacesListExternal/Style.less portlet/SpacesOverview/Style.less portlet/SuggestionsPeopleAndSpace/Style.less portlet/TopBarMenu/Style.less - portlet/WhoIsOnLine/Style.less portlet/VerticalMenu/Style.less common/siteDetails/Style.less common/AdministrationSite/Style.less diff --git a/webapp/portlet/src/main/resources/locale/portlet/social/SpacesListApplication_en.properties b/webapp/portlet/src/main/resources/locale/portlet/social/SpacesListApplication_en.properties index 0ae0f765220..4008a1e6bff 100644 --- a/webapp/portlet/src/main/resources/locale/portlet/social/SpacesListApplication_en.properties +++ b/webapp/portlet/src/main/resources/locale/portlet/social/SpacesListApplication_en.properties @@ -30,6 +30,8 @@ spacesList.label.name=Name spacesList.label.spaceTemplate=Template spacesList.label.yes=Yes spacesList.label.no=No +spacesList.label.cancel=Cancel +spacesList.label.apply=Apply spacesList.label.hidden=Hidden spacesList.label.hiddenSpace=Hidden space spacesList.label.registration=Registration @@ -53,7 +55,7 @@ spacesList.button.createSpace=Create spacesList.button.updateSpace=Update spacesList.button.showMore=Show more spacesList.button.remove=Remove -spacesList.button.edit=Edit +spacesList.button.openSettings=Open Settings spacesList.button.leave=Leave spacesList.button.acceptToJoin=Accept to join spacesList.button.refuseToJoin=Decline @@ -66,8 +68,10 @@ spacesList.button.close=Close spacesList.button.continue=Continue spacesList.button.back=Back spacesList.button.cancel=Cancel +spacesList.button.add=Add spacesList.filter.all=All spaces spacesList.filter.userSpaces=My spaces +spacesList.filter.managingSpaces=Administrated Spaces spacesList.filter.favoriteSpaces=Favorite spaces spacesList.filter.invitedSpaces=Invitations spacesList.filter.pendingSpaces=Pending requests @@ -78,3 +82,28 @@ spaceList.label.openSpaceMenu=Open Space Menu spaceList.label.openSpaceActionMenu=Open Space Action Menu spaceList.checkExternals.warning=Space {0} contains guest users spaceList.alert.label=space +spaceList.advanced.filter.button.title=Filter +spaceList.advanced.filter.drawer.title=Filter Spaces +spaceList.advanced.filter.spaceType.label=Space Type +spaceList.spaceAvatar.alt=Space Avatar +spaceList.spaceMembers={0} Members +spaceList.publicSite=Website +spacesList.button.options=Space Options +spacesList.button.answerInvitation=Answer +spacesList.button.unreadActivities=Unread activities +spacesList.label.pendingRequests={0} user requests are waiting for review +spacesList.label.pendingRequests.description=Please find below, the user requests to join spaces you manage +spacesList.label.invitationsSent=You are invited to join {0} spaces +spacesList.label.usersRequests=You have sent {0} requests to join spaces +spacesList.pending.drawer.title=Requests to review +spacesList.pending.loadMore=Load More +spacesList.pending.placeholder.emptyRequests=No remaining request to review +spacesList.pending.placeholder.close=Close +spacesList.pending.userAddedAsSpaceMember=The user is now a space member +spacesList.pending.userRequestDenied=User request successfully denied +spacesList.pending.error.unknownErrorWhenSavingRoles=An unknown error happened when saving roles. Please contact your administrator. +spacesList.button.copyLink=Copy Link +spacesList.button.copyLink.success=Link copied in the clipboard +spacesList.button.copyLink.error=Error while copying site URL +spacesList.button.visitPublicSite=Visit public site +spacesList.button.openSpace=Open Space diff --git a/webapp/portlet/src/main/webapp/WEB-INF/gatein-resources.xml b/webapp/portlet/src/main/webapp/WEB-INF/gatein-resources.xml index f290758ff98..177bc4c690f 100644 --- a/webapp/portlet/src/main/webapp/WEB-INF/gatein-resources.xml +++ b/webapp/portlet/src/main/webapp/WEB-INF/gatein-resources.xml @@ -62,8 +62,6 @@ social-portlet SpaceSettingPortlet Enterprise - /skin/css/portlet/SpaceSettings/Style.css - 1 ImageCropper @@ -99,14 +97,6 @@ 1 - - social-portlet - SpacesList - Enterprise - /skin/css/portlet/SpacesList/Style.css - 1 - - social-portlet SpaceMenuPortlet @@ -180,14 +170,6 @@ 1 - - social-portlet - WhoIsOnLinePortlet - Enterprise - /skin/css/portlet/WhoIsOnLine/Style.css - 1 - - social-portlet GettingStarted @@ -290,15 +272,6 @@ 1 - - social-portlet - - SpaceSearch - Enterprise - /skin/css/portlet/SpaceSearch/Style.css - 1 - - social-portlet @@ -1182,6 +1155,9 @@ spacesListComponents + + applicationToolbarComponent + commonVueComponents diff --git a/webapp/portlet/src/main/webapp/WEB-INF/jsp/portlet/topbarLogo.jsp b/webapp/portlet/src/main/webapp/WEB-INF/jsp/portlet/topbarLogo.jsp index 0478293cdd1..bf2097a74c3 100644 --- a/webapp/portlet/src/main/webapp/WEB-INF/jsp/portlet/topbarLogo.jsp +++ b/webapp/portlet/src/main/webapp/WEB-INF/jsp/portlet/topbarLogo.jsp @@ -35,6 +35,7 @@ boolean isFavorite= false; boolean muted= false; boolean isMember =false; + boolean canRedactOnSpace =false; String authenticatedUser = request.getRemoteUser(); List managers = new ArrayList<>(); String spaceDescription= ""; @@ -69,6 +70,7 @@ spaceId = space.getId(); SpaceService spaceService = ExoContainerContext.getService(SpaceService.class); isMember = authenticatedUser == null ? false : spaceService.isMember(space, authenticatedUser); + canRedactOnSpace = authenticatedUser == null ? false : spaceService.canRedactOnSpace(space, authenticatedUser); isFavorite = authenticatedUser == null ? false : favoriteService.isFavorite(new Favorite(space.DEFAULT_SPACE_METADATA_OBJECT_TYPE, space.getId(), null, Long.parseLong(userIdentity.getId()))); muted = authenticatedUser == null ? false : userSetting.isSpaceMuted(Long.parseLong(spaceId)); logoPath = space.getAvatarUrl(); @@ -88,12 +90,12 @@ String directionVuetifyClass = requestContext.getOrientation().isRT() ? "v-application--is-rtl" : "v-application--is-ltr"; %> -
+
-
-
+
+
<% if (space == null) { %> <% if (logoPath != null) { %> @@ -130,7 +132,8 @@ membersNumber: `<%=membersNumber%>`, spaceDescription: `<%=URLEncoder.encode(spaceDescription.replace(" ", "._.")).replace("._.", " ")%>`, managers: window.topbarLogoManagers, - homePath: `<%=homePath%>` + homePath: `<%=homePath%>`, + canRedactOnSpace: <%=canRedactOnSpace%>, }));
diff --git a/webapp/portlet/src/main/webapp/WEB-INF/portlet.xml b/webapp/portlet/src/main/webapp/WEB-INF/portlet.xml index 9d78616dc51..fa185911221 100644 --- a/webapp/portlet/src/main/webapp/WEB-INF/portlet.xml +++ b/webapp/portlet/src/main/webapp/WEB-INF/portlet.xml @@ -498,7 +498,7 @@ layout-css-class - no-layout-style + no-layout-style full-height text/html @@ -733,24 +733,10 @@ org.exoplatform.commons.api.portlet.GenericDispatchedViewPortlet portlet-view-dispatched-file-path - /WEB-INF/jsp/portlet/spacesOverview.jsp - - - use-js-manager - true - - - js-manager-jsModule - PORTLET/social-portlet/SpacesOverview - - - prefetch.resources - true - - - prefetch.resource.rest - + /html/spacesOverview.html + -1 + PUBLIC text/html diff --git a/webapp/portlet/src/main/webapp/WEB-INF/jsp/portlet/spacesOverview.jsp b/webapp/portlet/src/main/webapp/html/spacesOverview.html similarity index 52% rename from webapp/portlet/src/main/webapp/WEB-INF/jsp/portlet/spacesOverview.jsp rename to webapp/portlet/src/main/webapp/html/spacesOverview.html index eaa593061f9..282f272ed68 100644 --- a/webapp/portlet/src/main/webapp/WEB-INF/jsp/portlet/spacesOverview.jsp +++ b/webapp/portlet/src/main/webapp/html/spacesOverview.html @@ -2,5 +2,8 @@
+
diff --git a/webapp/portlet/src/main/webapp/skin/less/common/SpaceCard/Style-mobile.less b/webapp/portlet/src/main/webapp/skin/less/common/SpaceCard/Style-mobile.less deleted file mode 100644 index c9fa0efe498..00000000000 --- a/webapp/portlet/src/main/webapp/skin/less/common/SpaceCard/Style-mobile.less +++ /dev/null @@ -1,121 +0,0 @@ -/** - - This file is part of the Meeds project (https://meeds.io/). - - Copyright (C) 2020 - 2023 Meeds Association contact@meeds.io - - 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. - -*/ - -.spaceCardFront, .spaceCardItem, .spaceCardFlip { - height: 72px; - max-height: 72px; - min-height: 72px; - margin-bottom: 5px; -} - -.spaceAvatar { - position: absolute; - max-width: 60px; - margin: 6px 8px; - - .v-image { - height: 60px !important; - max-height: 60px !important; - width: 60px !important; - max-width: 60px !important; - } -} - -.spaceToolbarIcons { - width: 50px; - right: 3px; - margin: auto; - position: absolute; - padding: 0 !important; - - .spaceActionIcon { - color: @btnColor !important; - } -} - -.spaceCardActions { - float: right; - margin-top: 32px; - margin-right: 2px; - - button { - border-radius: 50%; - padding: 0; - width: 26px; - height: 26px; - font-size: 12px; - width: 24px; - height: 24px; - font-size: 12px; - - i { - margin-right: 0; - } - } -} - -.spaceCardBody { - float: left; - left: 72px; - position: absolute; - width: ~"calc(100% - 105px)"; - align-items: start !important; - text-align: left !important; - padding: 5px; - - > * { - float: left; - padding: 0 !important; - clear: both; - max-width: 100%; - margin: 6px 5px 0; - } -} - -.invitationButtons { - display: flex; - - button { - max-width: none !important; - width: auto !important; - min-width: auto !important; - } - - .refuseToJoinSpaceButton { - display: block !important; - margin-top: 0; - margin-left: 6px !important; - } - - .acceptToJoinSpaceButtonParent { - .acceptToJoinSpaceButton { - border-radius: 50% !important; - } - } -} - -.spaceBannerImg, .spaceInfoIcon, .spaceMenuIcon, .spaceButtonMenu, .spaceMembershipButton .spaceMembershipButtonText { - display: none !important; -} - -.spaceEditIcon { - display: block !important; -} - diff --git a/webapp/portlet/src/main/webapp/skin/less/common/SpaceCard/Style.less b/webapp/portlet/src/main/webapp/skin/less/common/SpaceCard/Style.less deleted file mode 100644 index 8a8f498ad41..00000000000 --- a/webapp/portlet/src/main/webapp/skin/less/common/SpaceCard/Style.less +++ /dev/null @@ -1,198 +0,0 @@ -/** - - This file is part of the Meeds project (https://meeds.io/). - - Copyright (C) 2020 - 2023 Meeds Association contact@meeds.io - - 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. - -*/ - -.spaceBannerImg { - position: absolute; -} -.spaceAvatar { - .v-image { - border-radius: 5px; - box-shadow: 0px 0px 0px -2px rgba(0, 0, 0, 0.1), 0px 0px 0px 1px rgba(0, 0, 0, 0.1), 0px 0px 0px 0px rgba(0, 0, 0, 0.1); - } - .v-image__image { - border-radius: 5px; - } -} -.joinSpaceButton:not(.skeleton-text), .acceptToJoinSpaceButton:not(.skeleton-text), .spaceButtonMenu:not(.skeleton-text) { - border: 1px solid @btnPrimaryBorder !important; - color: @btnPrimaryBorder !important; - i { - color: @btnPrimaryBorder !important; - } -} -.cancelRequestToJoinSpaceButton { - border: 1px solid @btnBorder !important; - color: @btnColor !important; - - .v-btn__content { - max-width: 100%; - span { - width: auto; - max-width: calc( 100% - 28px ); - min-width: auto; - display: inline-block !important; - overflow: hidden !important; - text-overflow: ellipsis !important; - } - } -} -.leaveSpaceButton, .refuseToJoinSpaceButton { - border: 1px solid @errorColor !important; - color: @errorColor !important; - - .v-btn__content { - max-width: 100%; - span { - width: auto; - max-width: calc( 100% - 28px ); - min-width: auto; - display: inline-block !important; - overflow: hidden !important; - text-overflow: ellipsis !important; - } - } -} -.refuseToJoinSpaceButton { - margin-top: 2px; -} -.spaceMenuIcon { - height: 26px !important; - width: 26px !important; - margin-top: 6px; - - &:not(.skeleton-text) { - color: #fff !important; - background: @btnPrimaryDisableBackground !important; - } -} -.spaceInfoIcon { - height: 26px; - width: 26px; - margin-top: 6px; - - &:not(.skeleton-text) { - background: #fff; - border: 1px solid @infoBorder !important; - color: @infoBorder !important; - } -} -.spaceToolbarIcons { - display: flex; -} -.spaceActionMenu { - right: 21px ~'; /** orientation=lt */ '; - left: auto ~'!important; /** orientation=lt */ '; - left: 21px ~'; /** orientation=rt */ '; - right: auto ~'!important; /** orientation=rt */ '; - top: 42px !important; -} -.spaceCardFlipped { - transform: rotateY(180deg); -} -.spaceCardFlip { - transition: 0.6s; - transform-style: preserve-3d; - position: relative; - min-height: @spaceCardParentMaxHeight; - padding: 0; -} -.spaceCardFront, .spaceCardBack { - backface-visibility: hidden; - position: absolute; - top: 0; - left: 0 ~'; /** orientation=lt */ '; - right: 0 ~'; /** orientation=rt */ '; - height: @spaceCardMaxHeight; - max-height: @spaceCardMaxHeight; - width: 100%; - max-width: 100%; -} -.spaceCardFront { - z-index: 2; - transform: rotateY(0deg); -} -.spaceCardBack { - transform: rotateY(180deg); -} -.spaceCardItem { - height: @spaceCardMaxHeight; - max-height: @spaceCardMaxHeight; - flex-direction: column; - border-radius: 5px; -} -.spaceDisplayName { - color: @textColor !important; -} -.spaceMembersLabel { - color: @greyColorLighten1 !important; -} -.spaceCardActions { - align-items: flex-end !important; - button i { - margin-right: 10px ~'; /** orientation=lt */ '; - margin-left: 10px ~'; /** orientation=rt */ '; - } -} -.joinSpaceDisabledLabel, .invitationButtons { - width:100%; -} -.acceptToJoinSpaceButtonParent { - white-space: nowrap; - .acceptToJoinSpaceButton { - max-width: 85%; - width: 85%; - border-right: 0 ~'; /** orientation=lt */ '; - border-bottom-right-radius: 0 ~'!important; /** orientation=lt */ '; - border-top-right-radius: 0 ~'!important; /** orientation=lt */ '; - border-left: 0 ~'; /** orientation=rt */ '; - border-bottom-left-radius: 0 ~'!important; /** orientation=rt */ '; - border-top-left-radius: 0 ~'!important; /** orientation=rt */ '; - - .v-btn__content { - max-width: 100%; - span { - width: auto; - max-width: calc( 100% - 28px ); - min-width: auto; - display: inline-block !important; - overflow: hidden !important; - text-overflow: ellipsis !important; - } - } - } - .spaceButtonMenu { - max-width: 15%; - width: 15%; - padding: 5px 20px; - height: auto; - border-left: 0 ~'; /** orientation=lt */ '; - margin-left: -11px ~'; /** orientation=lt */ '; - border-bottom-left-radius: 0 ~'!important; /** orientation=lt */ '; - border-top-left-radius: 0 ~'!important; /** orientation=lt */ '; - border-right: 0 ~'; /** orientation=rt */ '; - margin-right: -11px ~'; /** orientation=rt */ '; - border-bottom-right-radius: 0 ~'!important; /** orientation=rt */ '; - border-top-right-radius: 0 ~'!important; /** orientation=rt */ '; - - i { - margin: 0; - } - } -} diff --git a/webapp/portlet/src/main/webapp/skin/less/portlet/SpaceSearch/Style.less b/webapp/portlet/src/main/webapp/skin/less/portlet/SpaceSearch/Style.less deleted file mode 100644 index 005db257b68..00000000000 --- a/webapp/portlet/src/main/webapp/skin/less/portlet/SpaceSearch/Style.less +++ /dev/null @@ -1,34 +0,0 @@ -/** - - This file is part of the Meeds project (https://meeds.io/). - - Copyright (C) 2020 - 2023 Meeds Association contact@meeds.io - - 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. - -*/ - -@import "../../variables.less"; -@import "../../mixins.less"; - -@spaceCardParentMargin: 22px; -@spaceCardMaxHeight: 227px; -@spaceCardParentMaxHeight: @spaceCardParentMargin + @spaceCardMaxHeight; - -.searchCard { - @import "../../common/SpaceCard/Style.less"; - - .btn { - box-sizing: border-box; - } -} diff --git a/webapp/portlet/src/main/webapp/skin/less/portlet/SpaceSettings/Style.less b/webapp/portlet/src/main/webapp/skin/less/portlet/SpaceSettings/Style.less deleted file mode 100644 index d02801a9331..00000000000 --- a/webapp/portlet/src/main/webapp/skin/less/portlet/SpaceSettings/Style.less +++ /dev/null @@ -1,69 +0,0 @@ -/** - - This file is part of the Meeds project (https://meeds.io/). - - Copyright (C) 2020 - 2023 Meeds Association contact@meeds.io - - 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. - -*/ - -@import "../../variables.less"; -@import "../../mixins.less"; - -#SpaceSettings { - .v-alert.error { - position: absolute; - top: 80px; - left: ~"calc(260px - 50%)"; - } -} - -.spaceAvatarHoverEdit { - position: relative !important; - background: linear-gradient(180deg, rgb(255, 255, 255) 0%, rgb(4, 4, 4) 80%, rgba(0,0,0,1) 100%); - - .v-image__image { - opacity: 0.8; - } - - .changeAvatarButton { - bottom: 0; - left: 50%; - transform: translateX(-50%); - position: absolute; - padding: 0; - margin: 0; - display: inline; - - .v-input__prepend-outer { - margin: 0; - - button { - background: rgba(0, 0, 0, 0.2) !important; - padding: 3px; - color: #fff; - border: 1px solid #fff !important; - border-radius: 50%; - height: 30px; - width: 30px; - } - } - - .v-input__control { - visibility: hidden; - width: 0; - height: 0; - } - } -} diff --git a/webapp/portlet/src/main/webapp/skin/less/portlet/SpacesList/Style.less b/webapp/portlet/src/main/webapp/skin/less/portlet/SpacesList/Style.less deleted file mode 100644 index 7d871819a34..00000000000 --- a/webapp/portlet/src/main/webapp/skin/less/portlet/SpacesList/Style.less +++ /dev/null @@ -1,90 +0,0 @@ -/** - - This file is part of the Meeds project (https://meeds.io/). - - Copyright (C) 2020 - 2023 Meeds Association contact@meeds.io - - 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. - -*/ - -@import "../../variables.less"; -@import "../../mixins.less"; - -@spaceCardParentMargin: 22px; -@spaceCardMaxHeight: 227px; -@spaceCardParentMaxHeight: @spaceCardParentMargin + @spaceCardMaxHeight; - -#spacesListApplication { - .selectSpacesFilter { - height: 40px; - width: auto; - padding-right: 20px; - } - #spacesListBody { - min-height: ~"calc(var(--100vh, 100vh) - 180px)"; - } - .noSpacesYetBlock { - min-height: ~"calc(var(--100vh, 100vh) - 280px)"; - color: @greyColorLighten1; - - .addNewSpaceLink { - padding-bottom: 3px; - } - .noSpacesYetIcons { - direction: ltr; - i::before { - font-size: 140px !important; - color: @greyColorLighten1; - } - } - } - .inputSpacesFilter { - max-width: 215px; - } - - .spaceFormDrawer { - textarea { - resize: none; - } - } - @import "../../common/SpaceCard/Style.less"; - - .spaceCardFront, .spaceCardBack { - > * { - margin: 0 5px; - } - } -} - -@media (max-width: @maxMobileWidth) { - #spacesListApplication { - #spacesListToolbar { - .addNewSpaceButton { - padding: 0 !important; - } - } - - .inputSpacesFilter { - .v-input__prepend-inner { - display: none; - } - - input{ - padding-top: 0; - } - } - - @import "../../common/SpaceCard/Style-mobile.less"; - } -} diff --git a/webapp/portlet/src/main/webapp/skin/less/portlet/WhoIsOnLine/Style.less b/webapp/portlet/src/main/webapp/skin/less/portlet/WhoIsOnLine/Style.less deleted file mode 100644 index c460728f893..00000000000 --- a/webapp/portlet/src/main/webapp/skin/less/portlet/WhoIsOnLine/Style.less +++ /dev/null @@ -1,62 +0,0 @@ -/** - - This file is part of the Meeds project (https://meeds.io/). - - Copyright (C) 2020 - 2023 Meeds Association contact@meeds.io - - 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. - -*/ - -@import "../../variables.less"; -@import "../../mixins.less"; - -.onlineHeader { - background: @primaryBackgroundLight; - border: 1px solid @primaryBackgroundHover; - border-radius: @borderRadiusSmall; - color: @textColor; - line-height: 25px; - padding: 0 5px 0 8px; - font-weight: bold; - margin-bottom: 5px; -} -#OnlinePortlet { - #onlineContent { - box-shadow : none; - border: none; - border-radius: 0; - .title { - padding: 12px; - font-size: 1rem!important; - font-weight: 400; - letter-spacing: .03125em!important; - line-height: 1.5rem; - text-transform: uppercase; - color: @greyColorLighten1; - } - ul { - list-style-type: none; - text-align: center; - padding: 10px 0 10px 0; - - } - .gallery li { - display: inline; - list-style: none; - text-align: center; - height: 40px; - width: 30px; - } - } -} diff --git a/webapp/portlet/src/main/webapp/vue-apps/application-toolbar/components/ApplicationToolbar.vue b/webapp/portlet/src/main/webapp/vue-apps/application-toolbar/components/ApplicationToolbar.vue index 2b7f21dd430..35ffc5cf36b 100644 --- a/webapp/portlet/src/main/webapp/vue-apps/application-toolbar/components/ApplicationToolbar.vue +++ b/webapp/portlet/src/main/webapp/vue-apps/application-toolbar/components/ApplicationToolbar.vue @@ -162,16 +162,16 @@ v-if="showFilterButton" id="applicationToolbarAdvancedFilterButton" :class="filterButtonClass" - :small="isCompact" + :small="!showRightFilterButtonText" text @click="$emit('filter-button-click', $event)"> fa-sliders-h {{ rightFilterButton.text }} @@ -282,6 +282,7 @@ export default { default: () => ({ hide: true, text: null, + displayText: null, // Force to display text even in compact mode }), }, filtersCount: { // Filter button: applied filter count @@ -335,6 +336,9 @@ export default { showLeftContent() { return !this.hideLeft && !this.expandFilter && (!this.isCompact || this.hasLeftContent || (this.hasCenterContent && this.hasRightContent)); }, + showRightFilterButtonText() { + return !this.isCompact || this.rightFilterButton?.displayText; + }, hasCenterButtonToggle() { return this.centerButtonToggle && !this.centerButtonToggle?.hide @@ -396,7 +400,7 @@ export default { return this.hasButtonFilter && !this.hideRightInputs; }, filterButtonClass() { - return `${this.isCompact && 'width-auto ms-4 px-0' || 'ms-4 px-2'} ${this.filtersCount && 'primary--text' || ''} ${!this.isCompact && (this.filtersCount && 'primary-border-color' || 'border-color') || ''}`; + return `${!this.showRightFilterButtonText && 'width-auto ms-4 px-0' || 'ms-4 px-2'} ${this.filtersCount && 'primary--text' || ''} ${this.showRightFilterButtonText && (this.filtersCount && 'primary-border-color' || 'border-color') || ''}`; }, hasRightContent() { return this.rightInputsCount > 0; @@ -480,6 +484,7 @@ export default { } }, beforeDestroy() { + this.$root.$off('reset-filter', this.reset); document.removeEventListener('keydown', this.clearSearch); document.removeEventListener('keydown', this.closeFilter); }, diff --git a/webapp/portlet/src/main/webapp/vue-apps/common/components/ExtensionRegistryComponents.vue b/webapp/portlet/src/main/webapp/vue-apps/common/components/ExtensionRegistryComponents.vue index c6d55bd906a..8e9cd8a2d2b 100644 --- a/webapp/portlet/src/main/webapp/vue-apps/common/components/ExtensionRegistryComponents.vue +++ b/webapp/portlet/src/main/webapp/vue-apps/common/components/ExtensionRegistryComponents.vue @@ -137,16 +137,7 @@ export default { }, }, created() { - document.addEventListener(`component-${this.name}-${this.type}-updated`, event => { - const component = event && event.detail; - if (component) { - if (!this.strictType || component.componentName === this.type) { - const components = this.components.slice(); - this.registerComponent(component, components); - this.components = components; - } - } - }); + document.addEventListener(`component-${this.name}-${this.type}-updated`, this.updateComponents); const registeredComponents = extensionRegistry.loadComponents(this.name); const components = []; if (this.strictType) { @@ -160,7 +151,20 @@ export default { } this.components = components; }, + beforeDestroy() { + document.removeEventListener(`component-${this.name}-${this.type}-updated`, this.updateComponents); + }, methods: { + updateComponents(event) { + const component = event && event.detail; + if (component) { + if (!this.strictType || component.componentName === this.type) { + const components = this.components.slice(); + this.registerComponent(component, components); + this.components = components; + } + } + }, registerComponent(component, components) { if (component.componentOptions.init) { const initResult = component.componentOptions.init(this.params); diff --git a/webapp/portlet/src/main/webapp/vue-apps/common/components/FavoriteButton.vue b/webapp/portlet/src/main/webapp/vue-apps/common/components/FavoriteButton.vue index 8bd0999b02f..a2cce890583 100644 --- a/webapp/portlet/src/main/webapp/vue-apps/common/components/FavoriteButton.vue +++ b/webapp/portlet/src/main/webapp/vue-apps/common/components/FavoriteButton.vue @@ -1,6 +1,5 @@