Please may we have an action (core action or VBO) to set the Source Domain? It would be helpful to be able to bulk update Source Domain on many nodes at once.

Issue fork domain-3048808

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

qdoscc created an issue. See original summary.

agentrickard’s picture

There is sample code in Drupal\domain_access\Plugin\Action that could be used to create these. I'm open to it.

slbrassard’s picture

StatusFileSize
new9.31 KB

Added two types of actions: one for unset domain source and one for setting the domain source per domain.

slbrassard’s picture

Status: Active » Needs review
vflirt’s picture

StatusFileSize
new3.62 KB

I have tested it out and if the content is assigned to all affiliates it is not working. I also added extra update access check.

Status: Needs review » Needs work

The last submitted patch, 5: set-domain-source-action-3048808-5.patch, failed testing. View results

vflirt’s picture

StatusFileSize
new9.5 KB

Attaching proper file as there are new files added/

agentrickard’s picture

Status: Needs work » Needs review

Looks pretty good on first review.

It should really have a test. There is a similar one in domain/tests/src/Functional/DomainActionsTest.php

agentrickard’s picture

Status: Needs review » Needs work
tim-diels’s picture

Status: Needs work » Needs review
Issue tags: +Needs tests
StatusFileSize
new9.74 KB
new1.75 KB

After testing, I'm not seeing the "Set" action for existing domains. These should be handled in the install function also and not only in the update function?

Also a small PHPCS issue with a t() that should be a $this-t() and another small PHPCS issue.

The tests are not that easy to add, so leaving that open and adding the issue tag.
Setting this to NR for the changes, can be set back to NW afterwards for the tests.

guardiola86’s picture

The patch is working for me. After running updates and clearing the cache, I can set the source origin. The only thing is that the domain must have already been checked in Domain Access, which is correct.

mably’s picture

Version: 8.x-1.x-dev » 2.0.x-dev
Status: Needs review » Needs work

Could we have a MR on 2.0.x please ?

mably’s picture

Status: Needs work » Needs review
Issue tags: +next-release
mably’s picture

Issue tags: -Needs tests

Simple test added. Looks like we are ready for merge.

/**
 * Tests the domain source actions.
 *
 * @group domain
 */
class DomainSourceActionsTest extends DomainTestBase {

  /**
   * {@inheritdoc}
   */
  protected static $modules = [
    'domain',
    'domain_access',
    'domain_source',
    'field',
    'node',
    'user',
  ];

  /**
   * Tests bulk actions through the content overview page.
   */
  public function testDomainSourceActions() {
    $perms = [
      'access administration pages',
      'access content overview',
      'edit any article content',
    ];
    $admin_user = $this->drupalCreateUser($perms);

    // Create test domains.
    $this->domainCreateTestDomains(2);

    // Create a test node.
    $node = $this->drupalCreateNode([
      'type' => 'article',
      'title' => 'Test node',
    ]);

    $this->drupalLogin($admin_user);

    $this->drupalGet('admin/content');

    // Try setting source without domain assignment.
    $action_id = 'domain_source_set_action.example_com';
    $edit = [
      'node_bulk_form[0]' => TRUE,
      'action' => $action_id,
    ];
    $this->submitForm($edit, 'Apply to selected items');

    // Check that we have the right warning on page.
    $this->assertSession()->pageTextContains('Content 1 must be assigned to domain example_com');

    // Try bulk assigning the domain to our node.
    $action_id = 'domain_access_add_action_example_com';
    $edit = [
      'node_bulk_form[0]' => TRUE,
      'action' => $action_id,
    ];
    $this->submitForm($edit, 'Apply to selected items');

    // Retry setting the domain source after the domain assignment.
    $action_id = 'domain_source_set_action.example_com';
    $edit = [
      'node_bulk_form[0]' => TRUE,
      'action' => $action_id,
    ];
    $this->submitForm($edit, 'Apply to selected items');

    // Check that we do not have the previous warning on page.
    $this->assertSession()->pageTextNotContains('Content 1 must be assigned to domain example_com');

    // Check that the domain source have been properly set.
    $node_storage = \Drupal::entityTypeManager()->getStorage('node');
    $node = $node_storage->load(1);
    // Check that the value is set.
    $value = domain_source_get($node);
    $this->assertEquals('example_com', $value, 'Node saved with proper source record.');

  }

}

  • mably committed 4a948dca on 2.0.x
    Issue #3048808 by vflirt, slbrassard, mably: Set domain source action
    
mably’s picture

Status: Needs review » Fixed
Issue tags: -next-release

Status: Fixed » Closed (fixed)

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