diff --git a/src/components/item/publish/PublicationStatusComponent.tsx b/src/components/item/publish/PublicationStatusComponent.tsx index 1ed3b597f..6f860e1ac 100644 --- a/src/components/item/publish/PublicationStatusComponent.tsx +++ b/src/components/item/publish/PublicationStatusComponent.tsx @@ -1,7 +1,6 @@ import CloudDoneIcon from '@mui/icons-material/CloudDone'; import CloudOffIcon from '@mui/icons-material/CloudOff'; 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 { Chip, ChipProps, CircularProgress } from '@mui/material'; @@ -12,17 +11,16 @@ import { useBuilderTranslation, useEnumsTranslation } from '@/config/i18n'; import { hooks } from '@/config/queryClient'; import { buildPublicationStatus } from '@/config/selectors'; import { BUILDER } from '@/langs/constants'; -import { PublicationStatusMap } from '@/types/publication'; function capitalizeFirstLetter(text: string) { return text.charAt(0).toUpperCase() + text.slice(1); } -type PublicationComponentMap = PublicationStatusMap<{ +type PublicationChip = { icon: JSX.Element; label: string; color: ChipProps['color'] | undefined; -}>; +}; type Props = { item: PackedItem; @@ -56,52 +54,67 @@ export const PublicationStatusComponent = ({ item }: Props): JSX.Element => { ); } - const chipMap: PublicationComponentMap = { - [PublicationStatus.Published]: { - icon: , - label: t(BUILDER.LIBRARY_SETTINGS_PUBLICATION_STATUS_PUBLISHED), - color: 'success', - }, - [PublicationStatus.PublishedChildren]: { - icon: , - label: t(BUILDER.LIBRARY_SETTINGS_PUBLICATION_STATUS_PUBLISHED_CHILDREN), - color: 'success', - }, - [PublicationStatus.Pending]: { - icon: , - label: t(BUILDER.LIBRARY_SETTINGS_PUBLICATION_STATUS_PENDING), - color: 'info', - }, - [PublicationStatus.ReadyToPublish]: { - icon: , - label: t(BUILDER.LIBRARY_SETTINGS_PUBLICATION_STATUS_READY_TO_PUBLISH), - color: undefined, - }, - [PublicationStatus.Invalid]: { - icon: , - label: t(BUILDER.LIBRARY_SETTINGS_PUBLICATION_STATUS_INVALID), - color: 'error', - }, - [PublicationStatus.Outdated]: { - icon: , - label: t(BUILDER.LIBRARY_SETTINGS_PUBLICATION_STATUS_OUTDATED), - color: 'warning', - }, - [PublicationStatus.Unpublished]: { - icon: , - 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 getChip = (publicationStatus: PublicationStatus): PublicationChip => { + switch (publicationStatus) { + case PublicationStatus.Unpublished: + return { + icon: , + label: t(BUILDER.LIBRARY_SETTINGS_PUBLICATION_STATUS_UNPUBLISHED), + color: undefined, + }; + // For now, outdated is not implemented correctly in backend or library, + // so we are just ignorign this state for the moment. + case PublicationStatus.Published: + case PublicationStatus.Outdated: + return { + icon: , + label: t(BUILDER.LIBRARY_SETTINGS_PUBLICATION_STATUS_PUBLISHED), + color: 'success' as const, + }; + case PublicationStatus.PublishedChildren: + return { + icon: , + label: t( + BUILDER.LIBRARY_SETTINGS_PUBLICATION_STATUS_PUBLISHED_CHILDREN, + ), + color: 'success' as const, + }; + case PublicationStatus.ReadyToPublish: + return { + icon: , + label: t( + BUILDER.LIBRARY_SETTINGS_PUBLICATION_STATUS_READY_TO_PUBLISH, + ), + color: undefined, + }; + case PublicationStatus.Pending: + return { + icon: , + label: t(BUILDER.LIBRARY_SETTINGS_PUBLICATION_STATUS_PENDING), + color: 'info' as const, + }; + case PublicationStatus.Invalid: + return { + icon: , + label: t(BUILDER.LIBRARY_SETTINGS_PUBLICATION_STATUS_INVALID), + color: 'error' as const, + }; + case PublicationStatus.ItemTypeNotAllowed: + default: + return { + icon: , + label: t( + BUILDER.LIBRARY_SETTINGS_PUBLICATION_STATUS_TYPE_NOT_ALLOWED, + { + itemType: translatedType, + }, + ), + color: 'info' as const, + }; + } + }; - const { icon, label, color } = chipMap[status]; + const { icon, label, color } = getChip(status); return ( { - const { t } = useBuilderTranslation(); - const { id: itemId } = item; - - const { mutate: validateItem, isLoading: isValidating } = - usePostItemValidation(); - const { mutate: unpublish, isLoading: isUnPublishing } = useUnpublishItem(); - - const handleValidateItem = () => validateItem({ itemId }); - const handleUnPublishItem = () => unpublish({ id: itemId }); - - const description = ( - - {t(BUILDER.LIBRARY_SETTINGS_VALIDATION_STATUS_OUTDATED)} - - ); - - return ( - - - {t(BUILDER.LIBRARY_SETTINGS_VALIDATION_VALIDATE_BUTTON)} - - - {t(BUILDER.LIBRARY_SETTINGS_UNPUBLISH_BUTTON)} - - - ); -}; - -export default OutdatedButton; diff --git a/src/components/item/publish/publicationButtons/PublicationButtonSelector.tsx b/src/components/item/publish/publicationButtons/PublicationButtonSelector.tsx index ce0b6bc90..83d0ca1a7 100644 --- a/src/components/item/publish/publicationButtons/PublicationButtonSelector.tsx +++ b/src/components/item/publish/publicationButtons/PublicationButtonSelector.tsx @@ -6,7 +6,6 @@ import { hooks } from '@/config/queryClient'; import InvalidButton from './InvalidButton'; import NotAllowedItemTypeButton from './NotAllowedItemTypeButton'; -import OutdatedButton from './OutdatedButton'; import PendingButton from './PendingButton'; import PublishedButton from './PublishedButton'; import PublishedChildrenButton from './PublishedChildrenButton'; @@ -40,14 +39,15 @@ export const PublicationButtonSelector = ({ notifyCoEditors={notifyCoEditors} /> ); + // For now, outdated is not implemented correctly in backend or library, + // so we are just ignorign this state for the moment. case PublicationStatus.Published: + case PublicationStatus.Outdated: return ; case PublicationStatus.PublishedChildren: return ; case PublicationStatus.Invalid: return ; - case PublicationStatus.Outdated: - return ; case PublicationStatus.ItemTypeNotAllowed: return ; default: diff --git a/src/langs/ar.json b/src/langs/ar.json index e2353b6ce..3d63d4028 100644 --- a/src/langs/ar.json +++ b/src/langs/ar.json @@ -190,7 +190,7 @@ "LIBRARY_SETTINGS_PREVIEW_DESCRIPTION": "فيما يلي الشكل الذي سيبدو عليه منشورك في مكتبة Graasp.", "LIBRARY_SETTINGS_UNPUBLISH_BUTTON": "إلغاء النّشر", "LIBRARY_SETTINGS_VALIDATION_CONFIGURATION_TITLE": "ميّزات العٌنصر", - "LIBRARY_SETTINGS_VALIDATION_INFORMATIONS": "يجب التحقق من صحة العنصر الخاص بك قبل نشره. الرّجاء الانتظار حتى تنتهي عملية التحقق.", + "LIBRARY_SETTINGS_VALIDATION_INFORMATIONS": "يمكنك نشر العنصر الخاص بك في مكتبة غراسب. يرجى الانتظار لبعض الوقت حتى تنتهي عملية التحقق من صحة العنصر.", "LIBRARY_SETTINGS_VALIDATION_PUBLICATION_TITLE": "المنشور", "LIBRARY_SETTINGS_VALIDATION_REFRESH_BUTTON": "تحديث", "LIBRARY_SETTINGS_VALIDATION_STATUS_FAILURE": "قد يحتوي العنصر الخاصّ بك على محتوى غير لائق. يرجى إزالته والتحقق من صحة العنصر الخاص بك مرة أخرى. إذا كان لديك أي سؤال ، فيرجى الاتصال بـ {{contact}}.", @@ -198,8 +198,7 @@ "LIBRARY_SETTINGS_VALIDATION_STATUS_READY_TO_PUBLISH": "العنصر صالح وجاهز للنشر في مكتبة Graasp.", "LIBRARY_SETTINGS_VALIDATION_STATUS_OUTDATED": "تم تحديث العنصر منذ آخر عملية تحقق. ويجب التحقق من صحتها مرة أخرى للتأكد من أنها لا تزال صالحة.", "LIBRARY_SETTINGS_VALIDATION_TITLE": "التصديق", - "LIBRARY_SETTINGS_VALIDATION_VALIDATE_BUTTON": "صدِّق", - "LIBRARY_SETTINGS_VISIBILITY_INFORMATIONS": "العنصر المنشور لم يعد عامًا بعد الآن. يجب أن يكون العنصر عامًا ليكون متاحًا في مكتبة Graasp.", + "LIBRARY_SETTINGS_VALIDATION_VALIDATE_BUTTON": "نشر", "LIBRARY_SETTINGS_VISIBILITY_CHANGE_BUTTON": "تغيير الرؤية", "LIBRARY_SETTINGS_RETRY_BUTTON": "أعد المحاولة", "LIBRARY_SETTINGS_VIEW_LIBRARY_BUTTON": "عرض على مكتبة Graasp", diff --git a/src/langs/constants.ts b/src/langs/constants.ts index 820fd1217..4d37f4443 100644 --- a/src/langs/constants.ts +++ b/src/langs/constants.ts @@ -130,8 +130,6 @@ export const BUILDER = { LIBRARY_SETTINGS_PREVIEW_TITLE: 'LIBRARY_SETTINGS_PREVIEW_TITLE', LIBRARY_SETTINGS_PREVIEW_DESCRIPTION: 'LIBRARY_SETTINGS_PREVIEW_DESCRIPTION', LIBRARY_SETTINGS_VALIDATION_TITLE: 'LIBRARY_SETTINGS_VALIDATION_TITLE', - LIBRARY_SETTINGS_VISIBILITY_INFORMATIONS: - 'LIBRARY_SETTINGS_VISIBILITY_INFORMATIONS', LIBRARY_SETTINGS_VISIBILITY_CHANGE_BUTTON: 'LIBRARY_SETTINGS_VISIBILITY_CHANGE_BUTTON', LIBRARY_SETTINGS_VIEW_LIBRARY_BUTTON: 'LIBRARY_SETTINGS_VIEW_LIBRARY_BUTTON', diff --git a/src/langs/de.json b/src/langs/de.json index 0cf415ffe..fdf52af9d 100644 --- a/src/langs/de.json +++ b/src/langs/de.json @@ -190,7 +190,7 @@ "LIBRARY_SETTINGS_PREVIEW_DESCRIPTION": "Unten sehen Sie, wie Ihre Veröffentlichung in der Graasp-Bibliothek aussehen wird.", "LIBRARY_SETTINGS_UNPUBLISH_BUTTON": "Veröffentlichung aufheben", "LIBRARY_SETTINGS_VALIDATION_CONFIGURATION_TITLE": "Eigenschaften des Elements", - "LIBRARY_SETTINGS_VALIDATION_INFORMATIONS": "Sie müssen Ihr Element \"validieren\", bevor Sie es veröffentlichen. Haben Sie etwas Geduld, bis die Validierung abgeschlossen ist. Sobald die Validierung abgeschlossen ist, klicken Sie auf \"aktualisieren\"", + "LIBRARY_SETTINGS_VALIDATION_INFORMATIONS": "Sie können Ihren Artikel in der Graasp-Bibliothek veröffentlichen. Bitte warten Sie einige Zeit, bis die Validierung des Artikels abgeschlossen ist.", "LIBRARY_SETTINGS_VALIDATION_PUBLICATION_TITLE": "Veröffentlichung", "LIBRARY_SETTINGS_VALIDATION_REFRESH_BUTTON": "Aktualisieren", "LIBRARY_SETTINGS_VALIDATION_STATUS_FAILURE": "Ihr Element enthält möglicherweise unangemessene Inhalte. Bitte entfernen Sie sie und validieren Sie Ihr Element erneut. Bei Fragen wenden Sie sich bitte an {{contact}}.", @@ -198,8 +198,7 @@ "LIBRARY_SETTINGS_VALIDATION_STATUS_READY_TO_PUBLISH": "Ihr Element ist gültig und bereit zur Veröffentlichung in der Graasp-Bibliothek.", "LIBRARY_SETTINGS_VALIDATION_STATUS_OUTDATED": "Das Element wurde seit der letzten Überprüfung aktualisiert. Es muss erneut validiert werden, um sicherzustellen, dass es noch gültig ist.", "LIBRARY_SETTINGS_VALIDATION_TITLE": "Validierung", - "LIBRARY_SETTINGS_VALIDATION_VALIDATE_BUTTON": "Validieren", - "LIBRARY_SETTINGS_VISIBILITY_INFORMATIONS": "Das veröffentlichte Element ist nicht mehr öffentlich. Das Element muss öffentlich sein, um in der Graasp-Bibliothek verfügbar zu sein.", + "LIBRARY_SETTINGS_VALIDATION_VALIDATE_BUTTON": "Veröffentlichen", "LIBRARY_SETTINGS_VISIBILITY_CHANGE_BUTTON": "Sichtbarkeit ändern", "LIBRARY_SETTINGS_RETRY_BUTTON": "Wiederholen", "LIBRARY_SETTINGS_VIEW_LIBRARY_BUTTON": "In der Graasp-Bibliothek anzeigen", diff --git a/src/langs/en.json b/src/langs/en.json index 36b3a43a0..d30fcfc23 100644 --- a/src/langs/en.json +++ b/src/langs/en.json @@ -190,7 +190,7 @@ "LIBRARY_SETTINGS_PREVIEW_DESCRIPTION": "Below is what your publication will look like in Graasp Library.", "LIBRARY_SETTINGS_UNPUBLISH_BUTTON": "Unpublish", "LIBRARY_SETTINGS_VALIDATION_CONFIGURATION_TITLE": "Item attributes", - "LIBRARY_SETTINGS_VALIDATION_INFORMATIONS": "You need to validate your item before publishing it. Please allow some time for the validation to finish.", + "LIBRARY_SETTINGS_VALIDATION_INFORMATIONS": "You can publish your item in the Graasp Library. Please allow some time for the item's validation to finish.", "LIBRARY_SETTINGS_VALIDATION_PUBLICATION_TITLE": "Publication", "LIBRARY_SETTINGS_VALIDATION_REFRESH_BUTTON": "Refresh", "LIBRARY_SETTINGS_VALIDATION_STATUS_FAILURE": "Your item might contain inappropriate content. Please remove them and validate your item again. If you have any question, please contact {{contact}}.", @@ -198,8 +198,7 @@ "LIBRARY_SETTINGS_VALIDATION_STATUS_READY_TO_PUBLISH": "The item is valid and ready to be published in Graasp Library.", "LIBRARY_SETTINGS_VALIDATION_STATUS_OUTDATED": "The element was updated since the last verification. It must be validated again to be sure that it is still valid.", "LIBRARY_SETTINGS_VALIDATION_TITLE": "Validation", - "LIBRARY_SETTINGS_VALIDATION_VALIDATE_BUTTON": "Validate", - "LIBRARY_SETTINGS_VISIBILITY_INFORMATIONS": "The published element is not public anymore. The item have to be public to be available in Graasp Library.", + "LIBRARY_SETTINGS_VALIDATION_VALIDATE_BUTTON": "Publish", "LIBRARY_SETTINGS_VISIBILITY_CHANGE_BUTTON": "Change the visibility", "LIBRARY_SETTINGS_RETRY_BUTTON": "Retry", "LIBRARY_SETTINGS_VIEW_LIBRARY_BUTTON": "View on Graasp Library", diff --git a/src/langs/es.json b/src/langs/es.json index 8b8ffbd4e..48ad98dda 100644 --- a/src/langs/es.json +++ b/src/langs/es.json @@ -186,7 +186,7 @@ "LIBRARY_SETTINGS_PREVIEW_DESCRIPTION": "A continuación se muestra cómo se verá su publicación en la biblioteca Graasp.", "LIBRARY_SETTINGS_UNPUBLISH_BUTTON": "Despublicar", "LIBRARY_SETTINGS_VALIDATION_CONFIGURATION_TITLE": "Atributos del artículo", - "LIBRARY_SETTINGS_VALIDATION_INFORMATIONS": "Debe validar su artículo antes de publicarlo. Espere algo de tiempo para que finalice la validación.", + "LIBRARY_SETTINGS_VALIDATION_INFORMATIONS": "Puede publicar su artículo en la biblioteca de Graasp. Espere a que finalice la validación del artículo.", "LIBRARY_SETTINGS_VALIDATION_PUBLICATION_TITLE": "Publicación", "LIBRARY_SETTINGS_VALIDATION_REFRESH_BUTTON": "Actualizar", "LIBRARY_SETTINGS_VALIDATION_STATUS_FAILURE": "Su artículo puede contener contenido inapropiado. Elimínelos y valide su artículo nuevamente. Si tiene alguna pregunta, comuníquese con {{contact}}.", @@ -194,7 +194,7 @@ "LIBRARY_SETTINGS_VALIDATION_STATUS_READY_TO_PUBLISH": "El artículo es válido y está listo para ser publicado en la Biblioteca Graasp.", "LIBRARY_SETTINGS_VALIDATION_STATUS_OUTDATED": "El elemento fue actualizado desde la última verificación. Se debe validar nuevamente para estar seguros de que aún es válido.", "LIBRARY_SETTINGS_VALIDATION_TITLE": "Validación", - "LIBRARY_SETTINGS_VALIDATION_VALIDATE_BUTTON": "Validar", + "LIBRARY_SETTINGS_VALIDATION_VALIDATE_BUTTON": "Publicar", "LIBRARY_SETTINGS_VISIBILITY_INFORMATIONS": "El elemento publicado ya no es público. El artículo debe ser público para estar disponible en la Biblioteca Graasp.", "LIBRARY_SETTINGS_VISIBILITY_CHANGE_BUTTON": "Cambiar la visibilidad", "LIBRARY_SETTINGS_RETRY_BUTTON": "Rever", diff --git a/src/langs/fr.json b/src/langs/fr.json index 7fcaa5125..965837bd5 100644 --- a/src/langs/fr.json +++ b/src/langs/fr.json @@ -190,7 +190,7 @@ "LIBRARY_SETTINGS_PREVIEW_DESCRIPTION": "Vous trouverez ci-dessous à quoi ressemblera votre publication dans la bibliothèque Graasp.", "LIBRARY_SETTINGS_UNPUBLISH_BUTTON": "Annuler la publication", "LIBRARY_SETTINGS_VALIDATION_CONFIGURATION_TITLE": "Propriétés de l'élément", - "LIBRARY_SETTINGS_VALIDATION_INFORMATIONS": "Vous avez besoin de valider votre élément avant de le publier. Attendez quelques minutes pour que la validation se termine.", + "LIBRARY_SETTINGS_VALIDATION_INFORMATIONS": "Vous pouvez publier votre article dans la bibliothèque Graasp. Veuillez patienter un instant pour que la validation de l'article soit terminée.", "LIBRARY_SETTINGS_VALIDATION_PUBLICATION_TITLE": "Publication", "LIBRARY_SETTINGS_VALIDATION_REFRESH_BUTTON": "Rafraîchir", "LIBRARY_SETTINGS_VALIDATION_STATUS_FAILURE": "Votre élément pourrait présenter des contenus inappropriés. Supprimez-les et validez à nouveau votre élément. Si vous avez des question, contactez {{contact}}.", @@ -198,7 +198,7 @@ "LIBRARY_SETTINGS_VALIDATION_STATUS_READY_TO_PUBLISH": "L'article est valide et prêt à être publié dans la bibliothèque Graasp.", "LIBRARY_SETTINGS_VALIDATION_STATUS_OUTDATED": "L'élément a été mis à jour depuis la dernière vérification. Il faut le valider à nouveau pour être sûr qu'il est toujours valable.", "LIBRARY_SETTINGS_VALIDATION_TITLE": "Validation", - "LIBRARY_SETTINGS_VALIDATION_VALIDATE_BUTTON": "Valider", + "LIBRARY_SETTINGS_VALIDATION_VALIDATE_BUTTON": "Publier", "LIBRARY_SETTINGS_VISIBILITY_INFORMATIONS": "L'élément publié n'est plus public. L'élément doit être public pour être disponible dans la bibliothèque Graasp.", "LIBRARY_SETTINGS_VISIBILITY_CHANGE_BUTTON": "Changer la visibilité", "LIBRARY_SETTINGS_RETRY_BUTTON": "Recommencez", diff --git a/src/langs/it.json b/src/langs/it.json index 433cda578..ffadb3053 100644 --- a/src/langs/it.json +++ b/src/langs/it.json @@ -186,7 +186,7 @@ "LIBRARY_SETTINGS_PREVIEW_DESCRIPTION": "Di seguito è riportato l'aspetto della tua pubblicazione nella Libreria Graasp.", "LIBRARY_SETTINGS_UNPUBLISH_BUTTON": "Non pubblicato", "LIBRARY_SETTINGS_VALIDATION_CONFIGURATION_TITLE": "Caratteristiche dell'elemento", - "LIBRARY_SETTINGS_VALIDATION_INFORMATIONS": "Devi convalidare il tuo elemento prima di pubblicarlo. Si prega di attendere un po' di tempo per il completamento della convalida.", + "LIBRARY_SETTINGS_VALIDATION_INFORMATIONS": "Potete pubblicare il vostro articolo nella Biblioteca Graasp. Si prega di attendere un po' di tempo per la convalida dell'articolo.", "LIBRARY_SETTINGS_VALIDATION_PUBLICATION_TITLE": "Pubblica", "LIBRARY_SETTINGS_VALIDATION_REFRESH_BUTTON": "Ricarica", "LIBRARY_SETTINGS_VALIDATION_STATUS_FAILURE": "Il tuo elemento potrebbe includere contenuti inappropriati. Rimuovili e convalida nuovamente il tuo elemento. In caso di domande, contatta {{contact}}.", @@ -194,7 +194,7 @@ "LIBRARY_SETTINGS_VALIDATION_STATUS_READY_TO_PUBLISH": "L'articolo è valido e pronto per essere pubblicato nella Biblioteca Graasp.", "LIBRARY_SETTINGS_VALIDATION_STATUS_OUTDATED": "L'elemento è stato aggiornato dall'ultima verifica. Deve essere convalidato nuovamente per essere sicuri che sia ancora valido.", "LIBRARY_SETTINGS_VALIDATION_TITLE": "Validazione", - "LIBRARY_SETTINGS_VALIDATION_VALIDATE_BUTTON": "Convalida", + "LIBRARY_SETTINGS_VALIDATION_VALIDATE_BUTTON": "Pubblica", "LIBRARY_SETTINGS_VISIBILITY_INFORMATIONS": "L'elemento pubblicato non è più pubblico. L'elemento deve essere pubblico per essere disponibile nella libreria Graasp.", "LIBRARY_SETTINGS_VISIBILITY_CHANGE_BUTTON": "Cambia la visibilità", "LIBRARY_SETTINGS_RETRY_BUTTON": "Riprova", diff --git a/src/types/publication.ts b/src/types/publication.ts deleted file mode 100644 index 1c1d4c215..000000000 --- a/src/types/publication.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { PublicationStatus } from '@graasp/sdk'; - -export type PublicationStatusMap = { - [status in PublicationStatus]: T; -};