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

Issue #3486291: Include the wrench icon on the detail's modal

parent 11fc8842
No related branches found
No related tags found
No related merge requests found
Showing with 47 additions and 0 deletions
......@@ -221,6 +221,7 @@ class RandomDataPlugin extends ProjectBrowserSourceBase {
'alt' => $machine_name . ' logo',
],
isCompatible: (bool) ($i / 4),
isMaintained: (bool) rand(0, 1),
isCovered: (bool) rand(0, 1),
projectUsageTotal: rand(0, 100000),
machineName: $machine_name,
......
......@@ -138,6 +138,7 @@ class ProjectBrowserSourceExample extends ProjectBrowserSourceBase {
// Maybe the source won't have all fields, but we still need to
// populate the values of all the properties.
isCompatible: TRUE,
isMaintained: TRUE,
isCovered: TRUE,
projectUsageTotal: 0,
machineName: $project_from_source['unique_name'],
......@@ -158,6 +159,7 @@ class ProjectBrowserSourceExample extends ProjectBrowserSourceBase {
// Maybe the source won't have all fields, but we still need to
// populate the values of all the properties.
isCompatible: TRUE,
isMaintained: TRUE,
isCovered: TRUE,
projectUsageTotal: 0,
machineName: $project_from_source['unique_name'] . '2',
......
......@@ -189,6 +189,7 @@ class DrupalCore extends ProjectBrowserSourceBase {
],
// All core projects are considered compatible.
isCompatible: TRUE,
isMaintained: TRUE,
isCovered: $module->info['package'] !== 'Core (Experimental)',
projectUsageTotal: -1,
machineName: $module_name,
......
......@@ -285,6 +285,9 @@ class DrupalDotOrgJsonApi extends ProjectBrowserSourceBase {
public function getProjects(array $query = []): ProjectsResultsPage {
$api_response = $this->fetchProjects($query);
$filter_values = $this->filterValues();
$maintained_values = $filter_values['maintained'] ?? [];
$returned_list = [];
if (is_array($api_response) && !empty($api_response['list'])) {
$related = !empty($api_response['related']) ? $api_response['related'] : NULL;
......@@ -373,6 +376,7 @@ class DrupalDotOrgJsonApi extends ProjectBrowserSourceBase {
$project_object = new Project(
logo: $logo,
isCompatible: $is_compatible,
isMaintained: in_array($maintenance_status['id'], $maintained_values),
isCovered: in_array($project['attributes']['field_security_advisory_coverage'], self::COVERED_VALUES),
projectUsageTotal: $project_usage_total,
machineName: $machine_name,
......
......@@ -102,6 +102,7 @@ class Recipes extends ProjectBrowserSourceBase {
]),
],
isCompatible: TRUE,
isMaintained: TRUE,
isCovered: TRUE,
projectUsageTotal: 0,
machineName: basename($path),
......
......@@ -84,6 +84,8 @@ class Project implements \JsonSerializable {
* Author of the project in array format.
* @param string $packageName
* The Composer package name of this project, e.g. `drupal/project_browser`.
* @param bool $isMaintained
* Whether the project is considered to be maintained or not.
* @param \Drupal\Core\Url|null $url
* URL of the project, if any. Defaults to NULL.
* @param array $categories
......@@ -112,6 +114,7 @@ class Project implements \JsonSerializable {
public string $title,
public array $author,
public string $packageName,
public bool $isMaintained = FALSE,
public ?Url $url = NULL,
public array $categories = [],
public array $images = [],
......@@ -193,6 +196,7 @@ class Project implements \JsonSerializable {
'author' => $this->author,
'warnings' => $this->warnings,
'package_name' => $this->packageName,
'is_maintained' => $this->isMaintained,
'url' => $this->url?->setAbsolute()->toString(),
'status' => match ($this->status) {
ActivationStatus::Absent => 'absent',
......
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.
......@@ -102,6 +102,16 @@
)}
</div>
{/if}
{#if project.is_maintained}
<div class="pb-module-page__sidebar_element">
<ProjectIcon
type="maintained"
variant="module-details"
classes="pb-module-page__module-details-icon-sidebar"
/>
{Drupal.t('The module is actively maintained by the maintainers')}
</div>
{/if}
{#if project.url}
<div
......
......@@ -416,6 +416,7 @@ class ProjectBrowserTestMock extends ProjectBrowserSourceBase {
// Mock projects are filtered and made sure that they are compatible
// before we even put them in the database.
isCompatible: TRUE,
isMaintained: in_array($project_data['maintenance_status'], self::MAINTAINED_VALUES),
isCovered: in_array($project_data['field_security_advisory_coverage'], self::COVERED_VALUES),
projectUsageTotal: array_reduce($project_data['project_data']['project_usage'] ?? [], fn($total, $project_usage) => $total + $project_usage) ?: 0,
machineName: $project_data['field_project_machine_name'],
......
......@@ -1168,4 +1168,27 @@ class ProjectBrowserUiTest extends WebDriverTestBase {
}
}
/**
* Verifies that the wrench icon is displayed only on maintained projects.
*/
public function testWrenchIcon(): void {
$assert_session = $this->assertSession();
$this->getSession()->resizeWindow(1460, 960);
$this->drupalGet('admin/modules/browse');
$this->svelteInitHelper('text', 'Helvetica');
// This asserts that status icon is present on the cards.
$this->assertNotNull($assert_session->waitForElementVisible('css', '.pb-project__maintenance-icon .pb-project__status-icon-btn'));
$assert_session->waitForButton('Helvetica')?->click();
$this->assertTrue($assert_session->waitForText('The module is actively maintained by the maintainers'));
// This asserts that status icon is present in detail's modal.
$this->assertNotNull($assert_session->waitForElementVisible('css', '.pb-detail-modal__sidebar .pb-project__status-icon-btn'));
$this->getSession()->getPage()->find('css', '.ui-dialog-titlebar-close')->click();
$this->clickWithWait(self::MAINTENANCE_OPTION_SELECTOR . self::OPTION_LAST_CHILD);
$this->assertEquals('Show all', $this->getElementText(self::MAINTENANCE_OPTION_SELECTOR . self::OPTION_LAST_CHILD));
// Asserts that the text followed by status icon is missing.
$assert_session->waitForButton('Eggman')?->click();
$this->assertFalse($assert_session->waitForText('The module is actively maintained by the maintainers'));
}
}
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