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

don't display archived/trashed entities #1358

Merged
merged 10 commits into from Jun 26, 2019

Conversation

tn3rb
Copy link
Member

@tn3rb tn3rb commented Jun 21, 2019

Problem this Pull Request solves

Archived/deleted entities still appear in the entity lists when using normal filters but this should not be the case.
This simply prevents trashed entities from being considered when checking the status for an entity.

plz note:

I removed several calls to assertDateTimeEntity() and assertTicketEntity() because that check is performed by isTrashed() and isArchived() so the check would be redundant.

How has this been tested

  • monkey based browser testing
  • added unit tests

Copy link
Contributor

@nerrad nerrad left a comment

Choose a reason for hiding this comment

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

How will you account for when wanting to filter trashed/archived entities by their status (for example a report that filters all tickets that were sold out including archived tickets)? I grok having the default not include trashed/archive but I think there still should be a way to override that in the call.

Also, I see there are no unit tests for this helper. Can you add some please?

@nerrad nerrad added this to Code Review in EDTR Refactor via automation Jun 24, 2019
@nerrad nerrad assigned tn3rb and unassigned tn3rb and nerrad Jun 24, 2019
@tn3rb tn3rb requested a review from nerrad June 25, 2019 20:24
export const isActive = ( DateTimeEntity, includeTrashed = false ) => {
return (
( includeTrashed && assertDateTimeEntity( DateTimeEntity ) ) ||
( ! includeTrashed && ! isTrashed( DateTimeEntity ) )
Copy link
Contributor

Choose a reason for hiding this comment

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

These conditionals are repeated multiple times. Would there be value in extracting it into it's own callback to keep things DRY? Something like (naming maybe could be better):

const hasValidDateAndIncludesTrashCondition = ( DateTimeEntity, includeTrashed ) => {
    return ( includeTrashed && assertDateTimeEntity( DateTimeEntity ) ) ||
        ( ! includeTrashed && ! isTrashed( DateTimeEntity ) );
}

Copy link
Member Author

Choose a reason for hiding this comment

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

oooo good point... dunno how I didn't notice that! will do

} );
describe( 'isActive()', () => {
it( 'returns false if Date Entity start and end dates are in future',
() => expect( isActive( upcomingDateEntity() ) ).toBe( false )
Copy link
Contributor

Choose a reason for hiding this comment

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

This returns the value of the expect call. Test callbacks should not return values (see jest-community/eslint-plugin-jest#136).

if (
( includeArchived && ! assertTicketEntity( TicketEntity ) ) ||
( ! includeArchived && isArchived( TicketEntity ) )
) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I have the same feedback here as the status-helper for date-times regarding extracting out this common condition into it's own function that you can call here and elsewhere (to keep code DRY).

@nerrad nerrad removed their assignment Jun 25, 2019
@tn3rb tn3rb requested a review from nerrad June 25, 2019 23:41
Copy link
Contributor

@nerrad nerrad left a comment

Choose a reason for hiding this comment

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

beeeeeeeautiful! 👍

@tn3rb tn3rb force-pushed the EDTR/archived-entity-status branch from 3662bd2 to 89e1909 Compare June 26, 2019 02:12
@tn3rb tn3rb merged commit df98acf into FET/editor-dates-tickets-refactor Jun 26, 2019
@tn3rb tn3rb deleted the EDTR/archived-entity-status branch June 26, 2019 04:57
@tn3rb tn3rb moved this from Code Review to Done in EDTR Refactor Jun 26, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
EDTR Refactor
  
Done
Development

Successfully merging this pull request may close these issues.

None yet

2 participants