Skip to content
Snippets Groups Projects
Commit c1ceeb4f authored by Martin Gottlieb's avatar Martin Gottlieb
Browse files

Issue #3418129: Compatibility with module filter

parent 89c5ddde
Branches
Tags
No related merge requests found
......@@ -279,7 +279,8 @@
.replace('-enable-description', '')
.replace(/-/g, '_');
openModuleAccordion(module);
var accordion = $('.module-documentation', $(this).parent());
$(accordion).accordion('option', 'active', 0);
})
});
......@@ -332,8 +333,4 @@
}
};
function openModuleAccordion(module) {
$('.module-documentation[data-module="' + module + '"]').accordion('option', 'active', 0);
}
})(jQuery, Drupal);
name: 'Module usage'
type: module
description: 'Document module usage in-site.'
description: 'Document how/why/where modules are used.'
package: 'Documentation'
core_version_requirement: ^10
dependencies:
......
......@@ -216,15 +216,26 @@ function module_usage_preprocess_system_modules_details__custom(&$variables) : v
$variables['#attached']['library'][] = 'module_usage/module_usage';
}
/**
* Implements hook_preprocess_HOOK().
*/
function module_usage_preprocess_system_modules_details__custom_filter(&$variables) : void {
$variables['#attached']['library'][] = 'module_usage/module_usage';
}
/**
* Implements hook_theme_suggestions_HOOK_alter().
*/
function module_usage_theme_suggestions_system_modules_details_alter(array &$suggestions, array $variables) : void {
// Add a new suggestion that is more specific than the theme's.
$moduleInfo = \Drupal::service('extension.list.module')->get('module_filter');
if (!empty($moduleInfo) && $moduleInfo->status == 1) {
$suggestions[] = 'system_modules_details__custom_filter';
}
else {
$suggestions[] = 'system_modules_details__custom';
}
}
/**
* Implements hook_theme().
......@@ -281,6 +292,12 @@ function module_usage_theme($existing, $type, $theme, $path) : array {
'template' => 'system-modules-details--custom',
'path' => $module_path . '/templates',
],
'system_modules_details__custom_filter' => [
'render element' => 'form',
'base hook' => 'system_modules_details',
'template' => 'system-modules-details--custom-filter',
'path' => $module_path . '/templates',
],
'module_usage_update_page__custom' => [
'variables' => [
'machine_name' => NULL
......
......@@ -572,8 +572,8 @@ class ModuleUsageService {
$version = $module->version;
$info = $moduleInfo[$machine_name];
if ($info->info['version'] != $version) {
$this->addEvent($machine_name, 'Version changed', $info->status, $info->info['version']);
$this->queryService->updateVersion($machine_name, $info->info['version']);
$this->addEvent($machine_name, 'Version changed', $info->status, $info->info['version'] ?? 'unknown');
$this->queryService->updateVersion($machine_name, $info->info['version'] ?? 'unknown');
}
}
}
......
{#
/**
* @file
* Default theme implementation for the modules listing page.
*
* Displays a list of all packages in a project.
*
* Available variables:
* - modules: Contains multiple module instances. Each module contains:
* - attributes: Attributes on the row.
* - checkbox: A checkbox for enabling the module.
* - name: The human-readable name of the module.
* - id: A unique identifier for interacting with the details element.
* - enable_id: A unique identifier for interacting with the checkbox element.
* - description: The description of the module.
* - machine_name: The module's machine name.
* - version: Information about the module version.
* - requires: A list of modules that this module requires.
* - required_by: A list of modules that require this module.
* - links: A list of administration links provided by the module.
*
* @see template_preprocess_system_modules_details()
*
* @ingroup themeable
*/
#}
<table class="responsive-enabled module-list" data-striping="1">
<thead>
<tr>
<th class="checkbox visually-hidden">{{ 'Installed'|t }}</th>
<th class="name visually-hidden">{{ 'Name'|t }}</th>
<th class="description visually-hidden priority-low">{{ 'Description'|t }}</th>
</tr>
</thead>
<tbody>
{% for module in modules %}
{% set zebra = cycle(['odd', 'even'], loop.index0) %}
<tr{{ module.attributes.addClass('module-list__module ' ~ zebra) }}>
<td class="checkbox">
{{ module.checkbox }}
</td>
<td class="module">
<label id="{{ module.id }}" for="{{ module.enable_id }}" class="module-name table-filter-text-source">{{ module.name }}</label>
</td>
<td class="description expand priority-low">
<details class="js-form-wrapper form-wrapper module-list__module-details" id="{{ module.enable_id }}-description">
<summary aria-controls="{{ module.enable_id }}-description" role="button" aria-expanded="false"><span class="text module-description">{{ module.description }}</span></summary>
<div class="details-wrapper">
<div class="details-description">
<div class="requirements">
<div class="admin-requirements">{{ 'Machine name: <span dir="ltr" class="module-machine-name table-filter-text-source">@machine-name</span>'|t({'@machine-name': module.machine_name }) }}</div>
{% if module.version %}
<div class="admin-requirements">{{ 'Version: @module-version'|t({'@module-version': module.version }) }}</div>
{% endif %}
{% if module.requires %}
<div class="admin-requirements requires">{{ 'Requires: @module-list'|t({'@module-list': module.requires }) }}</div>
{% endif %}
{% if module.required_by %}
<div class="admin-requirements required-by">{{ 'Required by: @module-list'|t({'@module-list': module.required_by }) }}</div>
{% endif %}
{% if module.path %}
<div class="admin-requirements module-path">{{ 'Module path: @module-list'|t({'@module-list': module.path }) }}</div>
{% endif %}
</div>
{% if module.links %}
<div class="links">
{% for link_type in ['help', 'permissions', 'configure'] %}
{{ module.links[link_type] }}
{% endfor %}
</div>
{% endif %}
{% set machine_name = module.machine_name|striptags %}
<div class="module-documentation" data-module="{{ machine_name }}">
<div class="btn module-accordion-header documentation-header" data-module="{{ machine_name }}">Module Usage Documentation</div>
<div class="module-accordion-body-container" data-module="{{ machine_name }}">
<div id ="extension-{{ machine_name }}"></div>
</div>
</div>
</div>
</div>
</details>
</td>
</tr>
{% endfor %}
</tbody>
</table>
......@@ -34,7 +34,8 @@
</thead>
<tbody>
{% for module in modules %}
<tr{{ module.attributes.addClass('module-list__module') }}>
{% set zebra = cycle(['odd', 'even'], loop.index0) %}
<tr{{ module.attributes.addClass('module-list__module ' ~ zebra) }}>
<td class="module-list__checkbox">
{{ module.checkbox }}
</td>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment