From 82f6bb1b533cf15dac0cefbbd0d92b4f71be3ab6 Mon Sep 17 00:00:00 2001 From: Mark Date: Mon, 3 Oct 2022 09:35:22 -0700 Subject: [PATCH 1/8] DEX-1435 add print statements to compare model choices and uniqAlgorithms --- src/models/identification/useIdConfigSchemas.js | 2 ++ src/models/sighting/useSightingFieldSchemas.js | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/models/identification/useIdConfigSchemas.js b/src/models/identification/useIdConfigSchemas.js index e701cb45..45814f53 100644 --- a/src/models/identification/useIdConfigSchemas.js +++ b/src/models/identification/useIdConfigSchemas.js @@ -57,6 +57,8 @@ export default function useIdConfigSchemas() { * for a given algorithm and modify choices contextually. * Just this for now though... */ const uniqAlgorithms = uniqBy(allAlgorithms, 'value'); + console.log('deleteMe uniqAlgorithms is: '); + console.log(uniqAlgorithms); return [ createFieldSchema(fieldTypes.multiselect, { diff --git a/src/models/sighting/useSightingFieldSchemas.js b/src/models/sighting/useSightingFieldSchemas.js index 95aec79d..cc07105d 100644 --- a/src/models/sighting/useSightingFieldSchemas.js +++ b/src/models/sighting/useSightingFieldSchemas.js @@ -70,6 +70,8 @@ export default function useSightingFieldSchemas() { id: 'DO_NOT_DETECT_AUTOMATICALLY', }), }); + console.log('deleteMe modelChoices are: '); + console.log(modelChoices); const customFields = get( data, From b79261090221ff19cf2e0a6942f54f1752273339 Mon Sep 17 00:00:00 2001 From: Mark Date: Mon, 3 Oct 2022 15:32:26 -0700 Subject: [PATCH 2/8] DEX-1435 create the new notification dialogs and establish the new schemas for the new notifications --- locale/en.json | 12 +++- ...ificationCollaborationEditDeniedDialog.jsx | 30 +++++++++ ...cationCollaborationManagerDeniedDialog.jsx | 30 +++++++++ ...CollaborationManagerEditApprovedDialog.jsx | 30 +++++++++ ...onCollaborationManagerEditDeniedDialog.jsx | 30 +++++++++ ...onCollaborationManagerEditRevokeDialog.jsx | 30 +++++++++ .../dialogs/notificationDialogUtils/index.js | 16 +++++ src/constants/notificationSchema.js | 63 +++++++++++++++++++ .../identification/useIdConfigSchemas.js | 2 - .../sighting/useSightingFieldSchemas.js | 2 - src/pages/notifications/Notifications.jsx | 8 +++ src/utils/notificationUtils.js | 2 + 12 files changed, 250 insertions(+), 5 deletions(-) create mode 100644 src/components/dialogs/notificationDialogUtils/NotificationCollaborationEditDeniedDialog.jsx create mode 100644 src/components/dialogs/notificationDialogUtils/NotificationCollaborationManagerDeniedDialog.jsx create mode 100644 src/components/dialogs/notificationDialogUtils/NotificationCollaborationManagerEditApprovedDialog.jsx create mode 100644 src/components/dialogs/notificationDialogUtils/NotificationCollaborationManagerEditDeniedDialog.jsx create mode 100644 src/components/dialogs/notificationDialogUtils/NotificationCollaborationManagerEditRevokeDialog.jsx diff --git a/locale/en.json b/locale/en.json index 78d1d505..47a1258d 100644 --- a/locale/en.json +++ b/locale/en.json @@ -1196,5 +1196,15 @@ "EDIT_COLLABORATION_CURRENT_STATE_LABEL": "Current state", "EDIT_COLLABORATION_CURRENT_STATE_DESCRIPTION": "Changing the state will cancel any pending requests.", "COLLABORATIONS": "Collaborations", - "URLS_MUST_INCLUDE_HTTPS": "All URLs must include https:// to be valid" + "URLS_MUST_INCLUDE_HTTPS": "All URLs must include https:// to be valid", + "EDIT_COLLABORATION_REVOKED_BY_USER_MANAGER": "Edit collaboration revoked by your user manager", + "EDIT_COLLABORATION_WAS_REVOKED_BY_YOUR_USER_MANAGER": "An edit-level collaboration with {userName} was revoked by your user manager.", + "COLLABORATION_EDIT_DENIED": "Collaboration edit denied", + "EDIT_COLLABORATION_DENIED_MESSAGE": "{userName} denied your collaboration edit request", + "COLLABORATION_DENIED_BY_USER_MANAGER": "Collaboration denied by your user manager", + "COLLABORATION_DENIED_BY_USER_MANAGER_MESSAGE": "Your collaboration with {userName} was denied by your user manager.", + "EDIT_COLLABORATION_DENIED_BY_USER_MANAGER": "Edit-level collaboration denied by your user manager", + "EDIT_COLLABORATION_DENIED_BY_USER_MANAGER_MESSAGE": "An edit-level collaboration with {userName} was denied by your user manager.", + "EDIT_COLLABORATION_APPROVED_BY_USER_MANAGER": "Edit collaboration approved by your user manager", + "EDIT_COLLABORATION_WAS_APPROVED_BY_YOUR_USER_MANAGER": "An edit-level collaboration with {userName} was approved by your user manager." } diff --git a/src/components/dialogs/notificationDialogUtils/NotificationCollaborationEditDeniedDialog.jsx b/src/components/dialogs/notificationDialogUtils/NotificationCollaborationEditDeniedDialog.jsx new file mode 100644 index 00000000..1ce68075 --- /dev/null +++ b/src/components/dialogs/notificationDialogUtils/NotificationCollaborationEditDeniedDialog.jsx @@ -0,0 +1,30 @@ +import React from 'react'; +import { get } from 'lodash-es'; +import { notificationSchema } from '../../../constants/notificationSchema'; +import NotificationDetailsDialog from '../NotificationDetailsDialog'; + +export default function NotificationCollaborationEditDeniedDialog({ + notification, + onClose, + open, +}) { + const notificationType = notification?.message_type; + const currentNotificationSchema = get( + notificationSchema, + notificationType, + ); + const availableButtons = []; + return ( + + ); +} diff --git a/src/components/dialogs/notificationDialogUtils/NotificationCollaborationManagerDeniedDialog.jsx b/src/components/dialogs/notificationDialogUtils/NotificationCollaborationManagerDeniedDialog.jsx new file mode 100644 index 00000000..67c6715e --- /dev/null +++ b/src/components/dialogs/notificationDialogUtils/NotificationCollaborationManagerDeniedDialog.jsx @@ -0,0 +1,30 @@ +import React from 'react'; +import { get } from 'lodash-es'; +import { notificationSchema } from '../../../constants/notificationSchema'; +import NotificationDetailsDialog from '../NotificationDetailsDialog'; + +export default function NotificationCollaborationManagerDeniedDialog({ + notification, + onClose, + open, +}) { + const notificationType = notification?.message_type; + const currentNotificationSchema = get( + notificationSchema, + notificationType, + ); + const availableButtons = []; + return ( + + ); +} diff --git a/src/components/dialogs/notificationDialogUtils/NotificationCollaborationManagerEditApprovedDialog.jsx b/src/components/dialogs/notificationDialogUtils/NotificationCollaborationManagerEditApprovedDialog.jsx new file mode 100644 index 00000000..c2f02111 --- /dev/null +++ b/src/components/dialogs/notificationDialogUtils/NotificationCollaborationManagerEditApprovedDialog.jsx @@ -0,0 +1,30 @@ +import React from 'react'; +import { get } from 'lodash-es'; +import { notificationSchema } from '../../../constants/notificationSchema'; +import NotificationDetailsDialog from '../NotificationDetailsDialog'; + +export default function NotificationCollaborationManagerEditApprovedDialog({ + notification, + onClose, + open, +}) { + const notificationType = notification?.message_type; + const currentNotificationSchema = get( + notificationSchema, + notificationType, + ); + const availableButtons = []; + return ( + + ); +} diff --git a/src/components/dialogs/notificationDialogUtils/NotificationCollaborationManagerEditDeniedDialog.jsx b/src/components/dialogs/notificationDialogUtils/NotificationCollaborationManagerEditDeniedDialog.jsx new file mode 100644 index 00000000..aebcb72a --- /dev/null +++ b/src/components/dialogs/notificationDialogUtils/NotificationCollaborationManagerEditDeniedDialog.jsx @@ -0,0 +1,30 @@ +import React from 'react'; +import { get } from 'lodash-es'; +import { notificationSchema } from '../../../constants/notificationSchema'; +import NotificationDetailsDialog from '../NotificationDetailsDialog'; + +export default function NotificationCollaborationManagerEditDeniedDialog({ + notification, + onClose, + open, +}) { + const notificationType = notification?.message_type; + const currentNotificationSchema = get( + notificationSchema, + notificationType, + ); + const availableButtons = []; + return ( + + ); +} diff --git a/src/components/dialogs/notificationDialogUtils/NotificationCollaborationManagerEditRevokeDialog.jsx b/src/components/dialogs/notificationDialogUtils/NotificationCollaborationManagerEditRevokeDialog.jsx new file mode 100644 index 00000000..46e71f15 --- /dev/null +++ b/src/components/dialogs/notificationDialogUtils/NotificationCollaborationManagerEditRevokeDialog.jsx @@ -0,0 +1,30 @@ +import React from 'react'; +import { get } from 'lodash-es'; +import { notificationSchema } from '../../../constants/notificationSchema'; +import NotificationDetailsDialog from '../NotificationDetailsDialog'; + +export default function NotificationCollaborationManagerEditRevokeDialog({ + notification, + onClose, + open, +}) { + const notificationType = notification?.message_type; + const currentNotificationSchema = get( + notificationSchema, + notificationType, + ); + const availableButtons = []; + return ( + + ); +} diff --git a/src/components/dialogs/notificationDialogUtils/index.js b/src/components/dialogs/notificationDialogUtils/index.js index 47ff61ee..40c7a141 100644 --- a/src/components/dialogs/notificationDialogUtils/index.js +++ b/src/components/dialogs/notificationDialogUtils/index.js @@ -10,6 +10,12 @@ import NotificationCollaborationManagerRevokeDialog from './NotificationCollabor import NotificationIndividualMergeRequestDialog from './NotificationIndividualMergeRequestDialog'; import NotificationIndividualMergeCompleteDialog from './NotificationIndividualMergeCompleteDialog'; import NotificationIndividualMergeBlockDialog from './NotificationIndividualMergeBlockDialog'; +import NotificationCollaborationManagerEditApprovedDialog from './NotificationCollaborationManagerEditApprovedDialog'; +import NotificationCollaborationManagerEditRevokeDialog from './NotificationCollaborationManagerEditRevokeDialog'; +import NotificationCollaborationEditDeniedDialog from './NotificationCollaborationEditDeniedDialog'; +import NotificationCollaborationManagerDeniedDialog from './NotificationCollaborationManagerDeniedDialog'; +import NotificationCollaborationManagerEditDeniedDialog from './NotificationCollaborationManagerEditDeniedDialog'; + import { notificationTypeNames } from '../../../constants/notificationSchema'; export const notificationTypes = { @@ -37,4 +43,14 @@ export const notificationTypes = { NotificationIndividualMergeCompleteDialog, [notificationTypeNames.individual_merge_blocked]: NotificationIndividualMergeBlockDialog, + [notificationTypeNames.collaboration_manager_edit_approved]: + NotificationCollaborationManagerEditApprovedDialog, + [notificationTypeNames.collaboration_manager_edit_revoke]: + NotificationCollaborationManagerEditRevokeDialog, + [notificationTypeNames.collaboration_edit_denied]: + NotificationCollaborationEditDeniedDialog, + [notificationTypeNames.collaboration_manager_denied]: + NotificationCollaborationManagerDeniedDialog, + [notificationTypeNames.collaboration_manager_edit_denied]: + NotificationCollaborationManagerEditDeniedDialog, }; diff --git a/src/constants/notificationSchema.js b/src/constants/notificationSchema.js index d26de82d..eaddc3e1 100644 --- a/src/constants/notificationSchema.js +++ b/src/constants/notificationSchema.js @@ -11,9 +11,72 @@ export const notificationTypeNames = { individual_merge_request: 'individual_merge_request', individual_merge_complete: 'individual_merge_complete', individual_merge_blocked: 'individual_merge_blocked', + + collaboration_manager_edit_approved: + 'collaboration_manager_edit_approved', + collaboration_manager_edit_revoke: + 'collaboration_manager_edit_revoke', + collaboration_edit_denied: 'collaboration_edit_denied', + collaboration_manager_denied: 'collaboration_manager_denied', + collaboration_manager_edit_denied: + 'collaboration_manager_edit_denied', }; const notificationSchemaPlaceholder = {}; + +notificationSchemaPlaceholder[ + notificationTypeNames.collaboration_manager_edit_approved +] = { + titleId: 'EDIT_COLLABORATION_DENIED_BY_USER_MANAGER', + notificationMessage: + 'EDIT_COLLABORATION_DENIED_BY_USER_MANAGER_MESSAGE', + moreDetailedDescription: + 'EDIT_COLLABORATION_DENIED_BY_USER_MANAGER_MESSAGE', + showNotificationDialog: false, + buttonPath: '/#collab-card', +}; + +notificationSchemaPlaceholder[ + notificationTypeNames.collaboration_manager_edit_approved +] = { + titleId: 'EDIT_COLLABORATION_APPROVED_BY_USER_MANAGER', + notificationMessage: + 'EDIT_COLLABORATION_WAS_APPROVED_BY_YOUR_USER_MANAGER', + moreDetailedDescription: + 'EDIT_COLLABORATION_WAS_APPROVED_BY_YOUR_USER_MANAGER', + showNotificationDialog: false, + buttonPath: '/#collab-card', +}; +notificationSchemaPlaceholder[ + notificationTypeNames.collaboration_manager_denied +] = { + titleId: 'COLLABORATION_DENIED_BY_USER_MANAGER', + notificationMessage: 'COLLABORATION_DENIED_BY_USER_MANAGER_MESSAGE', + moreDetailedDescription: + 'COLLABORATION_DENIED_BY_USER_MANAGER_MESSAGE', + showNotificationDialog: false, + buttonPath: '/#collab-card', +}; +notificationSchemaPlaceholder[ + notificationTypeNames.collaboration_edit_denied +] = { + titleId: 'COLLABORATION_EDIT_DENIED', + notificationMessage: 'EDIT_COLLABORATION_DENIED_MESSAGE', + moreDetailedDescription: 'EDIT_COLLABORATION_DENIED_MESSAGE', + showNotificationDialog: false, + buttonPath: '/#collab-card', +}; +notificationSchemaPlaceholder[ + notificationTypeNames.collaboration_manager_edit_revoke +] = { + titleId: 'EDIT_COLLABORATION_REVOKED_BY_USER_MANAGER', + notificationMessage: + 'EDIT_COLLABORATION_WAS_REVOKED_BY_YOUR_USER_MANAGER', + moreDetailedDescription: + 'EDIT_COLLABORATION_WAS_REVOKED_BY_YOUR_USER_MANAGER', + showNotificationDialog: false, + buttonPath: '/#collab-card', +}; notificationSchemaPlaceholder[ notificationTypeNames.collaboration_manager_create ] = { diff --git a/src/models/identification/useIdConfigSchemas.js b/src/models/identification/useIdConfigSchemas.js index 45814f53..e701cb45 100644 --- a/src/models/identification/useIdConfigSchemas.js +++ b/src/models/identification/useIdConfigSchemas.js @@ -57,8 +57,6 @@ export default function useIdConfigSchemas() { * for a given algorithm and modify choices contextually. * Just this for now though... */ const uniqAlgorithms = uniqBy(allAlgorithms, 'value'); - console.log('deleteMe uniqAlgorithms is: '); - console.log(uniqAlgorithms); return [ createFieldSchema(fieldTypes.multiselect, { diff --git a/src/models/sighting/useSightingFieldSchemas.js b/src/models/sighting/useSightingFieldSchemas.js index cc07105d..95aec79d 100644 --- a/src/models/sighting/useSightingFieldSchemas.js +++ b/src/models/sighting/useSightingFieldSchemas.js @@ -70,8 +70,6 @@ export default function useSightingFieldSchemas() { id: 'DO_NOT_DETECT_AUTOMATICALLY', }), }); - console.log('deleteMe modelChoices are: '); - console.log(modelChoices); const customFields = get( data, diff --git a/src/pages/notifications/Notifications.jsx b/src/pages/notifications/Notifications.jsx index 0cf00166..332bb1ae 100644 --- a/src/pages/notifications/Notifications.jsx +++ b/src/pages/notifications/Notifications.jsx @@ -85,6 +85,10 @@ export default function Notifications() { notificationSchema, notificationType, ); + // console.log( + // 'deleteMe currentNotificationSchema is: ', + // ); + // console.log(currentNotificationSchema); const read = get(notification, 'is_read', false); const { userName, @@ -97,6 +101,10 @@ export default function Notifications() { theirIndividualGuid, formattedDeadline, } = getNotificationProps(intl, notification); + console.log( + 'deleteMe getNotificationProps(intl, notification) are: ', + ); + console.log(getNotificationProps(intl, notification)); const createdDate = notification?.created; const timeSince = calculatePrettyTimeElapsedSince(createdDate); diff --git a/src/utils/notificationUtils.js b/src/utils/notificationUtils.js index 3548df83..96f57831 100644 --- a/src/utils/notificationUtils.js +++ b/src/utils/notificationUtils.js @@ -3,6 +3,8 @@ import { get } from 'lodash-es'; import { formatDateCustom } from './formatters'; export const getNotificationProps = (intl, notification) => { + console.log('deleteMe notification in notificationUtils is: '); + console.log(notification); const userName = notification?.sender_name || 'Unnamed User'; const userNameGuid = notification?.sender_guid; const user1Name = From 633b6555a96ae8b086956ad361b8254f18033c9a Mon Sep 17 00:00:00 2001 From: Mark Date: Tue, 4 Oct 2022 13:12:05 -0700 Subject: [PATCH 3/8] DEX-1435 continue implementing BE changes, this time from PR 822 on the BE --- locale/en.json | 9 +++--- .../NotificationPaneDisplayText.jsx | 14 ++++++++ .../NotificationsPane.jsx | 17 +++++++++- .../AuthenticatedAppHeader/index.js | 1 + .../dialogs/NotificationDetailsDialog.jsx | 18 ++++++++++- src/pages/notifications/Notifications.jsx | 32 +++++++++++++++++-- src/utils/notificationUtils.js | 31 ++++++++++++++++-- 7 files changed, 111 insertions(+), 11 deletions(-) diff --git a/locale/en.json b/locale/en.json index 47a1258d..69eb9c97 100644 --- a/locale/en.json +++ b/locale/en.json @@ -1198,13 +1198,14 @@ "COLLABORATIONS": "Collaborations", "URLS_MUST_INCLUDE_HTTPS": "All URLs must include https:// to be valid", "EDIT_COLLABORATION_REVOKED_BY_USER_MANAGER": "Edit collaboration revoked by your user manager", - "EDIT_COLLABORATION_WAS_REVOKED_BY_YOUR_USER_MANAGER": "An edit-level collaboration with {userName} was revoked by your user manager.", + "EDIT_COLLABORATION_WAS_REVOKED_BY_YOUR_USER_MANAGER": "An edit-level collaboration with {otherUserNameForManagerNotifications} was revoked by your user manager.", "COLLABORATION_EDIT_DENIED": "Collaboration edit denied", "EDIT_COLLABORATION_DENIED_MESSAGE": "{userName} denied your collaboration edit request", "COLLABORATION_DENIED_BY_USER_MANAGER": "Collaboration denied by your user manager", - "COLLABORATION_DENIED_BY_USER_MANAGER_MESSAGE": "Your collaboration with {userName} was denied by your user manager.", + "COLLABORATION_DENIED_BY_USER_MANAGER_MESSAGE": "Your collaboration with {otherUserNameForManagerNotifications} was denied by your user manager {managerName}.", "EDIT_COLLABORATION_DENIED_BY_USER_MANAGER": "Edit-level collaboration denied by your user manager", - "EDIT_COLLABORATION_DENIED_BY_USER_MANAGER_MESSAGE": "An edit-level collaboration with {userName} was denied by your user manager.", + "EDIT_COLLABORATION_DENIED_BY_USER_MANAGER_MESSAGE": "An edit-level collaboration with {otherUserNameForManagerNotifications} was denied by your user manager {managerName}.", "EDIT_COLLABORATION_APPROVED_BY_USER_MANAGER": "Edit collaboration approved by your user manager", - "EDIT_COLLABORATION_WAS_APPROVED_BY_YOUR_USER_MANAGER": "An edit-level collaboration with {userName} was approved by your user manager." + "EDIT_COLLABORATION_WAS_APPROVED_BY_YOUR_USER_MANAGER": "An edit-level collaboration with {otherUserNameForManagerNotifications} was approved by your user manager {managerName}.", + "UNNAMED_MANAGER": "Unnamed manager" } diff --git a/src/components/AuthenticatedAppHeader/NotificationPaneDisplayText.jsx b/src/components/AuthenticatedAppHeader/NotificationPaneDisplayText.jsx index 65cecfed..886c60e2 100644 --- a/src/components/AuthenticatedAppHeader/NotificationPaneDisplayText.jsx +++ b/src/components/AuthenticatedAppHeader/NotificationPaneDisplayText.jsx @@ -15,6 +15,9 @@ export default function NotificationPaneDisplayText({ theirIndividualName, theirIndividualGuid, formattedDeadline, + otherUserGuidForManagerNotifications, + otherUserNameForManagerNotifications, + managerName, timeSince, }) { const theme = useTheme(); @@ -54,6 +57,17 @@ export default function NotificationPaneDisplayText({ ), formattedDeadline, + otherUserNameForManagerNotifications: ( + + + {otherUserNameForManagerNotifications} + + + ), + managerName, }} /> diff --git a/src/components/AuthenticatedAppHeader/index.js b/src/components/AuthenticatedAppHeader/index.js index f13247f2..0aed4a72 100644 --- a/src/components/AuthenticatedAppHeader/index.js +++ b/src/components/AuthenticatedAppHeader/index.js @@ -142,6 +142,7 @@ export default function AppHeader() { refreshNotifications={refreshNotifications} shouldOpen={shouldOpenNotificationPane} setShouldOpen={setShouldOpenNotificationPane} + currentUserGuid={meData?.guid} /> setUserMenuAnchorEl(e.currentTarget)} diff --git a/src/components/dialogs/NotificationDetailsDialog.jsx b/src/components/dialogs/NotificationDetailsDialog.jsx index 96dd322a..3e9ff614 100644 --- a/src/components/dialogs/NotificationDetailsDialog.jsx +++ b/src/components/dialogs/NotificationDetailsDialog.jsx @@ -12,6 +12,7 @@ import ButtonLink from '../ButtonLink'; import Button from '../Button'; import CustomAlert from '../Alert'; import { getNotificationProps } from '../../utils/notificationUtils'; +import useGetMe from '../../models/users/useGetMe'; export default function NotificationDetailsDialog({ open, @@ -27,6 +28,7 @@ export default function NotificationDetailsDialog({ const onCloseDialog = () => { onClose(); }; + const { data: currentUserData } = useGetMe(); const { userName, @@ -38,7 +40,10 @@ export default function NotificationDetailsDialog({ theirIndividualName, theirIndividualGuid, formattedDeadline, - } = getNotificationProps(intl, notification); + otherUserGuidForManagerNotifications, + otherUserNameForManagerNotifications, + managerName, + } = getNotificationProps(intl, notification, currentUserData?.guid); return ( ), formattedDeadline, + otherUserNameForManagerNotifications: ( + + + {otherUserNameForManagerNotifications} + + + ), + managerName, }} /> diff --git a/src/pages/notifications/Notifications.jsx b/src/pages/notifications/Notifications.jsx index 332bb1ae..dc492e33 100644 --- a/src/pages/notifications/Notifications.jsx +++ b/src/pages/notifications/Notifications.jsx @@ -26,6 +26,7 @@ import { notificationSchema } from '../../constants/notificationSchema'; import { notificationTypes } from '../../components/dialogs/notificationDialogUtils'; import queryKeys from '../../constants/queryKeys'; import { getNotificationProps } from '../../utils/notificationUtils'; +import useGetMe from '../../models/users/useGetMe'; export default function Notifications() { const intl = useIntl(); @@ -36,6 +37,7 @@ export default function Notifications() { const { data: notifications, loading: notificationsLoading } = useNotifications(true); + const { data: currentUserData } = useGetMe(); const { markRead } = usePatchNotification(); @@ -100,11 +102,24 @@ export default function Notifications() { theirIndividualName, theirIndividualGuid, formattedDeadline, - } = getNotificationProps(intl, notification); + otherUserGuidForManagerNotifications, + otherUserNameForManagerNotifications, + managerName, + } = getNotificationProps( + intl, + notification, + currentUserData?.guid, + ); + console.log( + 'deteleMe getNotificationProps (intl,notification,currentUserData?.guid,) are: ', + ); console.log( - 'deleteMe getNotificationProps(intl, notification) are: ', + getNotificationProps( + intl, + notification, + currentUserData?.guid, + ), ); - console.log(getNotificationProps(intl, notification)); const createdDate = notification?.created; const timeSince = calculatePrettyTimeElapsedSince(createdDate); @@ -157,6 +172,17 @@ export default function Notifications() { ), formattedDeadline, + otherUserNameForManagerNotifications: ( + + + {otherUserNameForManagerNotifications} + + + ), + managerName, }, )} diff --git a/src/utils/notificationUtils.js b/src/utils/notificationUtils.js index 96f57831..3eb2cf7d 100644 --- a/src/utils/notificationUtils.js +++ b/src/utils/notificationUtils.js @@ -2,7 +2,11 @@ import { get } from 'lodash-es'; import { formatDateCustom } from './formatters'; -export const getNotificationProps = (intl, notification) => { +export const getNotificationProps = ( + intl, + notification, + currentUserGuid, +) => { console.log('deleteMe notification in notificationUtils is: '); console.log(notification); const userName = notification?.sender_name || 'Unnamed User'; @@ -11,13 +15,33 @@ export const getNotificationProps = (intl, notification) => { notification?.message_values?.user1_name || 'Unnamed User'; const user2Name = notification?.message_values?.user2_name || 'Unnamed User'; + const user1Guid = notification?.message_values?.user1_guid || ''; + const user2Guid = notification?.message_values?.user2_guid || ''; + const otherUserGuidForManagerNotifications = + currentUserGuid === user1Guid ? user2Guid : user1Guid; + const otherUserNameForManagerNotifications = + otherUserGuidForManagerNotifications === user1Guid + ? user1Name + : user2Name; + const managerName = + notification?.message_values?.manager_name || + intl.formatMessage({ id: 'UNNAMED_MANAGER' }); + console.log( + 'deleteMe otherUserGuidForManagerNotifications is: ' + + otherUserGuidForManagerNotifications, + ); + console.log( + 'deleteMe otherUserNameForManagerNotifications is: ' + + otherUserNameForManagerNotifications, + ); + console.log('deleteMe managerName is: ' + managerName); const theirIndividualName = get(notification, [ 'message_values', 'other_individuals', '0', 'primaryName', - ]); + ]); // @TODO perhaps implement currentUserGuid for this and the below related? const theirIndividualGuid = get(notification, [ 'message_values', 'other_individuals', @@ -44,5 +68,8 @@ export const getNotificationProps = (intl, notification) => { theirIndividualName, theirIndividualGuid, formattedDeadline, + otherUserGuidForManagerNotifications, + otherUserNameForManagerNotifications, + managerName, }; }; From b4e2c204f544dfb8a0e52fb84a476d2b16a1a6ec Mon Sep 17 00:00:00 2001 From: Mark Date: Tue, 4 Oct 2022 14:10:23 -0700 Subject: [PATCH 4/8] DEX-1435 clean up and internationalize --- locale/en.json | 4 ++-- src/pages/notifications/Notifications.jsx | 4 ---- src/utils/notificationUtils.js | 22 +++++++--------------- 3 files changed, 9 insertions(+), 21 deletions(-) diff --git a/locale/en.json b/locale/en.json index 69eb9c97..fe93e890 100644 --- a/locale/en.json +++ b/locale/en.json @@ -1197,8 +1197,8 @@ "EDIT_COLLABORATION_CURRENT_STATE_DESCRIPTION": "Changing the state will cancel any pending requests.", "COLLABORATIONS": "Collaborations", "URLS_MUST_INCLUDE_HTTPS": "All URLs must include https:// to be valid", - "EDIT_COLLABORATION_REVOKED_BY_USER_MANAGER": "Edit collaboration revoked by your user manager", - "EDIT_COLLABORATION_WAS_REVOKED_BY_YOUR_USER_MANAGER": "An edit-level collaboration with {otherUserNameForManagerNotifications} was revoked by your user manager.", + "EDIT_COLLABORATION_REVOKED_BY_USER_MANAGER": "Edit collaboration revoked by your user manager.", + "EDIT_COLLABORATION_WAS_REVOKED_BY_YOUR_USER_MANAGER": "An edit-level collaboration with {otherUserNameForManagerNotifications} was revoked by your user manager {managerName}.", "COLLABORATION_EDIT_DENIED": "Collaboration edit denied", "EDIT_COLLABORATION_DENIED_MESSAGE": "{userName} denied your collaboration edit request", "COLLABORATION_DENIED_BY_USER_MANAGER": "Collaboration denied by your user manager", diff --git a/src/pages/notifications/Notifications.jsx b/src/pages/notifications/Notifications.jsx index dc492e33..37b1d0e2 100644 --- a/src/pages/notifications/Notifications.jsx +++ b/src/pages/notifications/Notifications.jsx @@ -87,10 +87,6 @@ export default function Notifications() { notificationSchema, notificationType, ); - // console.log( - // 'deleteMe currentNotificationSchema is: ', - // ); - // console.log(currentNotificationSchema); const read = get(notification, 'is_read', false); const { userName, diff --git a/src/utils/notificationUtils.js b/src/utils/notificationUtils.js index 3eb2cf7d..252b8e75 100644 --- a/src/utils/notificationUtils.js +++ b/src/utils/notificationUtils.js @@ -7,14 +7,16 @@ export const getNotificationProps = ( notification, currentUserGuid, ) => { - console.log('deleteMe notification in notificationUtils is: '); - console.log(notification); - const userName = notification?.sender_name || 'Unnamed User'; + const userName = + notification?.sender_name || + intl.formatMessage({ id: 'Unnamed User' }); const userNameGuid = notification?.sender_guid; const user1Name = - notification?.message_values?.user1_name || 'Unnamed User'; + notification?.message_values?.user1_name || + intl.formatMessage({ id: 'Unnamed User' }); const user2Name = - notification?.message_values?.user2_name || 'Unnamed User'; + notification?.message_values?.user2_name || + intl.formatMessage({ id: 'Unnamed User' }); const user1Guid = notification?.message_values?.user1_guid || ''; const user2Guid = notification?.message_values?.user2_guid || ''; const otherUserGuidForManagerNotifications = @@ -26,16 +28,6 @@ export const getNotificationProps = ( const managerName = notification?.message_values?.manager_name || intl.formatMessage({ id: 'UNNAMED_MANAGER' }); - console.log( - 'deleteMe otherUserGuidForManagerNotifications is: ' + - otherUserGuidForManagerNotifications, - ); - console.log( - 'deleteMe otherUserNameForManagerNotifications is: ' + - otherUserNameForManagerNotifications, - ); - console.log('deleteMe managerName is: ' + managerName); - const theirIndividualName = get(notification, [ 'message_values', 'other_individuals', From 043edb1fc22b3d57c4756912436c3054ad47b373 Mon Sep 17 00:00:00 2001 From: Mark Date: Tue, 4 Oct 2022 14:26:25 -0700 Subject: [PATCH 5/8] DEX-1435 add last improvements during pre code review --- src/pages/notifications/Notifications.jsx | 10 ---------- src/utils/notificationUtils.js | 2 +- 2 files changed, 1 insertion(+), 11 deletions(-) diff --git a/src/pages/notifications/Notifications.jsx b/src/pages/notifications/Notifications.jsx index 37b1d0e2..d83984f8 100644 --- a/src/pages/notifications/Notifications.jsx +++ b/src/pages/notifications/Notifications.jsx @@ -106,16 +106,6 @@ export default function Notifications() { notification, currentUserData?.guid, ); - console.log( - 'deteleMe getNotificationProps (intl,notification,currentUserData?.guid,) are: ', - ); - console.log( - getNotificationProps( - intl, - notification, - currentUserData?.guid, - ), - ); const createdDate = notification?.created; const timeSince = calculatePrettyTimeElapsedSince(createdDate); diff --git a/src/utils/notificationUtils.js b/src/utils/notificationUtils.js index 252b8e75..e398a6f6 100644 --- a/src/utils/notificationUtils.js +++ b/src/utils/notificationUtils.js @@ -33,7 +33,7 @@ export const getNotificationProps = ( 'other_individuals', '0', 'primaryName', - ]); // @TODO perhaps implement currentUserGuid for this and the below related? + ]); const theirIndividualGuid = get(notification, [ 'message_values', 'other_individuals', From 82cfbd170b5c594e29e26a71c00fdf455ce2796b Mon Sep 17 00:00:00 2001 From: Mark Date: Tue, 4 Oct 2022 14:40:19 -0700 Subject: [PATCH 6/8] DEX-1435 fix i8n issue --- src/utils/notificationUtils.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/utils/notificationUtils.js b/src/utils/notificationUtils.js index e398a6f6..89c2e94c 100644 --- a/src/utils/notificationUtils.js +++ b/src/utils/notificationUtils.js @@ -9,14 +9,14 @@ export const getNotificationProps = ( ) => { const userName = notification?.sender_name || - intl.formatMessage({ id: 'Unnamed User' }); + intl.formatMessage({ id: 'UNNAMED_USER' }); const userNameGuid = notification?.sender_guid; const user1Name = notification?.message_values?.user1_name || - intl.formatMessage({ id: 'Unnamed User' }); + intl.formatMessage({ id: 'UNNAMED_USER' }); const user2Name = notification?.message_values?.user2_name || - intl.formatMessage({ id: 'Unnamed User' }); + intl.formatMessage({ id: 'UNNAMED_USER' }); const user1Guid = notification?.message_values?.user1_guid || ''; const user2Guid = notification?.message_values?.user2_guid || ''; const otherUserGuidForManagerNotifications = From d66d30e25318d7efd55500342e99529a9f691b5e Mon Sep 17 00:00:00 2001 From: Mark Date: Tue, 4 Oct 2022 14:44:51 -0700 Subject: [PATCH 7/8] DEX-1435 change your to a --- locale/en.json | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/locale/en.json b/locale/en.json index fe93e890..58286e07 100644 --- a/locale/en.json +++ b/locale/en.json @@ -1051,7 +1051,7 @@ "INDIVIDUALS_MERGE_PENDING_TITLE": "Merge pending", "INDIVIDUALS_MERGE_PENDING_DESCRIPTION": "Your merge could not be completed immediately because you do not have edit access to all of the sightings associated with these individuals. A notification has been sent to the researchers who own these sightings so they can approve or block the merge. They must respond by {deadlineDate} to block the merge or it will proceed.", "DATE_MISSING": "DATE MISSING", - "COLLABORATION_ESTABLISHED_BY_USER_MANAGER": "Collaboration established by your user manager", + "COLLABORATION_ESTABLISHED_BY_USER_MANAGER": "Collaboration established by a user manager", "COLLABORATION_REVOKE_TITLE": "Revoke collaboration", "COLLABORATION_EDIT_REQUEST_TITLE": "Edit collaboration request", "COLLABORATION_EDIT_APPROVED_TITLE": "Collaboration edit approved", @@ -1197,15 +1197,15 @@ "EDIT_COLLABORATION_CURRENT_STATE_DESCRIPTION": "Changing the state will cancel any pending requests.", "COLLABORATIONS": "Collaborations", "URLS_MUST_INCLUDE_HTTPS": "All URLs must include https:// to be valid", - "EDIT_COLLABORATION_REVOKED_BY_USER_MANAGER": "Edit collaboration revoked by your user manager.", - "EDIT_COLLABORATION_WAS_REVOKED_BY_YOUR_USER_MANAGER": "An edit-level collaboration with {otherUserNameForManagerNotifications} was revoked by your user manager {managerName}.", + "EDIT_COLLABORATION_REVOKED_BY_USER_MANAGER": "Edit collaboration revoked by a user manager.", + "EDIT_COLLABORATION_WAS_REVOKED_BY_YOUR_USER_MANAGER": "An edit-level collaboration with {otherUserNameForManagerNotifications} was revoked by a user manager {managerName}.", "COLLABORATION_EDIT_DENIED": "Collaboration edit denied", "EDIT_COLLABORATION_DENIED_MESSAGE": "{userName} denied your collaboration edit request", - "COLLABORATION_DENIED_BY_USER_MANAGER": "Collaboration denied by your user manager", - "COLLABORATION_DENIED_BY_USER_MANAGER_MESSAGE": "Your collaboration with {otherUserNameForManagerNotifications} was denied by your user manager {managerName}.", - "EDIT_COLLABORATION_DENIED_BY_USER_MANAGER": "Edit-level collaboration denied by your user manager", - "EDIT_COLLABORATION_DENIED_BY_USER_MANAGER_MESSAGE": "An edit-level collaboration with {otherUserNameForManagerNotifications} was denied by your user manager {managerName}.", - "EDIT_COLLABORATION_APPROVED_BY_USER_MANAGER": "Edit collaboration approved by your user manager", - "EDIT_COLLABORATION_WAS_APPROVED_BY_YOUR_USER_MANAGER": "An edit-level collaboration with {otherUserNameForManagerNotifications} was approved by your user manager {managerName}.", + "COLLABORATION_DENIED_BY_USER_MANAGER": "Collaboration denied by a user manager", + "COLLABORATION_DENIED_BY_USER_MANAGER_MESSAGE": "Your collaboration with {otherUserNameForManagerNotifications} was denied by a user manager {managerName}.", + "EDIT_COLLABORATION_DENIED_BY_USER_MANAGER": "Edit-level collaboration denied by a user manager", + "EDIT_COLLABORATION_DENIED_BY_USER_MANAGER_MESSAGE": "An edit-level collaboration with {otherUserNameForManagerNotifications} was denied by a user manager {managerName}.", + "EDIT_COLLABORATION_APPROVED_BY_USER_MANAGER": "Edit collaboration approved by a user manager", + "EDIT_COLLABORATION_WAS_APPROVED_BY_YOUR_USER_MANAGER": "An edit-level collaboration with {otherUserNameForManagerNotifications} was approved by a user manager {managerName}.", "UNNAMED_MANAGER": "Unnamed manager" } From d0f5ef001f8830958c282db36d705c3cccec2779 Mon Sep 17 00:00:00 2001 From: Mark Date: Wed, 5 Oct 2022 16:22:05 -0700 Subject: [PATCH 8/8] DEX-1435 respond to code review feedback --- locale/en.json | 4 ++-- .../dialogs/NotificationDetailsDialog.jsx | 17 ++++++++++++++-- src/constants/notificationSchema.js | 10 +++++----- src/pages/notifications/Notifications.jsx | 20 +++++++++++++------ src/utils/notificationUtils.js | 11 ++++------ 5 files changed, 40 insertions(+), 22 deletions(-) diff --git a/locale/en.json b/locale/en.json index 58286e07..1587703a 100644 --- a/locale/en.json +++ b/locale/en.json @@ -1198,7 +1198,7 @@ "COLLABORATIONS": "Collaborations", "URLS_MUST_INCLUDE_HTTPS": "All URLs must include https:// to be valid", "EDIT_COLLABORATION_REVOKED_BY_USER_MANAGER": "Edit collaboration revoked by a user manager.", - "EDIT_COLLABORATION_WAS_REVOKED_BY_YOUR_USER_MANAGER": "An edit-level collaboration with {otherUserNameForManagerNotifications} was revoked by a user manager {managerName}.", + "EDIT_COLLABORATION_WAS_REVOKED_BY_A_USER_MANAGER": "An edit-level collaboration with {otherUserNameForManagerNotifications} was revoked by a user manager {managerName}.", "COLLABORATION_EDIT_DENIED": "Collaboration edit denied", "EDIT_COLLABORATION_DENIED_MESSAGE": "{userName} denied your collaboration edit request", "COLLABORATION_DENIED_BY_USER_MANAGER": "Collaboration denied by a user manager", @@ -1206,6 +1206,6 @@ "EDIT_COLLABORATION_DENIED_BY_USER_MANAGER": "Edit-level collaboration denied by a user manager", "EDIT_COLLABORATION_DENIED_BY_USER_MANAGER_MESSAGE": "An edit-level collaboration with {otherUserNameForManagerNotifications} was denied by a user manager {managerName}.", "EDIT_COLLABORATION_APPROVED_BY_USER_MANAGER": "Edit collaboration approved by a user manager", - "EDIT_COLLABORATION_WAS_APPROVED_BY_YOUR_USER_MANAGER": "An edit-level collaboration with {otherUserNameForManagerNotifications} was approved by a user manager {managerName}.", + "EDIT_COLLABORATION_WAS_APPROVED_BY_A_USER_MANAGER": "An edit-level collaboration with {otherUserNameForManagerNotifications} was approved by a user manager {managerName}.", "UNNAMED_MANAGER": "Unnamed manager" } diff --git a/src/components/dialogs/NotificationDetailsDialog.jsx b/src/components/dialogs/NotificationDetailsDialog.jsx index 3e9ff614..0eb2a97c 100644 --- a/src/components/dialogs/NotificationDetailsDialog.jsx +++ b/src/components/dialogs/NotificationDetailsDialog.jsx @@ -28,7 +28,20 @@ export default function NotificationDetailsDialog({ const onCloseDialog = () => { onClose(); }; - const { data: currentUserData } = useGetMe(); + const { + data: currentUserData, + loading: currentUserLoading, + error: currentUserError, + } = useGetMe(); + + const props = + currentUserLoading || currentUserError + ? {} + : getNotificationProps( + intl, + notification, + currentUserData?.guid, + ); const { userName, @@ -43,7 +56,7 @@ export default function NotificationDetailsDialog({ otherUserGuidForManagerNotifications, otherUserNameForManagerNotifications, managerName, - } = getNotificationProps(intl, notification, currentUserData?.guid); + } = props; return ( { - const userName = - notification?.sender_name || - intl.formatMessage({ id: 'UNNAMED_USER' }); + const unnamedUser = intl.formatMessage({ id: 'UNNAMED_USER' }); + const userName = notification?.sender_name || unnamedUser; const userNameGuid = notification?.sender_guid; const user1Name = - notification?.message_values?.user1_name || - intl.formatMessage({ id: 'UNNAMED_USER' }); + notification?.message_values?.user1_name || unnamedUser; const user2Name = - notification?.message_values?.user2_name || - intl.formatMessage({ id: 'UNNAMED_USER' }); + notification?.message_values?.user2_name || unnamedUser; const user1Guid = notification?.message_values?.user1_guid || ''; const user2Guid = notification?.message_values?.user2_guid || ''; const otherUserGuidForManagerNotifications =