-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: restrict publication to folders only
- 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
- Loading branch information
Showing
20 changed files
with
241 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
src/components/item/publish/publicationButtons/NotAllowedItemTypeButton.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 ( | ||
<Alert severity="info"> | ||
{t(BUILDER.LIBRARY_SETTINGS_TYPE_NOT_ALLOWED_STATUS, { | ||
allowedItemTypes: translatedAllowedTypes, | ||
count: allowedTypes.length, | ||
})} | ||
</Alert> | ||
); | ||
}; | ||
|
||
export default NotAllowedItemTypeButton; |
Oops, something went wrong.