-
Notifications
You must be signed in to change notification settings - Fork 7
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
Restrict splash to one story #1753
base: main
Are you sure you want to change the base?
Conversation
f7ea656
to
3f25f08
Compare
…ves the card we're inserting to standard
8225941
to
86888cc
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like the functionailty is good here but I find the nesting if else statement quite difficult to read. I think early returns would help improve the readibility here. Let me know if you'd like to work together to refactor this.
if (numberOfArticlesAlreadyInGroup === 0 || undefined) { | ||
events.dropArticle( | ||
this.props.id, | ||
isDropFromCAPIFeed(e) ? 'feed' : 'url', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The isDropFromCAPIFeed(e) ? 'feed' : 'url'
gets used several times, could we refactor this out to line 266 and store in a variable?
if (to.groupName !== 'splash') { | ||
events.dropArticle(this.props.id, isDropFromCAPIFeed(e) ? 'feed' : 'url'); | ||
this.props.insertCardFromDropEvent(e, to, 'collection'); | ||
} else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I find the nested if else quite difficult to parse, what would you think about refactoring this code to use early returns instead? I think it might make this decision logic easier to follow.
What's changed?
Closes this fronts+curation ticket
As per the ticket description, we want the tool to reflect how the frontend renders so that fronts editors will have clarity over what will appear to users. In this case specifically, as the splash can only contain up to a single story, we want to make sure this is limited in the tool as well.
The approach I've taken is to update the
handleInsert
andhandleMove
functions called when a card is dragged to a collection/group, such that if we're not adding a card to a group with the name splash, nothing has changed and the pre-existing logic keeps running to insert as normal. This only concerns the new fairground containers, so it didn't feel necessary to ensure this is implemented retroactively.If we are adding to a splash, we check how many cards there already are in the group and which position we're inserting to:
Some new properties to relevant components have been added to enable checking these conditions (e.g. the ids of the groups in the collection, and the name and cards currently in the relevant group).
Manual testing would involve checking these four scenarios, for both dragging from the feed of stories and moving between groups.
The jest tests have just been updated to pass, but not take into account these conditions yet - happy to try adding these variations though.
The branch is currently up on code.
Video
insert.move.mov
Checklist
General
Client