diff --git a/src/Controller/InstallerController.php b/src/Controller/InstallerController.php index dc2ff6d884e0e64c5275884f30f3145a264ce34a..47f223f16cd963e670279c43e02d9db6d5dfc0b0 100644 --- a/src/Controller/InstallerController.php +++ b/src/Controller/InstallerController.php @@ -210,7 +210,7 @@ class InstallerController extends ControllerBase { // accessed after. This final check ensures a destroy is not attempted // during apply. if ($this->installer->isApplying()) { - throw new StageException($this->installer, 'A stage can not be unlocked while applying'); + throw new StageException('Another project is being added. Try again in a few minutes.'); } // Adding the TRUE parameter to destroy is dangerous, but we provide it @@ -230,7 +230,7 @@ class InstallerController extends ControllerBase { return $this->errorResponse($e); } $this->installState->deleteAll(); - $this->messenger()->addStatus($this->t('Install staging area unlocked.')); + $this->messenger()->addStatus($this->t('Operation complete, you can add a new project again.')); return $this->redirect('project_browser.browse'); } @@ -272,13 +272,13 @@ class InstallerController extends ControllerBase { if (!$stage_available) { $updated_time = $this->installState->getFirstUpdatedTime(); if (!$this->installer->lockCameFromProjectBrowserInstaller()) { - return $this->lockedResponse($this->t('The installation stage is locked by a process outside of Project Browser'), ''); + return $this->lockedResponse($this->t('The process for adding projects was locked by something else outside of Project Browser. Projects can be added again once the process is unlocked. Try again in a few minutes.'), ''); } if (empty($updated_time)) { $unlock_url = self::getUrlWithReplacedCsrfTokenPlaceholder( Url::fromRoute('project_browser.install.unlock') ); - $message = t('An install staging area claimed by Project Browser exists but has expired. You may unlock the stage and try the install again.'); + $message = t('The process for adding projects is locked, but that lock has expired. Use [+ unlock link] to unlock the process and try to add the project again.'); return $this->lockedResponse($message, $unlock_url); } $time_since_updated = $this->time->getRequestTime() - $updated_time; @@ -287,26 +287,20 @@ class InstallerController extends ControllerBase { $minutes = $time_since_updated > 60 ? $minutes : 'less than 1'; if ($this->installer->isApplying()) { $message = empty(floor($hours)) ? - $this->t('The install staging area was locked @minutes minutes ago. It should not be unlocked as the changes from staging are being applied to the site.', [ - '@minutes' => $minutes, - ]) : - $this->t('The install staging area was locked @hours hours, @minutes minutes ago. It should not be unlocked as the changes from staging are being applied to the site.', [ - '@hours' => $hours, - '@minutes' => $minutes, - ]); + $this->t('The process for adding the project was locked @minutes minutes ago. It should not be unlocked while changes are being applied to the site.', ['@minutes' => $minutes]) : + $this->t('The process for adding the project was locked @hours hours, @minutes minutes ago. It should not be unlocked + while changes are being applied to the site.', ['@hours' => $hours, '@minutes' => $minutes]); return $this->lockedResponse($message, ''); } elseif ($hours === 0 && ($minutes < 7 || $minutes === 'less than 1')) { - $message = $this->t('The install staging area was locked @minutes minutes ago. This is recent enough that a legitimate installation may be in progress. Consider waiting before unlocking the installation staging area.', ['@minutes' => $minutes]); + $message = $this->t('The process for adding the project that was locked @minutes minutes ago might still be in progress. Consider waiting a few more minutes before using [+unlock link].', ['@minutes' => $minutes]); } else { $message = empty($hours) ? - $this->t('The install staging area was locked @minutes minutes ago.', ['@minutes' => $minutes]) : - $this->t('The install staging area was locked @hours hours, @minutes minutes ago.', [ - '@hours' => $hours, - '@minutes' => $minutes, - ]); + $this->t('The process for adding the project was locked @minutes minutes ago. Use [+ unlock link] to unlock the process.', ['@minutes' => $minutes]) : + $this->t('The process for adding the project was locked @hours hours, @minutes minutes ago. Use [+ unlock link] to unlock the process.', + ['@hours' => $hours, '@minutes' => $minutes]); } $unlock_url = self::getUrlWithReplacedCsrfTokenPlaceholder( diff --git a/sveltejs/public/build/bundle.js b/sveltejs/public/build/bundle.js index b238c0d358745cc5a5d3a0162ea3956d95d02b26..b7a1496402b684ac8ca5289b28b3464655b1df6a 100644 Binary files a/sveltejs/public/build/bundle.js and b/sveltejs/public/build/bundle.js differ diff --git a/sveltejs/public/build/bundle.js.map b/sveltejs/public/build/bundle.js.map index 44642ed1977cd6767846588d8e145d532428f94c..91895f3563f488d43bd78adad7d02d91d66b72e9 100644 Binary files a/sveltejs/public/build/bundle.js.map and b/sveltejs/public/build/bundle.js.map differ diff --git a/sveltejs/src/ProcessQueueButton.svelte b/sveltejs/src/ProcessQueueButton.svelte index 7c5e8f6575111c056f06547a1280393d9b284ee7..44d4a5b9b15c8ec0599b6437514a3b3bfa989438 100644 --- a/sveltejs/src/ProcessQueueButton.svelte +++ b/sveltejs/src/ProcessQueueButton.svelte @@ -47,9 +47,14 @@ const unlockUrl = new URL(err.unlock_url, BASE_URL); unlockUrl.searchParams.set('destination', currentUrl); - div.innerHTML += `<p>${errorMessage} <a href="${ - unlockUrl.pathname + unlockUrl.search - }" id="unlock-link">${Drupal.t('Unlock Install Stage')}</a></p>`; + const updatedMessage = errorMessage.replace( + '[+ unlock link]', + `<a href="${ + unlockUrl.pathname + unlockUrl.search + }" id="unlock-link">${Drupal.t('unlock link')}</a>`, + ); + + div.innerHTML += `<p>${updatedMessage}</p>`; } catch (urlError) { div.innerHTML += `<p>${errorMessage}</p>`; } diff --git a/tests/src/Functional/InstallerControllerTest.php b/tests/src/Functional/InstallerControllerTest.php index d62ae2f8cb49838c2fcf60ffe688c101b209f329..ccba786a502c38d9c0de8eb33df04e890cecf809 100644 --- a/tests/src/Functional/InstallerControllerTest.php +++ b/tests/src/Functional/InstallerControllerTest.php @@ -442,7 +442,7 @@ class InstallerControllerTest extends BrowserTestBase { // Check for mid install unlock offer message. $this->drupalGet('admin/modules/project_browser/install-begin'); $this->assertSession()->statusCodeEquals(418); - $this->assertMatchesRegularExpression('/{"message":"The install staging area was locked less than 1 minutes ago. This is recent enough that a legitimate installation may be in progress. Consider waiting before unlocking the installation staging area.","unlock_url":".*admin..modules..project_browser..install..unlock\?token=[a-zA-Z0-9_-]*"}/', $this->getSession()->getPage()->getContent()); + $this->assertMatchesRegularExpression('/{"message":"The process for adding the project that was locked less than 1 minutes ago might still be in progress. Consider waiting a few more minutes before using \[\+unlock link\].","unlock_url":".*admin..modules..project_browser..install..unlock\?token=[a-zA-Z0-9_-]*"}/', $this->getSession()->getPage()->getContent()); $expected = [ 'project_browser_test_mock/awesome_module' => [ 'source' => 'project_browser_test_mock', @@ -457,23 +457,23 @@ class InstallerControllerTest extends BrowserTestBase { $this->assertSession()->statusCodeEquals(418); $this->assertFalse($this->installer->isAvailable()); $this->assertFalse($this->installer->isApplying()); - $this->assertMatchesRegularExpression('/{"message":"The install staging area was locked 13 minutes ago.","unlock_url":".*admin..modules..project_browser..install..unlock\?token=[a-zA-Z0-9_-]*"}/', $this->getSession()->getPage()->getContent()); + $this->assertMatchesRegularExpression('/{"message":"The process for adding the project was locked 13 minutes ago. Use \[\+ unlock link\] to unlock the process.","unlock_url":".*admin..modules..project_browser..install..unlock\?token=[a-zA-Z0-9_-]*"}/', $this->getSession()->getPage()->getContent()); $this->doApply(); TestTime::setFakeTimeByOffset('+800 seconds'); $this->drupalGet('admin/modules/project_browser/install-begin'); $this->assertSession()->statusCodeEquals(418); $this->assertFalse($this->installer->isAvailable()); $this->assertTrue($this->installer->isApplying()); - $this->assertMatchesRegularExpression('/{"message":"The install staging area was locked 13 minutes ago. It should not be unlocked as the changes from staging are being applied to the site.","unlock_url":""}/', $this->getSession()->getPage()->getContent()); + $this->assertMatchesRegularExpression('/{"message":"The process for adding the project was locked 13 minutes ago. It should not be unlocked while changes are being applied to the site.","unlock_url":""}/', $this->getSession()->getPage()->getContent()); TestTime::setFakeTimeByOffset("+55 minutes"); $this->drupalGet('admin/modules/project_browser/install-begin'); $this->assertSession()->statusCodeEquals(418); - $this->assertMatchesRegularExpression('/{"message":"The install staging area was locked 55 minutes ago. It should not be unlocked as the changes from staging are being applied to the site.","unlock_url":""}/', $this->getSession()->getPage()->getContent()); + $this->assertMatchesRegularExpression('/{"message":"The process for adding the project was locked 55 minutes ago. It should not be unlocked while changes are being applied to the site.","unlock_url":""}/', $this->getSession()->getPage()->getContent()); // Unlocking the stage becomes possible after 1 hour regardless of source. TestTime::setFakeTimeByOffset("+75 minutes"); $this->drupalGet('admin/modules/project_browser/install-begin'); $this->assertSession()->statusCodeEquals(418); - $this->assertMatchesRegularExpression('/{"message":"The install staging area was locked 1 hours, 15 minutes ago.","unlock_url":".*admin..modules..project_browser..install..unlock\?token=[a-zA-Z0-9_-]*"}/', $this->getSession()->getPage()->getContent()); + $this->assertMatchesRegularExpression('/{"message":"The process for adding the project was locked 1 hours, 15 minutes ago. Use \[\+ unlock link\] to unlock the process.","unlock_url":".*admin..modules..project_browser..install..unlock\?token=[a-zA-Z0-9_-]*"}/', $this->getSession()->getPage()->getContent()); } /** @@ -492,13 +492,13 @@ class InstallerControllerTest extends BrowserTestBase { $this->assertFalse($this->installer->isAvailable()); $this->assertFalse($this->installer->isApplying()); $json = Json::decode($content); - $this->assertSame('An install staging area claimed by Project Browser exists but has expired. You may unlock the stage and try the install again.', $json['message']); + $this->assertSame('The process for adding projects is locked, but that lock has expired. Use [+ unlock link] to unlock the process and try to add the project again.', $json['message']); $path = explode('?', $json['unlock_url'])[0]; $token = explode('=', $json['unlock_url'])[1]; $unlock_content = $this->drupalGet($path, ['query' => ['token' => $token]]); $this->assertSession()->statusCodeEquals(200); $this->assertTrue($this->installer->isAvailable()); - $this->assertStringContainsString('Install staging area unlocked', $unlock_content); + $this->assertStringContainsString('Operation complete, you can add a new project again.', $unlock_content); $this->assertTrue($this->installer->isAvailable()); $this->assertFalse($this->installer->isApplying()); } @@ -516,13 +516,13 @@ class InstallerControllerTest extends BrowserTestBase { $this->assertFalse($this->installer->isAvailable()); $this->assertFalse($this->installer->isApplying()); $json = Json::decode($content); - $this->assertSame('An install staging area claimed by Project Browser exists but has expired. You may unlock the stage and try the install again.', $json['message']); + $this->assertSame('The process for adding projects is locked, but that lock has expired. Use [+ unlock link] to unlock the process and try to add the project again.', $json['message']); $path = explode('?', $json['unlock_url'])[0]; $token = explode('=', $json['unlock_url'])[1]; $unlock_content = $this->drupalGet($path, ['query' => ['token' => $token]]); $this->assertSession()->statusCodeEquals(200); $this->assertTrue($this->installer->isAvailable()); - $this->assertStringContainsString('Install staging area unlocked', $unlock_content); + $this->assertStringContainsString('Operation complete, you can add a new project again.', $unlock_content); $this->assertTrue($this->installer->isAvailable()); $this->assertFalse($this->installer->isApplying()); } diff --git a/tests/src/FunctionalJavascript/ProjectBrowserInstallerUiTest.php b/tests/src/FunctionalJavascript/ProjectBrowserInstallerUiTest.php index 0138d61337eab01509f0c003793b19d0b85f9b82..a9172649663f35921f90c8a3ce16d763411ce23e 100644 --- a/tests/src/FunctionalJavascript/ProjectBrowserInstallerUiTest.php +++ b/tests/src/FunctionalJavascript/ProjectBrowserInstallerUiTest.php @@ -208,7 +208,7 @@ class ProjectBrowserInstallerUiTest extends WebDriverTestBase { $this->assertNotEmpty($assert_session->waitForButton('Install selected projects')); $page->pressButton('Install selected projects'); - $this->assertTrue($assert_session->waitForText('An install staging area claimed by Project Browser exists but has expired. You may unlock the stage and try the install again.')); + $this->assertTrue($assert_session->waitForText('The process for adding projects is locked, but that lock has expired. Use unlock link to unlock the process and try to add the project again.')); // Click Unlock Install Stage link. $this->clickWithWait('#ui-id-1 > p > a'); @@ -249,7 +249,7 @@ class ProjectBrowserInstallerUiTest extends WebDriverTestBase { $cream_cheese_button->click(); $this->assertNotEmpty($assert_session->waitForButton('Install selected projects')); $page->pressButton('Install selected projects'); - $this->assertTrue($assert_session->waitForText('An install staging area claimed by Project Browser exists but has expired. You may unlock the stage and try the install again.')); + $this->assertTrue($assert_session->waitForText('The process for adding projects is locked, but that lock has expired. Use unlock link to unlock the process and try to add the project again.')); // Click Unlock Install Stage link. $this->clickWithWait('#ui-id-1 > p > a'); $this->svelteInitHelper('text', 'Cream cheese on a bagel');