diff --git a/cypress/e2e/item/create/createDocument.cy.ts b/cypress/e2e/item/create/createDocument.cy.ts
index c4893632a..718cf9b09 100644
--- a/cypress/e2e/item/create/createDocument.cy.ts
+++ b/cypress/e2e/item/create/createDocument.cy.ts
@@ -1,4 +1,5 @@
import {
+ DocumentItemExtraFlavor,
DocumentItemFactory,
ItemType,
PackedFolderItemFactory,
@@ -93,4 +94,27 @@ describe('Create Document', () => {
true,
);
});
+
+ it('create document with flavor', () => {
+ cy.setUpApi();
+ cy.visit(HOME_PATH);
+
+ const documentToCreate = DocumentItemFactory({
+ name: 'document',
+ extra: {
+ [ItemType.DOCUMENT]: {
+ content: '
Some Title
',
+ flavor: DocumentItemExtraFlavor.Error,
+ },
+ },
+ });
+ createDocument(documentToCreate);
+
+ cy.wait('@postItem').then(({ request: { body } }) => {
+ expect(body.extra.document.flavor).to.eq(
+ documentToCreate.extra.document.flavor,
+ );
+ expect(body.extra.document.content).to.contain('Some Title');
+ });
+ });
});
diff --git a/cypress/e2e/item/create/createLink.cy.ts b/cypress/e2e/item/create/createLink.cy.ts
index d627bfc24..df6aca0c6 100644
--- a/cypress/e2e/item/create/createLink.cy.ts
+++ b/cypress/e2e/item/create/createLink.cy.ts
@@ -1,4 +1,4 @@
-import { PackedFolderItemFactory } from '@graasp/sdk';
+import { ItemType, PackedFolderItemFactory } from '@graasp/sdk';
import { HOME_PATH, buildItemPath } from '../../../../src/config/paths';
import {
@@ -49,10 +49,10 @@ describe('Create Link', () => {
createLink({ url: 'graasp.org' });
cy.get(`#${ITEM_FORM_CONFIRM_BUTTON_ID}`).click();
- cy.wait('@postItem').then(() => {
+ cy.wait('@postItem').then(({ request: { body } }) => {
// check item is created and displayed
cy.wait(CREATE_ITEM_PAUSE);
-
+ expect(body.extra[ItemType.LINK].url).to.contain('http');
// expect update
cy.wait('@getAccessibleItems');
});
diff --git a/cypress/support/commands/item.ts b/cypress/support/commands/item.ts
index d98ed5e2c..2193615a9 100644
--- a/cypress/support/commands/item.ts
+++ b/cypress/support/commands/item.ts
@@ -3,6 +3,7 @@ import { DiscriminatedItem, getAppExtra, getDocumentExtra } from '@graasp/sdk';
import {
CUSTOM_APP_CYPRESS_ID,
CUSTOM_APP_URL_ID,
+ FLAVOR_SELECT_ID,
FOLDER_FORM_DESCRIPTION_ID,
HOME_MODAL_ITEM_ID,
ITEM_FORM_APP_URL_ID,
@@ -121,6 +122,11 @@ Cypress.Commands.add(
({ name = '', extra }, { confirm = true } = {}) => {
cy.fillBaseItemModal({ name }, { confirm: false });
+ if (extra.document.flavor) {
+ cy.get(`#${FLAVOR_SELECT_ID} div`).click();
+ cy.get(`li[data-value="${extra.document.flavor}"]`).click();
+ }
+
const content =
// first select all the text and then remove it to have a clear field, then type new text
`{selectall}{backspace}${getDocumentExtra(extra)?.content}`;
@@ -133,7 +139,7 @@ Cypress.Commands.add(
}
if (confirm) {
- cy.get(`#${ITEM_FORM_CONFIRM_BUTTON_ID}`).click();
+ cy.get(`#${ITEM_FORM_CONFIRM_BUTTON_ID}`).scrollIntoView().click();
}
},
);
diff --git a/src/components/item/form/document/DocumentCreateForm.tsx b/src/components/item/form/document/DocumentCreateForm.tsx
index 70adbc6eb..3b729b11b 100644
--- a/src/components/item/form/document/DocumentCreateForm.tsx
+++ b/src/components/item/form/document/DocumentCreateForm.tsx
@@ -55,8 +55,8 @@ export function DocumentCreateForm({
defaultValues: { flavor: DocumentItemExtraFlavor.None },
});
const {
- reset,
handleSubmit,
+ setValue,
formState: { isValid, isSubmitted },
} = methods;
@@ -91,7 +91,9 @@ export function DocumentCreateForm({
reset({ content: v })}
+ onChange={(v) => {
+ setValue('content', v);
+ }}
placeholder={translateBuilder(BUILDER.TEXT_EDITOR_PLACEHOLDER)}
/>
diff --git a/src/components/item/form/link/LinkForm.tsx b/src/components/item/form/link/LinkForm.tsx
index d3878d3b0..84e15ad74 100644
--- a/src/components/item/form/link/LinkForm.tsx
+++ b/src/components/item/form/link/LinkForm.tsx
@@ -125,7 +125,7 @@ export const LinkForm = ({
type: ItemType.LINK,
description: data.description,
extra: buildLinkExtra({
- url: data.url,
+ url: normalizeURL(data.url),
description: linkData?.description,
thumbnails: linkData?.thumbnails,
icons: linkData?.icons,
diff --git a/src/components/item/move/MoveButton.tsx b/src/components/item/move/MoveButton.tsx
index 97ba5620c..c30390f89 100644
--- a/src/components/item/move/MoveButton.tsx
+++ b/src/components/item/move/MoveButton.tsx
@@ -20,7 +20,7 @@ type MoveButtonProps = {
};
const MoveButton = ({
- color = 'primary',
+ color,
id,
type = ActionButton.ICON_BUTTON,
onClick,
diff --git a/src/components/item/sharing/ItemSharingTab.tsx b/src/components/item/sharing/ItemSharingTab.tsx
index 4d9dd5629..893bde620 100644
--- a/src/components/item/sharing/ItemSharingTab.tsx
+++ b/src/components/item/sharing/ItemSharingTab.tsx
@@ -61,9 +61,7 @@ const ItemSharingTab = (): JSX.Element => {
)}
) : (
-
-
-
+
)}
diff --git a/src/components/item/sharing/VisibilitySelect.tsx b/src/components/item/sharing/VisibilitySelect.tsx
index 5409510ff..54af44080 100644
--- a/src/components/item/sharing/VisibilitySelect.tsx
+++ b/src/components/item/sharing/VisibilitySelect.tsx
@@ -1,4 +1,4 @@
-import { MenuItem, Select, Typography } from '@mui/material';
+import { Alert, MenuItem, Select, Stack } from '@mui/material';
import { PackedItem } from '@graasp/sdk';
import { Loader } from '@graasp/ui';
@@ -75,42 +75,44 @@ const VisibilitySelect = ({ item, edit }: Props): JSX.Element | null => {
return (
<>
- {isModalOpen && (
-
- )}
- {edit && (
-
- )}
- {renderVisiblityIndication()}
+
+ {isModalOpen && (
+
+ )}
+ {edit && (
+
+ )}
+ {renderVisiblityIndication()}
+
{isDisabled && (
-
+
{translateBuilder(
BUILDER.ITEM_SETTINGS_VISIBILITY_CANNOT_EDIT_PARENT_MESSAGE,
)}
-
+
)}
>
);
diff --git a/src/components/main/ItemMenuContent.tsx b/src/components/main/ItemMenuContent.tsx
index 385f9f1d6..a1f628a85 100644
--- a/src/components/main/ItemMenuContent.tsx
+++ b/src/components/main/ItemMenuContent.tsx
@@ -114,6 +114,7 @@ const ItemMenuContent = ({ item }: Props): JSX.Element | null => {
canAdmin ? (
{
openMoveModal();