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

Cloning issue with Event series and Event instances. #330

Merged
merged 4 commits into from
May 7, 2021
Merged

Cloning issue with Event series and Event instances. #330

merged 4 commits into from
May 7, 2021

Conversation

bharath-kondeti
Copy link

@bharath-kondeti bharath-kondeti commented Apr 29, 2021

Related Issue/Ticket:

ymcatwincities#135

Steps to test:

  • Run composer install
  • Then drush cr for clearing caches.
  • Finally observe the issue is resolved.

Quality checks:

Please check these boxes to confirm this PR covers the following cases:

  • Maintaining our upgrade path is essential. Check one or the other:
    • No updates are necessary for this change.
  • Front end fixes should be tested against all of the Open Y Themes.
    • This change does not contain front-end fixes

@froboy
Copy link

froboy commented May 3, 2021

retest

@froboy
Copy link

froboy commented May 3, 2021

I tested here and this looks good. Reproduction steps (from the linked issue):

  • Log into Virtual Y site as an Admin
  • Edit an Event
  • Click the Clone tab
  • After verifying form is complete, scroll to the bottom to observe Virtual Y Permissions section is present.
  • Save the cloned event
  • View the event in the Schedule
  • Edit the cloned event, scroll down to view the Virtual Y Permissions.
  • Note that Virtual YMCA and Virtual YMCA Premium roles are selected.
  • Sign out, then log in as a Virtual YMCA member.
  • Note the event is included in the Schedule

Copy link

@anpolimus anpolimus left a comment

Choose a reason for hiding this comment

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

Hi, @bharath-kondeti .
Thank you for your PR!
Let's improve it a little bit and avoid hard-coding.
I've proposed a better way to get events bundles from config.
You can read it from there instead of hard-coding in it in the array.

  • can you add some comments about your changes in code?
    Devs that will work with this code in the future will better understand why this check was added.

@@ -193,6 +193,10 @@ function openy_gated_content_form_alter(&$form, FormStateInterface $form_state,
'eventinstance_live_stream_edit_form',
'eventinstance_virtual_meeting_edit_form',
];
$events_bundle = [

Choose a reason for hiding this comment

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

It might be replaced to:
$events_bundle = $gcConfig['permissions_entities']['eventseries']
to get this array and to avoid hard coding

Copy link

@duozersk duozersk May 5, 2021

Choose a reason for hiding this comment

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

@anpolimus while your suggestion does look like an improvement over the original code change - why do we even need this $events_bundle here? If you check later in the code we do already iterate over the "permissions_entities" config array, taking into account both entity type and bundle. And then the new changes suggest that we check if the bundle (the one we get from the iteration cycle) is included into this new $events_bundle variable taken from the same configuration array we iterate on... it doesn't make any sense to me.

Copy link
Author

Choose a reason for hiding this comment

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

@duozersk, Actually, we do not have clone functionality on blogs or videos, whereas it exists on eventseries/eventinstances(virtual_meetings, live_streams) and this behavior is being added from reccurring_events module.

Hence, I had to do an additional check to add _clone_form into $allowedForms array only for eventseries/eventinstances not to blogs/videos.

Copy link

Choose a reason for hiding this comment

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

@bharath-kondeti - OK, I see your motivation. Still you are checking only for the bundle name, and not for the entity type. And the code change gets the bundle names for the "eventseries" entity type (from config), but then affects the "eventinstance" entity types bundles too. It creates "hidden logic"... and the codebase that is hard to maintain.

We do have the "permissions_entities" config - that is the list of entity types/bundles that should have Virtual Y custom permissions handling. The fact that we do have clone functionality only on eventseries/eventinstance entity types doesn't change the thing that we should have custom permissions handling on the node entity type with gc_video and vy_blog_post bundles. And we shouldn't add more meanings to this config or add code that uses just parts of this config...

My motivation here is that we need to write clean, clear and maintainable code. And either use the things we already created in the way they were initially created for (permissions_entities config) or create another thing having another meaning (like permissions_entities_clone config, for instance) if the already existing one doesn't fit our usage. I don't want to see the hidden logic in the code, it won't help us in the long run.

Still I do think that we can use this permissions_entities config as it is without any filtering (based on the fact that currently we don't have clone functionality for blogs and videos). Cause we might add this cloning functionality later on; or another Y might enable it. And having clone form IDs for these 2 bundles doesn't hurt or brake anything - and makes the code much cleaner.

Copy link

Choose a reason for hiding this comment

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

Another thought (if we are going down the filtering path) - according to the explained intent you want to address the eventinstance/eventseries entity types - then why to filter by bundle names and not by entity types?...

Copy link
Author

Choose a reason for hiding this comment

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

@duozersk, I have updated the code. Please do verify

@anpolimus, Can we please have testing done on this again.

Copy link

Choose a reason for hiding this comment

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

@bharath-kondeti Thank you! It looks awesome now!

@AnastasiiaPys
Copy link

@bharath-kondeti @froboy Should I take steps for review from here? ymcatwincities#135

@fjbot
Copy link

fjbot commented May 5, 2021

Build 3000
Coding standards checks failed.
See http://ci.fivejars.com:8080/job/OPENY_GC_PR/3000/display/redirect

@fjbot
Copy link

fjbot commented May 5, 2021

Build 3000
Build failed.
See http://ci.fivejars.com:8080/job/OPENY_GC_PR/3000/display/redirect for details.

@anpolimus
Copy link

@AnastasiiaPys , you can start testing once build is ok

@AnastasiiaPys
Copy link

Tested. Works as expected.

@anpolimus anpolimus merged commit bbeb494 into fivejars:1.4 May 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants