Skip to content

Commit

Permalink
feat: remove Outdate and NotPublic states (#1367)
Browse files Browse the repository at this point in the history
  • Loading branch information
ReidyT authored Jul 25, 2024
1 parent 9ca52c9 commit 184affd
Show file tree
Hide file tree
Showing 16 changed files with 89 additions and 239 deletions.
51 changes: 0 additions & 51 deletions cypress/e2e/item/publish/publishedItem.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,31 +176,6 @@ describe('Private Item', () => {
});
});

describe('Visibility of published item is private again', () => {
const status = PublicationStatus.NotPublic;
const itemValidationGroup = ItemValidationGroupFactory(privateItem);

beforeEach(() => {
setUpAndVisitItemPage(PublishedItemFactory(privateItem), {
itemPublicationStatus: status,
itemValidationGroups: [itemValidationGroup],
});
openPublishItemTab(privateItem.id);
});

it('Publication status should be Not Public', () => {
getPublicationStatusComponent(status)
.should('exist')
.should('be.visible');
});

it('Should ask before change item visility to public', () => {
getPublicationButton(status).click(); // Click on change visibility
confirmSetItemToPublic();
waitOnSetItemPublic(privateItem);
});
});

describe('Item is not valid', () => {
const status = PublicationStatus.Invalid;
const itemValidationGroup = ItemValidationGroupFactory(privateItem, {
Expand Down Expand Up @@ -310,32 +285,6 @@ describe('Public Item', () => {
});
});

describe('Outdated Item', () => {
const status = PublicationStatus.Outdated;
const itemValidationGroup = ItemValidationGroupFactory(publicItem, {
isOutDated: true,
});

beforeEach(() => {
setUpAndVisitItemPage(publicItem, {
itemPublicationStatus: status,
itemValidationGroups: [itemValidationGroup],
});
openPublishItemTab(publicItem.id);
});

it('Publication status should be Outdated', () => {
getPublicationStatusComponent(status)
.should('exist')
.should('be.visible');
});

it('Item can be validated again', () => {
getPublicationButton(status).click(); // click on validate
waitOnItemValidation(publicItem);
});
});

describe('Published Item', () => {
const status = PublicationStatus.Published;
const itemValidationGroup = ItemValidationGroupFactory(publicItem);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"@graasp/chatbox": "3.1.0",
"@graasp/map": "1.16.0",
"@graasp/query-client": "3.16.0",
"@graasp/sdk": "4.20.0",
"@graasp/sdk": "4.21.0",
"@graasp/translations": "1.32.0",
"@graasp/ui": "4.22.0",
"@mui/icons-material": "5.16.4",
Expand Down
118 changes: 62 additions & 56 deletions src/components/item/publish/PublicationStatusComponent.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
import CloudDoneIcon from '@mui/icons-material/CloudDone';
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, PublicationStatus } from '@graasp/sdk';
Expand All @@ -14,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 @@ -58,57 +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: <CloudUploadIcon />,
label: t(BUILDER.LIBRARY_SETTINGS_PUBLICATION_STATUS_READY_TO_PUBLISH),
color: 'success',
},
[PublicationStatus.NotPublic]: {
icon: <PublicOffIcon />,
label: t(BUILDER.LIBRARY_SETTINGS_PUBLICATION_STATUS_NOT_PUBLIC),
color: 'error',
},
[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
44 changes: 0 additions & 44 deletions src/components/item/publish/publicationButtons/NotPublicButton.tsx

This file was deleted.

48 changes: 0 additions & 48 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,8 +6,6 @@ import { hooks } from '@/config/queryClient';

import InvalidButton from './InvalidButton';
import NotAllowedItemTypeButton from './NotAllowedItemTypeButton';
import NotPublicButton from './NotPublicButton';
import OutdatedButton from './OutdatedButton';
import PendingButton from './PendingButton';
import PublishedButton from './PublishedButton';
import PublishedChildrenButton from './PublishedChildrenButton';
Expand Down Expand Up @@ -41,16 +39,15 @@ export const PublicationButtonSelector = ({
notifyCoEditors={notifyCoEditors}
/>
);
case PublicationStatus.NotPublic:
return <NotPublicButton item={item} />;
// 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
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { LoadingButton } from '@mui/lab';
import { Alert } from '@mui/material';
import { Typography } from '@mui/material';

import { PackedItem, PublicationStatus } from '@graasp/sdk';

Expand Down Expand Up @@ -48,9 +48,9 @@ export const ReadyToPublishButton = ({
};

const description = (
<Alert severity="success">
<Typography>
{t(BUILDER.LIBRARY_SETTINGS_VALIDATION_STATUS_READY_TO_PUBLISH)}
</Alert>
</Typography>
);

return (
Expand Down
7 changes: 3 additions & 4 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 All @@ -212,7 +211,7 @@
"LIBRARY_SETTINGS_PUBLICATION_STATUS_PUBLISHED": "منشورة",
"LIBRARY_SETTINGS_PUBLICATION_STATUS_PUBLISHED_CHILDREN": "جزء من مجموعة منشورة",
"LIBRARY_SETTINGS_PUBLICATION_STATUS_PENDING": "في انتظار التحقق من الصحة",
"LIBRARY_SETTINGS_PUBLICATION_STATUS_READY_TO_PUBLISH": "جاهز للنشر",
"LIBRARY_SETTINGS_PUBLICATION_STATUS_READY_TO_PUBLISH": "غير منشورة",
"LIBRARY_SETTINGS_PUBLICATION_STATUS_NOT_PUBLIC": "ينبغي أن تكون عامة",
"LIBRARY_SETTINGS_PUBLICATION_STATUS_INVALID": "غير صالح",
"LIBRARY_SETTINGS_PUBLICATION_STATUS_OUTDATED": "عفا عليها الزمن",
Expand Down
Loading

0 comments on commit 184affd

Please sign in to comment.