This suggestion came in from our end-users. On our project, we currently have only 2 sites. Each site only has one channel. And the two sites cross-share content between them (so only one remote per site). When visiting the content pull form, they have 2 select lists, each with only a single value in them. The suggestion made is that:

  • When on the Entity Sync pull form, if only one site is available, that option is pre-selected.
  • On the same form, if only one channel is available from the selected site, that option is pre-selected.
  • On a site where only one remote and one channel on that remote is available, both options should be selected and the list of entities should be shown upon visiting the page (AJAX loading after the rest of the page okay).

IMO it would be best if these were not select lists if only one option was available, instead just a text string was shown indicating the site name and channel, when only one is available either.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

quicksketch created an issue. See original summary.

Grimreaper’s picture

Assigned: Unassigned » Grimreaper
Grimreaper’s picture

Assigned: Grimreaper » Unassigned
Status: Active » Needs review
FileSize
4.09 KB

Hi quicksketch!

Happy new year!

Here is a patch that pre-select the remote and channel and disable the select list if only one choice is available.

The automated tests are currently failing on drupal.org. There is a dedicated issue for that #3101334: Fix automated tests, so please ignore this failure.

Waiting your feedbacks before merging.

Regards,

quicksketch’s picture

Hi @Grimreaper! I ran into a problem with this patch in that array_key_first() is PHP 7.3+. Apparently we're using 7.2 currently. Considering the array of $channel_options is only going to have one value, we could use key() and still get the same result 100% of the time.

So instead of

      $channel_default_value = array_key_first($channel_options);

Use

      $channel_default_value = key($channel_options);
quicksketch’s picture

Here's a patch that works the same but makes that one line difference for lower versions of PHP.

Grimreaper’s picture

Assigned: Unassigned » Grimreaper

Hi @quicksketch,

Thanks for the test and the feedback. Here is my review:

+++ b/modules/entity_share_client/src/Form/PullForm.php
@@ -404,13 +415,25 @@ class PullForm extends FormBase {
+      $channel_default_value = array_key_first($channel_options);

I will change into key() too here.

I will make the change and commit.

  • Grimreaper authored 3d72095 on 8.x-2.x
    Issue #3095252 by quicksketch, Grimreaper: Hide or pre-select Entity...
Grimreaper’s picture

Assigned: Grimreaper » Unassigned
Status: Needs review » Fixed

This is merged now!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.