Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .env.staging
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
VITE_APP_API_URL="https://staging-api-cms.footlight.io"
VITE_APP_OPEN_API_URL="https://staging-api.footlight.io"
VITE_APP_ARTS_DATA_URI="https://api.artsdata.ca/"
VITE_APP_ARTS_DATA_PAGE_URI="https://kg.artsdata.ca/resource/"
VITE_APP_DEEPL_URL="https://www.deepl.com/translator#"
Expand Down
64 changes: 44 additions & 20 deletions src/components/Dropdown/EventStatus/EventStatus.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { ExclamationCircleOutlined } from '@ant-design/icons';
import { useTranslation } from 'react-i18next';
import { eventPublishOptions } from '../../../constants/eventPublishOptions';
import './eventStatus.css';
import ProtectedComponents from '../../../layout/ProtectedComponents';
import { eventPublishState } from '../../../constants/eventPublishState';
import { useNavigate, useOutletContext, useParams } from 'react-router-dom';
import { PathName } from '../../../constants/pathName';
Expand All @@ -23,6 +22,7 @@ function EventStatusOptions({
updateEventState,
deleteEvent,
featureEvents,
onGetStructuredData,
...rest
}) {
const { t } = useTranslation();
Expand All @@ -33,7 +33,20 @@ function EventStatusOptions({
const calendar = getCurrentCalendarDetailsFromUserDetails(user, calendarId);
const canFeature = [userRoles.ADMIN, userRoles.EDITOR].includes(calendar[0]?.role) || user?.isSuperAdmin;

const items = eventPublishOptions
// Write-action tier, reproducing the previous ProtectedComponents wrapper (super admin bypasses
// read-only) plus the duplicate-only dropdown the list rendered for guests and non-creator
// contributors. The dropdown itself now always renders so read actions stay available to everyone.
const role = calendar[0]?.role;
const isOwner = user?.id === creator?.userId;
let writeTier; // 'all' | 'duplicateOnly' | 'none'
if (user?.isSuperAdmin) writeTier = 'all';
else if (isReadOnly) writeTier = 'none';
else if (role === userRoles.ADMIN || role === userRoles.EDITOR) writeTier = 'all';
else if (role === userRoles.CONTRIBUTOR) writeTier = isOwner ? 'all' : 'duplicateOnly';
else if (role === userRoles.GUEST) writeTier = 'duplicateOnly';
else writeTier = 'none';

const publishStateItems = eventPublishOptions
.filter((item) => canFeature || (item.key !== '4' && item.key !== '5'))
.map((item) => {
if (publishState == eventPublishState.PUBLISHED) {
Expand Down Expand Up @@ -82,6 +95,18 @@ function EventStatusOptions({
}
});

let writeItems = [];
if (writeTier === 'all') writeItems = publishStateItems.filter(Boolean);
else if (writeTier === 'duplicateOnly') writeItems = eventPublishOptions.filter((item) => item.key === '3');
if (!writeItems.some((item) => item?.key)) writeItems = [];

const copyJsonLdItem = { key: '7', label: t('dashboard.events.publishOptions.copyJsonLd') };
const featureIndex = writeItems.findIndex((item) => item?.key === '4' || item?.key === '5');
const dividerIndex = writeItems.findIndex((item) => item?.type === 'divider');
const insertIndex = featureIndex !== -1 ? featureIndex + 1 : dividerIndex !== -1 ? dividerIndex : 0;

const items = [...writeItems.slice(0, insertIndex), copyJsonLdItem, ...writeItems.slice(insertIndex)];

const showDeleteConfirm = () => {
confirm({
title: t('dashboard.events.deleteEvent.title'),
Expand Down Expand Up @@ -110,7 +135,8 @@ function EventStatusOptions({
});
};
const onClick = ({ key }) => {
if (key == '2') showDeleteConfirm();
if (key === '7') onGetStructuredData && onGetStructuredData(eventData);
else if (key == '2') showDeleteConfirm();
else if (key === '0' || key === '1' || key === '6') {
const isPublishing = key === '0';
const isUnpublishing = key === '1' || key === '6';
Expand Down Expand Up @@ -163,23 +189,21 @@ function EventStatusOptions({
}
};
return (
<ProtectedComponents creator={creator} isReadOnly={isReadOnly}>
<Dropdown
{...rest}
className="calendar-dropdown-wrapper"
overlayClassName="event-dropdown-popup"
overlayStyle={{
minWidth: '150px',
}}
getPopupContainer={(trigger) => trigger.parentNode}
menu={{
items,
onClick,
}}
trigger={['click']}>
{children}
</Dropdown>
</ProtectedComponents>
<Dropdown
{...rest}
className="calendar-dropdown-wrapper"
overlayClassName="event-dropdown-popup"
overlayStyle={{
minWidth: '150px',
}}
getPopupContainer={(trigger) => trigger.parentNode}
menu={{
items,
onClick,
}}
trigger={['click']}>
{children}
</Dropdown>
);
}

Expand Down
Loading
Loading