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

fix: cant edit an item twice without reloading #842

Merged
merged 7 commits into from
Oct 25, 2023
Merged
Show file tree
Hide file tree
Changes from 6 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
2 changes: 1 addition & 1 deletion .github/workflows/cypress.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
run: tsc --noEmit

- name: Build App
run: NODE_OPTIONS=--max-old-space-size=4096 yarn build:test
run: NODE_OPTIONS=--max-old-space-size=8192 yarn build:test
shell: bash
env:
VITE_PORT: ${{ vars.VITE_PORT }}
Expand Down
5 changes: 5 additions & 0 deletions cypress/fixtures/items.ts
Original file line number Diff line number Diff line change
Expand Up @@ -686,6 +686,7 @@ export const PUBLISHED_ITEM: ItemForTest = {
item,
createdAt: new Date(),
creator: MEMBERS.ANNA,
totalViews: 0,
},
memberships: [
{
Expand Down Expand Up @@ -896,6 +897,7 @@ export const PUBLISHED_ITEMS_WITH_CC_LICENSE: ItemForTest[] = [
item,
createdAt: new Date(),
creator: MEMBERS.ANNA,
totalViews: 0,
},
memberships: [
{
Expand Down Expand Up @@ -934,6 +936,7 @@ export const PUBLISHED_ITEMS_WITH_CC_LICENSE: ItemForTest[] = [
item,
createdAt: new Date(),
creator: MEMBERS.ANNA,
totalViews: 0,
},
memberships: [
{
Expand Down Expand Up @@ -972,6 +975,7 @@ export const PUBLISHED_ITEMS_WITH_CC_LICENSE: ItemForTest[] = [
item,
createdAt: new Date(),
creator: MEMBERS.ANNA,
totalViews: 0,
},
memberships: [
{
Expand Down Expand Up @@ -1010,6 +1014,7 @@ export const PUBLISHED_ITEMS_WITH_CC_LICENSE: ItemForTest[] = [
item,
createdAt: new Date(),
creator: MEMBERS.ANNA,
totalViews: 0,
},
memberships: [
{
Expand Down
62 changes: 32 additions & 30 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@
"@emotion/react": "11.11.1",
"@emotion/styled": "11.11.0",
"@graasp/chatbox": "2.0.1",
"@graasp/query-client": "1.11.0",
"@graasp/sdk": "1.8.0",
"@graasp/query-client": "1.11.1",
"@graasp/sdk": "1.9.2",
"@graasp/translations": "1.19.2",
"@graasp/ui": "3.6.0",
"@mui/icons-material": "5.14.13",
"@graasp/ui": "3.6.1",
"@mui/icons-material": "5.14.14",
"@mui/lab": "5.0.0-alpha.148",
"@mui/material": "5.14.13",
"@sentry/react": "7.73.0",
"@mui/material": "5.14.14",
"@sentry/react": "7.74.1",
"@uppy/core": "3.3.1",
"@uppy/dashboard": "3.4.2",
"@uppy/drag-drop": "3.0.2",
Expand All @@ -38,11 +38,12 @@
"ag-grid-react": "29.3.5",
"axios": "1.5.0",
"date-fns": "2.30.0",
"filesize": "10.0.12",
"http-status-codes": "2.2.0",
"filesize": "10.1.0",
"http-status-codes": "2.3.0",
"immutable": "4.3.4",
"katex": "0.16.9",
"lodash.groupby": "4.6.0",
"lodash.isequal": "4.5.0",
"lodash.partition": "4.6.0",
"lodash.truncate": "4.4.2",
"papaparse": "5.4.1",
Expand All @@ -52,13 +53,13 @@
"react-csv": "2.2.2",
"react-dom": "18.2.0",
"react-ga4": "2.1.0",
"react-i18next": "13.2.0",
"react-i18next": "13.3.1",
"react-image-crop": "9.1.1",
"react-qr-code": "2.0.12",
"react-query": "3.39.3",
"react-quill": "2.0.0",
"react-router": "6.15.0",
"react-router-dom": "6.15.0",
"react-router": "6.17.0",
"react-router-dom": "6.17.0",
"react-toastify": "9.1.3",
"short-uuid": "4.2.2",
"stylis": "4.3.0",
Expand Down Expand Up @@ -104,30 +105,31 @@
"devDependencies": {
"@commitlint/cli": "17.8.1",
"@commitlint/config-conventional": "17.8.1",
"@cypress/code-coverage": "3.11.0",
"@testing-library/jest-dom": "^6.0.0",
"@cypress/code-coverage": "3.12.4",
"@testing-library/jest-dom": "^6.1.4",
"@testing-library/react": "^14.0.0",
"@testing-library/user-event": "^14.4.3",
"@testing-library/user-event": "^14.5.1",
"@trivago/prettier-plugin-sort-imports": "4.2.0",
"@types/jest": "29.5.4",
"@types/jest": "29.5.6",
"@types/lodash.isequal": "4.5.7",
"@types/lodash.partition": "4.6.8",
"@types/lodash.truncate": "4.4.8",
"@types/node": "18.17.12",
"@types/papaparse": "5.3.8",
"@types/qs": "6.9.7",
"@types/node": "20.8.7",
"@types/papaparse": "5.3.10",
"@types/qs": "6.9.9",
"@types/react": "18.2.31",
"@types/react-csv": "1.1.3",
"@types/react-dom": "18.2.7",
"@types/uuid": "9.0.2",
"@types/validator": "13.11.1",
"@typescript-eslint/eslint-plugin": "6.5.0",
"@typescript-eslint/parser": "6.5.0",
"@vitejs/plugin-react": "4.0.4",
"concurrently": "8.2.1",
"cypress": "13.3.0",
"@types/react-csv": "1.1.7",
"@types/react-dom": "18.2.14",
"@types/uuid": "9.0.6",
"@types/validator": "13.11.5",
"@typescript-eslint/eslint-plugin": "6.8.0",
"@typescript-eslint/parser": "6.8.0",
"@vitejs/plugin-react": "4.1.0",
"concurrently": "8.2.2",
"cypress": "13.3.2",
"cypress-localstorage-commands": "2.2.4",
"env-cmd": "10.1.0",
"eslint": "^8.47.0",
"eslint": "^8.51.0",
"eslint-config-airbnb": "19.0.4",
"eslint-config-prettier": "9.0.0",
"eslint-import-resolver-typescript": "3.6.1",
Expand All @@ -137,10 +139,10 @@
"eslint-plugin-react-hooks": "4.6.0",
"husky": "8.0.3",
"nyc": "15.1.0",
"prettier": "3.0.2",
"prettier": "3.0.3",
"rollup-plugin-visualizer": "5.9.2",
"typescript": "5.2.2",
"vite": "4.4.9",
"vite": "4.5.0",
"vite-plugin-checker": "0.6.2",
"vite-plugin-istanbul": "5.0.0"
},
Expand Down
4 changes: 1 addition & 3 deletions src/components/RecycleBinScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ import { Box } from '@mui/material';

import { Loader } from '@graasp/ui';

import { List } from 'immutable';

import { useBuilderTranslation } from '../config/i18n';
import { hooks } from '../config/queryClient';
import {
Expand Down Expand Up @@ -67,7 +65,7 @@ const RecycleBinLoadableContent = (): JSX.Element => {
id={RECYCLED_ITEMS_ID}
clickable={false}
title={translateBuilder(BUILDER.RECYCLE_BIN_TITLE)}
items={recycledItems ?? List()}
items={recycledItems}
actions={RowActions}
ToolbarActions={ToolbarActions}
showThumbnails={false}
Expand Down
4 changes: 1 addition & 3 deletions src/components/SharedItems.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ import Box from '@mui/material/Box';

import { Loader } from '@graasp/ui';

import { List } from 'immutable';

import { BUILDER } from '@/langs/constants';

import { useBuilderTranslation } from '../config/i18n';
Expand Down Expand Up @@ -35,7 +33,7 @@ const SharedItemsLoadableContent = (): JSX.Element => {
<Items
id={SHARED_ITEMS_ID}
title={translateBuilder(BUILDER.SHARED_ITEMS_TITLE)}
items={sharedItems ?? List()}
items={sharedItems}
showCreator
/>
</Box>
Expand Down
22 changes: 16 additions & 6 deletions src/components/common/EditButton.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import { useState } from 'react';

import { Dialog } from '@mui/material';

import { DiscriminatedItem, ItemType } from '@graasp/sdk';
import { EditButton as GraaspEditButton } from '@graasp/ui';

import { useBuilderTranslation } from '../../config/i18n';
import {
EDIT_ITEM_BUTTON_CLASS,
EDIT_MODAL_ID,
buildEditButtonId,
} from '../../config/selectors';
import { BUILDER } from '../../langs/constants';
Expand All @@ -30,7 +33,7 @@ const EditButton = ({ item }: Props): JSX.Element => {
};

const typeToFormComponent = (): EditModalContentType => {
switch (item?.type) {
switch (item.type) {
case ItemType.DOCUMENT:
return DocumentForm;
case ItemType.LOCAL_FILE:
Expand All @@ -50,12 +53,19 @@ const EditButton = ({ item }: Props): JSX.Element => {

return (
<>
<EditModalWrapper
item={item}
ComponentType={typeToFormComponent()}
setOpen={setOpen}
<Dialog
id={EDIT_MODAL_ID}
open={open}
/>
// onClose={onClose}
spaenleh marked this conversation as resolved.
Show resolved Hide resolved
maxWidth="sm"
fullWidth
>
<EditModalWrapper
item={item}
ComponentType={typeToFormComponent()}
setOpen={setOpen}
/>
</Dialog>
<GraaspEditButton
tooltip={translateBuilder(BUILDER.EDIT_ITEM_BUTTON)}
id={buildEditButtonId(item.id)}
Expand Down
5 changes: 4 additions & 1 deletion src/components/common/FavoriteButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,10 @@ const FavoriteButton = ({
return null;
}

const isFavorite = isItemFavorite(item, favorites);
const isFavorite = isItemFavorite(
item,
favorites as List<ItemFavoriteRecord>,
);

const handleFavorite = () => {
addFavorite.mutate(item.id);
Expand Down
4 changes: 2 additions & 2 deletions src/components/item/form/DocumentForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { ITEM_FORM_DOCUMENT_TEXT_ID } from '../../../config/selectors';
import { BUILDER } from '../../../langs/constants';
import { buildDocumentExtra } from '../../../utils/itemExtra';
import type { EditModalContentPropType } from './EditModalWrapper';
import BaseForm from './NameForm';
import NameForm from './NameForm';

export const DocumentExtraForm = ({
documentItemId,
Expand Down Expand Up @@ -138,7 +138,7 @@ const DocumentForm = ({
return (
<>
<Box>
<BaseForm
<NameForm
setChanges={setChanges}
item={item}
required
Expand Down
Loading