Skip to content
Snippets Groups Projects
Commit 22c5545b authored by utkarsh_33's avatar utkarsh_33 Committed by Chris Wells
Browse files

Issue #3323354 by utkarsh_33, chrisfromredfin, narendrar, srishtiiee, rkoller,...

Issue #3323354 by utkarsh_33, chrisfromredfin, narendrar, srishtiiee, rkoller, benjifisher, lostcarpark, tim.plunkett, anmolgoyal74, bnjmnm, worldlinemine, ravi.shankar, simohell: Review all pop-up messages shown by the Svelte UI installer for user friendliness
parent 7928200f
No related branches found
No related tags found
No related merge requests found
......@@ -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(
......
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
......@@ -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>`;
}
......
......@@ -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());
}
......
......@@ -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');
......
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