Skip to content

Commit

Permalink
feat: Rework Spaces Management List columns - MEED-7761 - Meeds-io/MI…
Browse files Browse the repository at this point in the history
…Ps#160

This change will allow to review the list of displayed columns in Spaces Management UI. In addition, this change will allow to add extended columns to Spaces Administration Table.
  • Loading branch information
boubaker committed Nov 11, 2024
1 parent e190302 commit 3efb779
Show file tree
Hide file tree
Showing 13 changed files with 242 additions and 144 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public class SpaceFilter implements Cloneable {

private List<Space> includeSpaces;

private List<Space> exclusions;
private List<Long> excludedIds;

private String remoteId;

Expand Down Expand Up @@ -102,7 +102,7 @@ public boolean isUnifiedSearch() {
public SpaceFilter clone() { // NOSONAR
return new SpaceFilter(spaceNameSearchCondition,
includeSpaces,
exclusions,
excludedIds,
remoteId,
identityId,
templateId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public XSpaceFilter setSpaceFilter(SpaceFilter spaceFilter) {
this.setSorting(spaceFilter.getSorting());
this.setFavorite(spaceFilter.isFavorite());
this.setTemplateId(spaceFilter.getTemplateId());
this.setExcludedIds(spaceFilter.getExcludedIds());
if (spaceFilter.getSpaceNameSearchCondition() != null) {
this.setSpaceNameSearchCondition(spaceFilter.getSpaceNameSearchCondition());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import java.util.LinkedList;
import java.util.List;

import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;

import org.exoplatform.commons.persistence.impl.EntityManagerHolder;
Expand Down Expand Up @@ -136,6 +136,10 @@ private Predicate buildPredicateFilter(Root<SpaceEntity> root, CriteriaQuery<?>
predicates.add(root.get(SpaceEntity_.templateId).in(spaceFilter.getTemplateId()));
}

if (CollectionUtils.isNotEmpty(spaceFilter.getExcludedIds())) {
predicates.add(root.get(SpaceEntity_.id).in(spaceFilter.getExcludedIds()).not());
}

// status
if (CollectionUtils.isNotEmpty(spaceFilter.getStatusList())) {
Path<SpaceMemberEntity> join = getMembersJoin(root, JoinType.INNER);
Expand Down Expand Up @@ -251,10 +255,10 @@ private Order[] buildOrder(Root<SpaceEntity> spaceEntity, CriteriaBuilder cb, Li
}

private Expression<?> getSortField(Root<SpaceEntity> spaceEntity, SortBy sortBy) {
if (sortBy.equals(SortBy.DATE)) {
if (sortBy.equals(SortBy.DATE)) {
return spaceEntity.get(SpaceEntity_.createdDate);
} else {
return spaceEntity.get(SpaceEntity_.prettyName);
return spaceEntity.get(SpaceEntity_.displayName);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,22 @@ public void testDefaultSpaceAvatar() {
assertTrue(profile.isDefaultAvatar());
}

public void testGetSpacesWithExcludedIds() throws Exception {
SpaceFilter spaceFilter = new SpaceFilter();
ArrayList<Long> excludedIds = new ArrayList<>();
for (int i = 0; i < 6; i++) {
Space space = this.getSpaceInstance(i);
if (i % 2 == 0) {
excludedIds.add(Long.parseLong(space.getId()));
}
}
ListAccess<Space> spaces = spaceService.getAllSpacesByFilter(spaceFilter);
int size = spaces.getSize();
spaceFilter.setExcludedIds(excludedIds);
spaces = spaceService.getAllSpacesByFilter(spaceFilter);
assertEquals(size - 3, spaces.getSize());
}

public void testUpdateSpaceAvatar() throws IOException {
this.getSpaceInstance(0);
Space space = spaceService.getSpaceByPrettyName(MY_SPACE_0_PRETTY_NAME);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,9 @@ public Response getSpaces( // NOSONAR
@Parameter(description = "Tag names used to search spaces", required = true)
@QueryParam("tags")
List<String> tagNames,
@Parameter(description = "Excluded space ids", required = false)
@QueryParam("excludedId")
List<Long> excludedIds,
@Parameter(description = "Asking for a full representation of a specific subresource, ex: members or managers",
required = false)
@QueryParam("expand")
Expand All @@ -252,6 +255,7 @@ public Response getSpaces( // NOSONAR
}
spaceFilter.setTagNames(tagNames);
spaceFilter.setTemplateId(templateId);
spaceFilter.setExcludedIds(excludedIds);

if (StringUtils.isNotBlank(sort)) {
SortBy sortBy = Sorting.SortBy.valueOf(sort.toUpperCase());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ social.spaces.administration.manageSpaces.spaceBindingForm.confirmation.confirm=
social.spaces.administration.manageSpaces.spaceBindingForm.removeBinding.confirm=Confirm
social.spaces.administration.manageSpaces=Manage spaces
social.spaces.administration.manageSpaces.space=Space
social.spaces.administration.manageSpaces.description=Description
social.spaces.administration.manageSpaces.visibility=Visibility
social.spaces.administration.manageSpaces.visibility.public=Public
Expand Down
2 changes: 0 additions & 2 deletions webapp/src/main/webapp/WEB-INF/portlet.xml
Original file line number Diff line number Diff line change
Expand Up @@ -439,8 +439,6 @@
<supports>
<mime-type>text/html</mime-type>
</supports>
<supported-locale>en</supported-locale>
<resource-bundle>locale.portlet.social.SpacesAdministrationPortlet</resource-bundle>
<portlet-info>
<title>Spaces Administration</title>
</portlet-info>
Expand Down
39 changes: 22 additions & 17 deletions webapp/src/main/webapp/vue-apps/common/components/SpaceAvatar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,17 @@
class="my-auto">
<img
:src="defaultAvatarUrl"
:alt="displayName"
class="object-fit-cover ma-auto"
loading="lazy"
alt="">
loading="lazy">
</v-avatar>
<div
v-if="fullname || !isMobile"
:class="subtitleNewLineClass"
class="pull-left text-truncate ms-2">
:class="[subtitleNewLineClass, textTruncateClass]"
class="pull-left ms-2">
<p
class="text-truncate my-auto hidden-space">
:class="textTruncateClass"
class="my-auto hidden-space">
{{ $t('spacesList.label.hiddenSpace') }}
</p>
</div>
Expand All @@ -46,9 +47,9 @@
<img
:src="avatarUrl"
:class="avatarClass"
:alt="displayName"
class="object-fit-cover ma-auto"
loading="lazy"
alt="">
loading="lazy">
</v-avatar>
</a>
<a
Expand All @@ -61,12 +62,12 @@
class="flex-nowrap flex-shrink-0 d-flex spaceAvatar">
<div
v-if="displayName || $slots.subTitle"
:class="subtitleNewLineClass"
class="text-truncate ms-2">
:class="[subtitleNewLineClass, textTruncateClass]"
class="ms-2">
<p
v-if="displayName"
:class="[fullnameStyle, linkStyle && 'primary--text' || '']"
class="text-truncate my-auto">
:class="[fullnameStyle, linkStyle && 'primary--text' || '', textTruncateClass]"
class="my-auto">
{{ displayName }}
</p>
<p v-if="$slots.subTitle" class="text-subtitle my-auto">
Expand All @@ -92,18 +93,18 @@
<img
:src="avatarUrl"
:class="avatarClass"
:alt="displayName"
class="object-fit-cover ma-auto"
loading="lazy"
alt="">
loading="lazy">
</v-avatar>
<div
v-if="displayName || $slots.subTitle"
:class="subtitleNewLineClass"
class="text-truncate ms-2">
:class="[subtitleNewLineClass, textTruncateClass]"
class="ms-2">
<p
v-if="displayName"
:class="[fullnameStyle, linkStyle && 'primary--text' || '']"
class="text-truncate my-auto text-body">
:class="[fullnameStyle, linkStyle && 'primary--text' || '', textTruncateClass]"
class="my-auto text-body">
{{ displayName }}
</p>
<p v-if="$slots.subTitle" class="text-subtitle my-auto">
Expand Down Expand Up @@ -175,6 +176,10 @@ export default {
type: String,
default: () => '',
},
textTruncateClass: {
type: String,
default: () => 'text-truncate',
},
},
data() {
return {
Expand Down
55 changes: 38 additions & 17 deletions webapp/src/main/webapp/vue-apps/common/js/SpaceService.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,30 +125,51 @@ export function getSpaceByGroupSuffix(groupSuffix, expand) {
});
}

export function getSpaces(query, offset, limit, filter, expand, templateId) {
if (!expand) {
expand = filter === 'requests' ? 'pending' : limit && 'managers' || '';
}
export function getSpaces(query, offset, limit, filter, expand, templateId, sortBy, sortDirection) {
return getSpacesByFilter({
query,
offset,
limit,
filter,
expand,
templateId,
sortBy,
sortDirection,
});
}

export function getSpacesByFilter(options) {
const formData = new FormData();
if (query) {
formData.append('q', query);
if (options.expand) {
formData.append('expand', options.expand);
} else {
formData.append('expand', options.filter === 'requests' ? 'pending' : options.limit && 'managers' || '');
}
if (templateId) {
formData.append('templateId', templateId);
if (options.query) {
formData.append('q', options.query);
}
if (offset) {
formData.append('offset', offset);
if (options.templateId) {
formData.append('templateId', options.templateId);
}
if (limit) {
formData.append('limit', limit);
if (options.offset) {
formData.append('offset', options.offset);
}
if (filter) {
formData.append('filterType', filter);
if (options.limit) {
formData.append('limit', options.limit);
}
formData.append('returnSize', true);
if (expand) {
formData.append('expand', expand);
if (options.filter) {
formData.append('filterType', options.filter);
}
if (options.sortBy) {
formData.append('sort', options.sortBy);
}
if (options.sortDirection) {
formData.append('order', options.sortDirection);
}
if (options.excludedIds?.length) {
options.excludedIds.forEach(id => formData.append('excludedId', id));
}
formData.append('returnSize', true);
const urlParams = new URLSearchParams(formData).toString();
return fetch(`${eXo.env.portal.context}/${eXo.env.portal.rest}/v1/social/spaces?${urlParams}`, {
method: 'GET',
Expand Down
Loading

0 comments on commit 3efb779

Please sign in to comment.