From 3f25f08b86fd25901b74f220b8bf4f830899efa4 Mon Sep 17 00:00:00 2001 From: Georges Lebreton <102960844+Georges-GNM@users.noreply.github.com> Date: Wed, 29 Jan 2025 17:01:35 +0000 Subject: [PATCH] remove unnecessary number of cards in group prop --- fronts-client/src/components/FrontsEdit/Collection.tsx | 3 --- fronts-client/src/components/FrontsEdit/FrontContent.tsx | 4 ++-- fronts-client/src/components/clipboard/CardLevel.tsx | 3 --- fronts-client/src/components/clipboard/GroupLevel.tsx | 3 --- fronts-client/src/lib/dnd/Level.tsx | 3 --- fronts-client/src/lib/dnd/__tests__/dnd.spec.tsx | 3 --- fronts-client/src/util/collectionUtils.ts | 1 - 7 files changed, 2 insertions(+), 18 deletions(-) diff --git a/fronts-client/src/components/FrontsEdit/Collection.tsx b/fronts-client/src/components/FrontsEdit/Collection.tsx index 0f5d1adda93..97c456ca2c6 100644 --- a/fronts-client/src/components/FrontsEdit/Collection.tsx +++ b/fronts-client/src/components/FrontsEdit/Collection.tsx @@ -163,8 +163,6 @@ class CollectionContext extends React.Component isUneditable={isUneditable} groupId={group.uuid} groupName={group.name ? group.name : ''} - //todo: numberOfCards can probably just be got by the card array - numberOfCardsInGroup={group.cards.length} groupsIds={groupsIds} onMove={handleMove} onDrop={handleInsert} @@ -200,7 +198,6 @@ class CollectionContext extends React.Component isUneditable={isUneditable} cardId={card.uuid} groupName={group.name ? group.name : ''} - numberOfCardsInGroup={group.cards.length} groupsIds={groupsIds} onMove={handleMove} onDrop={handleInsert} diff --git a/fronts-client/src/components/FrontsEdit/FrontContent.tsx b/fronts-client/src/components/FrontsEdit/FrontContent.tsx index 229ef5716a8..946d5b2b36c 100644 --- a/fronts-client/src/components/FrontsEdit/FrontContent.tsx +++ b/fronts-client/src/components/FrontsEdit/FrontContent.tsx @@ -179,7 +179,7 @@ class FrontContent extends React.Component { } public handleMove = (move: Move) => { - const numberOfArticlesAlreadyInGroup = move.to.numberOfCardsInGroup; + const numberOfArticlesAlreadyInGroup = move.to.cards?.length; // if we are inserting an article into any group that is not the splash, then we just insert if (move.to.groupName !== 'splash') { @@ -262,7 +262,7 @@ class FrontContent extends React.Component { }; public handleInsert = (e: React.DragEvent, to: PosSpec) => { - const numberOfArticlesAlreadyInGroup = to.numberOfCardsInGroup; + const numberOfArticlesAlreadyInGroup = to.cards?.length; // if we are inserting an article into any group that is not the splash, then we just insert if (to.groupName !== 'splash') { diff --git a/fronts-client/src/components/clipboard/CardLevel.tsx b/fronts-client/src/components/clipboard/CardLevel.tsx index b6d8b1946c7..7520d89b8de 100644 --- a/fronts-client/src/components/clipboard/CardLevel.tsx +++ b/fronts-client/src/components/clipboard/CardLevel.tsx @@ -21,7 +21,6 @@ interface OuterProps { dropMessage?: string; cardTypeAllowList?: CardTypes[]; groupName?: string; - numberOfCardsInGroup?: number; groupsIds?: string[]; } @@ -53,7 +52,6 @@ const CardLevel = ({ dropMessage, cardTypeAllowList, groupName, - numberOfCardsInGroup, groupsIds, }: Props) => ( ( { parentId: string; parentType: string; groupName?: string; - numberOfCardsInGroup?: number; groupsIds?: string[]; type: string; getDropType?: (item: T) => string; @@ -186,7 +184,6 @@ class Level extends React.Component, State> { type: this.props.parentType, id: this.props.parentId, groupName: this.props.groupName, - numberOfCardsInGroup: this.props.numberOfCardsInGroup, groupsIds: this.props.groupsIds, cards: this.props.arr, }; diff --git a/fronts-client/src/lib/dnd/__tests__/dnd.spec.tsx b/fronts-client/src/lib/dnd/__tests__/dnd.spec.tsx index 41d4f6ada1b..524085da9ae 100644 --- a/fronts-client/src/lib/dnd/__tests__/dnd.spec.tsx +++ b/fronts-client/src/lib/dnd/__tests__/dnd.spec.tsx @@ -116,7 +116,6 @@ describe('Curation', () => { groupsIds: undefined, id: '2', index: 1, - numberOfCardsInGroup: undefined, type: 'a', }, }); @@ -178,7 +177,6 @@ describe('Curation', () => { groupsIds: undefined, id: '2', index: 0, - numberOfCardsInGroup: undefined, type: 'a', }, }); @@ -295,7 +293,6 @@ describe('Curation', () => { groupsIds: undefined, id: '2', index: 1, - numberOfCardsInGroup: undefined, type: 'a', }); }); diff --git a/fronts-client/src/util/collectionUtils.ts b/fronts-client/src/util/collectionUtils.ts index b910106d21f..60cba848d02 100644 --- a/fronts-client/src/util/collectionUtils.ts +++ b/fronts-client/src/util/collectionUtils.ts @@ -64,7 +64,6 @@ export type InsertDropType = keyof typeof dropToCardMap; const dropToCard = (e: React.DragEvent): MappableDropType | null => { for (const [type, fn] of Object.entries(dropToCardMap)) { const data = e.dataTransfer.getData(type); - if (data) { return fn(data); }