-
history.push(redirectUri)}
- >
-
-
+ {isAllowedToSee(notification) ? (
+
+
+ history.push(redirectUri)}>
+
+
+
+
+ ) : null}
diff --git a/frontend/src/pages/Notifications/NotificationPage.js b/frontend/src/pages/Notifications/NotificationPage.js
index 508da4b66..280a818d6 100644
--- a/frontend/src/pages/Notifications/NotificationPage.js
+++ b/frontend/src/pages/Notifications/NotificationPage.js
@@ -12,7 +12,7 @@ const NotificationPage = ({
fetchNotifications,
notificationCount,
notificationOffset,
- setNotificationOffset
+ currentPage
}) => {
return (
@@ -25,8 +25,8 @@ const NotificationPage = ({
notificationsPerPage={notificationsPerPage}
fetchNotifications={fetchNotifications}
notificationCount={notificationCount}
- setNotificationOffset={setNotificationOffset}
notificationOffset={notificationOffset}
+ currentPage={currentPage}
/>
);
diff --git a/frontend/src/pages/Notifications/NotificationPageContainer.js b/frontend/src/pages/Notifications/NotificationPageContainer.js
index 819a13876..188c8e6d7 100644
--- a/frontend/src/pages/Notifications/NotificationPageContainer.js
+++ b/frontend/src/pages/Notifications/NotificationPageContainer.js
@@ -5,7 +5,6 @@ import {
markNotificationAsRead,
fetchNotifications,
setNotifcationsPerPage,
- setNotificationOffset,
markMultipleNotificationsAsRead,
enableLiveUpdates,
fetchNotificationCounts,
@@ -18,7 +17,7 @@ import { toJS } from "../../helper";
class NotificationPageContainer extends Component {
componentWillMount() {
- this.props.fetchNotifications(this.props.notificationOffset, this.props.notificationsPerPage);
+ this.props.fetchNotifications(this.props.currentPage);
this.props.disableLiveUpdates();
}
@@ -38,13 +37,11 @@ class NotificationPageContainer extends Component {
const mapDispatchToProps = (dispatch, props) => {
return {
- fetchNotifications: (offset, limit) => dispatch(fetchNotifications(true, offset, limit)),
- markNotificationAsRead: (notificationId, offset, limit) =>
- dispatch(markNotificationAsRead(notificationId, offset, limit)),
- markMultipleNotificationsAsRead: (notificationIds, offset, limit) =>
- dispatch(markMultipleNotificationsAsRead(notificationIds, offset, limit)),
- setNotifcationsPerPage: limit => dispatch(setNotifcationsPerPage(limit)),
- setNotificationOffset: offset => dispatch(setNotificationOffset(offset)),
+ fetchNotifications: page => dispatch(fetchNotifications(true, page)),
+ markNotificationAsRead: (notificationId, page) => dispatch(markNotificationAsRead(notificationId, page)),
+ markMultipleNotificationsAsRead: (notificationIds, page) =>
+ dispatch(markMultipleNotificationsAsRead(notificationIds, page)),
+ setNotifcationsPerPage: notificationPageSize => dispatch(setNotifcationsPerPage(notificationPageSize)),
enableLiveUpdates: () => dispatch(enableLiveUpdates()),
disableLiveUpdates: () => dispatch(disableLiveUpdates()),
fetchNotificationCounts: () => dispatch(fetchNotificationCounts())
@@ -54,10 +51,10 @@ const mapDispatchToProps = (dispatch, props) => {
const mapStateToProps = state => {
return {
notifications: state.getIn(["notifications", "notifications"]),
- notificationsPerPage: state.getIn(["notifications", "notificationsPerPage"]),
+ notificationsPerPage: state.getIn(["notifications", "notificationPageSize"]),
unreadNotificationCount: state.getIn(["notifications", "unreadNotificationCount"]),
- notificationCount: state.getIn(["notifications", "notificationCount"]),
- notificationOffset: state.getIn(["notifications", "notificationOffset"])
+ notificationCount: state.getIn(["notifications", "totalNotificationCount"]),
+ currentPage: state.getIn(["notifications", "currentNotificationPage"])
};
};
diff --git a/frontend/src/pages/Notifications/actions.js b/frontend/src/pages/Notifications/actions.js
index 9bd375513..74e7e625f 100644
--- a/frontend/src/pages/Notifications/actions.js
+++ b/frontend/src/pages/Notifications/actions.js
@@ -20,11 +20,11 @@ export const FETCH_ALL_NOTIFICATIONS_SUCCESS = "FETCH_ALL_NOTIFICATIONS_SUCCESS"
export const LIVE_UPDATE_NOTIFICATIONS = "LIVE_UPDATE_NOTIFICATIONS";
export const LIVE_UPDATE_NOTIFICATIONS_SUCCESS = "LIVE_UPDATE_NOTIFICATIONS_SUCCESS";
-export const MARK_MULTIPLE_NOTIFICATION_AS_READ = "MARK_MULTIPLE_NOTIFICATION_AS_READ";
-export const MARK_MULTIPLE_NOTIFICATION_AS_READ_SUCCESS = "MARK_MULTIPLE_NOTIFICATION_AS_READ_SUCCESS";
+export const MARK_MULTIPLE_NOTIFICATIONS_AS_READ = "MARK_MULTIPLE_NOTIFICATIONS_AS_READ";
+export const MARK_MULTIPLE_NOTIFICATIONS_AS_READ_SUCCESS = "MARK_MULTIPLE_NOTIFICATIONS_AS_READ_SUCCESS";
-export const FETCH_NOTIFICATION_COUNTS = "FETCH_NOTIFICATION_COUNTS";
-export const FETCH_NOTIFICATION_COUNTS_SUCCESS = "FETCH_NOTIFICATION_COUNTS_SUCCESS";
+export const FETCH_NOTIFICATION_COUNT = "FETCH_NOTIFICATION_COUNT";
+export const FETCH_NOTIFICATION_COUNT_SUCCESS = "FETCH_NOTIFICATION_COUNT_SUCCESS";
export const SET_NOTIFICATIONS_PER_PAGE = "SET_NOTIFICATIONS_PER_PAGE";
export const SET_NOTIFICATION_OFFSET = "SET_NOTIFICATION_OFFSET";
@@ -60,28 +60,26 @@ export function updateNotification(showLoading = false, offset) {
offset
};
}
-export function fetchNotifications(showLoading = false, offset, limit) {
+export function fetchNotifications(showLoading = false, notificationPage) {
return {
type: FETCH_ALL_NOTIFICATIONS,
showLoading,
- offset,
- limit
+ notificationPage
};
}
export function fetchNotificationCounts(showLoading = false) {
return {
- type: FETCH_NOTIFICATION_COUNTS,
+ type: FETCH_NOTIFICATION_COUNT,
showLoading
};
}
-export function markNotificationAsRead(notificationId, offset, limit) {
+export function markNotificationAsRead(notificationId, notificationPage) {
return {
type: MARK_NOTIFICATION_AS_READ,
notificationId,
- offset,
- limit
+ notificationPage
};
}
@@ -105,26 +103,18 @@ export function fetchHistoryItems(project, offset, limit) {
};
}
-export function markMultipleNotificationsAsRead(notificationIds, offset, limit) {
+export function markMultipleNotificationsAsRead(notificationIds, notificationPage) {
return {
- type: MARK_MULTIPLE_NOTIFICATION_AS_READ,
+ type: MARK_MULTIPLE_NOTIFICATIONS_AS_READ,
notificationIds,
- offset,
- limit
+ notificationPage
};
}
-export function setNotifcationsPerPage(limit) {
+export function setNotifcationsPerPage(notificationPageSize) {
return {
type: SET_NOTIFICATIONS_PER_PAGE,
- limit
- };
-}
-
-export function setNotificationOffset(offset) {
- return {
- type: SET_NOTIFICATION_OFFSET,
- offset
+ notificationPageSize: notificationPageSize
};
}
diff --git a/frontend/src/pages/Notifications/helper.js b/frontend/src/pages/Notifications/helper.js
index 2a40de965..6318758c6 100644
--- a/frontend/src/pages/Notifications/helper.js
+++ b/frontend/src/pages/Notifications/helper.js
@@ -1,31 +1,76 @@
import strings from "../../localizeStrings";
import { formatString } from "../../helper";
-// get hierarchic deepest displayName
-export function getDisplayName(notification) {
+const ACCESSMAP = {
+ PROJECT: "project",
+ SUBPROJECT: "subproject",
+ WORKFLOWITEM: "workflowitem"
+};
+
+export function getParentData(notification) {
+ const redacted = "Redacted";
const metadata = notification.metadata;
+ let projectDisplayName = "";
+ let subprojectDisplayName = "";
+
if (metadata !== undefined) {
- if (metadata.workflowitem !== undefined && metadata.workflowitem.hasViewPermissions === true) {
- return metadata.workflowitem.displayName;
- }
- if (metadata.subproject !== undefined && metadata.subproject.hasViewPermissions === true) {
- return metadata.subproject.displayName;
- }
- if (metadata.project !== undefined && metadata.project.hasViewPermissions === true) {
- return metadata.project.displayName;
+ if (metadata.project) {
+ const {
+ displayName: projectName = "",
+ hasViewPermissions: hasProjectViewPermissions = false
+ } = getDataFromNotification(metadata, ACCESSMAP.PROJECT);
+ projectDisplayName = hasProjectViewPermissions ? projectName : redacted;
+ if (metadata.subproject) {
+ const {
+ displayName: subprojectName = "",
+ hasViewPermissions: hasSubprojectViewPermissions = false
+ } = getDataFromNotification(metadata, ACCESSMAP.SUBPROJECT);
+ subprojectDisplayName = hasSubprojectViewPermissions ? subprojectName : redacted;
+ }
}
}
- return "";
+
+ return {
+ projectDisplayName,
+ subprojectDisplayName
+ };
}
+export const isAllowedToSee = notification => {
+ const metadata = notification.metadata;
+ if (metadata !== undefined) {
+ const { hasViewPermissions = false } = getDataFromNotification(metadata);
+ return hasViewPermissions;
+ }
+ return false;
+};
+
export const intentMapping = notification => {
const businessEvent = notification.businessEvent;
+ if (!businessEvent) {
+ console.warn("Notification has no business event");
+ return "";
+ }
const translation = strings.notification[businessEvent.type];
- const displayName = getDisplayName(notification);
- const text = formatString(translation, displayName);
- return `${text} ${isAllowedToSee(notification) ? "" : strings.notification.no_permissions}`;
+
+ const notificationMetaData = notification.metadata;
+ if (!notificationMetaData) {
+ console.warn("Notification has no metadata");
+ return "";
+ }
+
+ const { displayName = "", hasViewPermissions = false } = getDataFromNotification(notificationMetaData);
+
+ return hasViewPermissions
+ ? formatString(translation, displayName)
+ : formatString(translation, "") + " " + strings.notification.no_permissions;
};
+const getDataFromNotification = (metadata, type) =>
+ type
+ ? metadata[type]
+ : metadata[ACCESSMAP.WORKFLOWITEM] || metadata[ACCESSMAP.SUBPROJECT] || metadata[ACCESSMAP.PROJECT];
+
export const parseURI = ({ projectId, subprojectId }) => {
if (projectId && !subprojectId) {
return `/projects/${projectId}`;
@@ -35,19 +80,3 @@ export const parseURI = ({ projectId, subprojectId }) => {
throw new Error("not implemented");
}
};
-
-export const isAllowedToSee = notification => {
- const metadata = notification.metadata;
- if (metadata !== undefined) {
- if (metadata.workflowitem !== undefined) {
- return metadata.workflowitem.hasViewPermissions;
- }
- if (metadata.subproject !== undefined) {
- return metadata.subproject.hasViewPermissions;
- }
- if (metadata.project !== undefined) {
- return metadata.project.hasViewPermissions;
- }
- }
- return false;
-};
diff --git a/frontend/src/pages/Notifications/reducer.js b/frontend/src/pages/Notifications/reducer.js
index 32bb369a9..b544569f5 100644
--- a/frontend/src/pages/Notifications/reducer.js
+++ b/frontend/src/pages/Notifications/reducer.js
@@ -7,10 +7,9 @@ import {
HIDE_HISTORY,
FETCH_ALL_NOTIFICATIONS_SUCCESS,
HIDE_SNACKBAR,
- FETCH_NOTIFICATION_COUNTS_SUCCESS,
+ FETCH_NOTIFICATION_COUNT_SUCCESS,
SET_NOTIFICATIONS_PER_PAGE,
LIVE_UPDATE_NOTIFICATIONS_SUCCESS,
- SET_NOTIFICATION_OFFSET,
TIME_OUT_FLY_IN,
ENABLE_LIVE_UPDATES,
DISABLE_LIVE_UPDATES
@@ -26,17 +25,21 @@ const defaultState = fromJS({
snackbarError: false,
historyItems: [],
unreadNotificationCount: 0,
- notificationCount: 0,
notificationsPerPage: 20,
notificationOffset: 0,
- isLiveUpdatesEnabled: true
+ isLiveUpdatesEnabled: true,
+ totalNotificationCount: 0,
+ currentNotificationPage: 1,
+ notificationPageSize: 20
});
export default function navbarReducer(state = defaultState, action) {
switch (action.type) {
case FETCH_ALL_NOTIFICATIONS_SUCCESS:
return state.merge({
- notifications: fromJS(action.notifications)
+ notifications: fromJS(action.notifications),
+ currentNotificationPage: action.currentNotificationPage,
+ totalNotificationCount: action.totalNotificationCount
});
case ENABLE_LIVE_UPDATES: {
@@ -62,7 +65,7 @@ export default function navbarReducer(state = defaultState, action) {
case TIME_OUT_FLY_IN: {
return state.set("newNotifications", defaultState.get("newNotifications"));
}
- case FETCH_NOTIFICATION_COUNTS_SUCCESS:
+ case FETCH_NOTIFICATION_COUNT_SUCCESS:
return state.merge({
unreadNotificationCount: action.unreadNotificationCount,
notificationCount: action.notificationCount
@@ -83,9 +86,7 @@ export default function navbarReducer(state = defaultState, action) {
case HIDE_HISTORY:
return state.set("showHistory", false);
case SET_NOTIFICATIONS_PER_PAGE:
- return state.set("notificationsPerPage", action.limit);
- case SET_NOTIFICATION_OFFSET:
- return state.set("notificationOffset", action.offset);
+ return state.set("notificationPageSize", action.notificationPageSize);
case LOGOUT:
return defaultState;
default:
diff --git a/frontend/src/pages/Workflows/WorkflowAssigneeContainer.js b/frontend/src/pages/Workflows/WorkflowAssigneeContainer.js
index cd8e1c1cc..df7cb860d 100644
--- a/frontend/src/pages/Workflows/WorkflowAssigneeContainer.js
+++ b/frontend/src/pages/Workflows/WorkflowAssigneeContainer.js
@@ -28,10 +28,10 @@ class WorkflowAssigneeContainer extends Component {
};
render() {
- const { workflowItems, workflowitemId, users, title, disabled, workflowSortEnabled, status } = this.props;
+ const { workflowItems, workflowitemId, classes, users, title, disabled, workflowSortEnabled, status } = this.props;
const assignee = this.getWorkflowAssignee(workflowItems, workflowitemId);
return (
-