Skip to content

Commit

Permalink
feat: remove Unpublished state
Browse files Browse the repository at this point in the history
  • Loading branch information
ReidyT committed Jul 25, 2024
1 parent fb0903d commit d9f6414
Show file tree
Hide file tree
Showing 11 changed files with 77 additions and 133 deletions.
111 changes: 62 additions & 49 deletions src/components/item/publish/PublicationStatusComponent.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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;
Expand Down Expand Up @@ -56,52 +54,67 @@ export const PublicationStatusComponent = ({ item }: Props): JSX.Element => {
);
}

const chipMap: PublicationComponentMap = {
[PublicationStatus.Published]: {
icon: <CloudDoneIcon />,
label: t(BUILDER.LIBRARY_SETTINGS_PUBLICATION_STATUS_PUBLISHED),
color: 'success',
},
[PublicationStatus.PublishedChildren]: {
icon: <CloudDoneIcon />,
label: t(BUILDER.LIBRARY_SETTINGS_PUBLICATION_STATUS_PUBLISHED_CHILDREN),
color: 'success',
},
[PublicationStatus.Pending]: {
icon: <PendingActionsIcon />,
label: t(BUILDER.LIBRARY_SETTINGS_PUBLICATION_STATUS_PENDING),
color: 'info',
},
[PublicationStatus.ReadyToPublish]: {
icon: <CloudOffIcon />,
label: t(BUILDER.LIBRARY_SETTINGS_PUBLICATION_STATUS_READY_TO_PUBLISH),
color: undefined,
},
[PublicationStatus.Invalid]: {
icon: <ErrorIcon />,
label: t(BUILDER.LIBRARY_SETTINGS_PUBLICATION_STATUS_INVALID),
color: 'error',
},
[PublicationStatus.Outdated]: {
icon: <EventBusyIcon />,
label: t(BUILDER.LIBRARY_SETTINGS_PUBLICATION_STATUS_OUTDATED),
color: 'warning',
},
[PublicationStatus.Unpublished]: {
icon: <CloudOffIcon />,
label: t(BUILDER.LIBRARY_SETTINGS_PUBLICATION_STATUS_UNPUBLISHED),
color: undefined,
},
[PublicationStatus.ItemTypeNotAllowed]: {
icon: <InfoIcon />,
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: <CloudOffIcon />,
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: <CloudDoneIcon />,
label: t(BUILDER.LIBRARY_SETTINGS_PUBLICATION_STATUS_PUBLISHED),
color: 'success' as const,
};
case PublicationStatus.PublishedChildren:
return {
icon: <CloudDoneIcon />,
label: t(
BUILDER.LIBRARY_SETTINGS_PUBLICATION_STATUS_PUBLISHED_CHILDREN,
),
color: 'success' as const,
};
case PublicationStatus.ReadyToPublish:
return {
icon: <CloudOffIcon />,
label: t(
BUILDER.LIBRARY_SETTINGS_PUBLICATION_STATUS_READY_TO_PUBLISH,
),
color: undefined,
};
case PublicationStatus.Pending:
return {
icon: <PendingActionsIcon />,
label: t(BUILDER.LIBRARY_SETTINGS_PUBLICATION_STATUS_PENDING),
color: 'info' as const,
};
case PublicationStatus.Invalid:
return {
icon: <ErrorIcon />,
label: t(BUILDER.LIBRARY_SETTINGS_PUBLICATION_STATUS_INVALID),
color: 'error' as const,
};
case PublicationStatus.ItemTypeNotAllowed:
default:
return {
icon: <InfoIcon />,
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 (
<Chip
Expand Down
59 changes: 0 additions & 59 deletions src/components/item/publish/publicationButtons/OutdatedButton.tsx

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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 <PublishedButton item={item} isLoading={isStatusFirstLoading} />;
case PublicationStatus.PublishedChildren:
return <PublishedChildrenButton />;
case PublicationStatus.Invalid:
return <InvalidButton item={item} isLoading={isStatusFirstLoading} />;
case PublicationStatus.Outdated:
return <OutdatedButton item={item} isLoading={isStatusFirstLoading} />;
case PublicationStatus.ItemTypeNotAllowed:
return <NotAllowedItemTypeButton />;
default:
Expand Down
5 changes: 2 additions & 3 deletions src/langs/ar.json
Original file line number Diff line number Diff line change
Expand Up @@ -190,16 +190,15 @@
"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}}.",
"LIBRARY_SETTINGS_VALIDATION_STATUS_PENDING_AUTOMATIC": "العنصر الخاص بك في انتظار التصديق الأوتوماتيكي. بمجرد نجاح التحقق ، ستتمكن من نشر العنصر الخاص بك.",
"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",
Expand Down
2 changes: 0 additions & 2 deletions src/langs/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
5 changes: 2 additions & 3 deletions src/langs/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -190,16 +190,15 @@
"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}}.",
"LIBRARY_SETTINGS_VALIDATION_STATUS_PENDING_AUTOMATIC": "Für Ihr Element steht die automatische Validierung aus. Sobald die Validierung erfolgreich ist, können Sie Ihr element veröffentlichen.",
"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",
Expand Down
5 changes: 2 additions & 3 deletions src/langs/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -190,16 +190,15 @@
"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}}.",
"LIBRARY_SETTINGS_VALIDATION_STATUS_PENDING_AUTOMATIC": "Your item is pending automatic validation. Once the validation succeeds, you will be able to publish your item.",
"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",
Expand Down
4 changes: 2 additions & 2 deletions src/langs/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -186,15 +186,15 @@
"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}}.",
"LIBRARY_SETTINGS_VALIDATION_STATUS_PENDING_AUTOMATIC": "Tu artículo está pendiente de validación automática. Una vez que la validación sea exitosa, podrá publicar su artículo.",
"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",
Expand Down
4 changes: 2 additions & 2 deletions src/langs/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -190,15 +190,15 @@
"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}}.",
"LIBRARY_SETTINGS_VALIDATION_STATUS_PENDING_AUTOMATIC": "Votre élément est en cours de validation. Une fois réussie, vous pourrez publier votre élément.",
"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",
Expand Down
Loading

0 comments on commit d9f6414

Please sign in to comment.