Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge Meeds-io/MIPs#161 #1165

Merged
merged 29 commits into from
Dec 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
533df68
fix: Fix delete label in deletion confirmation popup - EXO-74699 - Me…
azayati Oct 14, 2024
7376c88
feat: Implement notes publication drawer - EXO-72738_EXO-72741 - Meed…
hakermi Oct 9, 2024
c874821
feat: Notes publication drawer in edit mode - EXO-72749_EXO-73246 - M…
hakermi Oct 9, 2024
f10c633
feat: Update note Editor and model to relay on note editor extensions…
sofyenne Oct 10, 2024
6bac345
fix: Featured image not saved at the note creation - EXO-74744 - Meed…
sofyenne Oct 14, 2024
fedb6ad
feat: Update notes overview to realy on the overview extensions - EXO…
sofyenne Oct 14, 2024
2c2c613
feat: Update note editor config to hide unnecessary extensions in sin…
sofyenne Oct 14, 2024
3d91488
feat: Update the size of favorite icon of notes detail to 20px - EXO-…
azayati Oct 17, 2024
a2dcbc0
feat: Remove space name from note url when copying note link and inse…
azayati Oct 16, 2024
d530cd2
fix: Fix space between save and close buttons of notes editor for XS …
azayati Oct 16, 2024
b77f05b
fix: Fix empty note without children displays the TOC of home- EXO-74…
azayati Oct 17, 2024
06d52a3
feat: Implement publish option - EXO-72742_EXO-72744_EXO-73081 - Meed…
hakermi Oct 18, 2024
962a502
feat: Implement Schedule option - EXO-72745 - Meeds-io/MIPs#161 (#1185)
hakermi Oct 25, 2024
91b29eb
feat: Implement Edit scheduling - EXO-74995_EXO-75003_EXO-75072 - Mee…
hakermi Oct 28, 2024
6ebfa5e
feat: Improve note editor display - EXO-73698 - Meeds-io/MIPs#161 (#1…
sofyenne Oct 30, 2024
fbc38c0
feat: Allow space member to schedule post - EXO-75098 - Meeds-io/MIPs…
hakermi Oct 31, 2024
390772c
feat: Remove useless noteEditorPluginsExtensions - EXO-75212 - Meeds-…
sofyenne Nov 7, 2024
a3e866c
feat: Implement hide author advanced publication settings option - EX…
hakermi Nov 4, 2024
5454d74
feat: Implement hide reaction advanced publication settings option - …
hakermi Nov 5, 2024
1ef7ae9
feat: Implement publish note - EXO-73041 - Meeds-io/MIPs#161 (#1212)
hakermi Nov 18, 2024
aa5546a
feat: Implement edit note publication schedule - EXO-75389 - Meeds-io…
hakermi Nov 19, 2024
c359328
feat: Adjust schedule note publication permissions - EXO-75520 - Meed…
hakermi Nov 28, 2024
b682159
feat: Make note treeview drawer a re-usable component - EXO-73047, EX…
hakermi Dec 4, 2024
b62b429
Fix: fix unable to save snv translation - EXO-75758 - Meeds-io/meeds#…
hakermi Dec 4, 2024
f26eb85
feat: broadcast note deleted event - EXO-75617 - Meeds-io/MIPs#161 (#…
hakermi Dec 5, 2024
9819993
fix: labels are not translated in publication drawer - EXO-75965 - me…
rdenarie Dec 11, 2024
3f20fa4
fix: Fix broadcasting note.page.version.created event when draftId is…
azayati Dec 17, 2024
ecc1365
feat: Add note toc plugin styles to generated sources - EXO-75747 - M…
hakermi Dec 16, 2024
efefce0
feat: Remove MIP-161 feature flags - EXO-76014 - Meeds-io/MIPs#161 (#…
hakermi Dec 19, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,10 @@ public class NotePageProperties implements Serializable {

private NoteFeaturedImage featuredImage;

private boolean hideAuthor;

private boolean hideReaction;

private boolean isDraft;

}
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,6 @@ public class PageEntity implements Serializable {
private String lang;

private PagePropertiesEntity properties;

private boolean extensionDataUpdated;
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,9 @@ public class PagePropertiesEntity implements Serializable {

private FeaturedImageEntity featuredImage;

private boolean hideAuthor;

private boolean hideReaction;

private boolean isDraft;
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ public static NotePageProperties toNotePageProperties(PagePropertiesEntity pageP
return new NotePageProperties(pagePropertiesEntity.getNoteId(),
pagePropertiesEntity.getSummary(),
toNoteFeaturedImage(pagePropertiesEntity.getFeaturedImage()),
pagePropertiesEntity.isHideAuthor(),
pagePropertiesEntity.isHideReaction(),
pagePropertiesEntity.isDraft());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import org.exoplatform.social.core.space.model.Space;
import org.exoplatform.social.core.space.spi.SpaceService;
import org.exoplatform.social.metadata.MetadataService;
import org.exoplatform.social.metadata.model.MetadataItem;
import org.exoplatform.social.metadata.model.MetadataKey;
import org.exoplatform.social.metadata.model.MetadataType;
import org.exoplatform.wiki.WikiException;
Expand All @@ -51,23 +52,26 @@

import java.io.ByteArrayInputStream;
import java.util.*;
import java.util.stream.Collectors;

/**
* Utility class to convert JPA entity objects
*/
public class EntityConverter {

private static final Log LOG = ExoLogger.getLogger(EntityConverter.class);
private static final Log LOG = ExoLogger.getLogger(EntityConverter.class);

private static SpaceService spaceService;
private static SpaceService spaceService;

private static MetadataService metadataService;
private static MetadataService metadataService;

public static final MetadataType NOTES_METADATA_TYPE = new MetadataType(1001, "notes");
public static final MetadataType NOTES_METADATA_TYPE = new MetadataType(1001, "notes");

public static final MetadataKey NOTES_METADATA_KEY = new MetadataKey(NOTES_METADATA_TYPE.getName(),
Utils.NOTES_METADATA_OBJECT_TYPE,
0);
public static final MetadataKey NOTES_METADATA_KEY = new MetadataKey(NOTES_METADATA_TYPE.getName(),
Utils.NOTES_METADATA_OBJECT_TYPE,
0);

private static final List<String> ORIGINAL_SHARED_PROPERTIES = List.of("hideReaction", "hideAuthor");

public static Wiki convertWikiEntityToWiki(WikiEntity wikiEntity) {
Wiki wiki = null;
Expand Down Expand Up @@ -147,7 +151,7 @@ public static Page convertPageEntityToPage(PageEntity pageEntity) {
}
return page;
}

public static void buildNotePageMetadata(Page note, boolean isDraft) {
if (note == null) {
return;
Expand All @@ -158,6 +162,7 @@ public static void buildNotePageMetadata(Page note, boolean isDraft) {
if (note.getLang() != null) {
noteId = noteId + "-" + note.getLang();
}
Map<String, String> originalNoteSharedProperties = getOriginalNoteSharedProperties(note, space.getId());
NoteMetadataObject noteMetadataObject = new NoteMetadataObject(isDraft ? "noteDraftPage" : "notePage",
noteId,
note.getParentPageId(),
Expand All @@ -167,40 +172,13 @@ public static void buildNotePageMetadata(Page note, boolean isDraft) {
.findFirst()
.ifPresent(metadataItem -> {
if (!MapUtils.isEmpty(metadataItem.getProperties())) {
buildPageProperties(metadataItem.getProperties(), note);
buildPageProperties(metadataItem.getProperties(), originalNoteSharedProperties, note);
}
});

}
}

private static void buildPageProperties(Map<String, String> properties, Page note) {
NotePageProperties notePageProperties = new NotePageProperties();
NoteFeaturedImage noteFeaturedImage = new NoteFeaturedImage();
notePageProperties.setNoteId(Long.parseLong(note.getId()));
notePageProperties.setSummary(properties.get(NoteServiceImpl.SUMMARY_PROP));
noteFeaturedImage.setId(Long.valueOf(properties.getOrDefault(NoteServiceImpl.FEATURED_IMAGE_ID, "0")));
noteFeaturedImage.setLastUpdated(Long.valueOf(properties.getOrDefault(NoteServiceImpl.FEATURED_IMAGE_UPDATED_DATE, "0")));
noteFeaturedImage.setAltText(properties.get(NoteServiceImpl.FEATURED_IMAGE_ALT_TEXT));
notePageProperties.setDraft(note.isDraftPage());
notePageProperties.setFeaturedImage(noteFeaturedImage);
note.setProperties(notePageProperties);
}

private static SpaceService getSpaceService() {
if (spaceService == null) {
spaceService = CommonsUtils.getService(SpaceService.class);
}
return spaceService;
}

private static MetadataService getMetadataService() {
if (metadataService == null) {
metadataService = CommonsUtils.getService(MetadataService.class);
}
return metadataService;
}

public static List<PermissionEntry> convertPermissionEntitiesToPermissionEntries(List<PermissionEntity> permissionEntities,
List<PermissionType> filteredPermissionTypes) {
List<PermissionEntry> permissionEntries = new ArrayList<>();
Expand Down Expand Up @@ -586,4 +564,60 @@ public static List<PageHistory> toPageHistoryVersions(List<PageVersionEntity> pa
public static List<DraftPage> toDraftPages(List<DraftPageEntity> draftPageEntities) {
return draftPageEntities.stream().map(EntityConverter::convertDraftPageEntityToDraftPage).toList();
}

private static Map<String, String> getOriginalNoteSharedProperties(Page note, String spaceId) {
if (note.getLang() == null || note.isDraftPage()) {
return new HashMap<>();
}
NoteMetadataObject originalNoteMetadataObject = new NoteMetadataObject("notePage",
note.getId(),
note.getParentPageId(),
Long.parseLong(spaceId));
List<MetadataItem> metadataItems = getMetadataService().getMetadataItemsByMetadataAndObject(NOTES_METADATA_KEY,
originalNoteMetadataObject);
Map<String, String> originalNoteSharedProperties = new HashMap<>();
if (!CollectionUtils.isEmpty(metadataItems)) {
originalNoteSharedProperties = metadataItems.getFirst().getProperties();
}
return originalNoteSharedProperties.entrySet()
.stream()
.filter(entry -> ORIGINAL_SHARED_PROPERTIES.contains(entry.getKey()))
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
}

private static void buildPageProperties(Map<String, String> properties,
Map<String, String> originalNoteSharedProperties,
Page note) {
Map<String, String> finalProperties = new HashMap<>(properties);
finalProperties.putAll(originalNoteSharedProperties);
NotePageProperties notePageProperties = new NotePageProperties();
NoteFeaturedImage noteFeaturedImage = new NoteFeaturedImage();
notePageProperties.setNoteId(Long.parseLong(note.getId()));
notePageProperties.setSummary(finalProperties.get(NoteServiceImpl.SUMMARY_PROP));
notePageProperties.setHideAuthor(Boolean.parseBoolean(finalProperties.getOrDefault(NoteServiceImpl.HIDE_AUTHOR_PROP,
"false")));
notePageProperties.setHideReaction(Boolean.parseBoolean(properties.getOrDefault(NoteServiceImpl.HIDE_REACTION_PROP,
"false")));
noteFeaturedImage.setId(Long.valueOf(finalProperties.getOrDefault(NoteServiceImpl.FEATURED_IMAGE_ID, "0")));
noteFeaturedImage.setLastUpdated(Long.valueOf(finalProperties.getOrDefault(NoteServiceImpl.FEATURED_IMAGE_UPDATED_DATE,
"0")));
noteFeaturedImage.setAltText(finalProperties.get(NoteServiceImpl.FEATURED_IMAGE_ALT_TEXT));
notePageProperties.setDraft(note.isDraftPage());
notePageProperties.setFeaturedImage(noteFeaturedImage);
note.setProperties(notePageProperties);
}

private static SpaceService getSpaceService() {
if (spaceService == null) {
spaceService = CommonsUtils.getService(SpaceService.class);
}
return spaceService;
}

private static MetadataService getMetadataService() {
if (metadataService == null) {
metadataService = CommonsUtils.getService(MetadataService.class);
}
return metadataService;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ public class Page {

private boolean hasChild;

private String latestVersionId;

private boolean isDeleted;

private Page parent;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,8 @@ public NoteToExport getNoteToExport(NoteToExport note, int exportId) throws Wiki

public String processNotesLinkForExport(NoteToExport note) throws WikiException {
String content = note.getContent();
String noteLinkprefix = "class=\"noteLink\" href=\"(?:.*?/|)(\\d+)";
String noteLinkprefix = "class=\"noteLink\" href=\"(?:.*?/)?(\\d+)\"";

String contentUpdated = content;
Map<String, String> urlToReplaces = new HashMap<>();
Pattern pattern = Pattern.compile(noteLinkprefix);
Expand All @@ -482,7 +483,7 @@ public String processNotesLinkForExport(NoteToExport note) throws WikiException
String noteParams = IMAGE_URL_REPLACEMENT_PREFIX + linkedNote.getWikiType() + IMAGE_URL_REPLACEMENT_SUFFIX
+ IMAGE_URL_REPLACEMENT_PREFIX + linkedNote.getWikiOwner() + IMAGE_URL_REPLACEMENT_SUFFIX
+ IMAGE_URL_REPLACEMENT_PREFIX + linkedNote.getName() + IMAGE_URL_REPLACEMENT_SUFFIX;
urlToReplaces.put(matchedLink + "\"", "class=\"noteLink\" href=\"" + noteParams + "\"");
urlToReplaces.put(matchedLink, "class=\"noteLink\" href=\"" + noteParams + "\"");
}
}
if (!urlToReplaces.isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,12 +154,18 @@ public class NoteServiceImpl implements NoteService {

public static final String SUMMARY_PROP = "summary";

public static final String HIDE_AUTHOR_PROP = "hideAuthor";

public static final String HIDE_REACTION_PROP = "hideReaction";

public static final String FEATURED_IMAGE_ID = "featuredImageId";

public static final String FEATURED_IMAGE_UPDATED_DATE = "featuredImageUpdatedDate";

public static final String FEATURED_IMAGE_ALT_TEXT = "featuredImageAltText";

public static final String NOTE_DELETED = "note.deleted";

private final WikiService wikiService;

private final DataStorage dataStorage;
Expand Down Expand Up @@ -244,7 +250,7 @@ public Page createNote(Wiki noteBook,
note.setContent(note.getContent());
Page createdPage = createNote(noteBook, parentPage, note);
NotePageProperties properties = note.getProperties();
String draftPageId = String.valueOf(properties != null && properties.isDraft() ? properties.getNoteId() : null);
String draftPageId = properties != null && properties.isDraft() ? String.valueOf(properties.getNoteId()) : null;
try {
if (properties != null) {
properties.setNoteId(Long.parseLong(createdPage.getId()));
Expand All @@ -270,6 +276,15 @@ public Page createNote(Wiki noteBook,
createdPage.setCanImport(canImportNotes(note.getAuthor(), space, note));
createdPage.setCanView(canViewNotes(note.getAuthor(), space, note));
}
dataStorage.addPageVersion(createdPage, userIdentity.getUserId());
PageVersion pageVersion = dataStorage.getPublishedVersionByPageIdAndLang(Long.valueOf(createdPage.getId()), createdPage.getLang());
createdPage.setLatestVersionId(pageVersion != null ? pageVersion.getId() : null);
if (pageVersion != null && draftPageId != null) {
Map<String, String> eventData = new HashMap<>();
eventData.put("draftPageId", draftPageId);
eventData.put("pageVersionId", pageVersion.getId());
Utils.broadcast(listenerService, "note.page.version.created", this, eventData);
}
return createdPage;
} else {
throw new EntityNotFoundException("Parent note not found");
Expand Down Expand Up @@ -395,7 +410,6 @@ public boolean deleteNote(String noteType, String noteOwner, String noteName) th

try {
dataStorage.deletePage(noteType, noteOwner, noteName);

} catch (WikiException e) {
log.error("Can't delete note '" + noteName + "' ", e);
return false;
Expand Down Expand Up @@ -445,7 +459,7 @@ public boolean deleteNote(String noteType, String noteOwner, String noteName, Id

deleteNote(noteType, noteOwner, noteName);
postDeletePage(noteType, noteOwner, noteName, note);

Utils.broadcast(listenerService, NOTE_DELETED, userIdentity, note);
// Post delete activity for all children pages
for (Page childNote : allChrildrenPages) {
postDeletePage(childNote.getWikiType(), childNote.getWikiOwner(), childNote.getName(), childNote);
Expand Down Expand Up @@ -1002,6 +1016,8 @@ public void createVersionOfNote(Page note, String userName) throws WikiException
PageVersion pageVersion = dataStorage.addPageVersion(note, userName);
pageVersion.setAttachmentObjectType(note.getAttachmentObjectType());
updateVersionContentImages(pageVersion);
String pageVersionId = pageVersion.getId();
note.setLatestVersionId(pageVersionId);
if (note.getLang() != null) {
try {
NotePageProperties properties = note.getProperties();
Expand All @@ -1023,8 +1039,14 @@ public void createVersionOfNote(Page note, String userName) throws WikiException
null,
NOTE_METADATA_PAGE_OBJECT_TYPE,
NOTE_METADATA_VERSION_PAGE_OBJECT_TYPE,
userName
);
userName);
}
DraftPage draftPage = dataStorage.getLatestDraftPageByTargetPageAndLang(Long.valueOf(note.getId()), note.getLang());
if (draftPage != null) {
Map<String, String> eventData = new HashMap<>();
eventData.put("draftPageId", draftPage.getId());
eventData.put("pageVersionId", pageVersionId);
Utils.broadcast(listenerService, "note.page.version.created", this, eventData);
}
}

Expand Down Expand Up @@ -1209,6 +1231,14 @@ public DraftPage createDraftForExistPage(DraftPage draftPage,
newDraftPage.setProperties(properties);
newDraftPage.setAttachmentObjectType(draftPage.getAttachmentObjectType());
newDraftPage = processImagesOnDraftCreation(newDraftPage, Long.parseLong(userIdentity.getId()));
//
PageVersion pageVersion = getPublishedVersionByPageIdAndLang(Long.valueOf(newDraftPage.getTargetPageId()), newDraftPage.getLang());
if (pageVersion != null) {
Map<String, String> eventData = new HashMap<>();
eventData.put("pageVersionId", pageVersion.getId());
eventData.put("draftForExistingPageId", newDraftPage.getId());
Utils.broadcast(listenerService, "note.draft.for.exist.page.created", this, eventData);
}
return newDraftPage;
}

Expand Down Expand Up @@ -1404,10 +1434,16 @@ public Page getNoteByIdAndLang(Long pageId, Identity userIdentity, String source
page.setContent(publishedVersion.getContent());
page.setLang(publishedVersion.getLang());
page.setProperties(publishedVersion.getProperties());
page.setLatestVersionId(publishedVersion.getId());
if (lang != null) {
page.setMetadatas(retrieveMetadataItems(pageId + "-" + lang, userIdentity.getUserId()));
}
}
if (page != null && publishedVersion == null && lang != null) {
//no version with lang, set the latest version id without lang
publishedVersion = dataStorage.getPublishedVersionByPageIdAndLang(pageId, null);
page.setLatestVersionId(publishedVersion == null ? null : publishedVersion.getId());
}
return page;
}

Expand All @@ -1420,8 +1456,7 @@ public Page getNoteByIdAndLang(Long pageId, String lang) {
page.setTitle(publishedVersion.getTitle());
page.setContent(publishedVersion.getContent());
page.setLang(publishedVersion.getLang());
page.setProperties(publishedVersion.getProperties());
}
page.setProperties(publishedVersion.getProperties());}
return page;
}

Expand Down Expand Up @@ -1714,6 +1749,8 @@ public NotePageProperties saveNoteMetadata(NotePageProperties notePageProperties
properties = metadataItem.getProperties();
}
properties.put(SUMMARY_PROP, notePageProperties.getSummary());
properties.put(HIDE_AUTHOR_PROP, String.valueOf(notePageProperties.isHideAuthor()));
properties.put(HIDE_REACTION_PROP, String.valueOf(notePageProperties.isHideReaction()));
if (featuredImageId != null) {
properties.put(FEATURED_IMAGE_ID, String.valueOf(featuredImageId));
properties.put(FEATURED_IMAGE_UPDATED_DATE, String.valueOf(new Date().getTime()));
Expand Down
Loading
Loading