From f102073570a8487699009813b9250b38ec20ba2f Mon Sep 17 00:00:00 2001 From: Divya Bhatt Date: Fri, 25 Oct 2024 10:40:46 +0100 Subject: [PATCH 1/2] Change method name to indicate collection update --- fronts-client/src/actions/Cards.ts | 14 +++++++++----- fronts-client/src/components/Clipboard.tsx | 2 +- .../FrontsEdit/FrontCollectionsOverview.tsx | 2 +- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/fronts-client/src/actions/Cards.ts b/fronts-client/src/actions/Cards.ts index 16c907155b4..e1170993222 100644 --- a/fronts-client/src/actions/Cards.ts +++ b/fronts-client/src/actions/Cards.ts @@ -200,9 +200,12 @@ const getRemoveActionCreatorFromType = ( : actionCreator; }; -const updateCardMetaWithPersist = addPersistMetaToAction(updateCardMeta, { - persistTo: 'collection', -}); +const updateCardMetaWithPersistForCollection = addPersistMetaToAction( + updateCardMeta, + { + persistTo: 'collection', + }, +); /** Cards in the standard group of a flexible general container should not be gigaboosted. * When moving a card from the splash group to the standard group, this function checks if the card should be modified. @@ -414,7 +417,7 @@ const addCardToClipboard = (uuid: string) => cloneCardToTarget(uuid, 'clipboard'); const addImageToCard = (uuid: string, imageData: ValidationResponse) => - updateCardMetaWithPersist( + updateCardMetaWithPersistForCollection( uuid, { ...getImageMetaFromValidationResponse(imageData), @@ -459,7 +462,8 @@ export const createArticleEntitiesFromDrop = ( export { insertCardWithCreate, moveCard, - updateCardMetaWithPersist, + updateCardMetaWithPersistForCollection, + updateCardMetaWithPersistForClipboard, removeCard, addImageToCard, copyCardImageMetaWithPersist, diff --git a/fronts-client/src/components/Clipboard.tsx b/fronts-client/src/components/Clipboard.tsx index d7fa0b71cf3..519d7031b8b 100644 --- a/fronts-client/src/components/Clipboard.tsx +++ b/fronts-client/src/components/Clipboard.tsx @@ -7,7 +7,7 @@ import { insertCardFromDropEvent } from 'util/collectionUtils'; import { moveCard, removeCard as removeCardAction, - updateCardMetaWithPersist as updateCardMeta, + updateCardMetaWithPersistForClipboard as updateCardMeta, } from 'actions/Cards'; import { editorSelectCard, diff --git a/fronts-client/src/components/FrontsEdit/FrontCollectionsOverview.tsx b/fronts-client/src/components/FrontsEdit/FrontCollectionsOverview.tsx index 8676c089628..8f44aebce2f 100644 --- a/fronts-client/src/components/FrontsEdit/FrontCollectionsOverview.tsx +++ b/fronts-client/src/components/FrontsEdit/FrontCollectionsOverview.tsx @@ -8,7 +8,7 @@ import CollectionOverview from './CollectionOverview'; import { CardSets } from 'types/Collection'; import ContainerHeadingPinline from 'components/typography/ContainerHeadingPinline'; import ContentContainer from 'components/layout/ContentContainer'; -import { updateCardMetaWithPersist as updateCardMetaAction } from 'actions/Cards'; +import { updateCardMetaWithPersistForCollection as updateCardMetaAction } from 'actions/Cards'; import { editorClearCardSelection } from 'bundles/frontsUI'; import { bindActionCreators } from 'redux'; import { Dispatch } from 'types/Store'; From 344fb35036ebf3045b6448add3becf711857236e Mon Sep 17 00:00:00 2001 From: Divya Bhatt Date: Fri, 25 Oct 2024 10:41:44 +0100 Subject: [PATCH 2/2] Add clipboard update action and call in meta edit --- fronts-client/src/actions/Cards.ts | 7 +++++++ fronts-client/src/components/card/Card.tsx | 24 +++++++++++++++------- 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/fronts-client/src/actions/Cards.ts b/fronts-client/src/actions/Cards.ts index e1170993222..e8fa2637229 100644 --- a/fronts-client/src/actions/Cards.ts +++ b/fronts-client/src/actions/Cards.ts @@ -207,6 +207,13 @@ const updateCardMetaWithPersistForCollection = addPersistMetaToAction( }, ); +const updateCardMetaWithPersistForClipboard = addPersistMetaToAction( + updateCardMeta, + { + persistTo: 'clipboard', + }, +); + /** Cards in the standard group of a flexible general container should not be gigaboosted. * When moving a card from the splash group to the standard group, this function checks if the card should be modified. * If so, it will automatically adjust the boost level from gigaboost to megaboost. diff --git a/fronts-client/src/components/card/Card.tsx b/fronts-client/src/components/card/Card.tsx index 36441482ab7..e75a9d571fe 100644 --- a/fronts-client/src/components/card/Card.tsx +++ b/fronts-client/src/components/card/Card.tsx @@ -42,7 +42,8 @@ import { } from 'bundles/frontsUI'; import { bindActionCreators } from 'redux'; import ArticleMetaForm from '../form/ArticleMetaForm'; -import { updateCardMetaWithPersist as updateCardMetaAction } from 'actions/Cards'; +import { updateCardMetaWithPersistForCollection as updateCardMetaActionForCollection } from 'actions/Cards'; +import { updateCardMetaWithPersistForClipboard as updateCardMetaActionForClipboard } from 'actions/Cards'; import { EditMode } from 'types/EditMode'; import { selectEditMode } from 'selectors/pathSelectors'; import { events } from 'services/GA'; @@ -111,7 +112,8 @@ type CardContainerProps = ContainerProps & { onAddToClipboard: (uuid: string) => void; copyCardImageMeta: (from: string, to: string) => void; addImageToCard: (id: string, response: ValidationResponse) => void; - updateCardMeta: (id: string, meta: CardMeta) => void; + updateCardMetaForCollection: (id: string, meta: CardMeta) => void; + updateCardMetaForClipboard: (id: string, meta: CardMeta) => void; clearCardSelection: (id: string) => void; type?: CardTypes; isSelected: boolean; @@ -151,7 +153,8 @@ class Card extends React.Component { textSize, isUneditable, numSupportingArticles, - updateCardMeta, + updateCardMetaForCollection, + updateCardMetaForClipboard, clearCardSelection, parentId, showMeta, @@ -313,7 +316,11 @@ class Card extends React.Component { key={uuid} form={uuid} onSave={(meta) => { - updateCardMeta(uuid, meta); + updateCardMetaForCollection(uuid, meta); + //todo - save data to clipboard as well a workaround to fix have persistent data even on page revisit, + // this needs proper testing when making frequent calls to dynamo for setting FeastClipboard field on edit, + // might need to check in future how to split these actions for editing meta on collection or editing meta on clipboard + updateCardMetaForClipboard(uuid, meta); clearCardSelection(uuid); }} onCancel={() => clearCardSelection(uuid)} @@ -327,7 +334,8 @@ class Card extends React.Component { key={uuid} form={uuid} onSave={(meta) => { - updateCardMeta(uuid, meta); + updateCardMetaForCollection(uuid, meta); + updateCardMetaForClipboard(uuid, meta); clearCardSelection(uuid); }} onCancel={() => clearCardSelection(uuid)} @@ -343,7 +351,8 @@ class Card extends React.Component { form={uuid} frontId={frontId} onSave={(meta) => { - updateCardMeta(uuid, meta); + updateCardMetaForCollection(uuid, meta); + updateCardMetaForClipboard(uuid, meta); clearCardSelection(uuid); }} onCancel={() => clearCardSelection(uuid)} @@ -520,7 +529,8 @@ const mapDispatchToProps = (dispatch: Dispatch) => { onAddToClipboard: addCardToClipboard, copyCardImageMeta: copyCardImageMetaWithPersist, addImageToCard, - updateCardMeta: updateCardMetaAction, + updateCardMetaForCollection: updateCardMetaActionForCollection, + updateCardMetaForClipboard: updateCardMetaActionForClipboard, clearCardSelection: editorClearCardSelection, }, dispatch,