Commit 02fa3749 authored by Gábor Hojtsy's avatar Gábor Hojtsy
Browse files

Issue #3168907 by Gábor Hojtsy, Kristen Pol: Projects already up to date are...

Issue #3168907 by Gábor Hojtsy, Kristen Pol: Projects already up to date are categorised as to be updated
parent 1dbabe7e
......@@ -373,7 +373,8 @@ class UpgradeStatusForm extends FormBase {
}
// Start of drupal.org data columns.
if (isset($extension->info['upgrade_status_update_link'])) {
$updatev = $this->t('Not applicable');
if (!empty($extension->info['upgrade_status_update_link'])) {
$option['updatev'] = [
'data' => [
'link' => [
......@@ -383,19 +384,29 @@ class UpgradeStatusForm extends FormBase {
],
]
];
unset($updatev);
}
else {
elseif (!empty($extension->info['upgrade_status_update'])) {
$updatev = $this->t('Unavailable');
if ($extension->info['upgrade_status_update'] == ProjectCollector::UPDATE_NOT_CHECKED) {
$updatev = $this->t('Unchecked');
}
elseif ($extension->info['upgrade_status_update'] == ProjectCollector::UPDATE_ALREADY_INSTALLED) {
$updatev = $this->t('Up to date');
}
}
if (!empty($updatev)) {
$option['updatev'] = [
'data' => [
'label' => [
'#type' => 'markup',
'#markup' => $this->t('N/A'),
'#markup' => $updatev,
],
]
];
}
$update_class = 'status-info-na';
$update_info = $this->t('N/A');
$update_info = $this->t('Not applicable');
if (isset($extension->info['upgrade_status_update'])) {
switch ($extension->info['upgrade_status_update']) {
case ProjectCollector::UPDATE_NOT_AVAILABLE:
......@@ -406,13 +417,16 @@ class UpgradeStatusForm extends FormBase {
$update_info = $this->t('Unchecked');
$update_class = 'status-info-unchecked';
break;
case ProjectCollector::UPDATE_NOT_DRUPAL_9_COMPATIBLE:
$update_info = $this->t('Incompatible');
$update_class = 'status-info-incompatible';
break;
case ProjectCollector::UPDATE_DRUPAL_9_COMPATIBLE:
$update_info = $this->t('Compatible');
$update_class = 'status-info-compatible';
case ProjectCollector::UPDATE_AVAILABLE:
case ProjectCollector::UPDATE_ALREADY_INSTALLED:
if ($extension->info['upgrade_status_update_compatible']) {
$update_info = $this->t('Compatible');
$update_class = 'status-info-compatible';
}
else {
$update_info = $this->t('Incompatible');
$update_class = 'status-info-incompatible';
}
break;
}
}
......@@ -430,7 +444,7 @@ class UpgradeStatusForm extends FormBase {
'data' => [
'label' => [
'#type' => 'markup',
'#markup' => $this->t('N/A'),
'#markup' => $this->t('Not applicable'),
],
]
];
......
......@@ -64,19 +64,14 @@ class ProjectCollector {
const UPDATE_NOT_AVAILABLE = 1;
/**
* Update available for a project but not Drupal 9 compatible.
* Update available for a project.
*/
const UPDATE_NOT_DRUPAL_9_COMPATIBLE = 2;
/**
* Drupal 9 compatible update available for a project.
*/
const UPDATE_DRUPAL_9_COMPATIBLE = 3;
const UPDATE_AVAILABLE = 2;
/**
* The latest version is already being used.
*/
const UPDATE_ALREADY_INSTALLED = 4;
const UPDATE_ALREADY_INSTALLED = 3;
/**
* Custom project.
......@@ -284,16 +279,21 @@ class ProjectCollector {
else {
// Add Drupal 9 compatibility info from the update's data.
$latest_release = reset($project_update['releases']);
$projects[$name]->info['upgrade_status_update'] = self::UPDATE_NOT_DRUPAL_9_COMPATIBLE;
$projects[$name]->info['upgrade_status_update_compatible'] = FALSE;
if (!empty($latest_release['core_compatibility']) && Semver::satisfies('9.0.0', $latest_release['core_compatibility'])) {
$projects[$name]->info['upgrade_status_update'] = self::UPDATE_DRUPAL_9_COMPATIBLE;
$projects[$name]->info['upgrade_status_update_compatible'] = TRUE;
}
// Denormalize update info into the extension info for our own use.
if ($extension->info['version'] !== $latest_release['version']) {
$projects[$name]->info['upgrade_status_update'] = self::UPDATE_AVAILABLE;
$link = $project_update['link'] . '/releases/' . $latest_release['version'];
$projects[$name]->info['upgrade_status_update_link'] = $link;
$projects[$name]->info['upgrade_status_update_version'] = $latest_release['version'];
}
else {
// If the current version is already the latest, store that.
$projects[$name]->info['upgrade_status_update'] = self::UPDATE_ALREADY_INSTALLED;
}
}
}
......@@ -301,7 +301,7 @@ class ProjectCollector {
$scan_result = $this->getResults($name);
// Pick a suggested next step for this project.
if ($extension->info['upgrade_status_9_compatible'] && $extension->info['upgrade_status_type'] == ProjectCollector::TYPE_CONTRIB) {
if ($extension->info['upgrade_status_9_compatible'] && $extension->info['upgrade_status_type'] == self::TYPE_CONTRIB) {
// If the project was contrib and already Drupal 9 compatible, relax.
$extension->info['upgrade_status_next'] = self::NEXT_RELAX;
}
......@@ -309,13 +309,13 @@ class ProjectCollector {
// Uninstalled modules should be removed.
$extension->info['upgrade_status_next'] = self::NEXT_REMOVE;
}
elseif (isset($extension->info['upgrade_status_update']) && in_array($extension->info['upgrade_status_update'], [self::UPDATE_DRUPAL_9_COMPATIBLE, self::UPDATE_NOT_DRUPAL_9_COMPATIBLE])) {
elseif (isset($extension->info['upgrade_status_update']) && $extension->info['upgrade_status_update'] == self::UPDATE_AVAILABLE) {
// If there was a Drupal 9 compatible update or even a yet incompatble
// update to this project, the best course of action is to update to
// that, since that should move closer to Drupal 9 compatibility.
$extension->info['upgrade_status_next'] = self::NEXT_UPDATE;
}
elseif ($extension->info['upgrade_status_type'] == ProjectCollector::TYPE_CONTRIB) {
elseif ($extension->info['upgrade_status_type'] == self::TYPE_CONTRIB) {
// For installed contributed modules that do not have compatile updates, collaborate.
$extension->info['upgrade_status_next'] = self::NEXT_COLLABORATE;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment