Skip to content

Commit 18cfe87

Browse files
author
kim
committed
refactor: apply changes
1 parent d767085 commit 18cfe87

13 files changed

Lines changed: 225 additions & 202 deletions

File tree

cypress/e2e/player/main.cy.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,17 @@ import {
3636

3737
const GRAASP_DOCUMENT_ITEM = PackedDocumentItemFactory();
3838
const items = [
39-
{ ...GRAASP_LINK_ITEM, permission: 'admin' as const },
39+
{ ...GRAASP_LINK_ITEM, permission: 'admin' as const, creator: null },
4040
{
4141
...GRAASP_LINK_ITEM_IFRAME_ONLY,
4242
permission: 'admin' as const,
4343
},
44-
{ ...YOUTUBE_LINK_ITEM, permission: 'admin' as const },
45-
{ ...IMAGE_ITEM_DEFAULT, permission: 'admin' as const },
46-
{ ...VIDEO_ITEM_DEFAULT, permission: 'admin' as const },
47-
{ ...PDF_ITEM_DEFAULT, permission: 'admin' as const },
48-
{ ...GRAASP_DOCUMENT_ITEM, permission: 'admin' as const },
49-
{ ...GRAASP_APP_ITEM, permission: 'admin' as const },
44+
{ ...YOUTUBE_LINK_ITEM, permission: 'admin' as const, creator: null },
45+
{ ...IMAGE_ITEM_DEFAULT, permission: 'admin' as const, creator: null },
46+
{ ...VIDEO_ITEM_DEFAULT, permission: 'admin' as const, creator: null },
47+
{ ...PDF_ITEM_DEFAULT, permission: 'admin' as const, creator: null },
48+
{ ...GRAASP_DOCUMENT_ITEM, permission: 'admin' as const, creator: null },
49+
{ ...GRAASP_APP_ITEM, permission: 'admin' as const, creator: null },
5050
...FOLDER_WITH_SUBFOLDER_ITEM.items,
5151
...FOLDER_WITHOUT_CHILDREN_ORDER.items,
5252
];

cypress/e2e/player/utils.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import {
22
CompleteGuest,
3+
FileItemExtra,
34
HttpMethod,
45
MimeTypes,
56
appendQueryParamToUrl,
@@ -96,7 +97,7 @@ export const expectAppViewScreenLayout = ({ id, extra }: AppItem): void => {
9697
};
9798

9899
export const expectFileViewScreenLayout = ({ id, extra }: FileItem): void => {
99-
const mimetype = getFileExtra(extra)?.mimetype ?? '';
100+
const mimetype = getFileExtra(extra as FileItemExtra)?.mimetype ?? '';
100101
// embedded element
101102
let selector = '';
102103
if (MimeTypes.isImage(mimetype)) {

cypress/fixtures/files.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ export const IMAGE_ITEM_DEFAULT: FileItem & { readFilepath: string } = {
1414
description: 'a default image description',
1515
type: 'file',
1616
path: 'bd5519a2_5ba9_4305_b221_185facbe6a99',
17-
creator: CURRENT_MEMBER,
1817
createdAt: '2021-03-16T16:00:50.968Z',
1918
updatedAt: '2021-03-16T16:00:52.655Z',
2019
extra: buildFileExtra({
@@ -39,7 +38,6 @@ export const VIDEO_ITEM_DEFAULT: FileItem & { readFilepath: string } = {
3938
description: 'a default video description',
4039
type: 'file',
4140
path: 'qd5519a2_5ba9_4305_b221_185facbe6a99',
42-
creator: CURRENT_MEMBER,
4341
createdAt: '2021-03-16T16:00:50.968Z',
4442
updatedAt: '2021-03-16T16:00:52.655Z',
4543
extra: buildFileExtra({
@@ -64,7 +62,6 @@ export const PDF_ITEM_DEFAULT: FileItem & { readFilepath: string } = {
6462
description: 'a default pdf description',
6563
type: 'file',
6664
path: 'cd5519a2_5ba9_4305_b221_185facbe6a99',
67-
creator: CURRENT_MEMBER,
6865
createdAt: '2021-03-16T16:00:50.968Z',
6966
updatedAt: '2021-03-16T16:00:52.655Z',
7067
extra: buildFileExtra({

cypress/support/server.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1659,15 +1659,12 @@ export const mockGetPublishItemsForMember = (
16591659
`${API_HOST}/${buildGetPublishedItemsForMemberRoute(ID_FORMAT)}`,
16601660
),
16611661
},
1662-
({ reply, url }) => {
1662+
({ reply }) => {
16631663
if (shoulThrow) {
16641664
return reply({ statusCode: StatusCodes.INTERNAL_SERVER_ERROR });
16651665
}
16661666

1667-
const memberId = url.slice(API_HOST.length).split('/')[4];
1668-
const published = publishedItemData
1669-
.filter((p) => p.item.creator.id === memberId)
1670-
.map((i) => i.item);
1667+
const published = publishedItemData.map((i) => i.item);
16711668
return reply(published);
16721669
},
16731670
).as('getPublishedItemsForMember');

src/AuthContext.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ export function AuthProvider({
131131
id: currentMember.id,
132132
lang: getCurrentAccountLang(currentMember, DEFAULT_LANG),
133133
type: AccountType.Guest as const,
134-
item: currentMember.itemLoginSchema.item as GenericItem,
134+
item: currentMember.itemLoginSchema.item as unknown as GenericItem,
135135
},
136136
logout,
137137
login: null,

src/modules/builder/components/item/settings/ItemMetadataContent.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import TableRow from '@mui/material/TableRow';
1010
import Typography from '@mui/material/Typography';
1111

1212
import {
13+
FileItemExtra,
1314
formatDate,
1415
formatFileSize,
1516
getFileExtra,
@@ -41,7 +42,7 @@ const ItemMetadataContent = (): JSX.Element => {
4142
let size = null;
4243
let mimetype = null;
4344
if (item.type === 'file') {
44-
const extra = getFileExtra(item.extra);
45+
const extra = getFileExtra(item.extra as FileItemExtra);
4546
mimetype = extra?.mimetype;
4647
size = extra?.size;
4748
}
@@ -84,7 +85,6 @@ const ItemMetadataContent = (): JSX.Element => {
8485
{mimetype ?? getItemType(item)}
8586
<Preview>
8687
{item.type === 'folder' &&
87-
// TODO: fix any
8888
// eslint-disable-next-line @typescript-eslint/no-explicit-any
8989
(isCapsule(item as any) ? (
9090
<ConvertToFolderButton

src/modules/builder/components/table/ItemCard.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@ import { formatDate, getLinkThumbnailUrl } from '@graasp/sdk';
77

88
import { NS } from '@/config/constants';
99
import { ITEM_CARD_CLASS, buildItemCard } from '@/config/selectors';
10-
import type { Item } from '@/openapi/client';
10+
import type { PackedItem } from '@/openapi/client';
1111
import { Card, type CardProps } from '@/ui/Card/Card';
1212
import TextDisplay from '@/ui/TextDisplay/TextDisplay';
1313

1414
import { getItemType } from '~builder/utils/capsule';
1515

1616
type Props = {
17-
item: Item;
17+
item: PackedItem;
1818
dense?: boolean;
1919
footer: JSX.Element;
2020
isOver?: boolean;

src/modules/builder/components/table/useSorting.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Dispatch, useState } from 'react';
22
import { useTranslation } from 'react-i18next';
33

44
import { NS } from '@/config/constants';
5-
import type { GenericItem } from '@/openapi/client';
5+
import type { PackedItem } from '@/openapi/client';
66

77
import { Ordering, OrderingType } from '~builder/enums';
88

@@ -24,14 +24,14 @@ export const useSorting = ({
2424
ordering: OrderingType;
2525
setSortBy: Dispatch<AllSortingOptions>;
2626
setOrdering: Dispatch<OrderingType>;
27-
sortFn: (a: GenericItem, b: GenericItem) => number;
27+
sortFn: (a: PackedItem, b: PackedItem) => number;
2828
} => {
2929
const [sortBy, setSortBy] = useState<AllSortingOptions>(
3030
s ?? SortingOptions.ItemUpdatedAt,
3131
);
3232
const [ordering, setOrdering] = useState<OrderingType>(o);
3333

34-
const sortFn = (a: GenericItem, b: GenericItem) => {
34+
const sortFn = (a: PackedItem, b: PackedItem) => {
3535
const f = ordering === Ordering.ASC ? 1 : -1;
3636
let value = 0;
3737
switch (sortBy) {

src/modules/player/common/ItemThumbnail.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,8 @@ const ItemThumbnail = ({
1919
return (
2020
<ItemIcon
2121
type={item.type}
22-
// TODO: fix type
2322
// eslint-disable-next-line @typescript-eslint/no-explicit-any
24-
mimetype={getMimetype((item as any).extra)}
23+
mimetype={getMimetype(item.extra as any)}
2524
alt={item.name}
2625
iconSrc={thumbnailSrc}
2726
/>

src/openapi/client/@tanstack/react-query.gen.ts

Lines changed: 3 additions & 3 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)