-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Select a space where notes event occurs - MEED-4273 - Meeds-io/m…
…eeds#1781 (#1043) This PR will ensure the ability to select a space or multiple ones when creating note event
- Loading branch information
Showing
14 changed files
with
469 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
notes-service/src/main/java/io/meeds/notes/plugin/NoteEventPlugin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/* | ||
* This file is part of the Meeds project (https://meeds.io/). | ||
* | ||
* Copyright (C) 2020 - 2024 Meeds Association [email protected] | ||
* | ||
* 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 io.meeds.notes.plugin; | ||
|
||
import java.util.*; | ||
|
||
import io.meeds.gamification.plugin.EventPlugin; | ||
import org.apache.commons.collections.CollectionUtils; | ||
|
||
public class NoteEventPlugin extends EventPlugin { | ||
|
||
public static final String EVENT_TYPE = "note"; | ||
|
||
public static final String GAMIFICATION_WIKI_ADD_PAGE = "addWikiPage"; | ||
|
||
public static final String GAMIFICATION_WIKI_UPDATE_PAGE = "updateWikiPage"; | ||
|
||
@Override | ||
public String getEventType() { | ||
return EVENT_TYPE; | ||
} | ||
|
||
public List<String> getTriggers() { | ||
return List.of(GAMIFICATION_WIKI_ADD_PAGE, GAMIFICATION_WIKI_UPDATE_PAGE); | ||
} | ||
|
||
@Override | ||
public boolean isValidEvent(Map<String, String> eventProperties, String triggerDetails) { | ||
List<String> desiredSpaceIds = eventProperties.get("spaceIds") != null | ||
? Arrays.asList(eventProperties.get("spaceIds") | ||
.split(",")) | ||
: Collections.emptyList(); | ||
Map<String, String> triggerDetailsMop = stringToMap(triggerDetails); | ||
return (CollectionUtils.isNotEmpty(desiredSpaceIds) && desiredSpaceIds.contains(triggerDetailsMop.get("spaceId"))); | ||
} | ||
|
||
private static Map<String, String> stringToMap(String mapAsString) { | ||
Map<String, String> map = new HashMap<>(); | ||
mapAsString = mapAsString.substring(1, mapAsString.length() - 1); | ||
String[] pairs = mapAsString.split(", "); | ||
for (String pair : pairs) { | ||
String[] keyValue = pair.split(": "); | ||
String key = keyValue[0].trim(); | ||
String value = keyValue[1].trim(); | ||
map.put(key, value); | ||
} | ||
return map; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
notes-webapp/src/main/webapp/vue-app/connectorEventExtensions/components/NotesEvent.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<!-- | ||
This file is part of the Meeds project (https://meeds.io/). | ||
Copyright (C) 2020 - 2024 Meeds Association [email protected] | ||
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. | ||
--> | ||
<template> | ||
<div> | ||
<notes-connector-event-form | ||
v-if="isEditing" | ||
:trigger="trigger" | ||
:properties="properties" /> | ||
<notes-connector-event-display | ||
v-else | ||
:trigger="trigger" | ||
:properties="properties" /> | ||
</div> | ||
</template> | ||
<script> | ||
export default { | ||
props: { | ||
properties: { | ||
type: Object, | ||
default: null | ||
}, | ||
trigger: { | ||
type: String, | ||
default: null | ||
}, | ||
isEditing: { | ||
type: Boolean, | ||
default: false | ||
} | ||
}, | ||
}; | ||
</script> |
Oops, something went wrong.