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

UHF-8926 #460

Merged
merged 15 commits into from
Oct 19, 2023
Merged

UHF-8926 #460

merged 15 commits into from
Oct 19, 2023

Conversation

rpnykanen
Copy link
Contributor

@rpnykanen rpnykanen commented Oct 13, 2023

UHF-8926

-Prevent white screen while editing group menu item translation
-Node's edit pages "published on main navigation" checkbox now updates based on group's menu content item's content translation status

What was done

Updated group module
Fixed white screen.
Form alter to keep the "content translation status" checkbox on correct state. For group content, the "published in main navigation" state follows the node's published state. Value is updated while saving (not with javascript)
Update hook to update group's menu item's content translation status to match node status.

How to install

  • Make sure your instance is up and running on correct branch.
    • git checkout UHF-8926
    • composer require drupal/helfi_navigation:dev-UHF-8926
    • make fresh
  • Run make drush-cr

How to test

Log in as user which is assigned to a group, for example user 19.

  • Go to any group, go to the group's menu and try to translate any menu item. The edit form for menu item should load without crash
  • Go to any node which is on the group's menu
    • The "published in main navigation" button should be in correct position when node edit form is loaded (matches menu translation state)
    • Updating node's "published in main navigation" should change the group menu item's translation status.
    • Creating and translating a node and adding it to a group should work normally
  • Compare couple of the group menus as incognito user with production menu. It should look the same
  • Check that this feature works
  • Check that code follows our standards

Other PRs:

/**
* Update group menu item's content translation status to match node's status.
*/
function helfi_group_update_9001() {
Copy link
Member

Choose a reason for hiding this comment

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

Missing return type.

}

$node = $node->getTranslation($langcode);
if ((bool) $menu_item->content_translation_status->value != (bool) $node->isPublished()) {
Copy link
Member

Choose a reason for hiding this comment

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

Use strict comparison !==, $node->isPublished() will always return boolean already

}

/**
* Ticket #UHF-8926: submit handler to set menu items translation status.
Copy link
Member

Choose a reason for hiding this comment

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

The ticket ID is reduntant here imo, it's already explained in code using this handler.

/**
* Implements hook_form_BASE_FORM_ID_alter().
*
* #UHF-8926 Prevent group's MenuContentLink's translation form from crashing
Copy link
Member

Choose a reason for hiding this comment

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

I think this comment could be explained better. Something like:

Group menu emits menu parent from entity's translation form. Make sure menu_parent is always set.

$values = $form_state->getValue('menu');
$node = $form_state->getFormObject()->getEntity();
$langCode = $node->language()->getId();
if (!empty($values['entity_id'])) {
Copy link
Member

Choose a reason for hiding this comment

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

These two ifs can be combined

@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

Copy link
Contributor

@teroelonen teroelonen left a comment

Choose a reason for hiding this comment

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

This is good to go 🦖

@rpnykanen rpnykanen merged commit 1df9ea9 into dev Oct 19, 2023
3 checks passed
@rpnykanen rpnykanen deleted the UHF-8926 branch October 19, 2023 07:24
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.

3 participants