Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: redesign add link interface #1165

Merged
merged 15 commits into from
May 28, 2024
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 1 addition & 22 deletions cypress/e2e/item/create/createDocument.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,7 @@ import {
PackedFolderItemFactory,
} from '@graasp/sdk';

import {
CREATE_ITEM_BUTTON_ID,
CREATE_ITEM_DOCUMENT_ID,
ITEM_FORM_CONFIRM_BUTTON_ID,
ITEM_FORM_DISPLAY_NAME_INPUT_ID,
ITEM_FORM_NAME_INPUT_ID,
} from '@/config/selectors';
import { ITEM_FORM_CONFIRM_BUTTON_ID } from '@/config/selectors';

import { HOME_PATH, buildItemPath } from '../../../../src/config/paths';
import ItemLayoutMode from '../../../../src/enums/itemLayoutMode';
Expand Down Expand Up @@ -74,19 +68,4 @@ describe('Create Document', () => {
true,
);
});

it('autoComplete document displayName', () => {
cy.setUpApi();
cy.visit(HOME_PATH);

cy.switchMode(ItemLayoutMode.List);

cy.get(`#${CREATE_ITEM_BUTTON_ID}`).click();
cy.get(`#${CREATE_ITEM_DOCUMENT_ID}`).click();
cy.get(`#${ITEM_FORM_NAME_INPUT_ID}`).type('Test Name');
cy.get(`#${ITEM_FORM_DISPLAY_NAME_INPUT_ID}`).should(
'have.value',
'Test Name',
);
});
});
4 changes: 4 additions & 0 deletions cypress/fixtures/links.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ export const YOUTUBE_LINK_ITEM: LinkItemType = PackedLinkItemFactory({
thumbnails: ['https://i.ytimg.com/vi/FmiEgBMTPLo/maxresdefault.jpg'],
icons: ['https://www.youtube.com/s/desktop/f0ff6c1d/img/favicon_96.png'],
}),
settings: {
// this is necessary for Youtube to show the embed
showLinkIframe: true,
},
});

export const INVALID_LINK_ITEM: LinkItemType = PackedLinkItemFactory({
Expand Down
3 changes: 3 additions & 0 deletions cypress/support/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ import {
mockGetItems,
mockGetItemsTags,
mockGetLatestValidationGroup,
mockGetLinkMetadata,
mockGetManyPublishItemInformations,
mockGetMember,
mockGetMemberMentions,
Expand Down Expand Up @@ -341,6 +342,8 @@ Cypress.Commands.add(
mockPatchShortLink(cachedShortLinks, patchShortLinkError);

mockDeleteShortLink(cachedShortLinks, deleteShortLinkError);

mockGetLinkMetadata();
},
);

Expand Down
26 changes: 26 additions & 0 deletions cypress/support/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2195,3 +2195,29 @@ export const mockDeleteShortLink = (
},
).as('deleteShortLink');
};

export const mockGetLinkMetadata = (): void => {
cy.intercept(
{
method: HttpMethod.Get,
url: new RegExp(`${API_HOST}/items/embedded-links/metadata*`),
},
({ reply, url }) => {
let linkUrl = new URL(url).searchParams.get('link');

if (!linkUrl.includes('http')) {
linkUrl = `https://${linkUrl}`;
}
if (URL.canParse(linkUrl)) {
return reply({
title: 'Page title',
description: 'Page description',
html: '',
icons: [],
thumbnails: [],
});
}
return reply({ statusCode: StatusCodes.BAD_REQUEST });
},
).as('getLinkMetadata');
};
3 changes: 2 additions & 1 deletion cypress/support/viewUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ export const expectLinkViewScreenLayout = ({
}

if (!html && (settings?.showLinkButton ?? DEFAULT_LINK_SHOW_BUTTON)) {
cy.get('[data-testid="OpenInNewIcon"]').should('be.visible');
// this data-testid is set in graasp/ui
cy.get('[data-testid="fancy-link-card"]').should('be.visible');
spaenleh marked this conversation as resolved.
Show resolved Hide resolved
}

if (description) {
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
"@emotion/styled": "11.11.5",
"@graasp/chatbox": "3.1.0",
"@graasp/map": "1.12.1",
"@graasp/query-client": "3.8.0",
"@graasp/sdk": "4.11.0",
"@graasp/query-client": "3.9.0",
"@graasp/sdk": "4.12.0",
"@graasp/translations": "1.28.0",
"@graasp/ui": "4.18.2",
"@graasp/ui": "4.19.0",
"@mui/icons-material": "5.15.18",
"@mui/lab": "5.0.0-alpha.170",
"@mui/material": "5.15.18",
Expand Down
3 changes: 1 addition & 2 deletions src/components/App.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Outlet, useLocation } from 'react-router';
import { Route, Routes } from 'react-router-dom';
import { Outlet, Route, Routes, useLocation } from 'react-router-dom';

import { buildSignInPath, saveUrlForRedirection } from '@graasp/sdk';
import { CustomInitialLoader, withAuthorization } from '@graasp/ui';
Expand Down
2 changes: 1 addition & 1 deletion src/components/context/FilterItemsContext.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { createContext, useContext, useEffect, useMemo, useState } from 'react';
import { useLocation } from 'react-router';
import { useLocation } from 'react-router-dom';

import { DiscriminatedItem } from '@graasp/sdk';

Expand Down
30 changes: 14 additions & 16 deletions src/components/item/ItemContent.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useOutletContext } from 'react-router';
import { useOutletContext } from 'react-router-dom';

import { Container, Skeleton, styled } from '@mui/material';

Expand Down Expand Up @@ -107,21 +107,19 @@ const LinkContent = ({
item: LinkItemType;
member?: Member | null;
}): JSX.Element => (
<StyledContainer>
<LinkItem
id={item.id}
memberId={member?.id}
isResizable
item={item}
height={ITEM_DEFAULT_HEIGHT}
showButton={Boolean(
item.settings?.showLinkButton ?? DEFAULT_LINK_SHOW_BUTTON,
)}
showIframe={Boolean(
item.settings?.showLinkIframe ?? DEFAULT_LINK_SHOW_IFRAME,
)}
/>
</StyledContainer>
<LinkItem
id={item.id}
memberId={member?.id}
isResizable
item={item}
height={ITEM_DEFAULT_HEIGHT}
showButton={Boolean(
item.settings?.showLinkButton ?? DEFAULT_LINK_SHOW_BUTTON,
)}
showIframe={Boolean(
item.settings?.showLinkIframe ?? DEFAULT_LINK_SHOW_IFRAME,
)}
/>
);

/**
Expand Down
70 changes: 0 additions & 70 deletions src/components/item/form/DisplayNameForm.tsx

This file was deleted.

6 changes: 0 additions & 6 deletions src/components/item/form/DocumentForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ import {
ITEM_FORM_DOCUMENT_TEXT_ID,
} from '../../../config/selectors';
import { BUILDER } from '../../../langs/constants';
import DisplayNameForm from './DisplayNameForm';
import type { EditModalContentPropType } from './EditModalWrapper';
import NameForm from './NameForm';

Expand Down Expand Up @@ -305,11 +304,6 @@ const DocumentForm = ({
required
updatedProperties={updatedProperties}
/>
<DisplayNameForm
setChanges={setChanges}
item={item}
updatedProperties={updatedProperties}
/>
</Stack>
<DocumentExtraForm
documentItemId={ITEM_FORM_DOCUMENT_TEXT_ID}
Expand Down
3 changes: 2 additions & 1 deletion src/components/item/form/FolderThumbnail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { FormEventHandler, useRef, useState } from 'react';
import { Dialog, Stack, styled, useTheme } from '@mui/material';

import { DiscriminatedItem } from '@graasp/sdk';
import { DEFAULT_LIGHT_PRIMARY_COLOR } from '@graasp/ui';

import { ImageUp as ImageUpIcon } from 'lucide-react';

Expand Down Expand Up @@ -96,7 +97,7 @@ const FolderThumbnail = ({ setChanges }: FolderThumbnailProps): JSX.Element => {
height={THUMBNAIL_DIMENSION}
width={THUMBNAIL_DIMENSION}
borderRadius={2}
bgcolor="#E4DFFF"
bgcolor={DEFAULT_LIGHT_PRIMARY_COLOR}
alignItems="center"
justifyContent="center"
overflow="hidden"
Expand Down
59 changes: 0 additions & 59 deletions src/components/item/form/LinkForm.tsx

This file was deleted.

Loading