From 9c737dd7c448860f8368a0e22d1a8e17d763e331 Mon Sep 17 00:00:00 2001 From: Thibault Reidy <147397675+ReidyT@users.noreply.github.com> Date: Thu, 13 Jun 2024 16:01:53 +0200 Subject: [PATCH] feat: restrict publication to folders only (#1284) - feat: improve the description components of the status button - feat: hide publication preview if type cannot be published - chore(dep): update sdk to 4.13.0 --- cypress/e2e/item/publish/publishedItem.cy.ts | 45 ++++++++++++++++++ cypress/fixtures/publish/publish.ts | 47 +++++++++++++++++++ package.json | 2 +- src/components/hooks/usePublicationStatus.tsx | 7 +++ .../item/publish/CoEditorsContainer.tsx | 8 +++- .../item/publish/ItemPublishTab.tsx | 47 +++++++++++++++---- .../publish/PublicationStatusComponent.tsx | 20 ++++++-- .../publicationButtons/InvalidButton.tsx | 12 +++-- .../NotAllowedItemTypeButton.tsx | 27 +++++++++++ .../publicationButtons/NotPublicButton.tsx | 8 +++- .../publicationButtons/OutdatedButton.tsx | 8 +++- .../publicationButtons/PendingButton.tsx | 13 ++--- .../PublicationButtonSelector.tsx | 3 ++ .../publicationButtons/PublishedButton.tsx | 6 ++- .../PublishedChildrenButton.tsx | 11 ++--- .../ReadyToPublishButton.tsx | 4 +- src/langs/constants.ts | 4 ++ src/langs/en.json | 3 ++ src/types/publication.ts | 1 + yarn.lock | 12 ++--- 20 files changed, 241 insertions(+), 47 deletions(-) create mode 100644 cypress/fixtures/publish/publish.ts create mode 100644 src/components/item/publish/publicationButtons/NotAllowedItemTypeButton.tsx diff --git a/cypress/e2e/item/publish/publishedItem.cy.ts b/cypress/e2e/item/publish/publishedItem.cy.ts index dfb157dbc..65b5b736c 100644 --- a/cypress/e2e/item/publish/publishedItem.cy.ts +++ b/cypress/e2e/item/publish/publishedItem.cy.ts @@ -1,11 +1,14 @@ import { ItemTagType, + ItemType, + ItemTypeUnion, ItemValidationGroup, ItemValidationStatus, Member, PackedFolderItemFactory, PackedItem, PermissionLevel, + PublishableItemTypeChecker, } from '@graasp/sdk'; import { PublicationStatus } from '@/types/publication'; @@ -24,6 +27,7 @@ import { PublishedItemFactory, } from '../../../fixtures/items'; import { MEMBERS } from '../../../fixtures/members'; +import { createPublicItemByType } from '../../../fixtures/publish/publish'; import { ItemForTest } from '../../../support/types'; const openPublishItemTab = (id: string) => { @@ -340,4 +344,45 @@ describe('Public Item', () => { waitOnUnpublishItem(publicItem); }); }); + + describe('Only authorized types can be published', () => { + const testItemType = ( + testTitle: string, + item: ItemForTest, + statusExpected: PublicationStatus, + ) => { + it(testTitle, () => { + setUpAndVisitItemPage(item); + openPublishItemTab(item.id); + getPublicationStatusComponent(statusExpected) + .should('exist') + .should('be.visible'); + }); + }; + + const testAuthorizedType = (item: ItemForTest) => { + testItemType( + `Publication should be allowed for type "${item.type}"`, + item, + PublicationStatus.Unpublished, + ); + }; + + const testUnauthorizedType = (item: ItemForTest) => { + testItemType( + `Publication should NOT be allowed for type "${item.type}"`, + item, + PublicationStatus.ItemTypeNotAllowed, + ); + }; + + Object.values(ItemType).forEach((itemType: ItemTypeUnion) => { + const item = createPublicItemByType(itemType); + if (PublishableItemTypeChecker.isItemTypeAllowedToBePublished(itemType)) { + testAuthorizedType(item); + } else { + testUnauthorizedType(item); + } + }); + }); }); diff --git a/cypress/fixtures/publish/publish.ts b/cypress/fixtures/publish/publish.ts new file mode 100644 index 000000000..22535541a --- /dev/null +++ b/cypress/fixtures/publish/publish.ts @@ -0,0 +1,47 @@ +import { + ItemTypeUnion, + PackedAppItemFactory, + PackedDocumentItemFactory, + PackedEtherpadItemFactory, + PackedFolderItemFactory, + PackedH5PItemFactory, + PackedLinkItemFactory, + PackedLocalFileItemFactory, + PackedS3FileItemFactory, + PackedShortcutItemFactory, +} from '@graasp/sdk'; + +import { ItemForTest } from '../../support/types'; + +export const createPublicItemByType = ( + itemType: ItemTypeUnion, +): ItemForTest => { + const publicTag = { publicTag: {} }; + + switch (itemType) { + case 'app': + return PackedAppItemFactory({}, publicTag); + case 'document': + return PackedDocumentItemFactory({}, publicTag); + case 'folder': + return PackedFolderItemFactory({}, publicTag); + case 'embeddedLink': + return PackedLinkItemFactory({}, publicTag); + case 'file': + return PackedLocalFileItemFactory({}, publicTag); + case 's3File': + return PackedS3FileItemFactory({}, publicTag); + case 'shortcut': + return PackedShortcutItemFactory({}, publicTag); + case 'h5p': + return PackedH5PItemFactory({}, publicTag); + case 'etherpad': + return PackedEtherpadItemFactory({}, publicTag); + default: + throw new Error( + `Item Type "${itemType}" is unknown in "createPublicItemWithType"`, + ); + } +}; + +export default createPublicItemByType; diff --git a/package.json b/package.json index cc345d4a5..b97fe03d2 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,7 @@ "@graasp/chatbox": "3.1.0", "@graasp/map": "1.15.0", "@graasp/query-client": "3.13.0", - "@graasp/sdk": "4.12.1", + "@graasp/sdk": "4.13.0", "@graasp/translations": "1.28.0", "@graasp/ui": "4.19.3", "@mui/icons-material": "5.15.19", diff --git a/src/components/hooks/usePublicationStatus.tsx b/src/components/hooks/usePublicationStatus.tsx index 0ede81896..f693fdc8b 100644 --- a/src/components/hooks/usePublicationStatus.tsx +++ b/src/components/hooks/usePublicationStatus.tsx @@ -2,10 +2,12 @@ import { useEffect, useState } from 'react'; import { ItemPublished, + ItemTypeUnion, ItemValidation, ItemValidationGroup, ItemValidationStatus, PackedItem, + PublishableItemTypeChecker, } from '@graasp/sdk'; import groupBy from 'lodash.groupby'; @@ -59,6 +61,9 @@ const isPublishedChildren = ({ publishedEntry?: ItemPublished; }) => Boolean(publishedEntry) && publishedEntry?.item?.path !== item?.path; +const isTypeNotAllowedToBePublished = (itemType: ItemTypeUnion) => + !PublishableItemTypeChecker.isItemTypeAllowedToBePublished(itemType); + type Props = { item: PackedItem }; type UsePublicationStatus = { status: PublicationStatus; @@ -83,6 +88,8 @@ const computePublicationStatus = ({ switch (true) { case isPublishedChildren({ item, publishedEntry }): return PublicationStatus.PublishedChildren; + case isTypeNotAllowedToBePublished(item.type): + return PublicationStatus.ItemTypeNotAllowed; case isUnpublished(validationGroup): return PublicationStatus.Unpublished; case isValidationOutdated({ item, validationGroup }): diff --git a/src/components/item/publish/CoEditorsContainer.tsx b/src/components/item/publish/CoEditorsContainer.tsx index 4b395ca6e..8c9c49b86 100644 --- a/src/components/item/publish/CoEditorsContainer.tsx +++ b/src/components/item/publish/CoEditorsContainer.tsx @@ -36,6 +36,11 @@ export const CoEditorsContainer = ({ settings.displayCoEditors ?? false, ); + const hiddenStatus = [ + PublicationStatus.PublishedChildren, + PublicationStatus.ItemTypeNotAllowed, + ]; + const { mutate: updateDisplayCoEditors, isLoading, @@ -68,8 +73,7 @@ export const CoEditorsContainer = ({ const handleNotifyCoEditorsChange = (isChecked: boolean): void => onNotificationChanged(isChecked); - // The publication is managed by the parent - if (status === PublicationStatus.PublishedChildren) { + if (hiddenStatus.includes(status)) { return null; } diff --git a/src/components/item/publish/ItemPublishTab.tsx b/src/components/item/publish/ItemPublishTab.tsx index f0e5e3db5..e7680816e 100644 --- a/src/components/item/publish/ItemPublishTab.tsx +++ b/src/components/item/publish/ItemPublishTab.tsx @@ -11,6 +11,7 @@ import { DataSyncContextProvider, useDataSyncContext, } from '@/components/context/DataSyncContext'; +import usePublicationStatus from '@/components/hooks/usePublicationStatus'; import CategoriesContainer from '@/components/item/publish/CategoriesContainer'; import CoEditorsContainer from '@/components/item/publish/CoEditorsContainer'; import EditItemDescription from '@/components/item/publish/EditItemDescription'; @@ -22,6 +23,7 @@ import { OutletType } from '@/components/pages/item/type'; import { useBuilderTranslation } from '@/config/i18n'; import { BUILDER } from '@/langs/constants'; import { SomeBreakPoints } from '@/types/breakpoint'; +import { PublicationStatus } from '@/types/publication'; import EditItemName from './EditItemName'; import CustomizedTags from './customizedTags/CustomizedTags'; @@ -35,11 +37,26 @@ const ItemPublishTab = (): JSX.Element => { const { isLoading: isMemberLoading } = useCurrentUserContext(); const isMobile = useMediaQuery(theme.breakpoints.down('md')); const { status } = useDataSyncContext(); + const { + status: publicationStatus, + isinitialLoading: isPublicationStatusLoading, + } = usePublicationStatus({ + item, + }); const [notifyCoEditors, setNotifyCoEditors] = useState(false); - if (isMemberLoading) { - return ; + if (isMemberLoading || isPublicationStatusLoading) { + return ( + + + + ); } if (!canAdmin) { @@ -117,8 +134,19 @@ const ItemPublishTab = (): JSX.Element => { ); - return ( - + const buildPublicationStack = (): JSX.Element => ( + + {buildPublicationHeader()} + {buildPublicationSection()} + + ); + + const buildView = () => { + if (publicationStatus === PublicationStatus.ItemTypeNotAllowed) { + return buildPublicationStack(); + } + + return ( {buildPreviewSection({ order: { xs: 1, md: 0 } })} {isMobile ? ( @@ -127,12 +155,15 @@ const ItemPublishTab = (): JSX.Element => { {buildPublicationSection({ order: { xs: 2 } })} ) : ( - - {buildPublicationHeader()} - {buildPublicationSection()} - + buildPublicationStack() )} + ); + }; + + return ( + + {buildView()} ); }; diff --git a/src/components/item/publish/PublicationStatusComponent.tsx b/src/components/item/publish/PublicationStatusComponent.tsx index 342a7a671..a232b3a2f 100644 --- a/src/components/item/publish/PublicationStatusComponent.tsx +++ b/src/components/item/publish/PublicationStatusComponent.tsx @@ -3,19 +3,24 @@ import CloudOffIcon from '@mui/icons-material/CloudOff'; import CloudUploadIcon from '@mui/icons-material/CloudUpload'; import ErrorIcon from '@mui/icons-material/Error'; import EventBusyIcon from '@mui/icons-material/EventBusy'; +import InfoIcon from '@mui/icons-material/Info'; import PendingActionsIcon from '@mui/icons-material/PendingActions'; import PublicOffIcon from '@mui/icons-material/PublicOff'; import { Chip, ChipProps, CircularProgress } from '@mui/material'; import { PackedItem } from '@graasp/sdk'; -import { useBuilderTranslation } from '@/config/i18n'; +import { useBuilderTranslation, useEnumsTranslation } from '@/config/i18n'; import { buildPublicationStatus } from '@/config/selectors'; import { BUILDER } from '@/langs/constants'; import { PublicationStatus, PublicationStatusMap } from '@/types/publication'; import usePublicationStatus from '../../hooks/usePublicationStatus'; +function capitalizeFirstLetter(text: string) { + return text.charAt(0).toUpperCase() + text.slice(1); +} + type PublicationComponentMap = PublicationStatusMap<{ icon: JSX.Element; label: string; @@ -28,7 +33,9 @@ type Props = { export const PublicationStatusComponent = ({ item }: Props): JSX.Element => { const { t } = useBuilderTranslation(); + const { t: translateEnum } = useEnumsTranslation(); const { status, isinitialLoading } = usePublicationStatus({ item }); + const translatedType = capitalizeFirstLetter(translateEnum(item.type)); if (isinitialLoading) { return ( @@ -55,12 +62,12 @@ export const PublicationStatusComponent = ({ item }: Props): JSX.Element => { [PublicationStatus.Pending]: { icon: , label: t(BUILDER.LIBRARY_SETTINGS_PUBLICATION_STATUS_PENDING), - color: 'warning', + color: 'info', }, [PublicationStatus.ReadyToPublish]: { icon: , label: t(BUILDER.LIBRARY_SETTINGS_PUBLICATION_STATUS_READY_TO_PUBLISH), - color: 'info', + color: 'success', }, [PublicationStatus.NotPublic]: { icon: , @@ -82,6 +89,13 @@ export const PublicationStatusComponent = ({ item }: Props): JSX.Element => { label: t(BUILDER.LIBRARY_SETTINGS_PUBLICATION_STATUS_UNPUBLISHED), color: undefined, }, + [PublicationStatus.ItemTypeNotAllowed]: { + icon: , + label: t(BUILDER.LIBRARY_SETTINGS_PUBLICATION_STATUS_TYPE_NOT_ALLOWED, { + itemType: translatedType, + }), + color: 'info', + }, } as const; const { icon, label, color } = chipMap[status]; diff --git a/src/components/item/publish/publicationButtons/InvalidButton.tsx b/src/components/item/publish/publicationButtons/InvalidButton.tsx index 99222408b..95e41e932 100644 --- a/src/components/item/publish/publicationButtons/InvalidButton.tsx +++ b/src/components/item/publish/publicationButtons/InvalidButton.tsx @@ -1,4 +1,4 @@ -import { LoadingButton } from '@mui/lab'; +import { Alert, LoadingButton } from '@mui/lab'; import { PackedItem } from '@graasp/sdk'; @@ -41,9 +41,13 @@ export const InvalidButton = ({ item, isLoading }: Props): JSX.Element => { closeModal(); }; - const description = t(BUILDER.LIBRARY_SETTINGS_VALIDATION_STATUS_FAILURE, { - contact: ADMIN_CONTACT, - }); + const description = ( + + {t(BUILDER.LIBRARY_SETTINGS_VALIDATION_STATUS_FAILURE, { + contact: ADMIN_CONTACT, + })} + + ); return ( <> diff --git a/src/components/item/publish/publicationButtons/NotAllowedItemTypeButton.tsx b/src/components/item/publish/publicationButtons/NotAllowedItemTypeButton.tsx new file mode 100644 index 000000000..41fd4c363 --- /dev/null +++ b/src/components/item/publish/publicationButtons/NotAllowedItemTypeButton.tsx @@ -0,0 +1,27 @@ +import { Alert } from '@mui/material'; + +import { PublishableItemTypeChecker } from '@graasp/sdk'; + +import { useBuilderTranslation, useEnumsTranslation } from '@/config/i18n'; +import { BUILDER } from '@/langs/constants'; + +export const NotAllowedItemTypeButton = (): JSX.Element => { + const { t } = useBuilderTranslation(); + const { t: translateEnum } = useEnumsTranslation(); + + const allowedTypes = PublishableItemTypeChecker.getAllowedTypes(); + const translatedAllowedTypes = allowedTypes + .map((e) => translateEnum(e)) + .join(', '); + + return ( + + {t(BUILDER.LIBRARY_SETTINGS_TYPE_NOT_ALLOWED_STATUS, { + allowedItemTypes: translatedAllowedTypes, + count: allowedTypes.length, + })} + + ); +}; + +export default NotAllowedItemTypeButton; diff --git a/src/components/item/publish/publicationButtons/NotPublicButton.tsx b/src/components/item/publish/publicationButtons/NotPublicButton.tsx index 37e32be36..23643648b 100644 --- a/src/components/item/publish/publicationButtons/NotPublicButton.tsx +++ b/src/components/item/publish/publicationButtons/NotPublicButton.tsx @@ -1,4 +1,4 @@ -import { LoadingButton } from '@mui/lab'; +import { Alert, LoadingButton } from '@mui/lab'; import { PackedItem } from '@graasp/sdk'; @@ -19,7 +19,11 @@ export const NotPublicButton = ({ item }: Props): JSX.Element => { const { t } = useBuilderTranslation(); const { isOpen, openModal, closeModal } = useModalStatus(); - const description = t(BUILDER.LIBRARY_SETTINGS_VISIBILITY_INFORMATIONS); + const description = ( + + {t(BUILDER.LIBRARY_SETTINGS_VISIBILITY_INFORMATIONS)} + + ); return ( <> diff --git a/src/components/item/publish/publicationButtons/OutdatedButton.tsx b/src/components/item/publish/publicationButtons/OutdatedButton.tsx index 511515709..200792304 100644 --- a/src/components/item/publish/publicationButtons/OutdatedButton.tsx +++ b/src/components/item/publish/publicationButtons/OutdatedButton.tsx @@ -1,4 +1,4 @@ -import { LoadingButton } from '@mui/lab'; +import { Alert, LoadingButton } from '@mui/lab'; import { PackedItem } from '@graasp/sdk'; @@ -26,7 +26,11 @@ export const OutdatedButton = ({ item, isLoading }: Props): JSX.Element => { const handleValidateItem = () => validateItem({ itemId }); - const description = t(BUILDER.LIBRARY_SETTINGS_VALIDATION_STATUS_OUTDATED); + const description = ( + + {t(BUILDER.LIBRARY_SETTINGS_VALIDATION_STATUS_OUTDATED)} + + ); return ( diff --git a/src/components/item/publish/publicationButtons/PendingButton.tsx b/src/components/item/publish/publicationButtons/PendingButton.tsx index 7e91b18e7..7f112d322 100644 --- a/src/components/item/publish/publicationButtons/PendingButton.tsx +++ b/src/components/item/publish/publicationButtons/PendingButton.tsx @@ -1,18 +1,15 @@ +import { Alert } from '@mui/material'; + import { useBuilderTranslation } from '@/config/i18n'; import { BUILDER } from '@/langs/constants'; -import PublicationButton from './PublicationButton'; - export const PendingButton = (): JSX.Element => { const { t } = useBuilderTranslation(); return ( - + + {t(BUILDER.LIBRARY_SETTINGS_VALIDATION_STATUS_PENDING_AUTOMATIC)} + ); }; diff --git a/src/components/item/publish/publicationButtons/PublicationButtonSelector.tsx b/src/components/item/publish/publicationButtons/PublicationButtonSelector.tsx index d43cd67c4..926f29a2b 100644 --- a/src/components/item/publish/publicationButtons/PublicationButtonSelector.tsx +++ b/src/components/item/publish/publicationButtons/PublicationButtonSelector.tsx @@ -6,6 +6,7 @@ import { usePublicationStatus } from '@/components/hooks/usePublicationStatus'; import { PublicationStatus } from '@/types/publication'; import InvalidButton from './InvalidButton'; +import NotAllowedItemTypeButton from './NotAllowedItemTypeButton'; import NotPublicButton from './NotPublicButton'; import OutdatedButton from './OutdatedButton'; import PendingButton from './PendingButton'; @@ -49,6 +50,8 @@ export const PublicationButtonSelector = ({ return ; case PublicationStatus.Outdated: return ; + case PublicationStatus.ItemTypeNotAllowed: + return ; default: console.error(`The status "${status}" is unknown.`); return undefined; diff --git a/src/components/item/publish/publicationButtons/PublishedButton.tsx b/src/components/item/publish/publicationButtons/PublishedButton.tsx index 10a632bc1..6d24d6c55 100644 --- a/src/components/item/publish/publicationButtons/PublishedButton.tsx +++ b/src/components/item/publish/publicationButtons/PublishedButton.tsx @@ -1,6 +1,6 @@ import LinkIcon from '@mui/icons-material/Link'; import { LoadingButton } from '@mui/lab'; -import { Button } from '@mui/material'; +import { Alert, Button } from '@mui/material'; import { ClientHostManager, PackedItem, ShortLinkPlatform } from '@graasp/sdk'; @@ -32,7 +32,9 @@ export const PublishedButton = ({ item, isLoading }: Props): JSX.Element => { return clientHostManager.getItemLink(ShortLinkPlatform.library, itemId); }; - const description = t(BUILDER.LIBRARY_SETTINGS_PUBLISHED_STATUS); + const description = ( + {t(BUILDER.LIBRARY_SETTINGS_PUBLISHED_STATUS)} + ); return ( diff --git a/src/components/item/publish/publicationButtons/PublishedChildrenButton.tsx b/src/components/item/publish/publicationButtons/PublishedChildrenButton.tsx index f05528bda..74ae326aa 100644 --- a/src/components/item/publish/publicationButtons/PublishedChildrenButton.tsx +++ b/src/components/item/publish/publicationButtons/PublishedChildrenButton.tsx @@ -1,16 +1,15 @@ +import { Alert } from '@mui/material'; + import { useBuilderTranslation } from '@/config/i18n'; import { BUILDER } from '@/langs/constants'; -import PublicationButton from './PublicationButton'; - export const PublishedChildrenButton = (): JSX.Element => { const { t } = useBuilderTranslation(); return ( - + + {t(BUILDER.LIBRARY_SETTINGS_CHILD_PUBLISHED_STATUS)} + ); }; diff --git a/src/components/item/publish/publicationButtons/ReadyToPublishButton.tsx b/src/components/item/publish/publicationButtons/ReadyToPublishButton.tsx index 017e5138e..7dc6da663 100644 --- a/src/components/item/publish/publicationButtons/ReadyToPublishButton.tsx +++ b/src/components/item/publish/publicationButtons/ReadyToPublishButton.tsx @@ -3,8 +3,6 @@ import { Alert } from '@mui/material'; import { PackedItem } from '@graasp/sdk'; -import { CheckIcon } from 'lucide-react'; - import useModalStatus from '@/components/hooks/useModalStatus'; import { useBuilderTranslation } from '@/config/i18n'; import { mutations } from '@/config/queryClient'; @@ -51,7 +49,7 @@ export const ReadyToPublishButton = ({ }; const description = ( - } severity="success"> + {t(BUILDER.LIBRARY_SETTINGS_VALIDATION_STATUS_READY_TO_PUBLISH)} ); diff --git a/src/langs/constants.ts b/src/langs/constants.ts index 2a7e005d1..abc1a453c 100644 --- a/src/langs/constants.ts +++ b/src/langs/constants.ts @@ -159,6 +159,8 @@ export const BUILDER = { 'LIBRARY_SETTINGS_PUBLICATION_STATUS_OUTDATED', LIBRARY_SETTINGS_PUBLICATION_STATUS_UNPUBLISHED: 'LIBRARY_SETTINGS_PUBLICATION_STATUS_UNPUBLISHED', + LIBRARY_SETTINGS_PUBLICATION_STATUS_TYPE_NOT_ALLOWED: + 'LIBRARY_SETTINGS_PUBLICATION_STATUS_TYPE_NOT_ALLOWED', LIBRARY_SETTINGS_ITEM_NAME_CANNOT_BE_EMPTY: 'LIBRARY_SETTINGS_ITEM_NAME_CANNOT_BE_EMPTY', @@ -319,6 +321,8 @@ export const BUILDER = { LIBRARY_SETTINGS_PUBLISHED_STATUS: 'LIBRARY_SETTINGS_PUBLISHED_STATUS', LIBRARY_SETTINGS_CHILD_PUBLISHED_STATUS: 'LIBRARY_SETTINGS_CHILD_PUBLISHED_STATUS', + LIBRARY_SETTINGS_TYPE_NOT_ALLOWED_STATUS: + 'LIBRARY_SETTINGS_TYPE_NOT_ALLOWED_STATUS', LIBRARY_SETTINGS_UNPUBLISH_BUTTON: 'LIBRARY_SETTINGS_UNPUBLISH_BUTTON', LIBRARY_SETTINGS_VALIDATION_CONFIGURATION_TITLE: 'LIBRARY_SETTINGS_VALIDATION_CONFIGURATION_TITLE', diff --git a/src/langs/en.json b/src/langs/en.json index 6a9ca1d1c..a266cfd01 100644 --- a/src/langs/en.json +++ b/src/langs/en.json @@ -186,6 +186,8 @@ "LIBRARY_SETTINGS_PUBLISH_NOTIFICATIONS_LABEL": "Send email notifications to all co-editors", "LIBRARY_SETTINGS_PUBLISHED_STATUS": "This element is published. Anyone can access it and is available on Graasp Library, our public repository of learning ressources.", "LIBRARY_SETTINGS_CHILD_PUBLISHED_STATUS": "This element is part of a collection that is already published. Publishing and un-publishing can be done at the collection root.", + "LIBRARY_SETTINGS_TYPE_NOT_ALLOWED_STATUS_one": "This element cannot be published. Only a {{allowedItemTypes}} is allowed to be published on Graasp Library.", + "LIBRARY_SETTINGS_TYPE_NOT_ALLOWED_STATUS_other": "This element cannot be published. Only the {{allowedItemTypes}} are allowed to be published on Graasp Library.", "LIBRARY_SETTINGS_TITLE": "Publication", "LIBRARY_SETTINGS_PREVIEW_TITLE": "Preview", "LIBRARY_SETTINGS_PREVIEW_DESCRIPTION": "Below is what your publication will look like in Graasp Library.", @@ -218,6 +220,7 @@ "LIBRARY_SETTINGS_PUBLICATION_STATUS_INVALID": "Invalid", "LIBRARY_SETTINGS_PUBLICATION_STATUS_OUTDATED": "Outdated", "LIBRARY_SETTINGS_PUBLICATION_STATUS_UNPUBLISHED": "Unpublished", + "LIBRARY_SETTINGS_PUBLICATION_STATUS_TYPE_NOT_ALLOWED": "{{itemType}} cannot be published", "LIBRARY_SETTINGS_ITEM_NAME_CANNOT_BE_EMPTY": "The item's name can't be empty", "PUBLIC_VISIBILITY_MODAL_TITLE": "Item visibility", "PUBLIC_VISIBILITY_MODAL_DESCRIPTION": "The visibility of this item is not Public. To publish it in the Library, you must set its visibility to pubic. This action will allow any user to have access to your item. Do you want to continue?", diff --git a/src/types/publication.ts b/src/types/publication.ts index 29fb2bd80..41330ef9f 100644 --- a/src/types/publication.ts +++ b/src/types/publication.ts @@ -7,6 +7,7 @@ export enum PublicationStatus { Invalid = 'invalid', Outdated = 'outdated', NotPublic = 'notPublic', + ItemTypeNotAllowed = 'itemTypeNotAllowed', } export type PublicationStatusMap = { diff --git a/yarn.lock b/yarn.lock index 9d1083b32..c207d3d42 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1768,9 +1768,9 @@ __metadata: languageName: node linkType: hard -"@graasp/sdk@npm:4.12.1": - version: 4.12.1 - resolution: "@graasp/sdk@npm:4.12.1" +"@graasp/sdk@npm:4.13.0": + version: 4.13.0 + resolution: "@graasp/sdk@npm:4.13.0" dependencies: "@faker-js/faker": "npm:8.4.1" filesize: "npm:10.1.2" @@ -1778,8 +1778,8 @@ __metadata: validator: "npm:13.12.0" peerDependencies: date-fns: ^3 - uuid: ^9 - checksum: 10/83d6cefb4598b699b746b90ba8d7de61a10a685f47d6847fa1ee2a2a8b444a83510e1e8ee4b5dfba525af3a9eeee0e08088e45280b334988ade1da5defdb0adc + uuid: ^9 || ^10.0.0 + checksum: 10/13ee13a6025172016efcecb36b1d7d052439dfb3daa0817559031f4c8b8bd6abc14cd328ffae174225378c51252cd63bee4195234d279605879e56971f90907c languageName: node linkType: hard @@ -8074,7 +8074,7 @@ __metadata: "@graasp/chatbox": "npm:3.1.0" "@graasp/map": "npm:1.15.0" "@graasp/query-client": "npm:3.13.0" - "@graasp/sdk": "npm:4.12.1" + "@graasp/sdk": "npm:4.13.0" "@graasp/translations": "npm:1.28.0" "@graasp/ui": "npm:4.19.3" "@mui/icons-material": "npm:5.15.19"