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 clipboard not saving overrides on refresh #1709

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all 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
21 changes: 16 additions & 5 deletions fronts-client/src/actions/Cards.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,9 +200,19 @@ const getRemoveActionCreatorFromType = (
: actionCreator;
};

const updateCardMetaWithPersist = addPersistMetaToAction(updateCardMeta, {
persistTo: 'collection',
});
const updateCardMetaWithPersistForCollection = addPersistMetaToAction(
updateCardMeta,
{
persistTo: 'collection',
},
);

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.
Expand Down Expand Up @@ -414,7 +424,7 @@ const addCardToClipboard = (uuid: string) =>
cloneCardToTarget(uuid, 'clipboard');

const addImageToCard = (uuid: string, imageData: ValidationResponse) =>
updateCardMetaWithPersist(
updateCardMetaWithPersistForCollection(
uuid,
{
...getImageMetaFromValidationResponse(imageData),
Expand Down Expand Up @@ -459,7 +469,8 @@ export const createArticleEntitiesFromDrop = (
export {
insertCardWithCreate,
moveCard,
updateCardMetaWithPersist,
updateCardMetaWithPersistForCollection,
updateCardMetaWithPersistForClipboard,
removeCard,
addImageToCard,
copyCardImageMetaWithPersist,
Expand Down
2 changes: 1 addition & 1 deletion fronts-client/src/components/Clipboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
24 changes: 17 additions & 7 deletions fronts-client/src/components/card/Card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -151,7 +153,8 @@ class Card extends React.Component<CardContainerProps> {
textSize,
isUneditable,
numSupportingArticles,
updateCardMeta,
updateCardMetaForCollection,
updateCardMetaForClipboard,
clearCardSelection,
parentId,
showMeta,
Expand Down Expand Up @@ -313,7 +316,11 @@ class Card extends React.Component<CardContainerProps> {
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)}
Expand All @@ -327,7 +334,8 @@ class Card extends React.Component<CardContainerProps> {
key={uuid}
form={uuid}
onSave={(meta) => {
updateCardMeta(uuid, meta);
updateCardMetaForCollection(uuid, meta);
updateCardMetaForClipboard(uuid, meta);
clearCardSelection(uuid);
}}
onCancel={() => clearCardSelection(uuid)}
Expand All @@ -343,7 +351,8 @@ class Card extends React.Component<CardContainerProps> {
form={uuid}
frontId={frontId}
onSave={(meta) => {
updateCardMeta(uuid, meta);
updateCardMetaForCollection(uuid, meta);
updateCardMetaForClipboard(uuid, meta);
clearCardSelection(uuid);
}}
onCancel={() => clearCardSelection(uuid)}
Expand Down Expand Up @@ -520,7 +529,8 @@ const mapDispatchToProps = (dispatch: Dispatch) => {
onAddToClipboard: addCardToClipboard,
copyCardImageMeta: copyCardImageMetaWithPersist,
addImageToCard,
updateCardMeta: updateCardMetaAction,
updateCardMetaForCollection: updateCardMetaActionForCollection,
updateCardMetaForClipboard: updateCardMetaActionForClipboard,
clearCardSelection: editorClearCardSelection,
},
dispatch,
Expand Down