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

Restrict splash to one story #1753

Open
wants to merge 15 commits into
base: main
Choose a base branch
from

Conversation

Georges-GNM
Copy link
Contributor

@Georges-GNM Georges-GNM commented Jan 23, 2025

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 and handleMove 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:

  • if there's no cards in the group already, we insert as normal
  • if there's a card in the group already, and we're inserting to the bottom of it, the card we're inserting is instead moved to the top of the standard stories group
  • if there's a card in the group already, and we're inserting to the top of it, the new story is inserted into the splash, and the previous story is moved to the top of the standard stories group.

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

  • 🤖 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

@Georges-GNM Georges-GNM self-assigned this Jan 29, 2025
@Georges-GNM Georges-GNM changed the title wip commit - added splash and number of cards in group to insert logic Restrict flex gen splash to one story Jan 29, 2025
@Georges-GNM Georges-GNM changed the title Restrict flex gen splash to one story Restrict splash to one story Jan 29, 2025
@Georges-GNM Georges-GNM force-pushed the gl/restrict-splash-to-one-item-in-flex-gen branch from f7ea656 to 3f25f08 Compare January 29, 2025 17:11
@Georges-GNM Georges-GNM marked this pull request as ready for review January 29, 2025 17:52
@Georges-GNM Georges-GNM requested a review from a team as a code owner January 29, 2025 17:52
@Georges-GNM Georges-GNM force-pushed the gl/restrict-splash-to-one-item-in-flex-gen branch from 8225941 to 86888cc Compare January 30, 2025 12:11
Copy link
Contributor

@abeddow91 abeddow91 left a 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',
Copy link
Contributor

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 {
Copy link
Contributor

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.

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

Successfully merging this pull request may close these issues.

2 participants