The UI at admin/config/search/redirect is missing bulk operations to delete URL redirects.

Before :

Redirect page before.

After :

Redirect page after, with bulk operations.
Redirect page after, with bulk operations.

Comments

Dave Reid created an issue. See original summary.

Bambell’s picture

Status: Active » Needs review
StatusFileSize
new13.57 KB
Bambell’s picture

StatusFileSize
new39.09 KB
new28.13 KB

Adding screenshots.

tduong’s picture

Issue summary: View changes
Status: Needs review » Needs work

Why is there an "Apply" button also under the table ? I guess this is provided by core in case there are a long entities list.. not sure if we should have there kind of actions/operations/forms/buttons with a fixed position and just have a single "Apply" button or whatever we have for a situation like this (duplicated buttons). Maybe it is better to open a core issue...

Feedbacks :D

  1. +++ b/src/Form/DeleteMultiple.php
    @@ -0,0 +1,140 @@
    +  protected $redirects = array();
    

    Use shortened array syntax.

  2. +++ b/src/Form/DeleteMultiple.php
    @@ -0,0 +1,140 @@
    +   * The tempstore factory.
    ...
    +   *   The tempstore factory.
    

    Specify 'private' in the comments.

  3. +++ b/src/Form/DeleteMultiple.php
    @@ -0,0 +1,140 @@
    +  protected $storage;
    ...
    +    $this->storage = $entity_type_manager->getStorage('redirect');
    ...
    +      $this->storage->delete($this->redirects);
    

    $redirectStorage

  4. +++ b/src/Form/DeleteMultiple.php
    @@ -0,0 +1,140 @@
    +  protected $account;
    ...
    +   * @param \Drupal\Core\Session\AccountInterface $account
    ...
    +  public function __construct(PrivateTempStoreFactory $temp_store_factory, EntityTypeManagerInterface $entity_type_manager, AccountInterface $account, TranslationInterface $string_translation) {
    ...
    +    $this->account = $account;
    ...
    +    $this->redirects = $this->privateTempStoreFactory->get('redirect_multiple_delete_confirm')->get($this->account->id());
    ...
    +      $this->privateTempStoreFactory->get('redirect_multiple_delete_confirm')->delete($this->account->id());
    

    $currentUser for better readability.

  5. +++ b/src/Plugin/Action/DeleteRedirect.php
    @@ -0,0 +1,92 @@
    + * Redirects to a redirect deletion form.
    + *
    + * @Action(
    + *   id = "redirect_delete_action",
    + *   label = @Translation("Delete redirect"),
    + *   type = "redirect",
    + *   confirm_form_route_name = "entity.redirect.multiple_delete_confirm"
    + * )
    + */
    +class DeleteRedirect extends ActionBase implements ContainerFactoryPluginInterface {
    

    Not sure if this is needed since there is already a RedirectDeleteForm for single redirect deletion...

  6. +++ b/src/Tests/RedirectUITest.php
    @@ -213,20 +213,29 @@ class RedirectUITest extends WebTestBase {
    -    // Delete the other redirect.
    -    $this->clickLink(t('Delete'));
    -    $this->drupalPostForm(NULL, array(), t('Delete'));
    ...
    -    $this->assertUrl('admin/config/search/redirect');
    

    I guess we still want the standard delete operation (like also in /admin/content), so we should keep the previous delete redirect test and just add yours below.

And don't forget to assign the issue to yourself!
Issue about changes in UI should have both before and after changes screenshots :)

Bambell’s picture

Assigned: Unassigned » Bambell
Status: Needs work » Needs review
StatusFileSize
new13.73 KB
new4.44 KB
new43.97 KB

Thanks for the review ! Changes 1. to 4. have been done. For 5., I'm pretty sure we need a new form just for this purpose (DeleteMultiple, which I renamed here for RedirectDeleteMultipleForm). For 6., it can't be seen in the patch, but redirect deletion via the current delete link is already tested. The test was deleting 2 redirects, for the purpose of emptying the list, so I just removed 1 to insert my test.

    // Test the plural form of the bulk delete action.
    $this->drupalGet('admin/config/search/redirect');
    $edit = [
      'redirect_bulk_form[0]' => TRUE,
      'redirect_bulk_form[1]' => TRUE,
    ];
    $this->drupalPostForm(NULL, $edit, t('Apply'));
    $this->assertText('Are you sure you want to delete these redirects?');
    $this->clickLink('Cancel');

    // Test the delete action.
    $this->clickLink(t('Delete'));
    $this->assertRaw(t('Are you sure you want to delete the URL redirect from %source to %redirect?',
      array('%source' => Url::fromUri('base:non-existing', ['query' => ['key' => 'value']])->toString(), '%redirect' => Url::fromUri('base:node')->toString())));
    $this->drupalPostForm(NULL, array(), t('Delete'));
    $this->assertUrl('admin/config/search/redirect');

    // Test the bulk delete action.
    $this->drupalPostForm(NULL, ['redirect_bulk_form[0]' => TRUE], t('Apply'));
    $this->assertText('Are you sure you want to delete this redirect?');
    $this->assertText('test27');
    $this->drupalPostForm(NULL, [], t('Delete'));

    $this->assertText(t('There is no redirect yet.'));

Also adding before screenshot.

tduong’s picture

Status: Needs review » Needs work

Cool :) Yes, haven't check that properly. My bad, sorry ^^'
Small thing:

+++ b/src/Plugin/Action/DeleteRedirect.php
@@ -0,0 +1,92 @@
+    $this->executeMultiple(array($object));

Use [].

As "before changes screenshots" I meant how the UI looked like at the beginning of the issue, so the page without the patch applied. So you can embed/show it in the IS what you've changed and how it was before ;)

Bambell’s picture

Issue summary: View changes
Status: Needs work » Needs review
StatusFileSize
new38.8 KB
new13.73 KB
new475 bytes

As "before changes screenshots" I meant how the UI looked like at the beginning of the issue [...]

Hahah, I can't believe that I posted an "after" screenshot again ..! Here we go. Using short array syntax and correct "before" screenshot uploaded. IS updated.

tduong’s picture

Yep, looks good to me! :)

berdir’s picture

Assigned: Bambell » Unassigned
Status: Needs review » Reviewed & tested by the community

Agreed.

  • Berdir committed b79c758 on 8.x-1.x authored by Bambell
    Issue #2702343 by Bambell: admin/config/search/redirect missing bulk...
berdir’s picture

Status: Reviewed & tested by the community » Fixed

Thanks, committed.

Status: Fixed » Closed (fixed)

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