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

Store recipes nested in feast collections, and ensure other card types are not permitted within them #1609

Merged
merged 7 commits into from
Aug 2, 2024

Conversation

jonathonherbert
Copy link
Contributor

@jonathonherbert jonathonherbert commented Jul 29, 2024

What's changed?

Stores recipes nested in feast collections, and ensures that other card types are not permitted within them.

Note the refresh, indicating that the data is stored correctly. Prior to this PR, refreshing the page would remove the nested items.

collections

Implementation notes

Although it's no longer possible to put chefs and feast collections within feast collections, the drop icons do still appear when the user hovers over them. I timeboxed fixing this but it turned out to be a bit more complicated that expected! Perhaps we can circle back if user feedback suggests it's a priority.

It wasn't far off the beaten track for this PR, so I've added some messaging changes, too – the drop placeholders say 'Place recipe here' (they used to say 'sublink'), and the sublink expander at the bottom of the Feast Collection card says 'recipes' rather than 'sublinks'.

How to test

  • Attempt to add various cards to a Feast Collection. Do recipes go in? Do all others stay out?
  • Refresh the page. The recipes should remain in the collection.
  • The behaviour of article drag and drop in usual fronts should not have changed – the 'sublinks' messaging should remain:
Screenshot 2024-07-29 at 16 24 04

All tested locally.

Checklist

General

  • 🤖 Relevant tests added
  • ✅ CI checks / tests run locally
  • 🔍 Checked on CODE

Client

  • 🚫 No obvious console errors on the client (i.e. React dev mode errors)
  • 🎛️ No regressions with existing user interactions (i.e. all existing buttons, inputs etc. work)
  • 📷 Screenshots / GIFs of relevant UI changes included

@jonathonherbert jonathonherbert requested a review from a team as a code owner July 29, 2024 15:16
which sadly cannot be modelled recursively, as the DynamoDB serialisers blow up – instead, we model a distinct type on the client, EditionsSupportingClientCard, which omits metadata altogether (for now), as no supporting cards require it. When metadata is eventually required, we will need a separate type for it (not EditionsClientMetadata), as it must not include a  property that allows arbitrarily nested cards
// behaviour to be bypassed.
denylistedDataTransferTypes?: string[];
// If this function returns false, all dragging behaviour is bypassed.
denyDragEvent?: (e: React.DragEvent) => boolean;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is now a function because we no longer what consumers will have to match on until render time.

}),
text: (url: string): RefDrop => ({ type: 'REF', data: url }),
};
const dropToCardMap = {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved to its own data structure so we could statically derive its keys, and get some type safety upstream.

import { CARD_TYPE } from 'lib/dnd/constants';
import { InsertDropType } from './collectionUtils';

export const handleDragStartForCard =
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Helper, as this code was repeated in four different places.

Copy link
Contributor

@fredex42 fredex42 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One small query, otherwise LGTM!

@@ -98,8 +100,7 @@ class Sublinks extends React.Component<SublinkProps> {
);
}

private dragEventNotDenylisted = (e: React.DragEvent) =>
!dragEventIsDenylisted(e, collectionDropTypeDenylist);
private dragEventNotDenylisted = (e: React.DragEvent) => !denyDragEvent()(e);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure I understand what this is for - is in why the double-negative, and whether it would be clearer to remove the indirection through the method given it's just a single call?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I see no reason not to move to an inline method! The reflex to use a method may have been related to a common pattern when class components were used and arrow fns were useful for lexical scoping, but that doesn't apply here. 88ec333

@jonathonherbert jonathonherbert merged commit 945875a into main Aug 2, 2024
12 checks passed
@jonathonherbert jonathonherbert deleted the jsh/permit-supporting-recipes branch August 2, 2024 11:53
@prout-bot
Copy link

Overdue on PROD (merged by @jonathonherbert 30 minutes and 3 seconds ago) What's gone wrong?

@prout-bot
Copy link

Seen on PROD (merged by @jonathonherbert 2 hours, 55 minutes and 57 seconds ago) Please check your changes!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants