From 09bdaa6dd66684b341ddd0741f236252fedd719f Mon Sep 17 00:00:00 2001 From: Abhishek P Anil Date: Fri, 2 Feb 2024 13:23:01 +0530 Subject: [PATCH 01/15] feat: added changes to event services api --- .../Dropdown/EventStatus/EventStatus.jsx | 32 +++++++++++++------ src/constants/eventPublishOptions.js | 4 +++ src/locales/en/translationEn.json | 6 ++-- src/locales/fr/transalationFr.json | 6 ++-- src/pages/Dashboard/AddEvent/AddEvent.jsx | 18 ++++++++--- src/services/events.js | 4 +-- 6 files changed, 50 insertions(+), 20 deletions(-) diff --git a/src/components/Dropdown/EventStatus/EventStatus.jsx b/src/components/Dropdown/EventStatus/EventStatus.jsx index 6c88b8357..5103b81e2 100644 --- a/src/components/Dropdown/EventStatus/EventStatus.jsx +++ b/src/components/Dropdown/EventStatus/EventStatus.jsx @@ -24,7 +24,7 @@ function EventStatusOptions({ children, publishState, creator, eventId, isFeatur const items = eventPublishOptions.map((item) => { if (publishState == eventPublishState.PUBLISHED) { - if (item.key != '0') { + if (item.key != '0' && item.key != '6') { if (isFeatured) { if (item.key !== '4') { return { @@ -45,12 +45,21 @@ function EventStatusOptions({ children, publishState, creator, eventId, isFeatur } } else { if (publishState == eventPublishState.DRAFT || publishState === eventPublishState.PENDING_REVIEW) - if (item.key != '1' && item.key !== '5' && item.key !== '4') - return { - key: item?.key, - label: item?.label, - type: item?.type, - }; + if (item.key != '1' && item.key !== '5' && item.key !== '4') { + if (item.key === '6') { + if (publishState === eventPublishState.PENDING_REVIEW) + return { + key: item?.key, + label: item?.label, + type: item?.type, + }; + } else + return { + key: item?.key, + label: item?.label, + type: item?.type, + }; + } if (item?.type === 'divider') return { key: item?.key, @@ -76,8 +85,13 @@ function EventStatusOptions({ children, publishState, creator, eventId, isFeatur }; const onClick = ({ key }) => { if (key == '2') showDeleteConfirm(); - else if (key === '0' || key === '1') { - updateEventState({ id: eventId, calendarId: calendarId }) + else if (key === '0' || key === '1' || key === '6') { + updateEventState({ + id: eventId, + calendarId: calendarId, + publishState: + key === '6' || key === '1' ? eventPublishState.DRAFT : key === '0' ? eventPublishState.PUBLISHED : undefined, + }) .unwrap() .then(() => {}) .catch(() => { diff --git a/src/constants/eventPublishOptions.js b/src/constants/eventPublishOptions.js index 6596b334c..7ff313f87 100644 --- a/src/constants/eventPublishOptions.js +++ b/src/constants/eventPublishOptions.js @@ -5,6 +5,10 @@ export const eventPublishOptions = [ label: {(t) => t('dashboard.events.publishOptions.publishEvent')}, key: '0', }, + { + label: {(t) => t('dashboard.events.publishOptions.revertToDraft')}, + key: '6', + }, { label: {(t) => t('dashboard.events.publishOptions.unpublishEvent')}, key: '1', diff --git a/src/locales/en/translationEn.json b/src/locales/en/translationEn.json index 1343c415a..1cc2c239e 100644 --- a/src/locales/en/translationEn.json +++ b/src/locales/en/translationEn.json @@ -340,7 +340,8 @@ "publish": "Publish", "saveAsDraft": "Save as draft", "save": "Save", - "sendToReview": "Send to review" + "sendToReview": "Send to review", + "revertToDraft": "Revert to draft" }, "notification": { "saveAsDraft": "Success! Your event has been saved as draft.", @@ -423,7 +424,8 @@ "featureEvent": "Feature this event", "unFeatureEvent": "Unfeature this event", "deleteEvent": "Delete event", - "duplicateEvent": "Duplicate Event" + "duplicateEvent": "Duplicate Event", + "revertToDraft":"Revert to draft" }, "publishState": { "published": "Published", diff --git a/src/locales/fr/transalationFr.json b/src/locales/fr/transalationFr.json index e26147d00..1d0491df6 100644 --- a/src/locales/fr/transalationFr.json +++ b/src/locales/fr/transalationFr.json @@ -339,7 +339,8 @@ "publish": "Publier", "saveAsDraft": "Enregistrer comme brouillon", "save": "Sauvegarder", - "sendToReview": "Envoyer pour révision" + "sendToReview": "Envoyer pour révision", + "revertToDraft": "Revenir au brouillon" }, "notification": { "saveAsDraft": "Succès! Votre événement a été enregistré comme brouillon.", @@ -423,7 +424,8 @@ "deleteEvent": "Supprimer l'événement", "duplicateEvent": "Dupliquer l’événement", "featureEvent": "Mettre en vedette", - "unFeatureEvent": "Retirer la mise en vedette" + "unFeatureEvent": "Retirer la mise en vedette", + "revertToDraft": "Revenir au brouillon" }, "publishState": { "published": "Publié", diff --git a/src/pages/Dashboard/AddEvent/AddEvent.jsx b/src/pages/Dashboard/AddEvent/AddEvent.jsx index 81dd4b90c..9e9f5a09a 100644 --- a/src/pages/Dashboard/AddEvent/AddEvent.jsx +++ b/src/pages/Dashboard/AddEvent/AddEvent.jsx @@ -734,7 +734,7 @@ function AddEvent() { return promise; }; - const reviewPublishHandler = (event) => { + const reviewPublishHandler = (event, publishState = undefined) => { event?.preventDefault(); const isValuesChanged = showDialog; setShowDialog(false); @@ -744,7 +744,7 @@ function AddEvent() { if (isValuesChanged) saveAsDraftHandler(event, true) .then((id) => { - updateEventState({ id: eventId ?? id, calendarId }) + updateEventState({ id: eventId ?? id, calendarId, publishState }) .unwrap() .then(() => { notification.success({ @@ -765,7 +765,7 @@ function AddEvent() { }) .catch((error) => console.log(error)); else - updateEventState({ id: eventId, calendarId }) + updateEventState({ id: eventId, calendarId, publishState }) .unwrap() .then(() => { notification.success({ @@ -823,8 +823,16 @@ function AddEvent() { saveAsDraftHandler(e)} + label={ + eventData?.publishState === eventPublishState.PENDING_REVIEW + ? t('dashboard.events.addEditEvent.saveOptions.revertToDraft') + : t('dashboard.events.addEditEvent.saveOptions.saveAsDraft') + } + onClick={(e) => { + if (eventData?.publishState === eventPublishState.PENDING_REVIEW) + reviewPublishHandler(e, eventPublishState.DRAFT); + else saveAsDraftHandler(e); + }} data-cy="button-save-event" disabled={updateEventLoading || addEventLoading || addImageLoading ? true : false} /> diff --git a/src/services/events.js b/src/services/events.js index 8eab3a35c..ba59a6911 100644 --- a/src/services/events.js +++ b/src/services/events.js @@ -30,8 +30,8 @@ export const eventsApi = createApi({ transformResponse: (response) => response, }), updateEventState: builder.mutation({ - query: ({ id, calendarId }) => ({ - url: `events/${id}/toggle-publish`, + query: ({ id, calendarId, publishState = undefined }) => ({ + url: `events/${id}/toggle-publish?publishState=${publishState ?? ''}`, method: 'PATCH', headers: { 'calendar-id': calendarId, From aa49ff427e40de3024f2e908018d2c3a6a2e6079 Mon Sep 17 00:00:00 2001 From: Abhishek P Anil Date: Mon, 19 Feb 2024 12:13:27 +0530 Subject: [PATCH 02/15] feat: added the translation and conditions for displaying event send back for review closes culturecreates/tech-support-tickets/issues/39 --- src/locales/en/translationEn.json | 5 +++-- src/locales/fr/transalationFr.json | 5 +++-- src/pages/Dashboard/AddEvent/AddEvent.jsx | 25 ++++++++++++++++++++++- 3 files changed, 30 insertions(+), 5 deletions(-) diff --git a/src/locales/en/translationEn.json b/src/locales/en/translationEn.json index 1cc2c239e..094731e35 100644 --- a/src/locales/en/translationEn.json +++ b/src/locales/en/translationEn.json @@ -347,7 +347,8 @@ "saveAsDraft": "Success! Your event has been saved as draft.", "sendToReview": "Success! Your event has been sent for review.", "publish": "Success! Your event has been published", - "updateEvent": "Success! Your event has been updated." + "updateEvent": "Success! Your event has been updated.", + "editFailedReviewForGuest": "This event needs attention. Review and update as needed, and then send to review." }, "validations": { "title": "Event title is required.", @@ -425,7 +426,7 @@ "unFeatureEvent": "Unfeature this event", "deleteEvent": "Delete event", "duplicateEvent": "Duplicate Event", - "revertToDraft":"Revert to draft" + "revertToDraft": "Revert to draft" }, "publishState": { "published": "Published", diff --git a/src/locales/fr/transalationFr.json b/src/locales/fr/transalationFr.json index 1d0491df6..60a67ca68 100644 --- a/src/locales/fr/transalationFr.json +++ b/src/locales/fr/transalationFr.json @@ -114,7 +114,7 @@ }, "readOnlyEvent": { "notification": { - "underReview": "Cet événement est en train d'être valider.", + "underReview": "Cet événement est en train d'être validé.", "underPublished": "Cet événement a été publié. Si vous voulez faire des changements, veuillez contacter l'administrateur du calendrier." } }, @@ -346,7 +346,8 @@ "saveAsDraft": "Succès! Votre événement a été enregistré comme brouillon.", "sendToReview": "Succès! Votre événement a été envoyé pour validation.", "publish": "Succès! Votre événement a été publié.", - "updateEvent": "Succès! Votre événement a été mis à jour." + "updateEvent": "Succès! Votre événement a été mis à jour.", + "editFailedReviewForGuest": "Cet événement a besoin de plus d'attention. Réviser et mettre à jour si nécessaire, puis envoyer pour validation." }, "validations": { "title": "Le titre de l'événement est requis.", diff --git a/src/pages/Dashboard/AddEvent/AddEvent.jsx b/src/pages/Dashboard/AddEvent/AddEvent.jsx index 9e9f5a09a..4b4a1d269 100644 --- a/src/pages/Dashboard/AddEvent/AddEvent.jsx +++ b/src/pages/Dashboard/AddEvent/AddEvent.jsx @@ -90,6 +90,7 @@ import { artsDataLinkChecker } from '../../../utils/artsDataLinkChecker'; import KeyboardAccessibleLayout from '../../../layout/KeyboardAccessibleLayout/KeyboardAccessibleLayout'; import CustomPopover from '../../../components/Popover/Popover'; import { removeEmptyParagraphsAtEnd } from '../../../utils/removeEmptyParagraphsAtEnd'; +import Alert from '../../../components/Alert'; const { TextArea } = Input; @@ -841,7 +842,7 @@ function AddEvent() { reviewPublishHandler(e)} + onClick={(e) => reviewPublishHandler(e, eventPublishState.PUBLISHED)} disabled={ updateEventLoading || addEventLoading || updateEventStateLoading || addImageLoading ? true : false } @@ -1492,6 +1493,28 @@ function AddEvent() { + {eventData?.publishState === eventPublishState.DRAFT && + eventData?.reviewFailed && + calendar[0]?.role === userRoles.GUEST && + eventData?.creator?.userId == user?.id && ( + + + + + + } + additionalClassName="alert-warning" + /> + + + + + + )} <> From 31c14363dea6b0b27709839633c31afe0aa59045 Mon Sep 17 00:00:00 2001 From: Abhishek P Anil Date: Tue, 20 Feb 2024 15:17:29 +0530 Subject: [PATCH 03/15] feat: added read only modal and the condition to check read only --- src/constants/calendarModes.js | 4 +++ src/locales/en/translationEn.json | 6 +++++ src/locales/fr/transalationFr.json | 6 +++++ src/pages/Dashboard/Dashboard.jsx | 39 ++++++++++++++++++++++++++++-- src/pages/Dashboard/dashboard.css | 11 +++++++++ 5 files changed, 64 insertions(+), 2 deletions(-) create mode 100644 src/constants/calendarModes.js diff --git a/src/constants/calendarModes.js b/src/constants/calendarModes.js new file mode 100644 index 000000000..4c0e9d044 --- /dev/null +++ b/src/constants/calendarModes.js @@ -0,0 +1,4 @@ +export const calendarModes = { + READ_ONLY: 'ReadOnly', + READ_WRITE: 'ReadWrite', +}; diff --git a/src/locales/en/translationEn.json b/src/locales/en/translationEn.json index 07e987437..eedb6fe06 100644 --- a/src/locales/en/translationEn.json +++ b/src/locales/en/translationEn.json @@ -68,6 +68,12 @@ "acceptInvitationSuccess": "Success! Invitation accepted." }, "dashboard": { + "calendar": { + "readOnlyMode": { + "heading": "Calendar in read only mode", + "content": "The calendar is currently read only. Editing is unavailable for users. Try again later or contact your admin for details." + } + }, "topNavigation": { "userProfile": "User Profile", "logOut": "Log out", diff --git a/src/locales/fr/transalationFr.json b/src/locales/fr/transalationFr.json index 072d59f5c..0115b90c6 100644 --- a/src/locales/fr/transalationFr.json +++ b/src/locales/fr/transalationFr.json @@ -68,6 +68,12 @@ "acceptInvitationSuccess": "Success ! Invitation acceptée." }, "dashboard": { + "calendar": { + "readOnlyMode": { + "heading": "Calendrier en mode lecture seule", + "content": "Le calendrier est actuellement en mode lecture seule. Les utilisateurs ne peuvent pas modifier son contenu. Réessayez plus tard ou contactez votre administrateur pour plus de détails." + } + }, "topNavigation": { "userProfile": "Profil", "logOut": "Déconnexion", diff --git a/src/pages/Dashboard/Dashboard.jsx b/src/pages/Dashboard/Dashboard.jsx index 2256d201f..100f59fd5 100644 --- a/src/pages/Dashboard/Dashboard.jsx +++ b/src/pages/Dashboard/Dashboard.jsx @@ -1,6 +1,6 @@ import React, { useEffect, useRef, useState } from 'react'; import './dashboard.css'; -import { Grid, Layout } from 'antd'; +import { Grid, Layout, Row, Col } from 'antd'; import { Outlet, useLocation, useSearchParams } from 'react-router-dom'; import NavigationBar from '../../components/NavigationBar/Dashboard'; import Sidebar from '../../components/Sidebar/Main'; @@ -19,6 +19,9 @@ import i18n from 'i18next'; import Cookies from 'js-cookie'; import { useLazyGetCurrentUserQuery } from '../../services/users'; import ErrorLayout from '../../layout/ErrorLayout/ErrorLayout'; +import CustomModal from '../../components/Modal/Common/CustomModal'; +import { useTranslation } from 'react-i18next'; +import { calendarModes } from '../../constants/calendarModes'; const { Header, Content } = Layout; const { useBreakpoint } = Grid; @@ -32,6 +35,7 @@ function Dashboard() { const [getCalendar, { currentData: currentCalendarData }] = useLazyGetCalendarQuery(); const reloadStatus = useSelector(getReloadStatusForCalendar); const screens = useBreakpoint(); + const { t } = useTranslation(); const { currentData: allCalendarsData, @@ -49,6 +53,7 @@ function Dashboard() { searchParams.get('page') ? searchParams.get('page') : Cookies.get('page') ?? 1, ); const [contentBackgroundColor, setContentBackgroundColor] = useState('#fff'); + const [isReadOnly, setIsReadOnly] = useState(false); useEffect(() => { if (!accessToken && accessToken === '') { @@ -84,7 +89,18 @@ function Dashboard() { } if (calendarId && accessToken) { - getCalendar({ id: calendarId, sessionId: timestampRef }); + getCalendar({ id: calendarId, sessionId: timestampRef }) + .unwrap() + .then((response) => { + if (response?.mode === calendarModes.READ_ONLY) { + setIsReadOnly(true); + } else setIsReadOnly(false); + }) + .catch((error) => { + if (error.status === 404) { + navigate(PathName.NotFound); + } + }); dispatch(setSelectedCalendar(String(calendarId))); } else { let activeCalendarId = Cookies.get('calendarId'); @@ -146,6 +162,25 @@ function Dashboard() { overflowY: 'scroll', background: contentBackgroundColor, }}> + + {t('dashboard.calendar.readOnlyMode.heading')} + + } + onCancel={() => setIsReadOnly(false)} + footer={false}> + + +
+ {t('dashboard.calendar.readOnlyMode.content')} +
+ +
+
diff --git a/src/pages/Dashboard/dashboard.css b/src/pages/Dashboard/dashboard.css index eb10daf23..2dcae14e7 100644 --- a/src/pages/Dashboard/dashboard.css +++ b/src/pages/Dashboard/dashboard.css @@ -20,6 +20,17 @@ background: #f9faff; } +.calendar-read-only-modal .ant-modal-header .calendar-read-only-title { + font-weight: 700; + font-size: 20px; + color: #222732; +} + +.calendar-read-only-modal .ant-modal-body .calendar-read-only-content { + font-weight: 400; + font-size: 16px; + color: #646d7b; +} @media only screen and (max-width: 428px) { .dashboard-wrapper .site-layout-background { padding: 16px; From a7c5ccfc987713d4e01fb1793f6638445532c598 Mon Sep 17 00:00:00 2001 From: Abhishek P Anil Date: Wed, 21 Feb 2024 13:11:52 +0530 Subject: [PATCH 04/15] feat: restricted access to edit event from list and also direct access in read only --- .../Dropdown/EventStatus/EventStatus.jsx | 5 +- src/components/List/Events/List.jsx | 65 ++++++++++--------- .../ProtectedComponents.jsx | 35 +++++----- .../ReadOnlyProtectedComponent.jsx | 32 ++++----- src/pages/Dashboard/AddEvent/AddEvent.jsx | 18 ++++- src/pages/Dashboard/Dashboard.jsx | 15 ++++- 6 files changed, 99 insertions(+), 71 deletions(-) diff --git a/src/components/Dropdown/EventStatus/EventStatus.jsx b/src/components/Dropdown/EventStatus/EventStatus.jsx index 6c88b8357..fe0c9a1ab 100644 --- a/src/components/Dropdown/EventStatus/EventStatus.jsx +++ b/src/components/Dropdown/EventStatus/EventStatus.jsx @@ -11,13 +11,14 @@ import { useFeatureEventsMutation, useUpdateEventStateMutation, } from '../../../services/events'; -import { useNavigate, useParams } from 'react-router-dom'; +import { useNavigate, useOutletContext, useParams } from 'react-router-dom'; import { PathName } from '../../../constants/pathName'; const { confirm } = Modal; function EventStatusOptions({ children, publishState, creator, eventId, isFeatured, eventData, ...rest }) { const { t } = useTranslation(); const { calendarId } = useParams(); const navigate = useNavigate(); + const [, , , , , isReadOnly] = useOutletContext(); const [updateEventState] = useUpdateEventStateMutation(); const [deleteEvent] = useDeleteEventMutation(); const [featureEvents] = useFeatureEventsMutation(); @@ -127,7 +128,7 @@ function EventStatusOptions({ children, publishState, creator, eventId, isFeatur } }; return ( - + { - if (routinghandler(user, calendarId, creatorId, publishState)) + if (routinghandler(user, calendarId, creatorId, publishState, false, isReadOnly)) navigate(`${location.pathname}${PathName.AddEvent}/${id}`); else navigate(`${location.pathname}/${id}`); }; @@ -74,36 +74,39 @@ function Lists(props) { actions={[ calendar[0]?.role === userRoles.GUEST || (calendar[0]?.role === userRoles.CONTRIBUTOR && eventItem?.creator?.userId != user?.id) ? ( - { - if (open) setSelectedItemId(eventItem?.id); - else setSelectedItemId(null); - }} - overlayStyle={{ - minWidth: '150px', - }} - getPopupContainer={(trigger) => trigger.parentNode} - menu={{ - items: [ - { - key: '0', - label: t('dashboard.events.publishOptions.duplicateEvent'), + !isReadOnly && ( + { + if (open) setSelectedItemId(eventItem?.id); + else setSelectedItemId(null); + }} + overlayStyle={{ + minWidth: '150px', + }} + getPopupContainer={(trigger) => trigger.parentNode} + menu={{ + items: [ + { + key: '0', + label: t('dashboard.events.publishOptions.duplicateEvent'), + }, + ], + onClick: ({ key }) => { + if (key === '0') + navigate(`${location.pathname}${PathName.AddEvent}?duplicateId=${eventItem?.id}`); }, - ], - onClick: ({ key }) => { - if (key === '0') navigate(`${location.pathname}${PathName.AddEvent}?duplicateId=${eventItem?.id}`); - }, - }} - trigger={['click']}> - - - - + }} + trigger={['click']}> + + + + + ) ) : ( { diff --git a/src/layout/ProtectedComponents/ProtectedComponents.jsx b/src/layout/ProtectedComponents/ProtectedComponents.jsx index 73463e894..cbbe26346 100644 --- a/src/layout/ProtectedComponents/ProtectedComponents.jsx +++ b/src/layout/ProtectedComponents/ProtectedComponents.jsx @@ -3,7 +3,7 @@ import { useSelector } from 'react-redux'; import { getUserDetails } from '../../redux/reducer/userSlice'; import { userRoles } from '../../constants/userRoles'; -function ProtectedComponents({ children, creator, isEntity }) { +function ProtectedComponents({ children, creator, isEntity, isReadOnly }) { let { calendarId } = useParams(); const { user } = useSelector(getUserDetails); if (user.isSuperAdmin) { @@ -13,23 +13,24 @@ function ProtectedComponents({ children, creator, isEntity }) { const calendar = user?.roles.filter((calendar) => { return calendar.calendarId === calendarId; }); - - switch (calendar[0]?.role) { - case userRoles.GUEST: - if (isEntity == true) { + if (isReadOnly) return; + else + switch (calendar[0]?.role) { + case userRoles.GUEST: + if (isEntity == true) { + if (user?.id === creator?.userId) return children; + } else return; + break; + case userRoles.CONTRIBUTOR: if (user?.id === creator?.userId) return children; - } else return; - break; - case userRoles.CONTRIBUTOR: - if (user?.id === creator?.userId) return children; - else return; - case userRoles.EDITOR: - return children; - case userRoles.ADMIN: - return children; - default: - return; - } + else return; + case userRoles.EDITOR: + return children; + case userRoles.ADMIN: + return children; + default: + return; + } } export default ProtectedComponents; diff --git a/src/layout/ReadOnlyProtectedComponent/ReadOnlyProtectedComponent.jsx b/src/layout/ReadOnlyProtectedComponent/ReadOnlyProtectedComponent.jsx index a913584d3..1528d3a20 100644 --- a/src/layout/ReadOnlyProtectedComponent/ReadOnlyProtectedComponent.jsx +++ b/src/layout/ReadOnlyProtectedComponent/ReadOnlyProtectedComponent.jsx @@ -3,7 +3,7 @@ import { useSelector } from 'react-redux'; import { getUserDetails } from '../../redux/reducer/userSlice'; import { userRoles } from '../../constants/userRoles'; -function ReadOnlyProtectedComponent({ children, creator }) { +function ReadOnlyProtectedComponent({ children, creator, isReadOnly }) { let { calendarId } = useParams(); const { user } = useSelector(getUserDetails); @@ -15,20 +15,22 @@ function ReadOnlyProtectedComponent({ children, creator }) { return calendar.calendarId === calendarId; }); - switch (calendar[0]?.role) { - case userRoles.GUEST: - if (user?.id === creator) return children; - else return; - case userRoles.CONTRIBUTOR: - if (user?.id === creator) return children; - else return; - case userRoles.EDITOR: - return children; - case userRoles.ADMIN: - return children; - default: - return; - } + if (isReadOnly) return; + else + switch (calendar[0]?.role) { + case userRoles.GUEST: + if (user?.id === creator) return children; + else return; + case userRoles.CONTRIBUTOR: + if (user?.id === creator) return children; + else return; + case userRoles.EDITOR: + return children; + case userRoles.ADMIN: + return children; + default: + return; + } } export default ReadOnlyProtectedComponent; diff --git a/src/pages/Dashboard/AddEvent/AddEvent.jsx b/src/pages/Dashboard/AddEvent/AddEvent.jsx index dc9b41c7d..895caea02 100644 --- a/src/pages/Dashboard/AddEvent/AddEvent.jsx +++ b/src/pages/Dashboard/AddEvent/AddEvent.jsx @@ -111,6 +111,7 @@ function AddEvent() { _setPageNumber, // eslint-disable-next-line no-unused-vars _getCalendar, setContentBackgroundColor, + isReadOnly, ] = useOutletContext(); const { currentData: eventData, @@ -1102,7 +1103,8 @@ function AddEvent() { if (calendarId && eventData && currentCalendarData) { let initialAddedFields = [], isRecurring = false; - if (routinghandler(user, calendarId, eventData?.creator?.userId, eventData?.publishState) || duplicateId) { + + if (routinghandler(user, calendarId, eventData?.creator?.userId, eventData?.publishState, false) || duplicateId) { if (eventData?.recurringEvent && Object.keys(eventData?.recurringEvent)?.length > 0) isRecurring = true; setDateType( dateTimeTypeHandler( @@ -1326,8 +1328,11 @@ function AddEvent() { }, }); } - } else - window.location.replace(`${location?.origin}${PathName.Dashboard}/${calendarId}${PathName.Events}/${eventId}`); + } else { + navigate(`${PathName.Dashboard}/${calendarId}${PathName.Events}/${eventId}`, { + replace: true, + }); + } } }, [isLoading, currentCalendarData]); @@ -1436,6 +1441,13 @@ function AddEvent() { } }, [initialEntityLoading, currentCalendarData, initialExternalSourceLoading]); + useEffect(() => { + if (isReadOnly) { + if (eventId) navigate(`${PathName.Dashboard}/${calendarId}${PathName.Events}/${eventId}`, { replace: true }); + else navigate(`${PathName.Dashboard}/${calendarId}${PathName.Events}`, { replace: true }); + } + }, [isReadOnly]); + return !isLoading && !taxonomyLoading && !initialEntityLoading && diff --git a/src/pages/Dashboard/Dashboard.jsx b/src/pages/Dashboard/Dashboard.jsx index 100f59fd5..0efb79d7f 100644 --- a/src/pages/Dashboard/Dashboard.jsx +++ b/src/pages/Dashboard/Dashboard.jsx @@ -54,6 +54,7 @@ function Dashboard() { ); const [contentBackgroundColor, setContentBackgroundColor] = useState('#fff'); const [isReadOnly, setIsReadOnly] = useState(false); + const [isModalVisible, setIsModalVisible] = useState(false); useEffect(() => { if (!accessToken && accessToken === '') { @@ -94,6 +95,7 @@ function Dashboard() { .then((response) => { if (response?.mode === calendarModes.READ_ONLY) { setIsReadOnly(true); + setIsModalVisible(true); } else setIsReadOnly(false); }) .catch((error) => { @@ -163,7 +165,7 @@ function Dashboard() { background: contentBackgroundColor, }}> } - onCancel={() => setIsReadOnly(false)} + onCancel={() => setIsModalVisible(false)} footer={false}> @@ -182,7 +184,14 @@ function Dashboard() { From fc87242e61b8d70d17c2010373a2d7f8cf953a85 Mon Sep 17 00:00:00 2001 From: Abhishek P Anil Date: Wed, 21 Feb 2024 13:18:51 +0530 Subject: [PATCH 05/15] feat: restricted the options menu in listing pages for all workspaces --- src/pages/Dashboard/Dashboard.jsx | 2 +- src/pages/Dashboard/Organizations/Organizations.jsx | 3 ++- src/pages/Dashboard/People/People.jsx | 3 ++- src/pages/Dashboard/Places/Places.jsx | 3 ++- .../Dashboard/Settings/UserManagement/UserManagement.jsx | 5 +++-- src/pages/Dashboard/Taxonomy/Taxonomy.jsx | 3 ++- 6 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/pages/Dashboard/Dashboard.jsx b/src/pages/Dashboard/Dashboard.jsx index 0efb79d7f..febbb80fc 100644 --- a/src/pages/Dashboard/Dashboard.jsx +++ b/src/pages/Dashboard/Dashboard.jsx @@ -96,7 +96,7 @@ function Dashboard() { if (response?.mode === calendarModes.READ_ONLY) { setIsReadOnly(true); setIsModalVisible(true); - } else setIsReadOnly(false); + } else setIsReadOnly(true); }) .catch((error) => { if (error.status === 404) { diff --git a/src/pages/Dashboard/Organizations/Organizations.jsx b/src/pages/Dashboard/Organizations/Organizations.jsx index 74bcf69ee..eb5b9278a 100644 --- a/src/pages/Dashboard/Organizations/Organizations.jsx +++ b/src/pages/Dashboard/Organizations/Organizations.jsx @@ -50,6 +50,7 @@ function Organizations() { _setPageNumber, // eslint-disable-next-line no-unused-vars _getCalendar, setContentBackgroundColor, + isReadOnly, ] = useOutletContext(); setContentBackgroundColor('#fff'); @@ -251,7 +252,7 @@ function Organizations() { artsDataLink={artsDataLinkChecker(item?.sameAs)} listItemHandler={() => listItemHandler(item?.id)} actions={[ - adminCheckHandler() && ( + adminCheckHandler() && !isReadOnly && ( listItemHandler(item?.id)} actions={[ - adminCheckHandler() && ( + adminCheckHandler() && !isReadOnly && ( listItemHandler(item?.id)} actions={[ - adminCheckHandler() && ( + adminCheckHandler() && !isReadOnly && ( { const { t } = useTranslation(); const { user } = useSelector(getUserDetails); let [searchParams, setSearchParams] = useSearchParams(); + const [, , , , , isReadOnly] = useOutletContext(); const navigate = useNavigate(); const screens = useBreakpoint(); @@ -592,7 +593,7 @@ const UserManagement = () => { styles={handleListCardStyles(item)} invitedBy={item?.invitedBy && } actions={[ - adminCheckHandler() && ( + adminCheckHandler() && !isReadOnly && ( { if (open) setSelectedItemId(item?._id); diff --git a/src/pages/Dashboard/Taxonomy/Taxonomy.jsx b/src/pages/Dashboard/Taxonomy/Taxonomy.jsx index d9f7dc230..c097685d8 100644 --- a/src/pages/Dashboard/Taxonomy/Taxonomy.jsx +++ b/src/pages/Dashboard/Taxonomy/Taxonomy.jsx @@ -47,6 +47,7 @@ const Taxonomy = () => { _setPageNumber, // eslint-disable-next-line no-unused-vars getCalendar, setContentBackgroundColor, + isReadOnly, ] = useOutletContext(); setContentBackgroundColor('#fff'); const navigate = useNavigate(); @@ -442,7 +443,7 @@ const Taxonomy = () => { updatedByUserName={item?.modifier?.userName} listItemHandler={() => listItemHandler(item?.id)} actions={[ - adminCheckHandler() && ( + adminCheckHandler() && !isReadOnly && ( Date: Wed, 21 Feb 2024 13:23:30 +0530 Subject: [PATCH 06/15] feat: restricted access to taxonomy edit from listing page --- src/pages/Dashboard/Dashboard.jsx | 2 +- src/pages/Dashboard/Taxonomy/Taxonomy.jsx | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/pages/Dashboard/Dashboard.jsx b/src/pages/Dashboard/Dashboard.jsx index febbb80fc..0efb79d7f 100644 --- a/src/pages/Dashboard/Dashboard.jsx +++ b/src/pages/Dashboard/Dashboard.jsx @@ -96,7 +96,7 @@ function Dashboard() { if (response?.mode === calendarModes.READ_ONLY) { setIsReadOnly(true); setIsModalVisible(true); - } else setIsReadOnly(true); + } else setIsReadOnly(false); }) .catch((error) => { if (error.status === 404) { diff --git a/src/pages/Dashboard/Taxonomy/Taxonomy.jsx b/src/pages/Dashboard/Taxonomy/Taxonomy.jsx index c097685d8..a09e77ede 100644 --- a/src/pages/Dashboard/Taxonomy/Taxonomy.jsx +++ b/src/pages/Dashboard/Taxonomy/Taxonomy.jsx @@ -189,6 +189,7 @@ const Taxonomy = () => { }; const listItemHandler = (id) => { adminCheckHandler() && + !isReadOnly && navigate(`${PathName.Dashboard}/${calendarId}${PathName.Taxonomies}${PathName.AddTaxonomy}?id=${id}`); }; const deleteOrganizationHandler = (id) => { From e192a48e415a3c1064925398300f7cb0419fd67f Mon Sep 17 00:00:00 2001 From: Abhishek P Anil Date: Wed, 21 Feb 2024 13:28:37 +0530 Subject: [PATCH 07/15] feat: add buttons in all workspaces are disabled if readonly --- src/pages/Dashboard/Events/Events.jsx | 2 ++ src/pages/Dashboard/Organizations/Organizations.jsx | 1 + src/pages/Dashboard/People/People.jsx | 1 + src/pages/Dashboard/Places/Places.jsx | 1 + .../Dashboard/Settings/UserManagement/UserManagement.jsx | 5 +++-- src/pages/Dashboard/Taxonomy/Taxonomy.jsx | 1 + 6 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/pages/Dashboard/Events/Events.jsx b/src/pages/Dashboard/Events/Events.jsx index 36f653772..800b1cbaf 100644 --- a/src/pages/Dashboard/Events/Events.jsx +++ b/src/pages/Dashboard/Events/Events.jsx @@ -49,6 +49,7 @@ function Events() { setPageNumber, // eslint-disable-next-line no-unused-vars _getCalendar, setContentBackgroundColor, + isReadOnly, ] = useOutletContext(); setContentBackgroundColor('#fff'); @@ -565,6 +566,7 @@ function Events() { navigate(`${PathName.Dashboard}/${calendarId}${PathName.Organizations}${PathName.Search}`) diff --git a/src/pages/Dashboard/People/People.jsx b/src/pages/Dashboard/People/People.jsx index 0c8984a28..781cb2007 100644 --- a/src/pages/Dashboard/People/People.jsx +++ b/src/pages/Dashboard/People/People.jsx @@ -175,6 +175,7 @@ function People() { { navigate(`${PathName.Dashboard}/${calendarId}${PathName.People}${PathName.Search}`); diff --git a/src/pages/Dashboard/Places/Places.jsx b/src/pages/Dashboard/Places/Places.jsx index 9fa9102bb..bd75d8e92 100644 --- a/src/pages/Dashboard/Places/Places.jsx +++ b/src/pages/Dashboard/Places/Places.jsx @@ -178,6 +178,7 @@ function Places() { { navigate(`${PathName.Dashboard}/${calendarId}${PathName.Places}${PathName.Search}`); }} diff --git a/src/pages/Dashboard/Settings/UserManagement/UserManagement.jsx b/src/pages/Dashboard/Settings/UserManagement/UserManagement.jsx index 682a50c7e..ecedd31f2 100644 --- a/src/pages/Dashboard/Settings/UserManagement/UserManagement.jsx +++ b/src/pages/Dashboard/Settings/UserManagement/UserManagement.jsx @@ -395,7 +395,7 @@ const UserManagement = () => { } }; - const addEventHandler = () => { + const addUserHandler = () => { navigate(`${PathName.Dashboard}/${calendarId}${PathName.Settings}${PathName.UserManagement}${PathName.AddUser}`); }; @@ -476,8 +476,9 @@ const UserManagement = () => { diff --git a/src/pages/Dashboard/Taxonomy/Taxonomy.jsx b/src/pages/Dashboard/Taxonomy/Taxonomy.jsx index a09e77ede..44b36b13b 100644 --- a/src/pages/Dashboard/Taxonomy/Taxonomy.jsx +++ b/src/pages/Dashboard/Taxonomy/Taxonomy.jsx @@ -259,6 +259,7 @@ const Taxonomy = () => { Date: Wed, 21 Feb 2024 13:32:51 +0530 Subject: [PATCH 08/15] feat: added the disabled button css --- src/components/Button/AddEvent/addEvent.css | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/components/Button/AddEvent/addEvent.css b/src/components/Button/AddEvent/addEvent.css index 073f7f5af..ba8ab665a 100644 --- a/src/components/Button/AddEvent/addEvent.css +++ b/src/components/Button/AddEvent/addEvent.css @@ -12,3 +12,10 @@ background-color: #0f0e98; border-color: #0f0e98; } + +.add-event-button[disabled], +.add-event-button[disabled]:hover { + background-color: #9196a3; + border-color: #9196a3; + color: #ffffff; +} From e801638bd62c7b92e472af0fcd997a42f66accb1 Mon Sep 17 00:00:00 2001 From: Abhishek P Anil Date: Wed, 21 Feb 2024 13:44:25 +0530 Subject: [PATCH 09/15] feat: edit button in read only page for person,org ,place is not shown for read only but users are editable --- .../OrganizationsReadOnly/OrganizationsReadOnly.jsx | 3 ++- src/pages/Dashboard/PersonReadOnly/PersonReadOnly.jsx | 3 ++- src/pages/Dashboard/PlaceReadOnly/PlaceReadOnly.jsx | 3 ++- .../Dashboard/Settings/UserManagement/UserManagement.jsx | 6 ++---- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/pages/Dashboard/OrganizationsReadOnly/OrganizationsReadOnly.jsx b/src/pages/Dashboard/OrganizationsReadOnly/OrganizationsReadOnly.jsx index 75f7346e7..d404cf146 100644 --- a/src/pages/Dashboard/OrganizationsReadOnly/OrganizationsReadOnly.jsx +++ b/src/pages/Dashboard/OrganizationsReadOnly/OrganizationsReadOnly.jsx @@ -38,6 +38,7 @@ function OrganizationsReadOnly() { _setPageNumber, // eslint-disable-next-line no-unused-vars _getCalendar, setContentBackgroundColor, + isReadOnly, ] = useOutletContext(); setContentBackgroundColor('#F9FAFF'); @@ -155,7 +156,7 @@ function OrganizationsReadOnly() { - +
- +
- +
{ const { t } = useTranslation(); const { user } = useSelector(getUserDetails); let [searchParams, setSearchParams] = useSearchParams(); - const [, , , , , isReadOnly] = useOutletContext(); const navigate = useNavigate(); const screens = useBreakpoint(); @@ -476,7 +475,6 @@ const UserManagement = () => { { styles={handleListCardStyles(item)} invitedBy={item?.invitedBy && } actions={[ - adminCheckHandler() && !isReadOnly && ( + adminCheckHandler() && ( { if (open) setSelectedItemId(item?._id); From d3f361130201311e5251eb916bc09348286219a3 Mon Sep 17 00:00:00 2001 From: Abhishek P Anil Date: Wed, 21 Feb 2024 13:52:52 +0530 Subject: [PATCH 10/15] feat: restricted access to search pages in different workspace --- .../Dashboard/SearchOrganizations/SearchOrganizations.jsx | 6 ++++++ src/pages/Dashboard/SearchPerson/SearchPerson.jsx | 7 +++++++ src/pages/Dashboard/SearchPlaces/SearchPlaces.jsx | 7 +++++++ .../Dashboard/SelectTaxonomyType/SelectTaxonomyType.jsx | 7 +++++++ 4 files changed, 27 insertions(+) diff --git a/src/pages/Dashboard/SearchOrganizations/SearchOrganizations.jsx b/src/pages/Dashboard/SearchOrganizations/SearchOrganizations.jsx index 6353cd109..6f3dc5672 100644 --- a/src/pages/Dashboard/SearchOrganizations/SearchOrganizations.jsx +++ b/src/pages/Dashboard/SearchOrganizations/SearchOrganizations.jsx @@ -32,6 +32,7 @@ function SearchOrganizations() { _setPageNumber, // eslint-disable-next-line no-unused-vars _getCalendar, setContentBackgroundColor, + isReadOnly, ] = useOutletContext(); setContentBackgroundColor('#F9FAFF'); const navigate = useNavigate(); @@ -109,6 +110,11 @@ function SearchOrganizations() { }) .catch((error) => console.log(error)); }; + useEffect(() => { + if (isReadOnly) { + navigate(`${PathName.Dashboard}/${calendarId}${PathName.Organizations}`, { replace: true }); + } + }, [isReadOnly]); const debounceSearch = useCallback(useDebounce(searchHandler, SEARCH_DELAY), []); diff --git a/src/pages/Dashboard/SearchPerson/SearchPerson.jsx b/src/pages/Dashboard/SearchPerson/SearchPerson.jsx index 2c12a9883..58d34ef84 100644 --- a/src/pages/Dashboard/SearchPerson/SearchPerson.jsx +++ b/src/pages/Dashboard/SearchPerson/SearchPerson.jsx @@ -32,6 +32,7 @@ function SearchPerson() { _setPageNumber, // eslint-disable-next-line no-unused-vars _getCalendar, setContentBackgroundColor, + isReadOnly, ] = useOutletContext(); setContentBackgroundColor('#F9FAFF'); const navigate = useNavigate(); @@ -109,6 +110,12 @@ function SearchPerson() { .catch((error) => console.log(error)); }; + useEffect(() => { + if (isReadOnly) { + navigate(`${PathName.Dashboard}/${calendarId}${PathName.People}`, { replace: true }); + } + }, [isReadOnly]); + const debounceSearch = useCallback(useDebounce(searchHandler, SEARCH_DELAY), []); return ( diff --git a/src/pages/Dashboard/SearchPlaces/SearchPlaces.jsx b/src/pages/Dashboard/SearchPlaces/SearchPlaces.jsx index 98b05cf67..3b2a0b3f7 100644 --- a/src/pages/Dashboard/SearchPlaces/SearchPlaces.jsx +++ b/src/pages/Dashboard/SearchPlaces/SearchPlaces.jsx @@ -32,6 +32,7 @@ function SearchPlaces() { _setPageNumber, // eslint-disable-next-line no-unused-vars _getCalendar, setContentBackgroundColor, + isReadOnly, ] = useOutletContext(); setContentBackgroundColor('#F9FAFF'); const navigate = useNavigate(); @@ -107,6 +108,12 @@ function SearchPlaces() { .catch((error) => console.log(error)); }; + useEffect(() => { + if (isReadOnly) { + navigate(`${PathName.Dashboard}/${calendarId}${PathName.Places}`, { replace: true }); + } + }, [isReadOnly]); + const debounceSearch = useCallback(useDebounce(searchHandler, SEARCH_DELAY), []); return ( diff --git a/src/pages/Dashboard/SelectTaxonomyType/SelectTaxonomyType.jsx b/src/pages/Dashboard/SelectTaxonomyType/SelectTaxonomyType.jsx index fd942bf4a..d1e765a61 100644 --- a/src/pages/Dashboard/SelectTaxonomyType/SelectTaxonomyType.jsx +++ b/src/pages/Dashboard/SelectTaxonomyType/SelectTaxonomyType.jsx @@ -24,6 +24,7 @@ const SelectTaxonomyType = () => { _setPageNumber, // eslint-disable-next-line no-unused-vars _getCalendar, setContentBackgroundColor, + isReadOnly, ] = useOutletContext(); setContentBackgroundColor('#F9FAFF'); const { user } = useSelector(getUserDetails); @@ -71,6 +72,12 @@ const SelectTaxonomyType = () => { formInstance.setFieldsValue({ [fieldType]: value }); }; + useEffect(() => { + if (isReadOnly) { + navigate(`${PathName.Dashboard}/${calendarId}${PathName.Taxonomies}`, { replace: true }); + } + }, [isReadOnly]); + return (
From efd5a2cee5cfe2477d8c19f28612b7970977ccf7 Mon Sep 17 00:00:00 2001 From: Abhishek P Anil Date: Wed, 21 Feb 2024 14:08:43 +0530 Subject: [PATCH 11/15] feat: restricted direct access to the forms other than usr form --- src/pages/Dashboard/AddTaxonomy/AddTaxonomy.jsx | 5 +++++ .../CreateNewOrganization/CreateNewOrganization.jsx | 9 +++++++++ src/pages/Dashboard/CreateNewPerson/CreateNewPerson.jsx | 8 ++++++++ src/pages/Dashboard/CreateNewPlace/CreateNewPlace.jsx | 8 ++++++++ 4 files changed, 30 insertions(+) diff --git a/src/pages/Dashboard/AddTaxonomy/AddTaxonomy.jsx b/src/pages/Dashboard/AddTaxonomy/AddTaxonomy.jsx index ab5f54524..46172e0b2 100644 --- a/src/pages/Dashboard/AddTaxonomy/AddTaxonomy.jsx +++ b/src/pages/Dashboard/AddTaxonomy/AddTaxonomy.jsx @@ -28,6 +28,7 @@ import { getUserDetails } from '../../../redux/reducer/userSlice'; import { setErrorStates } from '../../../redux/reducer/ErrorSlice'; import { Prompt } from '../../../hooks/usePrompt'; import { compareArraysOfObjects } from '../../../utils/genericObjectCompare'; +import { PathName } from '../../../constants/pathName'; const taxonomyClasses = taxonomyClassTranslations.map((item) => { return { ...item, value: item.key }; @@ -41,6 +42,7 @@ const AddTaxonomyTest = () => { _setPageNumber, // eslint-disable-next-line no-unused-vars getCalendar, setContentBackgroundColor, + isReadOnly, ] = useOutletContext(); let [searchParams, setSearchParams] = useSearchParams(); const [form] = Form.useForm(); @@ -274,6 +276,9 @@ const AddTaxonomyTest = () => { }); }; + useEffect(() => { + if (isReadOnly) navigate(`${PathName.Dashboard}/${calendarId}${PathName.Taxonomies}`, { replace: true }); + }, [isReadOnly]); return ( <> { + if (isReadOnly) { + if (organizationId) + navigate(`${PathName.Dashboard}/${calendarId}${PathName.Organizations}/${organizationId}`, { replace: true }); + else navigate(`${PathName.Dashboard}/${calendarId}${PathName.Organizations}`, { replace: true }); + } + }, [isReadOnly]); + useEffect(() => { if (artsDataId) { getArtsData(artsDataId); diff --git a/src/pages/Dashboard/CreateNewPerson/CreateNewPerson.jsx b/src/pages/Dashboard/CreateNewPerson/CreateNewPerson.jsx index 21ccba1e7..e41c83963 100644 --- a/src/pages/Dashboard/CreateNewPerson/CreateNewPerson.jsx +++ b/src/pages/Dashboard/CreateNewPerson/CreateNewPerson.jsx @@ -48,6 +48,7 @@ function CreateNewPerson() { _setPageNumber, // eslint-disable-next-line no-unused-vars _getCalendar, setContentBackgroundColor, + isReadOnly, ] = useOutletContext(); setContentBackgroundColor('#F9FAFF'); const { user } = useSelector(getUserDetails); @@ -398,6 +399,13 @@ function CreateNewPerson() { } }, [personLoading, currentCalendarData, externalEntityLoading]); + useEffect(() => { + if (isReadOnly) { + if (personId) navigate(`${PathName.Dashboard}/${calendarId}${PathName.People}/${personId}`, { replace: true }); + else navigate(`${PathName.Dashboard}/${calendarId}${PathName.People}`, { replace: true }); + } + }, [isReadOnly]); + useEffect(() => { if (artsDataId) { getArtsData(artsDataId); diff --git a/src/pages/Dashboard/CreateNewPlace/CreateNewPlace.jsx b/src/pages/Dashboard/CreateNewPlace/CreateNewPlace.jsx index 3ae95c322..7283ee0c2 100644 --- a/src/pages/Dashboard/CreateNewPlace/CreateNewPlace.jsx +++ b/src/pages/Dashboard/CreateNewPlace/CreateNewPlace.jsx @@ -91,6 +91,7 @@ function CreateNewPlace() { _setPageNumber, // eslint-disable-next-line no-unused-vars _getCalendar, setContentBackgroundColor, + isReadOnly, ] = useOutletContext(); setContentBackgroundColor('#F9FAFF'); const { user } = useSelector(getUserDetails); @@ -939,6 +940,13 @@ function CreateNewPlace() { } }, [isPlaceLoading, currentCalendarData, externalEntityLoading]); + useEffect(() => { + if (isReadOnly) { + if (placeId) navigate(`${PathName.Dashboard}/${calendarId}${PathName.Places}/${placeId}`, { replace: true }); + else navigate(`${PathName.Dashboard}/${calendarId}${PathName.Places}`, { replace: true }); + } + }, [isReadOnly]); + useEffect(() => { if (artsDataId) { getArtsDataPlace(artsDataId); From 243e0aa3e168fffd7ac08b1ca6ad3764918e93f3 Mon Sep 17 00:00:00 2001 From: Abhishek P Anil Date: Wed, 21 Feb 2024 16:20:19 +0530 Subject: [PATCH 12/15] feat: added read only mode tag for calendar dropdown --- src/components/Sidebar/Main/Sidebar.jsx | 35 +++++++++++++++++-------- src/locales/en/translationEn.json | 1 + src/locales/fr/transalationFr.json | 1 + 3 files changed, 26 insertions(+), 11 deletions(-) diff --git a/src/components/Sidebar/Main/Sidebar.jsx b/src/components/Sidebar/Main/Sidebar.jsx index 8596bb8cc..baaaa07c6 100644 --- a/src/components/Sidebar/Main/Sidebar.jsx +++ b/src/components/Sidebar/Main/Sidebar.jsx @@ -11,6 +11,7 @@ import { contentLanguageBilingual } from '../../../utils/bilingual'; import { useSelector } from 'react-redux'; import { getUserDetails } from '../../../redux/reducer/userSlice'; import { clearSessionStoredSearchQueries } from '../../../utils/clearSessionStoredSearchQueries'; +import { calendarModes } from '../../../constants/calendarModes'; const { Sider } = Layout; @@ -56,17 +57,29 @@ function Sidebar(props) {
), label: ( - <> - {label}{' '} - - +
+ + {label} + + + + {currentCalendarData?.mode === calendarModes.READ_ONLY && ( + + {t('dashboard.calendar.readOnlyMode.readOnlyMode')} + + )} +
), className: 'sidebar-calendar', }, diff --git a/src/locales/en/translationEn.json b/src/locales/en/translationEn.json index eedb6fe06..0222723e7 100644 --- a/src/locales/en/translationEn.json +++ b/src/locales/en/translationEn.json @@ -70,6 +70,7 @@ "dashboard": { "calendar": { "readOnlyMode": { + "readOnlyMode": "Read-only mode", "heading": "Calendar in read only mode", "content": "The calendar is currently read only. Editing is unavailable for users. Try again later or contact your admin for details." } diff --git a/src/locales/fr/transalationFr.json b/src/locales/fr/transalationFr.json index 0115b90c6..9e13991dd 100644 --- a/src/locales/fr/transalationFr.json +++ b/src/locales/fr/transalationFr.json @@ -70,6 +70,7 @@ "dashboard": { "calendar": { "readOnlyMode": { + "readOnlyMode": "Read-only mode", "heading": "Calendrier en mode lecture seule", "content": "Le calendrier est actuellement en mode lecture seule. Les utilisateurs ne peuvent pas modifier son contenu. Réessayez plus tard ou contactez votre administrateur pour plus de détails." } From 7986f490f91912af9ca68316900640fff5e9ad8d Mon Sep 17 00:00:00 2001 From: Abhishek P Anil Date: Wed, 21 Feb 2024 16:24:16 +0530 Subject: [PATCH 13/15] feat: added read only mode tag for responsive calendar dropdown --- .../Sidebar/Responsive/ResponsiveSidebar.jsx | 32 ++++++++++++++----- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/src/components/Sidebar/Responsive/ResponsiveSidebar.jsx b/src/components/Sidebar/Responsive/ResponsiveSidebar.jsx index d4630b959..d63e84a60 100644 --- a/src/components/Sidebar/Responsive/ResponsiveSidebar.jsx +++ b/src/components/Sidebar/Responsive/ResponsiveSidebar.jsx @@ -14,6 +14,7 @@ import { useTranslation } from 'react-i18next'; import CalendarList from '../../Dropdown/Calendar'; import { contentLanguageBilingual } from '../../../utils/bilingual'; import i18n from 'i18next'; +import { calendarModes } from '../../../constants/calendarModes'; function ResponsiveSidebar(props) { const { allCalendarsData, currentCalendarData, onClose, open, pageNumber, setPageNumber } = props; @@ -58,14 +59,29 @@ function ResponsiveSidebar(props) { /> ), label: ( - <> - {label}{' '} - - +
+ + {label} + + + + {currentCalendarData?.mode !== calendarModes.READ_ONLY && ( + + {t('dashboard.calendar.readOnlyMode.readOnlyMode')} + + )} +
), className: 'sidebar-calendar', }, From 144b9a409968e92d83c8d79b5eafec03efb36860 Mon Sep 17 00:00:00 2001 From: Abhishek P Anil Date: Wed, 21 Feb 2024 16:25:09 +0530 Subject: [PATCH 14/15] feat: added condtion for read only mode tag for responsive calendar dropdown --- src/components/Sidebar/Responsive/ResponsiveSidebar.jsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/Sidebar/Responsive/ResponsiveSidebar.jsx b/src/components/Sidebar/Responsive/ResponsiveSidebar.jsx index d63e84a60..9c576678f 100644 --- a/src/components/Sidebar/Responsive/ResponsiveSidebar.jsx +++ b/src/components/Sidebar/Responsive/ResponsiveSidebar.jsx @@ -64,7 +64,7 @@ function ResponsiveSidebar(props) { display: 'flex', flexDirection: 'column', }}> - + {label} - {currentCalendarData?.mode !== calendarModes.READ_ONLY && ( + {currentCalendarData?.mode === calendarModes.READ_ONLY && ( {t('dashboard.calendar.readOnlyMode.readOnlyMode')} From 9e6a4b1e129b71cd0c95e7cd7310d12b7598dd2b Mon Sep 17 00:00:00 2001 From: Abhishek P Anil Date: Wed, 21 Feb 2024 16:59:32 +0530 Subject: [PATCH 15/15] fix: fixed issue with saving validatio pop up for orgs --- src/pages/Dashboard/AddEvent/AddEvent.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/Dashboard/AddEvent/AddEvent.jsx b/src/pages/Dashboard/AddEvent/AddEvent.jsx index ead8b18b4..aa03f9862 100644 --- a/src/pages/Dashboard/AddEvent/AddEvent.jsx +++ b/src/pages/Dashboard/AddEvent/AddEvent.jsx @@ -302,7 +302,7 @@ function AddEvent() { 'eventLink', 'videoLink', 'facebookLink', - ...(eventData?.publishState === eventPublishState.PUBLISHED && type !== eventPublishState.DRAFT + ...(eventId && eventData?.publishState === eventPublishState.PUBLISHED && type !== eventPublishState.DRAFT ? validateFields : []), ]),