Skip to content
This repository was archived by the owner on Jan 23, 2025. It is now read-only.

Typeorm #629

Merged
merged 46 commits into from
Jun 1, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
f674892
refactor: change types given typeorm
pyphilia Feb 23, 2023
fbfa6ba
refactor: apply typeorm changes
pyphilia Feb 24, 2023
4f1d5c6
refactor: apply typeorm changes
pyphilia Feb 24, 2023
e8c3ce4
refactor: fix issues
pyphilia Mar 10, 2023
0f91d4c
refactor: add many fixes
pyphilia Mar 14, 2023
ef2600d
refactor: fix export zip
pyphilia Mar 17, 2023
1edcdc4
refactor: merge main
pyphilia Mar 17, 2023
3afd18d
refactor: apply fixes
pyphilia Mar 22, 2023
94d34a3
refactor: fix types
pyphilia Mar 27, 2023
47d90f5
refactor: use mutation hooks, move cypress to ts
pyphilia Apr 21, 2023
a281e7a
refactor: move cypress tests to ts
pyphilia Apr 28, 2023
9333be3
refactor: playwright
pyphilia Apr 28, 2023
7508d0d
refactor: use playwright and miragejs
pyphilia Apr 30, 2023
3428f76
refactor: fix cypress tests
pyphilia Apr 30, 2023
46d1086
refactor: fix tests
pyphilia May 3, 2023
f57a9b8
refactor: fix tests
pyphilia May 3, 2023
b8dc3ae
refactor: fix ts errors, update dep
pyphilia May 3, 2023
c4a89e6
refactor: fix tests
pyphilia May 4, 2023
d9a9d50
refactor: update query client, sdk, translations, ui
pyphilia May 10, 2023
829076a
refactor: merge main
pyphilia May 10, 2023
de7b8a2
refactor: fix issues
pyphilia May 10, 2023
38a9aaa
refactor: fix tests for mentions
pyphilia May 12, 2023
5baf43e
fix: chatbox
spaenleh May 12, 2023
3fd6117
refactor: fix chatbot and license adaption
spaenleh May 15, 2023
a6a0514
refactor: remove FC
pyphilia May 15, 2023
0418b59
refactor: fix errors
pyphilia May 15, 2023
f26468f
Merge remote-tracking branch 'origin/typeorm' into typeorm
pyphilia May 15, 2023
eec55a1
refactor: set tsconfig strict to true
pyphilia May 17, 2023
f2ff397
refactor: fix strict true undefined
pyphilia May 22, 2023
1fe92d0
refactor: fix tests
pyphilia May 22, 2023
d1930d9
refactor: update graasp ui
pyphilia May 22, 2023
1eb4f5c
refactor: update graasp ui
pyphilia May 22, 2023
6232734
refactor: add wait for edit caption in folder test
pyphilia May 23, 2023
52d3662
refactor: fix tests
pyphilia May 23, 2023
25aa724
refactor: enable back coverage
pyphilia May 23, 2023
de0dce0
fix: issues with items not rendering
spaenleh May 22, 2023
b4fed44
fix: member extra and sdk update
spaenleh May 25, 2023
c5bc815
fix: udpate ui and fix test with invalid value
spaenleh May 26, 2023
a098406
fix: issues ItemTagType casing
spaenleh May 26, 2023
ff701cb
refactor: fix ts issues after extension of tsconfig.json
spaenleh May 26, 2023
368823b
chore: remove conflicting inlinesourcemaps options
spaenleh May 30, 2023
f9c66c8
fix: config
spaenleh May 30, 2023
4e12db9
fix: test for redirection
spaenleh May 30, 2023
c253d1b
chore: update deps to rc
spaenleh May 30, 2023
61e2e87
chore: update chatbox version
spaenleh May 31, 2023
0fd41de
chore: update ui version
spaenleh Jun 1, 2023
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
Prev Previous commit
Next Next commit
refactor: apply typeorm changes
  • Loading branch information
pyphilia committed Feb 24, 2023
commit fbfa6ba86791d7ea3f8095eb48b32e79f40dcbe0
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,6 @@
"wait-on": "7.0.1"
},
"resolutions": {
"@graasp/ui": "0.11.1",
"@mui/icons-material": "5.11.0",
"@mui/material": "5.11.6",
"ansi-html": "0.0.8",
Expand All @@ -159,7 +158,9 @@
"node-forge": "1.3.0",
"nth-check": "2.0.1",
"react-error-overlay": "6.0.9",
"@graasp/translations": "1.4.0"
"@graasp/translations": "1.4.0",
"@graasp/query-client": "github:graasp/graasp-query-client#typeorm",
"@graasp/sdk": "github:graasp/graasp-sdk#typeorm"
},
"packageManager": "[email protected]"
}
4 changes: 2 additions & 2 deletions src/components/common/Chatbox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { hooks, useMutation } from '../../config/queryClient';
import { CHATBOX_ID, CHATBOX_INPUT_BOX_ID } from '../../config/selectors';
import { useCurrentUserContext } from '../context/CurrentUserContext';

const { useItemChat, useMembers, useAvatar, useItemMemberships } = hooks;
const { useItemChat, useAvatar, useItemMemberships } = hooks;

type Props = {
item: ItemRecord;
Expand Down Expand Up @@ -47,7 +47,7 @@ const Chatbox = ({ item }: Props): JSX.Element => {

// only show export chat when user has admin right on the item
const isAdmin =
itemPermissions?.find((perms) => perms.memberId === currentMember.id)
itemPermissions?.find((perms) => perms.member.id === currentMember.id)
?.permission === PermissionLevel.Admin;

return (
Expand Down
4 changes: 2 additions & 2 deletions src/components/item/ItemMetadataContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ const ItemMetadataContent = ({ item }: Props): JSX.Element => {
{translateBuilder(BUILDER.ITEM_METADATA_CREATED_AT_TITLE)}
</TableCell>
<TableCell align="right">
{formatDate(item.createdAt, {
{formatDate(item.createdAt as unknown as string, {
locale: i18n.language,
defaultValue: translateCommon(COMMON.UNKNOWN_DATE),
})}
Expand All @@ -117,7 +117,7 @@ const ItemMetadataContent = ({ item }: Props): JSX.Element => {
{translateBuilder(BUILDER.ITEM_METADATA_UPDATED_AT_TITLE)}
</TableCell>
<TableCell align="right">
{formatDate(item.updatedAt, {
{formatDate(item.updatedAt as unknown as string, {
locale: i18n.language,
defaultValue: translateCommon(COMMON.UNKNOWN_DATE),
})}
Expand Down
1 change: 0 additions & 1 deletion src/components/item/header/ItemHeaderActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ const ItemHeaderActions = ({
const { data: member } = useCurrentUserContext();

const { data: memberships } = useItemMemberships(id);
console.log(memberships, id);
const canEdit = isItemUpdateAllowedForUser({
memberships,
memberId: member?.id,
Expand Down
123 changes: 49 additions & 74 deletions src/components/item/publish/CategorySelection.tsx
Original file line number Diff line number Diff line change
@@ -1,26 +1,27 @@
import { List } from 'immutable';

import { AutocompleteChangeReason, Box } from '@mui/material';
import Typography from '@mui/material/Typography';

import { FC, SyntheticEvent } from 'react';
import { useParams } from 'react-router';

import { MUTATION_KEYS } from '@graasp/query-client';
import { Category } from '@graasp/sdk';
import { Category, CategoryType } from '@graasp/sdk';
import { BUILDER } from '@graasp/translations';
import { Loader } from '@graasp/ui';

import {
useBuilderTranslation,
useCategoriesTranslation,
} from '../../../config/i18n';
import { hooks, useMutation } from '../../../config/queryClient';
import { hooks, mutations } from '../../../config/queryClient';
import { LIBRARY_SETTINGS_CATEGORIES_ID } from '../../../config/selectors';
import { sortByName } from '../../../utils/item';
import { useCurrentUserContext } from '../../context/CurrentUserContext';
import DropdownMenu from './DropdownMenu';

const { useCategoryTypes, useCategories, useItemCategories } = hooks;
const { POST_ITEM_CATEGORY, DELETE_ITEM_CATEGORY } = MUTATION_KEYS;
const { useCategories, useItemCategories } = hooks;
const { usePostItemCategory, useDeleteItemCategory } = mutations;

const SELECT_OPTION = 'selectOption';
const REMOVE_OPTION = 'removeOption';
Expand All @@ -32,22 +33,8 @@ type Props = {
const CategorySelection: FC<Props> = ({ disabled }) => {
const { t: translateBuilder } = useBuilderTranslation();
const { t: translateCategories } = useCategoriesTranslation();
const { mutate: createItemCategory } = useMutation<
any,
any,
{
itemId: string;
categoryId: string;
}
>(POST_ITEM_CATEGORY);
const { mutate: deleteItemCategory } = useMutation<
any,
any,
{
itemId: string;
itemCategoryId: string;
}
>(DELETE_ITEM_CATEGORY);
const { mutate: createItemCategory } = usePostItemCategory();
const { mutate: deleteItemCategory } = useDeleteItemCategory();

// user
const { isLoading: isMemberLoading } = useCurrentUserContext();
Expand All @@ -58,84 +45,72 @@ const CategorySelection: FC<Props> = ({ disabled }) => {
// get itemCategories, categoryTypes and allCategories
const { data: itemCategories, isLoading: isItemCategoriesLoading } =
useItemCategories(itemId);
const { data: categoryTypes, isLoading: isCategoryTypesLoading } =
useCategoryTypes();
const { data: allCategories, isLoading: isCategoriesLoading } =
useCategories();

// process data
const categoriesMap = allCategories?.groupBy((entry) => entry.type);

if (
isMemberLoading ||
isItemCategoriesLoading ||
isCategoryTypesLoading ||
isCategoriesLoading
) {
if (isMemberLoading || isItemCategoriesLoading || isCategoriesLoading) {
return <Loader />;
}

const handleChange =
(_valueList: Category[]) =>
(
event: SyntheticEvent,
_values: Category[],
reason: AutocompleteChangeReason,
) => {
if (!itemId) {
console.error('No item id is defined');
return;
}
if (!categoriesMap.size) {
return null;
}

const target = event.target as HTMLOptionElement;
if (reason === SELECT_OPTION) {
// post new category
const newCategoryId = target.getAttribute('data-id');
createItemCategory({
const handleChange = (
event: SyntheticEvent,
_values: Category[],
reason: AutocompleteChangeReason,
) => {
if (!itemId) {
console.error('No item id is defined');
return;
}

const target = event.target as HTMLOptionElement;
if (reason === SELECT_OPTION) {
// post new category
const newCategoryId = target.getAttribute('data-id');
createItemCategory({
itemId,
categoryId: newCategoryId,
});
} else if (reason === REMOVE_OPTION) {
const deletedCategoryId = target.getAttribute('data-id');
const itemCategoryIdToDelete = itemCategories.find(
({ category }) => category.id === deletedCategoryId,
)?.id;
if (itemCategoryIdToDelete) {
deleteItemCategory({
itemId,
categoryId: newCategoryId,
itemCategoryId: itemCategoryIdToDelete,
});
} else if (reason === REMOVE_OPTION) {
const deletedCategoryId = target.getAttribute('data-id');
const itemCategoryIdToDelete = itemCategories.find(
({ categoryId }) => categoryId === deletedCategoryId,
)?.id;
if (itemCategoryIdToDelete) {
deleteItemCategory({
itemId,
itemCategoryId: itemCategoryIdToDelete,
});
}
}
};
}
};

return (
<Box mt={2} id={LIBRARY_SETTINGS_CATEGORIES_ID}>
<Typography variant="h6" mt={2}>
{translateBuilder(BUILDER.ITEM_CATEGORIES_SELECTION_TITLE)}
</Typography>
{categoryTypes?.map(({ id, name }) => {
let values = categoriesMap?.get(id)?.toJS() as Category[];

values =
values
{List(categoriesMap)?.map(([type, categories]) => {
const values =
categories
.map((c) => ({ ...c, name: translateCategories(c.name) }))
?.sort(sortByName) ?? ([] as Category[]);

if (!values.length) {
return null;
}
?.sort(sortByName) ?? List();

return (
<DropdownMenu
key={id}
key={type as CategoryType}
disabled={disabled}
title={translateCategories(name)}
handleChange={handleChange(values)}
title={translateCategories(type)}
handleChange={handleChange}
values={values}
// todo: fix with query client
selectedValues={itemCategories as any}
typeId={id}
selectedValues={itemCategories}
type={type}
/>
);
})}
Expand Down
27 changes: 16 additions & 11 deletions src/components/item/publish/DropdownMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import Typography from '@mui/material/Typography';

import { FC, SyntheticEvent } from 'react';

import { Category, ItemCategory } from '@graasp/sdk';
import { Category, CategoryType, ItemCategory } from '@graasp/sdk';
import { CategoryRecord, ItemCategoryRecord } from '@graasp/sdk/frontend';
import { BUILDER } from '@graasp/translations';

import { useBuilderTranslation } from '../../../config/i18n';
Expand All @@ -21,10 +22,10 @@ import {

type Props = {
disabled: boolean;
typeId: string;
type: CategoryType;
title: string;
values: Category[];
selectedValues?: List<ItemCategory>;
values: List<CategoryRecord>;
selectedValues?: List<ItemCategoryRecord>;
handleChange: (
_event: SyntheticEvent,
value: Category[],
Expand All @@ -34,31 +35,35 @@ type Props = {

const DropdownMenu: FC<Props> = ({
disabled,
typeId,
type,
title,
handleChange,
values,
selectedValues,
}) => {
const { t: translateBuilder } = useBuilderTranslation();

if (!values.size) {
return null;
}

const selected = values.filter(({ id }) =>
selectedValues?.find(({ categoryId }) => categoryId === id),
selectedValues?.find(({ category }) => category.id === id),
);

return (
<Box mt={2}>
<Typography variant="body1" id={buildCategorySelectionTitleId(typeId)}>
<Typography variant="body1" id={buildCategorySelectionTitleId(type)}>
{title}
</Typography>
<Autocomplete
sx={{ width: 'auto', maxWidth: '85%' }}
disabled={disabled || !values}
multiple
disableClearable
id={buildCategorySelectionId(typeId)}
value={selected}
options={values}
id={buildCategorySelectionId(type)}
value={selected.toArray()}
options={values.toArray()}
getOptionLabel={(option: Category) => option.name}
onChange={handleChange}
renderInput={(params) => (
Expand All @@ -75,7 +80,7 @@ const DropdownMenu: FC<Props> = ({
{...props}
// necessary for test
data-id={option.id}
id={buildCategorySelectionOptionId(typeId, option.id)}
id={buildCategorySelectionOptionId(type, option.id)}
>
{option.name}
</li>
Expand Down
Loading