Commit f722c3c3 authored by webchick's avatar webchick

Issue #2329829 by Cottser, lauriii | davidhernandez: Move update classes from...

Issue #2329829 by Cottser, lauriii | davidhernandez: Move update classes from preprocess to templates.
parent ddbd7f66
......@@ -29,9 +29,18 @@
* @ingroup themeable
*/
#}
{%
set status_classes = [
project.status == constant('UPDATE_NOT_SECURE') ? 'security-error',
project.status == constant('UPDATE_REVOKED') ? 'revoked',
project.status == constant('UPDATE_NOT_SUPPORTED') ? 'not-supported',
project.status == constant('UPDATE_NOT_CURRENT') ? 'not-current',
project.status == constant('UPDATE_CURRENT') ? 'current',
]
%}
<div class="version-status">
{%- if status.label -%}
<span{{ status.attributes }}>{{ status.label }}</span>
<span{{ status.attributes.addClass(status_classes) }}>{{ status.label }}</span>
{%- else -%}
{{ status.reason }}
{%- endif %}
......@@ -58,11 +67,18 @@
</div>
{% endif %}
{%
set extra_classes = [
project.status == constant('UPDATE_NOT_SECURE') ? 'project-not-secure',
project.status == constant('UPDATE_REVOKED') ? 'project-revoked',
project.status == constant('UPDATE_NOT_SUPPORTED') ? 'project-not-supported',
]
%}
<div class="info">
{% if extras %}
<div class="extra">
{% for extra in extras %}
<div{{ extra.attributes }}>
<div{{ extra.attributes.addClass(extra_classes) }}>
{{ extra.label }}: {{ extra.data }}
</div>
{% endfor %}
......
......@@ -238,7 +238,6 @@ function update_calculate_project_update_status(&$project_data, $available) {
$project_data['extra'] = array();
}
$project_data['extra'][] = array(
'class' => array('project-not-secure'),
'label' => t('Project not secure'),
'data' => t('This project has been labeled insecure by the Drupal security team, and is no longer available for download. Immediately disabling everything included by this project is strongly recommended!'),
);
......@@ -250,7 +249,6 @@ function update_calculate_project_update_status(&$project_data, $available) {
$project_data['extra'] = array();
}
$project_data['extra'][] = array(
'class' => array('project-revoked'),
'label' => t('Project revoked'),
'data' => t('This project has been revoked, and is no longer available for download. Disabling everything included by this project is strongly recommended!'),
);
......@@ -261,7 +259,6 @@ function update_calculate_project_update_status(&$project_data, $available) {
$project_data['extra'] = array();
}
$project_data['extra'][] = array(
'class' => array('project-not-supported'),
'label' => t('Project not supported'),
'data' => t('This project is no longer supported, and is no longer available for download. Disabling everything included by this project is strongly recommended!'),
);
......
......@@ -246,7 +246,7 @@ function template_preprocess_update_project_status(&$variables) {
if (!empty($project['extra'])) {
foreach ($project['extra'] as $value) {
$extra_item = array();
$extra_item['attributes'] = new Attribute(array('class' => $value['class']));
$extra_item['attributes'] = new Attribute();
$extra_item['label'] = $value['label'];
$extra_item['data'] = drupal_placeholder($value['data']);
$variables['extras'][] = $extra_item;
......@@ -290,32 +290,26 @@ function template_preprocess_update_project_status(&$variables) {
}
// Set the project status details.
$status_attributes = array();
$status_label = NULL;
switch ($project['status']) {
case UPDATE_NOT_SECURE:
$status_attributes['class'][] = 'security-error';
$status_label = t('Security update required!');
break;
case UPDATE_REVOKED:
$status_attributes['class'][] = 'revoked';
$status_label = t('Revoked!');
break;
case UPDATE_NOT_SUPPORTED:
$status_attributes['class'][] = 'not-supported';
$status_label = t('Not supported!');
break;
case UPDATE_NOT_CURRENT:
$status_attributes['class'][] = 'not-current';
$status_label = t('Update available');
break;
case UPDATE_CURRENT:
$status_attributes['class'][] = 'current';
$status_label = t('Up to date');
break;
}
$variables['status']['label'] = $status_label;
$variables['status']['attributes'] = new Attribute($status_attributes);
$variables['status']['attributes'] = new Attribute();
$variables['status']['reason'] = (isset($project['reason'])) ? $project['reason'] : NULL;
switch ($project['status']) {
......
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