From cfd3e545c52ed8ff88f7a1b16b124974c43fdfec Mon Sep 17 00:00:00 2001 From: erinz2020 Date: Mon, 15 Jan 2024 20:27:03 +0000 Subject: [PATCH 1/2] export collaboration remove duplicate keys add export export collaboration remove duplicate keys edit access modal debug with houston buggy day lots of new components restore editMetadata sweep out logs update key sweep out --- locale/en.json | 21 +- .../NotificationsPane.jsx | 2 +- src/components/EditUserMetadata.jsx | 236 ++++++------- src/components/PreferenceModal.jsx | 314 +++++++++--------- src/components/RequestCollaborationButton.jsx | 4 +- src/components/UserProfile.jsx | 42 ++- src/components/cards/MyCollaborationsCard.jsx | 18 + .../collaborations/CollaborationsDialog.jsx | 48 ++- .../collaborations/collaborationStates.js | 83 ++++- ...otificationCollaborationApprovedDialog.jsx | 3 + ...icationCollaborationEditApprovedDialog.jsx | 3 + ...ficationCollaborationEditRequestDialog.jsx | 4 + ...ationCollaborationExportApprovedDialog.jsx | 66 ++++ ...icationCollaborationExportDeniedDialog.jsx | 30 ++ ...cationCollaborationExportRequestDialog.jsx | 85 +++++ ...icationCollaborationExportRevokeDialog.jsx | 30 ++ ...llaborationManagerExportApprovedDialog.jsx | 30 ++ ...CollaborationManagerExportDeniedDialog.jsx | 31 ++ ...CollaborationManagerExportRevokeDialog.jsx | 30 ++ ...NotificationCollaborationRequestDialog.jsx | 4 + .../dialogs/notificationDialogUtils/index.js | 21 ++ src/constants/notificationSchema.js | 117 ++++++- .../collaboration/useRequestExportAccess.js | 10 + src/pages/dataPage/DataPage.jsx | 9 + .../settings/DefaultFieldTable.jsx | 1 - src/pages/home/Home.jsx | 2 + src/pages/user/User.jsx | 2 + .../CollaborationManagementForm.jsx | 1 - .../components/EditCollaborationDialog.jsx | 40 ++- .../userManagement/constants/collaboration.js | 1 + src/utils/collaborationUtils.js | 23 +- 31 files changed, 979 insertions(+), 332 deletions(-) create mode 100644 src/components/dialogs/notificationDialogUtils/NotificationCollaborationExportApprovedDialog.jsx create mode 100644 src/components/dialogs/notificationDialogUtils/NotificationCollaborationExportDeniedDialog.jsx create mode 100644 src/components/dialogs/notificationDialogUtils/NotificationCollaborationExportRequestDialog.jsx create mode 100644 src/components/dialogs/notificationDialogUtils/NotificationCollaborationExportRevokeDialog.jsx create mode 100644 src/components/dialogs/notificationDialogUtils/NotificationCollaborationManagerExportApprovedDialog.jsx create mode 100644 src/components/dialogs/notificationDialogUtils/NotificationCollaborationManagerExportDeniedDialog.jsx create mode 100644 src/components/dialogs/notificationDialogUtils/NotificationCollaborationManagerExportRevokeDialog.jsx create mode 100644 src/models/collaboration/useRequestExportAccess.js diff --git a/locale/en.json b/locale/en.json index c453f4018..1e39ab043 100644 --- a/locale/en.json +++ b/locale/en.json @@ -87,7 +87,9 @@ "COLLABORATION_VIEW_REQUEST_BRIEF": "{userName} has requested to collaborate with you", "COLLABORATION_VIEW_REQUEST_DESCRIPTION": "{userName} has requested to collaborate with you. If you grant access to {userName}, you will be able to view each other's data.", "COLLABORATION_EDIT_REQUEST_BRIEF": "{userName} has requested an edit collaboration with you", + "COLLABORATION_EXPORT_REQUEST_BRIEF": "{userName} has requested an export collaboration with you", "COLLABORATION_EDIT_REQUEST_DESCRIPTION": "{userName} has requested an edit collaboration with you. If you grant access to {userName}, you will be able to edit each other's data.", + "COLLABORATION_EXPORT_REQUEST_DESCRIPTION": "{userName} has requested an export collaboration with you. If you grant access to {userName}, you will be able to export each other's data.", "VIEW_USER_PROFILE": "View user profile", "SEARCH_RADIUS_LABEL": "Search radius (kilometers)", "SEARCH_CENTER_POINT": "Search center point", @@ -1049,7 +1051,9 @@ "COLLABORATION_APPROVED_TITLE": "Collaboration approved", "COLLABORATION_REVOKE_BRIEF": "{userName} revoked your collaboration request", "EDIT_COLLABORATION_APPROVED": "{userName} approved your collaboration edit request", + "EXPORT_COLLABORATION_APPROVED": "{userName} approved your collaboration export request", "EDIT_COLLABORATION_REVOKED": "{userName} revoked edit privileges for your collaboration with them", + "EXPORT_COLLABORATION_REVOKED": "{userName} revoked export privileges for your collaboration with them", "COLLABORATION_REVOKED_BY_MANAGER": "A collaboration was revoked by a user manager.", "INDIVIDUAL_MERGE_REQUEST_MESSAGE_DETAILED": "{userName} requested that {yourIndividualName} be merged with {theirIndividualName}. You have until {formattedDeadline} to respond.", "INDIVIDUAL_MERGE_REQUEST_MESSAGE": "{userName} wants to merge {yourIndividualName} with {theirIndividualName}", @@ -1060,8 +1064,11 @@ "COLLABORATION_ESTABLISHED_BY_USER_MANAGER": "Collaboration established by a user manager", "COLLABORATION_REVOKE_TITLE": "Revoke collaboration", "COLLABORATION_EDIT_REQUEST_TITLE": "Edit collaboration request", + "COLLABORATION_EXPORT_REQUEST_TITLE": "Export collaboration request", "COLLABORATION_EDIT_APPROVED_TITLE": "Collaboration edit approved", + "COLLABORATION_EXPORT_APPROVED_TITLE": "Collaboration export approved", "COLLABORATION_EDIT_REVOKE_TITLE": "Revoke edit privileges", + "COLLABORATION_EXPORT_REVOKE_TITLE": "Revoke export privileges", "COLLABORATION_MANAGER_REVOKE_TITLE": "Revoke manager-assigned collaboration", "INDIVIDUAL_MERGE_REQUEST_TITLE": "Individual merge request", "INDIVIDUAL_MERGE_COMPLETE_TITLE": "Individual merge completed", @@ -1206,15 +1213,23 @@ "ADD_COLLABORATION": "Add collaboration", "EMAIL": "Email", "EDIT_COLLABORATION_REVOKED_BY_USER_MANAGER": "Edit collaboration revoked by a user manager.", + "EXPORT_COLLABORATION_REVOKED_BY_USER_MANAGER": "Export collaboration revoked by a user manager.", "EDIT_COLLABORATION_WAS_REVOKED_BY_A_USER_MANAGER": "An edit-level collaboration with {otherUserNameForManagerNotifications} was revoked by a user manager {managerName}.", + "EXPORT_COLLABORATION_WAS_REVOKED_BY_A_USER_MANAGER": "An export-level collaboration with {otherUserNameForManagerNotifications} was revoked by a user manager {managerName}.", "COLLABORATION_EDIT_DENIED": "Collaboration edit denied", + "COLLABORATION_EXPORT_DENIED": "Collaboration export denied", "EDIT_COLLABORATION_DENIED_MESSAGE": "{userName} denied your collaboration edit request", + "EXPORT_COLLABORATION_DENIED_MESSAGE": "{userName} denied your collaboration export request", "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", + "EXPORT_COLLABORATION_DENIED_BY_USER_MANAGER": "Export-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}.", + "EXPORT_COLLABORATION_DENIED_BY_USER_MANAGER_MESSAGE": "An export-level collaboration with {otherUserNameForManagerNotifications} was denied by a user manager {managerName}.", "EDIT_COLLABORATION_APPROVED_BY_USER_MANAGER": "Edit collaboration approved by a user manager", + "EXPORT_COLLABORATION_APPROVED_BY_USER_MANAGER": "Export collaboration approved by a user manager", "EDIT_COLLABORATION_WAS_APPROVED_BY_A_USER_MANAGER": "An edit-level collaboration with {otherUserNameForManagerNotifications} was approved by a user manager {managerName}.", + "EXPORT_COLLABORATION_WAS_APPROVED_BY_A_USER_MANAGER": "An export-level collaboration with {otherUserNameForManagerNotifications} was approved by a user manager {managerName}.", "UNNAMED_MANAGER": "Unnamed manager", "STILL_GENERATING_LIST": "Still generating list; this can take up to one minute.", "SEARCH_TIMED_OUT_WHILE_TRYING_TO_CONNECT_TO_ITIS": "Search timed out while trying to connect to ITIS database. Try again later.", @@ -1290,5 +1305,9 @@ "MANAGE_REGIONS" : "Manage Regions", "EXPORT_RESULT" : "Export result", "EXPORT_ACCESS_RESTRICTED_WARNING" : "No results meet export criteria. Consider adjusting your search or requesting export collaborations.", - "OK" : "Ok" + "OK" : "Ok", + "EXPORT" : "Export", + "ACCESS" : "Access", + "COLLABORATE" : "Collaborate", + "COLLABORATION_STATE_EXPORT" : "Export" } diff --git a/src/components/AuthenticatedAppHeader/NotificationsPane.jsx b/src/components/AuthenticatedAppHeader/NotificationsPane.jsx index cfb378b4f..b5cadf099 100644 --- a/src/components/AuthenticatedAppHeader/NotificationsPane.jsx +++ b/src/components/AuthenticatedAppHeader/NotificationsPane.jsx @@ -101,7 +101,7 @@ export default function NotificationsPane({ const defaultButtonPath = get( currentNotificationSchema, 'buttonPath', - '/#collab-card', + '/user-profile/#collab-card', ); const buttonPath = deriveButtonPath ? deriveButtonPath(mergedIndividualGuid) diff --git a/src/components/EditUserMetadata.jsx b/src/components/EditUserMetadata.jsx index a9baf77b8..0f9bbf688 100644 --- a/src/components/EditUserMetadata.jsx +++ b/src/components/EditUserMetadata.jsx @@ -4,6 +4,14 @@ import { get, map, omit, find } from 'lodash-es'; import DialogContent from '@material-ui/core/DialogContent'; import DialogActions from '@material-ui/core/DialogActions'; +import Typography from '@material-ui/core/Typography'; +import { useTheme } from '@material-ui/core/styles'; +import Chip from '@material-ui/core/Chip'; +import { MailOutline } from '@material-ui/icons'; +import AccountCircleOutlinedIcon from '@material-ui/icons/AccountCircleOutlined'; +import ForumOutlinedIcon from '@material-ui/icons/ForumOutlined'; +import AccountBalanceOutlined from '@material-ui/icons/AccountBalanceOutlined'; +import PlaceOutlined from '@material-ui/icons/PlaceOutlined'; import CustomAlert from './Alert'; import { useReplaceUserProperties } from '../models/users/usePatchUser'; import { sanitizeTwitterHandle } from '../utils/formatters'; @@ -12,21 +20,11 @@ import InputRow from './fields/edit/InputRow'; import Button from './Button'; import PasswordVerificationAlert from './PasswordVerificationAlert'; import StandardDialog from './StandardDialog'; -import Typography from '@material-ui/core/Typography'; -import { useTheme } from '@material-ui/core/styles'; import EntityHeader from './EntityHeader'; import BigAvatar from './profilePhotos/BigAvatar'; import RequestCollaborationButton from './RequestCollaborationButton'; import Text from './Text'; -import Chip from '@material-ui/core/Chip'; -import { MailOutline } from '@material-ui/icons'; import UserProfileMetadataWrap from './UserProfileMetadataWrap'; -import AccountCircleOutlinedIcon from '@material-ui/icons/AccountCircleOutlined'; -import ForumOutlinedIcon from '@material-ui/icons/ForumOutlined'; -import AccountBalanceOutlined from '@material-ui/icons/AccountBalanceOutlined'; -import PlaceOutlined from '@material-ui/icons/PlaceOutlined'; - - function getInitialFormValues(schema) { return schema.reduce((memo, field) => { @@ -74,7 +72,6 @@ export default function EditUserMetadata({ setFieldValues(getInitialFormValues(metadata)); }, [metadata]); - return ( + + } - - } - renderOptions={ - - - - } - > -
+ > +
+
+ {communityUsername && ( + <> + + {`@${communityUsername}`} +
- {communityUsername && <> - - {`@${communityUsername}`} - -
- } - - -
- -
- - + style={{ + height: '20px', + width: '2px', + backgroundColor: 'gray', + margin: '0 10px', + }} + /> + + )} + +
+
+ + {metadata.map(field => { if (!field.editable) return null; @@ -163,46 +148,61 @@ export default function EditUserMetadata({ const labelId = get(field, 'labelId'); return ( -
- {labelId === 'FULL_NAME' && - - - } - {labelId === 'PROFILE_LABEL_EMAIL' && - - - } - {labelId === 'PROFILE_LABEL_FORUM_ID' && - - - } - {labelId === 'PROFILE_LABEL_AFFILIATION' && - - - } - {labelId === 'PROFILE_LABEL_LOCATION' && - - - } - - <> - - { - const newFormValues = { - ...fieldValues, - [field.name]: newValue, - }; - setFieldValues(newFormValues); - }} - /> - - -
+
+ {labelId === 'FULL_NAME' && ( + + + + )} + {labelId === 'PROFILE_LABEL_EMAIL' && ( + + + + )} + {labelId === 'PROFILE_LABEL_FORUM_ID' && ( + + + + )} + {labelId === 'PROFILE_LABEL_AFFILIATION' && ( + + + + )} + {labelId === 'PROFILE_LABEL_LOCATION' && ( + + + + )} + + + { + const newFormValues = { + ...fieldValues, + [field.name]: newValue, + }; + setFieldValues(newFormValues); + }} + /> + +
); })} diff --git a/src/components/PreferenceModal.jsx b/src/components/PreferenceModal.jsx index bd55fd33e..c9d96a00e 100644 --- a/src/components/PreferenceModal.jsx +++ b/src/components/PreferenceModal.jsx @@ -1,26 +1,24 @@ import React, { useEffect, useState, useMemo } from 'react'; import { get, has } from 'lodash-es'; -import useDocumentTitle from '../hooks/useDocumentTitle'; -import MainColumn from '../components/MainColumn'; -import UserDeleteDialog from '../components/dialogs/UserDeleteDialog'; -import Button from '../components/Button'; -import InputRow from '../components/fields/edit/InputRow'; -import Text from '../components/Text'; -import ErrorDialog from '../components/dialogs/ErrorDialog'; -import useGetMe from '../models/users/useGetMe'; -import { useReplaceUserProperty } from '../models/users/usePatchUser'; -import { useNotificationSettingsSchemas } from '../pages/preferences/useUserSettingsSchemas'; -import { deriveNotificationPreferences } from '../pages/preferences/deriveNotificationPreferences'; -import StandardDialog from '../components/StandardDialog'; import DialogContent from '@material-ui/core/DialogContent'; import MailOutline from '@material-ui/icons/MailOutline'; import EditOutline from '@material-ui/icons/EditOutlined'; import GroupAdd from '@material-ui/icons/GroupAdd'; import CallMerge from '@material-ui/icons/CallMerge'; -import UserProfileMetadataWrap from '../components/UserProfileMetadataWrap'; - - +import useDocumentTitle from '../hooks/useDocumentTitle'; +import MainColumn from './MainColumn'; +import UserDeleteDialog from './dialogs/UserDeleteDialog'; +import Button from './Button'; +import InputRow from './fields/edit/InputRow'; +import Text from './Text'; +import ErrorDialog from './dialogs/ErrorDialog'; +import useGetMe from '../models/users/useGetMe'; +import { useReplaceUserProperty } from '../models/users/usePatchUser'; +import { useNotificationSettingsSchemas } from '../pages/preferences/useUserSettingsSchemas'; +import { deriveNotificationPreferences } from '../pages/preferences/deriveNotificationPreferences'; +import StandardDialog from './StandardDialog'; +import UserProfileMetadataWrap from './UserProfileMetadataWrap'; function getInitialFormValues(schemas, data) { return schemas.reduce((memo, field) => { @@ -31,7 +29,7 @@ function getInitialFormValues(schemas, data) { }, {}); } -export default function Preferences({open, onClose}) { +export default function Preferences({ open, onClose }) { useDocumentTitle('PREFERENCES'); const { data } = useGetMe(); @@ -62,153 +60,153 @@ export default function Preferences({open, onClose}) { ); return ( - + - - { - clearError(); - }} - errorMessage={error} - /> - {deactivating && ( - setDeactivating(false)} - userData={data} - deactivatingSelf + PaperProps={{ style: { width: 900 } }} + maxWidth="lg" + open={open} + onClose={onClose} + titleId="PREFERENCES" + > + + { + clearError(); + }} + errorMessage={error} /> - )} - - setDeactivating(false)} + userData={data} + deactivatingSelf /> - - {schemas.map(notificationField => { - const fieldKey = get(notificationField, 'name'); - const fieldValue = get(formValues, fieldKey); - const backendValue = get(backendValues, fieldKey); - const valueHasChanged = fieldValue !== backendValue; - const labelId = get(notificationField, 'labelId'); - - return ( -
- {labelId === 'ALL_NOTIFICATION_EMAILS' && - - - } - {labelId === 'COLLABORATION_REQUESTS' && - - - } - {labelId === 'COLLABORATION_EDIT_REQUESTS' && - - - } - {labelId === 'MERGE_OF_INDIVIDUAL' && - - - } - - <> - -
+ + {schemas.map(notificationField => { + const fieldKey = get(notificationField, 'name'); + const fieldValue = get(formValues, fieldKey); + const backendValue = get(backendValues, fieldKey); + const valueHasChanged = fieldValue !== backendValue; + const labelId = get(notificationField, 'labelId'); + + return ( +
+ {labelId === 'ALL_NOTIFICATION_EMAILS' && ( + + + + )} + {labelId === 'COLLABORATION_REQUESTS' && ( + + + + )} + {labelId === 'COLLABORATION_EDIT_REQUESTS' && ( + + + + )} + {labelId === 'MERGE_OF_INDIVIDUAL' && ( + + + + )} + + +
+ { + setFormValues({ + ...formValues, + [fieldKey]: !fieldValue, + }); }} - > - - { - setFormValues({ - ...formValues, - [fieldKey]: !fieldValue, - }); - }} - minimalLabels - /> - - {valueHasChanged && ( -
-
- )} -
-
- + minimalLabels + /> + + {valueHasChanged && ( +
+
+ )}
- ); - })} - - - -
+ ); + })} + + + + - + {(!someoneElse || + viewerIsUserManager || + viewerIsUserAdmin) && ( + + )} + {!someoneElse && ( + + )}
c.test('viewState', activeCollaboration), ); + + const exportStateSchema = collaborationSchemas.find(c => + c.test('exportState', activeCollaboration), + ); + const editStateSchema = collaborationSchemas.find(c => c.test('editState', activeCollaboration), ); function cleanupAndClose() { setRequest(null); - clearRequestError(); + clearEditRequestError(); + clearexportRequestError(); onClose(); } @@ -79,14 +95,25 @@ export default function CollaborationsDialog({ schema={viewStateSchema} setRequest={setRequest} /> + @@ -115,6 +142,11 @@ export default function CollaborationsDialog({ collaborationGuid: activeCollaboration.guid, }); requestSuccessful = response?.status === 200; + } else if (request.sendExportRequest) { + const response = await requestExportAccess({ + collaborationGuid: activeCollaboration.guid, + }); + requestSuccessful = response?.status === 200; } else { const response = await patchCollaboration({ collaborationGuid: activeCollaboration.guid, diff --git a/src/components/cards/collaborations/collaborationStates.js b/src/components/cards/collaborations/collaborationStates.js index c8a9c9bd6..992887129 100644 --- a/src/components/cards/collaborations/collaborationStates.js +++ b/src/components/cards/collaborations/collaborationStates.js @@ -1,8 +1,13 @@ import { get } from 'lodash-es'; function buildCollaborationPatch(testKey, value) { - const path = - testKey === 'viewState' ? '/view_permission' : '/edit_permission'; + const permissions = { + viewState: '/view_permission', + exportState: '/export_permission', + editState: '/edit_permission', + }; + const path = permissions[testKey]; + return [ { op: 'replace', @@ -14,14 +19,16 @@ function buildCollaborationPatch(testKey, value) { export default { pending: { - viewDisablesEdit: true, + viewDisablesExport: true, + exportDisablesEdit: true, test: (testKey, collaboration) => get(collaboration, ['otherUserData', testKey]) === 'pending', currentStateMessage: 'Access requested. Waiting for your request to be approved.', }, waiting: { - viewDisablesEdit: true, + viewDisablesExport: true, + exportDisablesEdit: true, test: (testKey, collaboration) => get(collaboration, ['thisUserData', testKey]) === 'pending', currentStateMessage: 'Data access requested.', @@ -37,7 +44,8 @@ export default { buildCollaborationPatch(testKey, 'denied'), }, blocked: { - viewDisablesEdit: true, + viewDisablesExport: true, + exportDisablesEdit: true, test: (testKey, collaboration) => ['denied', 'revoked'].includes( get(collaboration, ['otherUserData', testKey]), @@ -46,7 +54,8 @@ export default { 'Access revoked. Only the collaboration partner or a user manager can restore access.', }, blocking: { - viewDisablesEdit: true, + viewDisablesExport: true, + exportDisablesEdit: true, test: (testKey, collaboration) => ['denied', 'revoked'].includes( get(collaboration, ['thisUserData', testKey]), @@ -59,7 +68,8 @@ export default { buildCollaborationPatch(testKey, 'approved'), }, granted: { - viewDisablesEdit: false, + viewDisablesExport: false, + exportDisablesEdit: false, test: (testKey, collaboration) => get(collaboration, ['otherUserData', testKey]) === 'approved', currentStateMessage: 'Access granted.', @@ -69,11 +79,48 @@ export default { getActionPatch: testKey => buildCollaborationPatch(testKey, 'revoked'), }, - untouched: { - viewDisablesEdit: true, + exportRequest: { + viewDisablesExport: false, + exportDisablesEdit: true, test: (testKey, collaboration) => + testKey === 'exportState' && get(collaboration, ['otherUserData', testKey]) === - 'not_initiated', + 'not_initiated' && + get(collaboration, ['otherUserData', 'viewState']) === + 'approved', + currentStateMessage: 'Access has not been requested.', + actionMessage: 'Request access', + actionVerificationMessage: + 'Are you sure you want to request access? Your data will also become available to your collaboration partner.', + getActionPatch: Function.prototype, + sendEditRequest: false, + sendExportRequest: true, + }, + exportDisabled: { + viewDisablesExport: true, + exportDisablesEdit: true, + test: (testKey, collaboration) => + testKey === 'exportState' && + get(collaboration, ['otherUserData', testKey]) === + 'not_initiated' && + get(collaboration, ['otherUserData', 'viewState']) !== + 'approved', + currentStateMessage: 'Access has not been requested.', + actionMessage: 'Request access', + actionVerificationMessage: + 'Are you sure you want to request access? Your data will also become available to your collaboration partner.', + getActionPatch: Function.prototype, + sendEditRequest: false, + sendExportRequest: false, + }, + editRequest: { + exportDisablesEdit: false, + test: (testKey, collaboration) => + testKey === 'editState' && + get(collaboration, ['otherUserData', testKey]) === + 'not_initiated' && + get(collaboration, ['otherUserData', 'exportState']) === + 'approved', currentStateMessage: 'Access has not been requested.', actionMessage: 'Request access', actionVerificationMessage: @@ -81,6 +128,22 @@ export default { getActionPatch: Function.prototype, sendEditRequest: true, }, + editDisabled: { + exportDisablesEdit: true, + test: (testKey, collaboration) => + testKey === 'editState' && + get(collaboration, ['otherUserData', testKey]) === + 'not_initiated' && + get(collaboration, ['otherUserData', 'exportState']) !== + 'approved', + currentStateMessage: 'Access has not been requested.', + actionMessage: 'Request access', + actionVerificationMessage: + 'Are you sure you want to request access? Your data will also become available to your collaboration partner.', + getActionPatch: Function.prototype, + sendEditRequest: false, + sendExportRequest: false, + }, confused: { test: () => true, currentStateMessage: diff --git a/src/components/dialogs/notificationDialogUtils/NotificationCollaborationApprovedDialog.jsx b/src/components/dialogs/notificationDialogUtils/NotificationCollaborationApprovedDialog.jsx index 4d4b155b0..0df38878c 100644 --- a/src/components/dialogs/notificationDialogUtils/NotificationCollaborationApprovedDialog.jsx +++ b/src/components/dialogs/notificationDialogUtils/NotificationCollaborationApprovedDialog.jsx @@ -4,12 +4,14 @@ import { get } from 'lodash-es'; import usePatchCollaboration from '../../../models/collaboration/usePatchCollaboration'; import { notificationSchema } from '../../../constants/notificationSchema'; import NotificationDetailsDialog from '../NotificationDetailsDialog'; +import { useHistory } from 'react-router-dom'; export default function NotificationCollaborationApprovedDialog({ open, onClose, notification, }) { + const history = useHistory(); const notificationType = notification?.message_type; const currentNotificationSchema = get( notificationSchema, @@ -37,6 +39,7 @@ export default function NotificationCollaborationApprovedDialog({ ], }); if (response?.status === 200) onClose(); + history.push(`/user-profile/#collab-card`); }; const availableButtons = [ { diff --git a/src/components/dialogs/notificationDialogUtils/NotificationCollaborationEditApprovedDialog.jsx b/src/components/dialogs/notificationDialogUtils/NotificationCollaborationEditApprovedDialog.jsx index 5060bd142..45234e009 100644 --- a/src/components/dialogs/notificationDialogUtils/NotificationCollaborationEditApprovedDialog.jsx +++ b/src/components/dialogs/notificationDialogUtils/NotificationCollaborationEditApprovedDialog.jsx @@ -4,12 +4,14 @@ import { get } from 'lodash-es'; import usePatchCollaboration from '../../../models/collaboration/usePatchCollaboration'; import { notificationSchema } from '../../../constants/notificationSchema'; import NotificationDetailsDialog from '../NotificationDetailsDialog'; +import { useHistory } from 'react-router-dom'; export default function NotificationCollaborationEditApprovedDialog({ open, onClose, notification, }) { + const history = useHistory(); const notificationType = notification?.message_type; const currentNotificationSchema = get( notificationSchema, @@ -37,6 +39,7 @@ export default function NotificationCollaborationEditApprovedDialog({ ], }); if (response?.status === 200) onClose(); + history.push(`/user-profile/#collab-card`); }; const availableButtons = [ { diff --git a/src/components/dialogs/notificationDialogUtils/NotificationCollaborationEditRequestDialog.jsx b/src/components/dialogs/notificationDialogUtils/NotificationCollaborationEditRequestDialog.jsx index 35ced2c30..948bc38fa 100644 --- a/src/components/dialogs/notificationDialogUtils/NotificationCollaborationEditRequestDialog.jsx +++ b/src/components/dialogs/notificationDialogUtils/NotificationCollaborationEditRequestDialog.jsx @@ -4,12 +4,14 @@ import { get } from 'lodash-es'; import usePatchCollaboration from '../../../models/collaboration/usePatchCollaboration'; import { notificationSchema } from '../../../constants/notificationSchema'; import NotificationDetailsDialog from '../NotificationDetailsDialog'; +import { useHistory } from 'react-router-dom'; export default function NotificationCollaborationEditRequestDialog({ open, onClose, notification, }) { + const history = useHistory(); const notificationType = notification?.message_type; const currentNotificationSchema = get( notificationSchema, @@ -37,6 +39,7 @@ export default function NotificationCollaborationEditRequestDialog({ ], }); if (response?.status === 200) onClose(); + history.push(`/user-profile/#collab-card`); }; const onClickDecline = async () => { const response = await patchCollaboration({ @@ -50,6 +53,7 @@ export default function NotificationCollaborationEditRequestDialog({ ], }); if (response?.status === 200) onClose(); + history.push(`/user-profile/#collab-card`); }; const availableButtons = [ { diff --git a/src/components/dialogs/notificationDialogUtils/NotificationCollaborationExportApprovedDialog.jsx b/src/components/dialogs/notificationDialogUtils/NotificationCollaborationExportApprovedDialog.jsx new file mode 100644 index 000000000..be73d0f57 --- /dev/null +++ b/src/components/dialogs/notificationDialogUtils/NotificationCollaborationExportApprovedDialog.jsx @@ -0,0 +1,66 @@ +import React from 'react'; +import { get } from 'lodash-es'; + +import usePatchCollaboration from '../../../models/collaboration/usePatchCollaboration'; +import { notificationSchema } from '../../../constants/notificationSchema'; +import NotificationDetailsDialog from '../NotificationDetailsDialog'; +import { useHistory } from 'react-router-dom'; + +export default function NotificationCollaborationExportApprovedDialog({ + open, + onClose, + notification, +}) { + const history = useHistory(); + const notificationType = notification?.message_type; + const currentNotificationSchema = get( + notificationSchema, + notificationType, + ); + const path = get(currentNotificationSchema, 'path'); + const { + mutate: patchCollaboration, + error, + isError, + } = usePatchCollaboration(); + const collaborationGuid = get(notification, [ + 'message_values', + 'collaboration_guid', + ]); + const onClickRevoke = async () => { + const response = await patchCollaboration({ + collaborationGuid, + operations: [ + { + op: 'replace', + path, + value: 'revoked', + }, + ], + }); + if (response?.status === 200) onClose(); + history.push(`/user-profile/#collab-card`); + }; + const availableButtons = [ + { + name: 'revoke', + buttonId: 'REVOKE_ACCESS', + onClick: onClickRevoke, + }, + ]; + return ( + + ); +} diff --git a/src/components/dialogs/notificationDialogUtils/NotificationCollaborationExportDeniedDialog.jsx b/src/components/dialogs/notificationDialogUtils/NotificationCollaborationExportDeniedDialog.jsx new file mode 100644 index 000000000..5fcb9f19e --- /dev/null +++ b/src/components/dialogs/notificationDialogUtils/NotificationCollaborationExportDeniedDialog.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 NotificationCollaborationExportDeniedDialog({ + notification, + onClose, + open, +}) { + const notificationType = notification?.message_type; + const currentNotificationSchema = get( + notificationSchema, + notificationType, + ); + const availableButtons = []; + return ( + + ); +} diff --git a/src/components/dialogs/notificationDialogUtils/NotificationCollaborationExportRequestDialog.jsx b/src/components/dialogs/notificationDialogUtils/NotificationCollaborationExportRequestDialog.jsx new file mode 100644 index 000000000..4d4ceaeec --- /dev/null +++ b/src/components/dialogs/notificationDialogUtils/NotificationCollaborationExportRequestDialog.jsx @@ -0,0 +1,85 @@ +import React from 'react'; +import { get } from 'lodash-es'; + +import usePatchCollaboration from '../../../models/collaboration/usePatchCollaboration'; +import { notificationSchema } from '../../../constants/notificationSchema'; +import NotificationDetailsDialog from '../NotificationDetailsDialog'; +import { useHistory } from 'react-router-dom'; + +export default function NotificationCollaborationExportRequestDialog({ + open, + onClose, + notification, +}) { + const history = useHistory(); + const notificationType = notification?.message_type; + const currentNotificationSchema = get( + notificationSchema, + notificationType, + ); + const path = get(currentNotificationSchema, 'path'); + const { + mutate: patchCollaboration, + error, + isError, + } = usePatchCollaboration(); + const collaborationGuid = get(notification, [ + 'message_values', + 'collaboration_guid', + ]); + const onClickGrant = async () => { + const response = await patchCollaboration({ + collaborationGuid, + operations: [ + { + op: 'replace', + path, + value: 'approved', + }, + ], + }); + if (response?.status === 200) onClose(); + history.push(`/user-profile/#collab-card`); + }; + const onClickDecline = async () => { + const response = await patchCollaboration({ + collaborationGuid, + operations: [ + { + op: 'replace', + path, + value: 'denied', + }, + ], + }); + if (response?.status === 200) onClose(); + history.push(`/user-profile/#collab-card`); + }; + const availableButtons = [ + { + name: 'grant', + buttonId: 'GRANT_ACCESS', + onClick: onClickGrant, + }, + { + name: 'decline', + buttonId: 'DECLINE_REQUEST', + onClick: onClickDecline, + }, + ]; + return ( + + ); +} diff --git a/src/components/dialogs/notificationDialogUtils/NotificationCollaborationExportRevokeDialog.jsx b/src/components/dialogs/notificationDialogUtils/NotificationCollaborationExportRevokeDialog.jsx new file mode 100644 index 000000000..683ba6277 --- /dev/null +++ b/src/components/dialogs/notificationDialogUtils/NotificationCollaborationExportRevokeDialog.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 NotificationCollaborationExportRevokeDialog({ + notification, + onClose, + open, +}) { + const notificationType = notification?.message_type; + const currentNotificationSchema = get( + notificationSchema, + notificationType, + ); + const availableButtons = []; + return ( + + ); +} diff --git a/src/components/dialogs/notificationDialogUtils/NotificationCollaborationManagerExportApprovedDialog.jsx b/src/components/dialogs/notificationDialogUtils/NotificationCollaborationManagerExportApprovedDialog.jsx new file mode 100644 index 000000000..6a50fb3d8 --- /dev/null +++ b/src/components/dialogs/notificationDialogUtils/NotificationCollaborationManagerExportApprovedDialog.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 NotificationCollaborationManagerExportApprovedDialog({ + notification, + onClose, + open, +}) { + const notificationType = notification?.message_type; + const currentNotificationSchema = get( + notificationSchema, + notificationType, + ); + const availableButtons = []; + return ( + + ); +} diff --git a/src/components/dialogs/notificationDialogUtils/NotificationCollaborationManagerExportDeniedDialog.jsx b/src/components/dialogs/notificationDialogUtils/NotificationCollaborationManagerExportDeniedDialog.jsx new file mode 100644 index 000000000..ea3d62ae5 --- /dev/null +++ b/src/components/dialogs/notificationDialogUtils/NotificationCollaborationManagerExportDeniedDialog.jsx @@ -0,0 +1,31 @@ + +import React from 'react'; +import { get } from 'lodash-es'; +import { notificationSchema } from '../../../constants/notificationSchema'; +import NotificationDetailsDialog from '../NotificationDetailsDialog'; + +export default function NotificationCollaborationManagerExportDeniedDialog({ + notification, + onClose, + open, +}) { + const notificationType = notification?.message_type; + const currentNotificationSchema = get( + notificationSchema, + notificationType, + ); + const availableButtons = []; + return ( + + ); +} diff --git a/src/components/dialogs/notificationDialogUtils/NotificationCollaborationManagerExportRevokeDialog.jsx b/src/components/dialogs/notificationDialogUtils/NotificationCollaborationManagerExportRevokeDialog.jsx new file mode 100644 index 000000000..b4823b4c9 --- /dev/null +++ b/src/components/dialogs/notificationDialogUtils/NotificationCollaborationManagerExportRevokeDialog.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 NotificationCollaborationManagerExportRevokeDialog({ + notification, + onClose, + open, +}) { + const notificationType = notification?.message_type; + const currentNotificationSchema = get( + notificationSchema, + notificationType, + ); + const availableButtons = []; + return ( + + ); +} diff --git a/src/components/dialogs/notificationDialogUtils/NotificationCollaborationRequestDialog.jsx b/src/components/dialogs/notificationDialogUtils/NotificationCollaborationRequestDialog.jsx index a6d577969..cdf8fb9de 100644 --- a/src/components/dialogs/notificationDialogUtils/NotificationCollaborationRequestDialog.jsx +++ b/src/components/dialogs/notificationDialogUtils/NotificationCollaborationRequestDialog.jsx @@ -4,12 +4,14 @@ import { get } from 'lodash-es'; import usePatchCollaboration from '../../../models/collaboration/usePatchCollaboration'; import { notificationSchema } from '../../../constants/notificationSchema'; import NotificationDetailsDialog from '../NotificationDetailsDialog'; +import { useHistory } from 'react-router-dom'; export default function NotificationCollaborationRequestDialog({ open, onClose, notification, }) { + const history = useHistory(); const notificationType = notification?.message_type; const currentNotificationSchema = get( notificationSchema, @@ -37,6 +39,7 @@ export default function NotificationCollaborationRequestDialog({ ], }); if (response?.status === 200) onClose(); + history.push(`/user-profile/#collab-card`); }; const onClickDecline = async () => { const response = await patchCollaboration({ @@ -50,6 +53,7 @@ export default function NotificationCollaborationRequestDialog({ ], }); if (response?.status === 200) onClose(); + history.push(`/user-profile/#collab-card`); }; const availableButtons = [ { diff --git a/src/components/dialogs/notificationDialogUtils/index.js b/src/components/dialogs/notificationDialogUtils/index.js index 40c7a1410..d99566c12 100644 --- a/src/components/dialogs/notificationDialogUtils/index.js +++ b/src/components/dialogs/notificationDialogUtils/index.js @@ -15,6 +15,13 @@ import NotificationCollaborationManagerEditRevokeDialog from './NotificationColl import NotificationCollaborationEditDeniedDialog from './NotificationCollaborationEditDeniedDialog'; import NotificationCollaborationManagerDeniedDialog from './NotificationCollaborationManagerDeniedDialog'; import NotificationCollaborationManagerEditDeniedDialog from './NotificationCollaborationManagerEditDeniedDialog'; +import NotificationCollaborationExportRequestDialog from './NotificationCollaborationExportRequestDialog'; +import NotificationCollaborationExportApprovedDialog from './NotificationCollaborationExportApprovedDialog'; +import NotificationCollaborationExportRevokeDialog from './NotificationCollaborationExportRevokeDialog'; +import NotificationCollaborationExportDeniedDialog from './NotificationCollaborationExportDeniedDialog'; +import NotificationCollaborationManagerExportApprovedDialog from './NotificationCollaborationManagerExportApprovedDialog'; +import NotificationCollaborationManagerExportRevokeDialog from './NotificationCollaborationManagerExportRevokeDialog'; +import NotificationCollaborationManagerExportDeniedDialog from './NotificationCollaborationManagerExportDeniedDialog'; import { notificationTypeNames } from '../../../constants/notificationSchema'; @@ -35,6 +42,12 @@ export const notificationTypes = { NotificationCollaborationEditApprovedDialog, [notificationTypeNames.collaboration_edit_revoke]: NotificationCollaborationEditRevokeDialog, + [notificationTypeNames.collaboration_export_request]: + NotificationCollaborationExportRequestDialog, + [notificationTypeNames.collaboration_export_approved]: + NotificationCollaborationExportApprovedDialog, + [notificationTypeNames.collaboration_export_revoke]: + NotificationCollaborationExportRevokeDialog, [notificationTypeNames.collaboration_manager_revoke]: NotificationCollaborationManagerRevokeDialog, [notificationTypeNames.individual_merge_request]: @@ -49,8 +62,16 @@ export const notificationTypes = { NotificationCollaborationManagerEditRevokeDialog, [notificationTypeNames.collaboration_edit_denied]: NotificationCollaborationEditDeniedDialog, + [notificationTypeNames.collaboration_manager_export_approved]: + NotificationCollaborationManagerExportApprovedDialog, + [notificationTypeNames.collaboration_manager_export_revoke]: + NotificationCollaborationManagerExportRevokeDialog, + [notificationTypeNames.collaboration_export_denied]: + NotificationCollaborationExportDeniedDialog, [notificationTypeNames.collaboration_manager_denied]: NotificationCollaborationManagerDeniedDialog, [notificationTypeNames.collaboration_manager_edit_denied]: NotificationCollaborationManagerEditDeniedDialog, + [notificationTypeNames.collaboration_manager_export_denied]: + NotificationCollaborationManagerExportDeniedDialog, }; diff --git a/src/constants/notificationSchema.js b/src/constants/notificationSchema.js index 3e88a412b..e8bb562f9 100644 --- a/src/constants/notificationSchema.js +++ b/src/constants/notificationSchema.js @@ -4,6 +4,9 @@ export const notificationTypeNames = { collaboration_approved: 'collaboration_approved', collaboration_revoke: 'collaboration_revoke', collaboration_denied: 'collaboration_denied', + collaboration_export_request: 'collaboration_export_request', + collaboration_export_approved: 'collaboration_export_approved', + collaboration_export_revoke: 'collaboration_export_revoke', collaboration_edit_request: 'collaboration_edit_request', collaboration_edit_approved: 'collaboration_edit_approved', collaboration_edit_revoke: 'collaboration_edit_revoke', @@ -14,12 +17,19 @@ export const notificationTypeNames = { collaboration_manager_edit_approved: 'collaboration_manager_edit_approved', + collaboration_manager_export_approved: + 'collaboration_manager_export_approved', collaboration_manager_edit_revoke: 'collaboration_manager_edit_revoke', + collaboration_manager_export_revoke: + 'collaboration_manager_export_revoke', collaboration_edit_denied: 'collaboration_edit_denied', + collaboration_export_denied: 'collaboration_export_denied', collaboration_manager_denied: 'collaboration_manager_denied', collaboration_manager_edit_denied: 'collaboration_manager_edit_denied', + collaboration_manager_export_denied: + 'collaboration_manager_export_denied', }; const notificationSchemaPlaceholder = {}; @@ -33,7 +43,19 @@ notificationSchemaPlaceholder[ moreDetailedDescription: 'EDIT_COLLABORATION_DENIED_BY_USER_MANAGER_MESSAGE', showNotificationDialog: false, - buttonPath: '/#collab-card', + buttonPath: '/user-profile/#collab-card', +}; + +notificationSchemaPlaceholder[ + notificationTypeNames.collaboration_manager_export_denied +] = { + titleId: 'EXPORT_COLLABORATION_DENIED_BY_USER_MANAGER', + notificationMessage: + 'EXPORT_COLLABORATION_DENIED_BY_USER_MANAGER_MESSAGE', + moreDetailedDescription: + 'EXPORT_COLLABORATION_DENIED_BY_USER_MANAGER_MESSAGE', + showNotificationDialog: false, + buttonPath: '/user-profile/#collab-card', }; notificationSchemaPlaceholder[ @@ -45,8 +67,21 @@ notificationSchemaPlaceholder[ moreDetailedDescription: 'EDIT_COLLABORATION_WAS_APPROVED_BY_A_USER_MANAGER', showNotificationDialog: false, - buttonPath: '/#collab-card', + buttonPath: '/user-profile/#collab-card', +}; + +notificationSchemaPlaceholder[ + notificationTypeNames.collaboration_manager_export_approved +] = { + titleId: 'EXPORT_COLLABORATION_APPROVED_BY_USER_MANAGER', + notificationMessage: + 'EXPORT_COLLABORATION_WAS_APPROVED_BY_A_USER_MANAGER', + moreDetailedDescription: + 'EXPORT_COLLABORATION_WAS_APPROVED_BY_A_USER_MANAGER', + showNotificationDialog: false, + buttonPath: '/user-profile/#collab-card', }; + notificationSchemaPlaceholder[ notificationTypeNames.collaboration_manager_denied ] = { @@ -55,7 +90,7 @@ notificationSchemaPlaceholder[ moreDetailedDescription: 'COLLABORATION_DENIED_BY_USER_MANAGER_MESSAGE', showNotificationDialog: false, - buttonPath: '/#collab-card', + buttonPath: '/user-profile/#collab-card', }; notificationSchemaPlaceholder[ notificationTypeNames.collaboration_edit_denied @@ -64,8 +99,19 @@ notificationSchemaPlaceholder[ notificationMessage: 'EDIT_COLLABORATION_DENIED_MESSAGE', moreDetailedDescription: 'EDIT_COLLABORATION_DENIED_MESSAGE', showNotificationDialog: false, - buttonPath: '/#collab-card', + buttonPath: '/user-profile/#collab-card', +}; + +notificationSchemaPlaceholder[ + notificationTypeNames.collaboration_export_denied +] = { + titleId: 'COLLABORATION_EXPORT_DENIED', + notificationMessage: 'EXPORT_COLLABORATION_DENIED_MESSAGE', + moreDetailedDescription: 'EXPORT_COLLABORATION_DENIED_MESSAGE', + showNotificationDialog: false, + buttonPath: '/user-profile/#collab-card', }; + notificationSchemaPlaceholder[ notificationTypeNames.collaboration_manager_edit_revoke ] = { @@ -75,8 +121,21 @@ notificationSchemaPlaceholder[ moreDetailedDescription: 'EDIT_COLLABORATION_WAS_REVOKED_BY_A_USER_MANAGER', showNotificationDialog: false, - buttonPath: '/#collab-card', + buttonPath: '/user-profile/#collab-card', }; + +notificationSchemaPlaceholder[ + notificationTypeNames.collaboration_manager_export_revoke +] = { + titleId: 'EXPORT_COLLABORATION_REVOKED_BY_USER_MANAGER', + notificationMessage: + 'EXPORT_COLLABORATION_WAS_REVOKED_BY_A_USER_MANAGER', + moreDetailedDescription: + 'EXPORT_COLLABORATION_WAS_REVOKED_BY_A_USER_MANAGER', + showNotificationDialog: false, + buttonPath: '/user-profile/#collab-card', +}; + notificationSchemaPlaceholder[ notificationTypeNames.collaboration_manager_create ] = { @@ -85,7 +144,7 @@ notificationSchemaPlaceholder[ moreDetailedDescription: 'A_COLLABORATION_WAS_CREATED_ON_YOUR_BEHALF_MORE_DETAILED', showNotificationDialog: false, - buttonPath: '/#collab-card', + buttonPath: '/user-profile/#collab-card', }; notificationSchemaPlaceholder[ notificationTypeNames.collaboration_request @@ -104,7 +163,7 @@ notificationSchemaPlaceholder[ moreDetailedDescription: 'COLLABORATION_APPROVED', showNotificationDialog: false, path: '/view_permission', - buttonPath: '/#collab-card', + buttonPath: '/user-profile/#collab-card', }; notificationSchemaPlaceholder[ notificationTypeNames.collaboration_revoke @@ -113,7 +172,7 @@ notificationSchemaPlaceholder[ notificationMessage: 'COLLABORATION_REVOKE_BRIEF', moreDetailedDescription: 'COLLABORATION_REVOKE_BRIEF', showNotificationDialog: false, - buttonPath: '/#collab-card', + buttonPath: '/user-profile/#collab-card', }; notificationSchemaPlaceholder[ notificationTypeNames.collaboration_denied @@ -122,7 +181,7 @@ notificationSchemaPlaceholder[ notificationMessage: 'COLLABORATION_DENIED_BRIEF', moreDetailedDescription: 'COLLABORATION_DENIED_BRIEF', showNotificationDialog: false, - buttonPath: '/#collab-card', + buttonPath: '/user-profile/#collab-card', }; notificationSchemaPlaceholder[ notificationTypeNames.collaboration_edit_request @@ -133,6 +192,17 @@ notificationSchemaPlaceholder[ showNotificationDialog: true, path: '/edit_permission', }; + +notificationSchemaPlaceholder[ + notificationTypeNames.collaboration_export_request +] = { + titleId: 'COLLABORATION_EXPORT_REQUEST_TITLE', + notificationMessage: 'COLLABORATION_EXPORT_REQUEST_BRIEF', + moreDetailedDescription: 'COLLABORATION_EXPORT_REQUEST_DESCRIPTION', + showNotificationDialog: true, + path: '/export_permission', +}; + notificationSchemaPlaceholder[ notificationTypeNames.collaboration_edit_approved ] = { @@ -141,8 +211,20 @@ notificationSchemaPlaceholder[ moreDetailedDescription: 'EDIT_COLLABORATION_APPROVED', showNotificationDialog: false, path: '/edit_permission', - buttonPath: '/#collab-card', + buttonPath: '/user-profile/#collab-card', }; + +notificationSchemaPlaceholder[ + notificationTypeNames.collaboration_export_approved +] = { + titleId: 'COLLABORATION_EXPORT_APPROVED_TITLE', + notificationMessage: 'EXPORT_COLLABORATION_APPROVED', + moreDetailedDescription: 'EXPORT_COLLABORATION_APPROVED', + showNotificationDialog: false, + path: '/export_permission', + buttonPath: '/user-profile/#collab-card', +}; + notificationSchemaPlaceholder[ notificationTypeNames.collaboration_edit_revoke ] = { @@ -150,8 +232,19 @@ notificationSchemaPlaceholder[ notificationMessage: 'EDIT_COLLABORATION_REVOKED', moreDetailedDescription: 'EDIT_COLLABORATION_REVOKED', showNotificationDialog: false, - buttonPath: '/#collab-card', + buttonPath: '/user-profile/#collab-card', }; + +notificationSchemaPlaceholder[ + notificationTypeNames.collaboration_export_revoke +] = { + titleId: 'COLLABORATION_EXPORT_REVOKE_TITLE', + notificationMessage: 'EXPORT_COLLABORATION_REVOKED', + moreDetailedDescription: 'EXPORT_COLLABORATION_REVOKED', + showNotificationDialog: false, + buttonPath: '/user-profile/#collab-card', +}; + notificationSchemaPlaceholder[ notificationTypeNames.collaboration_manager_revoke ] = { @@ -159,7 +252,7 @@ notificationSchemaPlaceholder[ notificationMessage: 'COLLABORATION_REVOKED_BY_MANAGER', moreDetailedDescription: 'COLLABORATION_REVOKED_BY_MANAGER', showNotificationDialog: false, - buttonPath: '/#collab-card', + buttonPath: '/user-profile/#collab-card', }; notificationSchemaPlaceholder[ notificationTypeNames.individual_merge_request diff --git a/src/models/collaboration/useRequestExportAccess.js b/src/models/collaboration/useRequestExportAccess.js new file mode 100644 index 000000000..2fd18965b --- /dev/null +++ b/src/models/collaboration/useRequestExportAccess.js @@ -0,0 +1,10 @@ +import { usePost } from '../../hooks/useMutate'; +import queryKeys from '../../constants/queryKeys'; + +export default function useRequestEditAccess() { + return usePost({ + deriveUrl: ({ collaborationGuid }) => + `/collaborations/export_request/${collaborationGuid}`, + fetchKeys: [queryKeys.me], + }); +} diff --git a/src/pages/dataPage/DataPage.jsx b/src/pages/dataPage/DataPage.jsx index efc9c3da9..881e1619c 100644 --- a/src/pages/dataPage/DataPage.jsx +++ b/src/pages/dataPage/DataPage.jsx @@ -4,6 +4,7 @@ import { FormattedMessage, useIntl } from 'react-intl'; import { FormControl, MenuItem, Select } from '@material-ui/core'; import { useHistory } from 'react-router-dom'; import { useTheme } from '@material-ui/core/styles'; +import { get } from 'lodash-es'; import useGetUserSightings from '../../models/users/useGetUserSightings'; import useGetUserUnprocessedAssetGroupSightings from '../../models/users/useGetUserUnproccessedAssetGroupSightings'; // import { formatUserMessage } from '../../utils/formatters'; @@ -20,10 +21,16 @@ import useDeleteSighting from '../../models/sighting/useDeleteSighting'; import useDeleteAssetGroupSighting from '../../models/assetGroupSighting/useDeleteAssetGroupSighting'; import ConfirmDelete from '../../components/ConfirmDelete'; import Paginator from '../../components/dataDisplays/Paginator'; +import ProfileSetup from '../home/ProfileSetup'; +import useDocumentTitle from '../../hooks/useDocumentTitle'; export default function DataPage() { const { data: userData, loading: userDataLoading } = useGetMe(); + const fullName = get(userData, ['full_name']); + + useDocumentTitle('HOME', { refreshKey: fullName }); + const theme = useTheme(); const history = useHistory(); @@ -102,6 +109,8 @@ export default function DataPage() { : deleteSightingOnClearError; if (userDataLoading) return ; + // if (error) handle error + if (!fullName) return ; return ( diff --git a/src/pages/fieldManagement/settings/DefaultFieldTable.jsx b/src/pages/fieldManagement/settings/DefaultFieldTable.jsx index 465a520e1..0475c50a3 100644 --- a/src/pages/fieldManagement/settings/DefaultFieldTable.jsx +++ b/src/pages/fieldManagement/settings/DefaultFieldTable.jsx @@ -95,7 +95,6 @@ export default function DefaultFieldTable({ siteSettings }) { const onSubmit = async () => { if (editField?.id === 'region') { - console.log('formSettings.regions', formSettings.regions); const response = await putSiteSetting({ property: editField.backendPath, data: formSettings.regions, diff --git a/src/pages/home/Home.jsx b/src/pages/home/Home.jsx index 7ae911e7e..bdec6f853 100644 --- a/src/pages/home/Home.jsx +++ b/src/pages/home/Home.jsx @@ -33,11 +33,13 @@ export default function Home() { if (!fullName) return ; const isUserManager = get(data, ['is_user_manager'], false); + const isUserAdmin = get(data, ['is_admin'], false); return ( ; const viewerIsUserManager = get(me, ['is_user_manager'], false); + const viewerIsUserAdmin = get(me, ['is_admin'], false); return ( -