Skip to content
Snippets Groups Projects
Unverified Commit ddaa5d17 authored by Pieter Frenssen's avatar Pieter Frenssen :paperclips: Committed by GitHub
Browse files

Merge pull request #1215 from ec-europa/ISAICP-4392

Isaicp 4392: Change the 'Cancel account' button label on the user cancel form
parents cce030f7 8d848e72
No related branches found
Tags v1.34.0
No related merge requests found
......@@ -30,11 +30,32 @@ Feature:
And I check "Amelia Barker"
And I select "Cancel the selected user account(s)" from "Action"
And I press the "Apply to selected items" button
Then I should see the text "User Hazel Olson cannot be deleted as it is currently the sole owner of these collections:"
Then I should not see the following lines of text:
| This action cannot be undone. |
| When cancelling these accounts |
| Require email confirmation to cancel account |
| Notify user when account is canceled |
But I should see the text "User Hazel Olson cannot be deleted as it is currently the sole owner of these collections:"
And I should see the text "User Amelia Barker cannot be deleted as it is currently the sole owner of these collections:"
And I should not see the text "This action cannot be undone."
And I should see the link "Lugia was just released"
And I should see the link "Articuno is hunted"
And I should see the link "Go back"
And I should not see the button "Cancel accounts"
Scenario: Canceling a user directly from the profile when he is the sole owner of a collection, cannot be done.
When I am logged in as a moderator
And I click "People"
And I click "Hazel Olson"
And I click "Edit" in the "Header" region
And I press "Cancel account"
Then I should not see the following lines of text:
| This action cannot be undone. |
| When cancelling these accounts |
| Require email confirmation to cancel account |
| Notify user when account is canceled |
But I should see the text "User Hazel Olson cannot be deleted as it is currently the sole owner of these collections:"
And I should see the link "Go back"
And I should not see the button "Cancel account"
@javascript
Scenario: A moderator deletes a user.
......@@ -45,11 +66,12 @@ Feature:
And I open the header local tasks menu
And I click "Edit" in the "Header" region
And I press "Cancel account"
And I press "Cancel account"
Then I should see the link "Go back"
When I press "Cancel account"
And I wait for the batch job to finish
And the following system email should have been sent:
| recipient_mail | AliciaPotter@example.com |
| subject | Your account has been deleted. |
| recipient_mail | AliciaPotter@example.com |
| subject | Your account has been deleted. |
| body | Your account alicia__1997 has been deleted.This action has been done in the framework of moderation activities regularly conducted on the Joinup platform. If you believe that this action has been performed by mistake, please contact The Joinup Support Team at |
@javascript
......
......@@ -538,6 +538,7 @@ function joinup_user_form_user_cancel_form_alter(&$form, FormStateInterface $for
$form['user_cancel_confirm']['#access'] = FALSE;
$form['user_cancel_notify']['#default_value'] = TRUE;
$form['user_cancel_notify']['#access'] = FALSE;
$form['actions']['cancel']['#title'] = t('Go back');
}
/**
......
......@@ -65,6 +65,9 @@ public function buildForm(array $form, FormStateInterface $form_state) {
$collections = $this->relationManager->getCollectionsWhereSoleOwner($this->entity);
if (!empty($collections)) {
// No access to the 'Cancel' button should be given if the user is the
// sole owner of a collection.
$form['actions']['submit']['#access'] = FALSE;
$form = [
'collections' => [
'#theme' => 'item_list',
......
......@@ -69,6 +69,9 @@ public function buildForm(array $form, FormStateInterface $form_state) {
foreach (Element::children($form['accounts']) as $user_id) {
/** @var \Drupal\user\Entity\User $account */
$account = $this->userStorage->load($user_id);
if (empty($account)) {
throw new \RuntimeException("User with id {$user_id} was not found.");
}
$collections = $this->relationManager->getCollectionsWhereSoleOwner($account);
if ($collections) {
......@@ -98,6 +101,9 @@ public function buildForm(array $form, FormStateInterface $form_state) {
// delete the user at this point.
unset($form['description']);
$form += $build;
// No access to the 'Cancel' button should be given if there is at least
// one user that is a sole owner of a collection.
$form['actions']['submit']['#access'] = FALSE;
}
return $form;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment