Skip to content

Commit

Permalink
feat: Review Spaces Form Creation Drawer - MEED-7804 - Meeds-io/MIP#1…
Browse files Browse the repository at this point in the history
…59 (#4209)

This change will review the Spaces Creation form to adopt the fields
selection Inputs display switch selected Template.
  • Loading branch information
boubaker committed Dec 3, 2024
1 parent 0637856 commit 82177dd
Show file tree
Hide file tree
Showing 75 changed files with 1,534 additions and 672 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,15 @@ public Response createSpace(
.entity(e.getCode().name())
.build());
}
saveSpaceAvatar(space, model);
saveSpaceBanner(model, space);
try {
inviteExternalUsers(uriInfo, model, space, authenticatedUser);
} catch (Exception e) {
LOG.warn("Error while sending external users invitations to space {}",
space.getGroupId(),
e);
}
return EntityBuilder.getResponse(EntityBuilder.buildEntityFromSpace(space, authenticatedUser, uriInfo.getPath(), expand),
uriInfo,
RestUtils.getJsonMediaType(),
Expand Down Expand Up @@ -771,36 +780,7 @@ public Response updateSpaceById(
spaceService.renameSpace(space, model.getDisplayName(), authenticatedUser);
}

if (model.getExternalInvitedUsers() != null
&& (securitySettingService.getRegistrationType() == UserRegistrationType.OPEN
|| securitySettingService.isRegistrationExternalUser())) {
String uri = uriInfo.getBaseUri()
.toString()
.substring(0,
uriInfo.getBaseUri()
.toString()
.lastIndexOf("/"));
StringBuilder url = new StringBuilder(uri);

PasswordRecoveryService passwordRecoveryService = CommonsUtils.getService(PasswordRecoveryService.class);
LocaleConfigService localeConfigService = CommonsUtils.getService(LocaleConfigService.class);
Locale locale = null;
try {
String defaultLanguage = localeConfigService.getDefaultLocaleConfig().getLocale().toLanguageTag();
locale = LocaleUtils.toLocale(defaultLanguage);
} catch (Exception e) {
LOG.error("Failure to retrieve portal config", e);
}
for (String externalInvitedUser : model.getExternalInvitedUsers()) {
String tokenId = passwordRecoveryService.sendExternalRegisterEmail(authenticatedUser,
externalInvitedUser,
locale,
space.getDisplayName(),
url);
spaceService.saveSpaceExternalInvitation(space.getId(), externalInvitedUser, tokenId);
}
}

inviteExternalUsers(uriInfo, model, space, authenticatedUser);
fillSpaceFromModel(space, model);
space.setEditor(authenticatedUser);
space = spaceService.updateSpace(space, model.getInvitedMembers());
Expand Down Expand Up @@ -1007,11 +987,11 @@ private void fillSpaceFromModel(Space space, SpaceEntity model) {
space.setTemplateId(model.getTemplateId());
}

if (StringUtils.isNotBlank(model.getBannerId())) {
if (StringUtils.isNotBlank(model.getId()) && StringUtils.isNotBlank(model.getBannerId())) {
updateProfileField(space, Profile.BANNER, model.getBannerId());
}

if (StringUtils.isNotBlank(model.getAvatarId())) {
if (StringUtils.isNotBlank(model.getId()) && StringUtils.isNotBlank(model.getAvatarId())) {
updateProfileField(space, Profile.AVATAR, model.getAvatarId());
}

Expand Down Expand Up @@ -1194,4 +1174,63 @@ private Response.ResponseBuilder getDefaultBannerBuilder() throws IOException {
return builder;
}

private void saveSpaceAvatar(Space space, SpaceEntity model) {
if (StringUtils.isNotBlank(model.getAvatarId())) {
try {
updateProfileField(space, Profile.AVATAR, model.getAvatarId());
} catch (IOException e) {
LOG.warn("Error adding Space Avatar. Avoid stopping space creation process and continue", e);
}
}
}

private void saveSpaceBanner(SpaceEntity model, Space space) {
if (StringUtils.isNotBlank(model.getBannerId())) {
try {
updateProfileField(space, Profile.BANNER, model.getBannerId());
} catch (IOException e) {
LOG.warn("Error adding Space Banner. Avoid stopping space creation process and continue", e);
}
}
}

private boolean inviteExternalUsers(UriInfo uriInfo, SpaceEntity model, Space space, String authenticatedUser) throws Exception {
int errorsCount = 0;
if (model.getExternalInvitedUsers() != null
&& (securitySettingService.getRegistrationType() == UserRegistrationType.OPEN
|| securitySettingService.isRegistrationExternalUser())) {
String uri = uriInfo.getBaseUri()
.toString()
.substring(0,
uriInfo.getBaseUri()
.toString()
.lastIndexOf("/"));
StringBuilder url = new StringBuilder(uri);

PasswordRecoveryService passwordRecoveryService = CommonsUtils.getService(PasswordRecoveryService.class);
LocaleConfigService localeConfigService = CommonsUtils.getService(LocaleConfigService.class);
Locale locale = null;
try {
String defaultLanguage = localeConfigService.getDefaultLocaleConfig().getLocale().toLanguageTag();
locale = LocaleUtils.toLocale(defaultLanguage);
} catch (Exception e) {
LOG.error("Failure to retrieve portal config", e);
}
for (String externalInvitedUser : model.getExternalInvitedUsers()) {
try {
String tokenId = passwordRecoveryService.sendExternalRegisterEmail(authenticatedUser,
externalInvitedUser,
locale,
space.getDisplayName(),
url);
spaceService.saveSpaceExternalInvitation(space.getId(), externalInvitedUser, tokenId);
} catch (Exception e) {
LOG.warn("Error while sending external invitation to user {}", externalInvitedUser, e);
errorsCount++;
}
}
}
return errorsCount == 0;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,7 @@ spacesList.label.noSpacesYetDescription2=ولكن يمكنك البدء ب
spacesList.label.noSpacesLink=إضافة الفضاء الأول الخاص بك.
spacesList.label.addNewSpace=إضافة فضاء
spacesList.label.editSpace=تعديل الفضاء {0}
spacesList.label.spaceDetails=تفاصيل الفضاء
spacesList.label.spaceAccess=Access Rules
spacesList.label.inviteUsers=دعوة المستخدمين
spacesList.label.displayName=الاسم الظاهر
spacesList.label.description=الوصف
spacesList.label.name=الاسم
spacesList.label.spaceTemplate=نموذج
spacesList.label.yes=نعم
spacesList.label.no=لا
spacesList.label.apply=Apply
Expand Down Expand Up @@ -64,7 +58,6 @@ spacesList.button.removeBookmark=إزالة من الإشارات المرجعي
spacesList.button.requestJoin=طلب الوصول
spacesList.button.cancelRequest=إلغاء الطلب
spacesList.button.close=اغلاق
spacesList.button.continue=متابعة
spacesList.button.back=الرجوع
spacesList.button.cancel=إلغاء
spacesList.button.add=Add
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,7 @@ spacesList.label.noSpacesYetDescription2=ولكن يمكنك البدء ب
spacesList.label.noSpacesLink=إضافة الفضاء الأول الخاص بك.
spacesList.label.addNewSpace=مساحة
spacesList.label.editSpace=تعديل الفضاء {0}
spacesList.label.spaceDetails=تفاصيل الفضاء
spacesList.label.spaceAccess=Access Rules
spacesList.label.inviteUsers=دعوة المستخدمين
spacesList.label.displayName=الاسم المعروض
spacesList.label.description=الوصف
spacesList.label.name=الاسم
spacesList.label.spaceTemplate=القالب
spacesList.label.yes=نعم
spacesList.label.no=لا
spacesList.label.apply=Apply
Expand Down Expand Up @@ -64,7 +58,6 @@ spacesList.button.removeBookmark=إزالة من الإشارات المرجعي
spacesList.button.requestJoin=طلب الوصول
spacesList.button.cancelRequest=إلغاء الطلب
spacesList.button.close=اغلاق
spacesList.button.continue=واصل
spacesList.button.back=رجوع
spacesList.button.cancel=الغاء
spacesList.button.add=Add
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,7 @@ spacesList.label.noSpacesYetDescription2=but you can start by
spacesList.label.noSpacesLink=adding your first space.
spacesList.label.addNewSpace=Add Space
spacesList.label.editSpace=Edit Space {0}
spacesList.label.spaceDetails=Space details
spacesList.label.spaceAccess=Access Rules
spacesList.label.inviteUsers=Invite users
spacesList.label.displayName=Display name
spacesList.label.description=Açıqlama
spacesList.label.name=Name
spacesList.label.spaceTemplate=Template
spacesList.label.yes=Yes
spacesList.label.no=No
spacesList.label.apply=Apply
Expand Down Expand Up @@ -64,7 +58,6 @@ spacesList.button.removeBookmark=Remove from bookmarked
spacesList.button.requestJoin=Request access
spacesList.button.cancelRequest=Cancel request
spacesList.button.close=Close
spacesList.button.continue=Continue
spacesList.button.back=Back
spacesList.button.cancel=Ləğv Et
spacesList.button.add=Add
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,7 @@ spacesList.label.noSpacesYetDescription2=but you can start by
spacesList.label.noSpacesLink=adding your first space.
spacesList.label.addNewSpace=Afegeix un Espai
spacesList.label.editSpace=Edit Space {0}
spacesList.label.spaceDetails=Space details
spacesList.label.spaceAccess=Access Rules
spacesList.label.inviteUsers=Invite users
spacesList.label.displayName=Display name
spacesList.label.description=Descripció
spacesList.label.name=Nom
spacesList.label.spaceTemplate=Plantilla
spacesList.label.yes=Sí
spacesList.label.no=No
spacesList.label.apply=Apply
Expand Down Expand Up @@ -64,7 +58,6 @@ spacesList.button.removeBookmark=Remove from bookmarked
spacesList.button.requestJoin=Request access
spacesList.button.cancelRequest=Cancel request
spacesList.button.close=Tanca
spacesList.button.continue=Continua
spacesList.button.back=Enrere
spacesList.button.cancel=Cancel·la
spacesList.button.add=Add
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,7 @@ spacesList.label.noSpacesYetDescription2=but you can start by
spacesList.label.noSpacesLink=adding your first space.
spacesList.label.addNewSpace=Add Space
spacesList.label.editSpace=Edit Space {0}
spacesList.label.spaceDetails=Space details
spacesList.label.spaceAccess=Access Rules
spacesList.label.inviteUsers=Invite users
spacesList.label.displayName=Display name
spacesList.label.description=Description
spacesList.label.name=Name
spacesList.label.spaceTemplate=Ang Template
spacesList.label.yes=Yes
spacesList.label.no=No
spacesList.label.apply=Apply
Expand Down Expand Up @@ -64,7 +58,6 @@ spacesList.button.removeBookmark=Remove from bookmarked
spacesList.button.requestJoin=Request access
spacesList.button.cancelRequest=Cancel request
spacesList.button.close=Close
spacesList.button.continue=Continue
spacesList.button.back=Back
spacesList.button.cancel=Cancel
spacesList.button.add=Add
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,7 @@ spacesList.label.noSpacesYetDescription2=but you can start by
spacesList.label.noSpacesLink=adding your first space.
spacesList.label.addNewSpace=Add Space
spacesList.label.editSpace=Edit Space {0}
spacesList.label.spaceDetails=Space details
spacesList.label.spaceAccess=Access Rules
spacesList.label.inviteUsers=Invite users
spacesList.label.displayName=Display name
spacesList.label.description=Description
spacesList.label.name=Name
spacesList.label.spaceTemplate=Template
spacesList.label.yes=Yes
spacesList.label.no=No
spacesList.label.apply=Apply
Expand Down Expand Up @@ -64,7 +58,6 @@ spacesList.button.removeBookmark=Remove from bookmarked
spacesList.button.requestJoin=Request access
spacesList.button.cancelRequest=Cancel request
spacesList.button.close=Close
spacesList.button.continue=Continue
spacesList.button.back=Back
spacesList.button.cancel=Cancel
spacesList.button.add=Add
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,7 @@ spacesList.label.noSpacesYetDescription2=but you can start by
spacesList.label.noSpacesLink=adding your first space.
spacesList.label.addNewSpace=Přidat skupinu
spacesList.label.editSpace=Edit Space {0}
spacesList.label.spaceDetails=Space details
spacesList.label.spaceAccess=Access Rules
spacesList.label.inviteUsers=Invite users
spacesList.label.displayName=Display name
spacesList.label.description=Popis
spacesList.label.name=Název
spacesList.label.spaceTemplate=Šablona
spacesList.label.yes=Ano
spacesList.label.no=Ne
spacesList.label.apply=Apply
Expand Down Expand Up @@ -64,7 +58,6 @@ spacesList.button.removeBookmark=Remove from bookmarked
spacesList.button.requestJoin=Request access
spacesList.button.cancelRequest=Cancel request
spacesList.button.close=Zavřít
spacesList.button.continue=Pokračovat
spacesList.button.back=Zpět
spacesList.button.cancel=Zrušit
spacesList.button.add=Add
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,7 @@ spacesList.label.noSpacesYetDescription2=aber Sie können jetzt
spacesList.label.noSpacesLink=Ihren ersten Raum hinzufügen.
spacesList.label.addNewSpace=Raum hinzufügen
spacesList.label.editSpace=Raum {0} bearbeiten
spacesList.label.spaceDetails=Raumdetails:
spacesList.label.spaceAccess=Access Rules
spacesList.label.inviteUsers=Benutzer einladen
spacesList.label.displayName=Anzeigename
spacesList.label.description=Beschreibung
spacesList.label.name=Name
spacesList.label.spaceTemplate=Vorlage
spacesList.label.yes=Ja
spacesList.label.no=Nein
spacesList.label.apply=Anwenden
Expand Down Expand Up @@ -64,7 +58,6 @@ spacesList.button.removeBookmark=Aus Lesezeichen entfernen
spacesList.button.requestJoin=Zugang anfordern
spacesList.button.cancelRequest=Anfrage abbrechen
spacesList.button.close=Schließen
spacesList.button.continue=Fortsetzen
spacesList.button.back=Zurück
spacesList.button.cancel=Abbrechen
spacesList.button.add=Hinzufügen
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,7 @@ spacesList.label.noSpacesYetDescription2=but you can start by
spacesList.label.noSpacesLink=adding your first space.
spacesList.label.addNewSpace=Προσθήκη Χώρου
spacesList.label.editSpace=Edit Space {0}
spacesList.label.spaceDetails=Space details
spacesList.label.spaceAccess=Access Rules
spacesList.label.inviteUsers=Invite users
spacesList.label.displayName=Display name
spacesList.label.description=Περιγραφή
spacesList.label.name=Όνομα
spacesList.label.spaceTemplate=Πρότυπο
spacesList.label.yes=Ναι
spacesList.label.no=Όχι
spacesList.label.apply=Apply
Expand Down Expand Up @@ -64,7 +58,6 @@ spacesList.button.removeBookmark=Remove from bookmarked
spacesList.button.requestJoin=Request access
spacesList.button.cancelRequest=Cancel request
spacesList.button.close=Κλείσιμο
spacesList.button.continue=Συνέχεια
spacesList.button.back=Επιστροφή
spacesList.button.cancel=Ακύρωση
spacesList.button.add=Add
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,26 +21,40 @@ spacesList.label.noSpacesYetDescription2=but you can start by
spacesList.label.noSpacesLink=adding your first space.
spacesList.label.addNewSpace=Add Space
spacesList.label.editSpace=Edit Space {0}
spacesList.label.spaceDetails=Space details
spacesList.label.spaceAccess=Access Rules
spacesList.label.inviteUsers=Invite users
spacesList.label.displayName=Display name
spacesList.label.description=Description
spacesList.label.name=Name
spacesList.label.spaceTemplate=Template
spacesList.label.nameTitle=Name
spacesList.label.nameLabel=Give a name to your space
spacesList.label.namePlaceholder=Name your space
spacesList.label.propertiesTitle=Properties
spacesList.label.descriptionLabel=Describe your space
spacesList.label.descriptionPlaceholder=Detail purpose of your space
spacesList.label.spaceAccessTitle=Access Control
spacesList.label.avatarLabel=Avatar
spacesList.label.bannerLabel=Banner
spacesList.label.changeBanner=Change Banner
spacesList.label.deleteBanner=Delete Banner
spacesList.label.changeAvatar=Change Avatar
spacesList.label.deleteAvatar=Delete Avatar
spacesList.label.invitationTitle=Invitation
spacesList.label.accessTitle=Access
spacesList.label.visibilityTitle=Visibility
spacesList.label.yes=Yes
spacesList.label.no=No
spacesList.label.apply=Apply
spacesList.label.hidden=Hidden
spacesList.label.hiddenSpace=Hidden space
spacesList.label.registration=Registration
spacesList.label.open=Open
spacesList.description.open=Any user can join the space. No validation required.
spacesList.label.validation=Request Approval
spacesList.description.validation=User can request to join. Membership must be approved by a host.
spacesList.label.closed=Invite Only
spacesList.description.closed=Users can't request to join. They should be invited.
spacesList.description.open=Anyone can join. No approval needed.
spacesList.description.validation=User can request to join. Membership must be approved by an admin.
spacesList.description.closed=Users can't request to join. Admins must send invitations.
spacesList.description.hidden=The space is not listed in the space directory
spacesList.label.private=Listed
spacesList.description.private=The space is visible in the directory.
spacesList.warning=Warning
spacesList.warning.descriptionExceededLength=The length of the text in field "Description" must be less than {0} characters.
Expand All @@ -64,7 +78,7 @@ spacesList.button.removeBookmark=Remove from bookmarked
spacesList.button.requestJoin=Request access
spacesList.button.cancelRequest=Cancel request
spacesList.button.close=Close
spacesList.button.continue=Continue
spacesList.button.next=Next
spacesList.button.back=Back
spacesList.button.cancel=Cancel
spacesList.button.add=Add
Expand Down Expand Up @@ -106,3 +120,5 @@ spacesList.button.copyLink.success=Link copied into the clipboard
spacesList.button.copyLink.error=Error while copying site URL
spacesList.button.visitPublicSite=Visit public site
spacesList.button.openSpace=Open Space
spacesList.title.usersToInvite=Invite users
spacesList.label.pending=Pending
Loading

0 comments on commit 82177dd

Please sign in to comment.