From 6a1afb287541059b7a14bf9e7c257c99d96fefee Mon Sep 17 00:00:00 2001
From: Helmi Akermi <70575401+hakermi@users.noreply.github.com>
Date: Mon, 18 Nov 2024 10:37:19 +0100
Subject: [PATCH] feat: Implement publish note - EXO-73041 - Meeds-io/MIPs#161
(#1212)
Implement publish note
feat: Add feature flag for publish note option - EXO-73041 - Meeds-io/MIPs#161 (#1219)
Add feature flag for publish note optio
fix: Fix enable condition of delete and import/export action menu options - EXO-73041 - Meeds-io/MIPs#161
fix enable condition of delete/import/export action menu options
feat: Refactor publish note option integration - EXO-73041 - Meeds-io/Meeds#161 (#1220)
Refactor publish note option integration
---
.../portlet/notes/notesPortlet_en.properties | 3 +
.../portlet/notes/notesPortlet_fr.properties | 3 +
.../conf/wiki/feature-flags-configuration.xml | 53 +++++++
.../main/webapp/WEB-INF/gatein-resources.xml | 6 +
.../webui/workspace/UINotesHeadTemplate.gtmpl | 11 ++
.../components/NotePublicationDrawer.vue | 9 +-
.../NotePublicationAdvancedOption.vue | 5 +
.../schedule-option/NoteScheduleOption.vue | 25 +++-
.../components/NoteFullRichEditor.vue | 2 +-
.../vue-app/notes-rich-editor/js/Utils.js | 30 ++++
.../notes/components/NoteBreadcrumb.vue | 1 +
.../notes/components/NoteTreeviewDrawer.vue | 1 +
.../notes/components/NotesOverview.vue | 119 ++++++++++++---
.../components/menu/NotesActionMenuItems.vue | 136 ++++--------------
.../components/menu/NotesActionsMenu.vue | 7 +-
.../components/menu/NotesMobileActionMenu.vue | 3 +-
.../main/webapp/vue-app/notes/extensions.js | 76 ++++++++++
.../webapp/vue-app/notes/initComponents.js | 4 +-
.../src/main/webapp/vue-app/notes/main.js | 3 +-
19 files changed, 355 insertions(+), 142 deletions(-)
create mode 100644 notes-webapp/src/main/webapp/WEB-INF/conf/wiki/feature-flags-configuration.xml
create mode 100644 notes-webapp/src/main/webapp/groovy/webui/workspace/UINotesHeadTemplate.gtmpl
create mode 100644 notes-webapp/src/main/webapp/vue-app/notes/extensions.js
diff --git a/notes-webapp/src/main/resources/locale/portlet/notes/notesPortlet_en.properties b/notes-webapp/src/main/resources/locale/portlet/notes/notesPortlet_en.properties
index 687794b17d..bee3b57ae8 100644
--- a/notes-webapp/src/main/resources/locale/portlet/notes/notesPortlet_en.properties
+++ b/notes-webapp/src/main/resources/locale/portlet/notes/notesPortlet_en.properties
@@ -105,6 +105,9 @@ notes.publication.schedule.publish.now.tooltip=By scheduling only a end date you
notes.publication.advanced.option.label=Advanced options
notes.publication.hide.author.label=Hide author
notes.publication.hide.reaction.label=Hide reaction
+notes.publication.success.message=Note successfully published
+notes.schedule.success.message=Note scheduled successfully
+notes.publication.externalPage.publish.cancel.label=Cancel publishing
popup.confirm=Confirm
popup.msg.confirmation=Confirmation
diff --git a/notes-webapp/src/main/resources/locale/portlet/notes/notesPortlet_fr.properties b/notes-webapp/src/main/resources/locale/portlet/notes/notesPortlet_fr.properties
index 94bf19edf0..feb72e9477 100644
--- a/notes-webapp/src/main/resources/locale/portlet/notes/notesPortlet_fr.properties
+++ b/notes-webapp/src/main/resources/locale/portlet/notes/notesPortlet_fr.properties
@@ -104,6 +104,9 @@ notes.publication.schedule.publish.now.tooltip=En programmant uniquement une dat
notes.publication.advanced.option.label=Options avancées
notes.publication.hide.author.label=Masquer l'auteur
notes.publication.hide.reaction.label=Masquer la réaction
+notes.publication.success.message=Note publi\u00E9e avec succ\u00E8s
+notes.schedule.success.message=Note planifi\u00E9 avec succ\u00E8s
+notes.publication.externalPage.publish.cancel.label=Annuler la publication
popup.confirm=Confirmer
popup.msg.confirmation=Confirmation
diff --git a/notes-webapp/src/main/webapp/WEB-INF/conf/wiki/feature-flags-configuration.xml b/notes-webapp/src/main/webapp/WEB-INF/conf/wiki/feature-flags-configuration.xml
new file mode 100644
index 0000000000..5202dd8bad
--- /dev/null
+++ b/notes-webapp/src/main/webapp/WEB-INF/conf/wiki/feature-flags-configuration.xml
@@ -0,0 +1,53 @@
+
+
+
+
+ NoteFeatureProperties
+ org.exoplatform.container.ExtendedPropertyConfigurator
+
+
+ NoteFeatureProperties
+ Note Feature enablement flag
+
+
+
+
+
+
+ org.exoplatform.groovyscript.text.TemplateService
+
+ UIPortalApplication-head
+ addTemplateExtension
+ org.exoplatform.groovyscript.text.TemplateExtensionPlugin
+
+
+ templates
+ The list of templates to include in HTML Page Header with UIPortalApplication.gtmpl
+ war:/groovy/webui/workspace/UINotesHeadTemplate.gtmpl
+
+
+
+
+
diff --git a/notes-webapp/src/main/webapp/WEB-INF/gatein-resources.xml b/notes-webapp/src/main/webapp/WEB-INF/gatein-resources.xml
index fbb9ee85ed..30e78d4ab6 100644
--- a/notes-webapp/src/main/webapp/WEB-INF/gatein-resources.xml
+++ b/notes-webapp/src/main/webapp/WEB-INF/gatein-resources.xml
@@ -49,6 +49,12 @@
false
/javascript/notes.bundle.js
+
+ NotesPublication
+
+
+ imageCropper
+
html2canvas
diff --git a/notes-webapp/src/main/webapp/groovy/webui/workspace/UINotesHeadTemplate.gtmpl b/notes-webapp/src/main/webapp/groovy/webui/workspace/UINotesHeadTemplate.gtmpl
new file mode 100644
index 0000000000..e9aacd6a2d
--- /dev/null
+++ b/notes-webapp/src/main/webapp/groovy/webui/workspace/UINotesHeadTemplate.gtmpl
@@ -0,0 +1,11 @@
+<%
+ import org.exoplatform.commons.api.settings.ExoFeatureService;
+ def rcontext = _ctx.getRequestContext();
+ ExoFeatureService featureService = uicomponent.getApplicationComponent(ExoFeatureService.class);
+ def userName = rcontext.getRemoteUser();
+%>
+
+
diff --git a/notes-webapp/src/main/webapp/vue-app/notes-publication/components/NotePublicationDrawer.vue b/notes-webapp/src/main/webapp/vue-app/notes-publication/components/NotePublicationDrawer.vue
index bda62e85b1..db4019ab4c 100644
--- a/notes-webapp/src/main/webapp/vue-app/notes-publication/components/NotePublicationDrawer.vue
+++ b/notes-webapp/src/main/webapp/vue-app/notes-publication/components/NotePublicationDrawer.vue
@@ -342,6 +342,8 @@ export default {
this.cloneScheduleSettings();
this.cloneAdvancedSettings();
this.clonePublicationSettings();
+ } else {
+ this.initSettings();
}
this.currentScheduleSettings = structuredClone(this.scheduleSettings);
this.currentAdvancedSettings = structuredClone(this.advancedSettings);
@@ -400,6 +402,11 @@ export default {
this.$refs?.scheduleOption?.cancelChanges();
this.$refs?.advancedOption?.cancelChanges();
},
+ initSettings() {
+ this.scheduleSettings = {};
+ this.advancedSettings = {};
+ this.publicationSettings = {post: true};
+ },
reset() {
setTimeout(() => {
this.cancelChanges();
@@ -422,7 +429,7 @@ export default {
return;
}
this.$emit('metadata-updated', this.noteObject.properties);
- this.$emit('publish', this.noteObject, this.publicationSettings);
+ this.$emit('publish', this.publicationSettings, this.noteObject,);
},
updateCurrentNoteObjectProperties(properties) {
this.noteObject.properties.noteId = Number(properties.noteId);
diff --git a/notes-webapp/src/main/webapp/vue-app/notes-publication/components/advanced-option/NotePublicationAdvancedOption.vue b/notes-webapp/src/main/webapp/vue-app/notes-publication/components/advanced-option/NotePublicationAdvancedOption.vue
index a2bfb8e007..7232a10188 100644
--- a/notes-webapp/src/main/webapp/vue-app/notes-publication/components/advanced-option/NotePublicationAdvancedOption.vue
+++ b/notes-webapp/src/main/webapp/vue-app/notes-publication/components/advanced-option/NotePublicationAdvancedOption.vue
@@ -91,6 +91,7 @@ export default {
},
initSettings() {
if (!this.editMode) {
+ this.resetSettings();
return;
}
this.hideAuthor = this.savedAdvancedSettings?.hideAuthor;
@@ -98,6 +99,10 @@ export default {
},
cancelChanges() {
this.initSettings();
+ },
+ resetSettings() {
+ this.hideAuthor = false;
+ this.hideReaction = false;
}
}
};
diff --git a/notes-webapp/src/main/webapp/vue-app/notes-publication/components/schedule-option/NoteScheduleOption.vue b/notes-webapp/src/main/webapp/vue-app/notes-publication/components/schedule-option/NoteScheduleOption.vue
index 1df7e12d1d..139a8803be 100644
--- a/notes-webapp/src/main/webapp/vue-app/notes-publication/components/schedule-option/NoteScheduleOption.vue
+++ b/notes-webapp/src/main/webapp/vue-app/notes-publication/components/schedule-option/NoteScheduleOption.vue
@@ -30,8 +30,17 @@
:multiple="isMultipleSelectionOption"
class="d-flex ms-n1 mt-0 pt-0">
+ v-if="fromExternalPage && !hasSavedUnpublishSchedule"
+ :label="$t('notes.publication.externalPage.publish.cancel.label')"
+ :value="CANCEL_SCHEDULE_OPTION" />
+
+
]*?)(\s+src="data:image\/[^;]+;base64,[^"]*")/g;
+ content = content.replace(regex, '$1');
+ return content;
+}
+
+export function isHasImagesToBeProcessed(htmlStringContent, objectType) {
+ // Parse the HTML content
+ const parser = new DOMParser();
+ const document = parser.parseFromString(htmlStringContent, 'text/html');
+
+ const imgTags = document.querySelectorAll('img');
+ const prefix = '/portal/rest/v1/social/attachments/';
+
+ for (const imgTag of imgTags) {
+ const src = imgTag.getAttribute('src');
+ if (src?.startsWith?.(prefix)) {
+ const srcPart = src.substring(prefix.length);
+ const sourceObject = srcPart.substring(0, srcPart.indexOf('/'));
+ if (sourceObject !== objectType) {
+ return true;
+ }
+ }
+ }
+ return htmlStringContent.includes('cke_upload_id=');
+}
diff --git a/notes-webapp/src/main/webapp/vue-app/notes/components/NoteBreadcrumb.vue b/notes-webapp/src/main/webapp/vue-app/notes/components/NoteBreadcrumb.vue
index 7cc648d9fb..fe432dc79f 100644
--- a/notes-webapp/src/main/webapp/vue-app/notes/components/NoteBreadcrumb.vue
+++ b/notes-webapp/src/main/webapp/vue-app/notes/components/NoteBreadcrumb.vue
@@ -134,6 +134,7 @@ export default {
openNote(note) {
if (note.noteId !== this.actualNoteId ) {
this.$emit('open-note',note.id);
+ document.dispatchEvent(new CustomEvent('note-navigation-updated', {detail: note}));
}
}
}
diff --git a/notes-webapp/src/main/webapp/vue-app/notes/components/NoteTreeviewDrawer.vue b/notes-webapp/src/main/webapp/vue-app/notes/components/NoteTreeviewDrawer.vue
index 782b157e92..0eb7579c36 100644
--- a/notes-webapp/src/main/webapp/vue-app/notes/components/NoteTreeviewDrawer.vue
+++ b/notes-webapp/src/main/webapp/vue-app/notes/components/NoteTreeviewDrawer.vue
@@ -701,6 +701,7 @@ export default {
this.$root.$emit('open-note-by-name', noteName, note.draftPage);
this.$refs.breadcrumbDrawer.close();
}
+ document.dispatchEvent(new CustomEvent('note-navigation-updated', {detail: note}));
} else {
this.$refs.breadcrumbDrawer.close();
}
diff --git a/notes-webapp/src/main/webapp/vue-app/notes/components/NotesOverview.vue b/notes-webapp/src/main/webapp/vue-app/notes/components/NotesOverview.vue
index dd1d2aac7b..168830ba06 100644
--- a/notes-webapp/src/main/webapp/vue-app/notes/components/NotesOverview.vue
+++ b/notes-webapp/src/main/webapp/vue-app/notes/components/NotesOverview.vue
@@ -279,15 +279,23 @@
+
+ :note="note" />
+ :note="note" />
@@ -301,21 +309,29 @@
ref="noteVersionsHistoryDrawer" />
-
+
+
+