Skip to content
Snippets Groups Projects
Commit 2928b5c6 authored by Indranil Roy's avatar Indranil Roy Committed by Lucas Hedding
Browse files

Issue #3248790 by heddn: Fix stylelint & eslint & php code standard warnings

parent 94ea8a87
No related branches found
No related tags found
1 merge request!86Resolve #3248790: Fix stylelint warnings
Pipeline #371305 passed
Showing
with 203 additions and 196 deletions
langcode: en
id: node.diff
label: 'Revision comparison'
label: "Revision comparison"
status: false
cache: true
targetEntityType: node
......
diff.settings:
type: config_object
label: 'Settings'
label: "Settings"
mapping:
general_settings:
type: mapping
label: 'General Settings'
label: "General Settings"
mapping:
radio_behavior:
type: label
label: 'Radio button behaviour'
label: "Radio button behaviour"
context_lines_leading:
type: integer
label: 'Number of leading context lines'
label: "Number of leading context lines"
context_lines_trailing:
type: integer
label: 'Number of trailing context lines'
label: "Number of trailing context lines"
revision_pager_limit:
type: integer
label: 'Revisions per page to be displayed in diff pager'
label: "Revisions per page to be displayed in diff pager"
layout_plugins:
type: sequence
label: 'Plugins'
label: "Plugins"
sequence:
type: mapping
label: 'Layout plugins configuration'
label: "Layout plugins configuration"
mapping:
enabled:
type: boolean
label: 'Enabled'
label: "Enabled"
weight:
type: integer
label: 'Weight'
label: "Weight"
visual_default_view_mode:
type: string
label: 'View mode'
label: "View mode"
visual_inline_theme:
type: string
label: 'Theme'
label: "Theme"
entity:
type: sequence
label: 'Entities'
label: "Entities"
sequence:
type: sequence
label: 'Entity ID'
label: "Entity ID"
sequence:
type: integer
label: 'Compare base field'
label: "Compare base field"
diff.plugins:
type: config_object
label: 'Entity Type'
label: "Entity Type"
mapping:
fields:
type: sequence
label: 'Field'
label: "Field"
sequence:
type: sequence
sequence:
type: mapping
label: 'Diff configuration for a field type'
label: "Diff configuration for a field type"
mapping:
type:
type: text
label: 'Plugin key'
label: "Plugin key"
settings:
type: diff.plugin.settings.[%parent.type]
diff.plugin.settings_base:
type: mapping
label: 'Settings for base diff builder plugin'
label: "Settings for base diff builder plugin"
mapping:
show_header:
type: integer
label: 'Compare the field title'
label: "Compare the field title"
markdown:
type: string
label: 'Mark-down function ID'
label: "Mark-down function ID"
# The plugins which extend the base diff builder plugin and don't provide
# any configuration form will validate on this entry.
......@@ -84,125 +84,124 @@ diff.plugin.settings.*:
diff.plugin.settings.file_field_diff_builder:
type: diff.plugin.settings_base
label: 'Settings for file field diff builder plugin'
label: "Settings for file field diff builder plugin"
mapping:
show_id:
type: integer
label: 'Compare the ID of the file'
label: "Compare the ID of the file"
compare_description_field:
type: integer
label: 'Compare the description of the file'
label: "Compare the description of the file"
compare_display_field:
type: integer
label: 'Compare the description of the file'
label: "Compare the description of the file"
property_separator:
type: text
label: 'Separator between multiple compared properties'
label: "Separator between multiple compared properties"
diff.plugin.settings.image_field_diff_builder:
type: diff.plugin.settings_base
label: 'Settings for image field diff builder plugin'
label: "Settings for image field diff builder plugin"
mapping:
show_id:
type: integer
label: 'Compare the ID of the image'
label: "Compare the ID of the image"
compare_alt_field:
type: integer
label: 'Compare the alt of the image'
label: "Compare the alt of the image"
compare_title_field:
type: integer
label: 'Compare the title of the image'
label: "Compare the title of the image"
property_separator:
type: text
label: 'Separator between multiple compared properties'
label: "Separator between multiple compared properties"
show_thumbnail:
type: integer
label: 'Show the image thumbnail'
label: "Show the image thumbnail"
diff.plugin.settings.list_field_diff_builder:
type: diff.plugin.settings_base
label: 'Settings for list field diff builder plugin'
label: "Settings for list field diff builder plugin"
mapping:
compare:
type: text
label: 'Comparison method key'
label: "Comparison method key"
diff.plugin.settings.term_reference_field_diff_builder:
type: diff.plugin.settings_base
label: 'Settings for term reference field diff builder plugin'
label: "Settings for term reference field diff builder plugin"
mapping:
show_name:
type: integer
label: 'Compare the taxonomy term string'
label: "Compare the taxonomy term string"
show_id:
type: integer
label: 'Compare the taxonomy term id'
label: "Compare the taxonomy term id"
diff.plugin.settings.text_field_diff_builder:
type: diff.plugin.settings_base
label: 'Settings for text field diff builder plugin'
label: "Settings for text field diff builder plugin"
mapping:
compare_format:
type: integer
label: 'Compare the format of the text'
label: "Compare the format of the text"
diff.plugin.settings.text_summary_field_diff_builder:
type: diff.plugin.settings_base
label: 'Settings for text with summary field diff builder plugin'
label: "Settings for text with summary field diff builder plugin"
mapping:
compare_format:
type: integer
label: 'Compare the format of the text'
label: "Compare the format of the text"
compare_summary:
type: integer
label: 'Compare the summary of the text'
label: "Compare the summary of the text"
diff.plugin.settings.link_field_diff_builder:
type: diff.plugin.settings_base
label: 'Settings for link field diff builder plugin'
label: "Settings for link field diff builder plugin"
mapping:
compare_title:
type: integer
label: 'Compare the title of the link'
label: "Compare the title of the link"
compare_uri:
type: integer
label: 'Compare the URI of the link'
label: "Compare the URI of the link"
diff.plugin.settings.comment_field_diff_builder:
type: diff.plugin.settings_base
label: 'Settings for comment field diff builder plugin'
label: "Settings for comment field diff builder plugin"
mapping:
compare_key:
type: integer
label: 'Compare the status key of the comments'
label: "Compare the status key of the comments"
compare_string:
type: integer
label: 'Compare the status string of the comments'
label: "Compare the status string of the comments"
diff.plugin.settings.entity_reference_field_diff_builder:
type: diff.plugin.settings_base
label: 'Settings for entity reference field diff builder plugin'
label: "Settings for entity reference field diff builder plugin"
mapping:
compare_entity_reference:
type: integer
label: 'Entity reference component to compare'
label: "Entity reference component to compare"
diff.layout_plugins:
type: config_object
label: 'Plugin'
label: "Plugin"
mapping:
type: sequence
sequence:
type: mapping
label: 'Diff configuration for a field type'
label: "Diff configuration for a field type"
mapping:
type:
type: text
label: 'Plugin key'
label: "Plugin key"
settings:
type: diff.layout_plugin.settings.[%parent.type]
diff.layout_plugin.settings_base:
type: mapping
label: 'Settings for base diff layout plugin'
mapping:
label: "Settings for base diff layout plugin"
......@@ -4,9 +4,9 @@
*/
td.diff-section-title,
div.diff-section-title {
padding: 0.1em 1em;
font-size: 0.83em;
font-weight: bold;
padding: 0.1em 1em;
}
td.diff-prevlink {
text-align: left;
......@@ -35,17 +35,17 @@ td.diff-context {
vertical-align: top;
}
td.diff-marker {
text-align: center;
padding: 0.3em 1em;
width: 1%;
padding: 0.3em 1em;
text-align: center;
}
td.diff td {
padding: 0 1em;
}
td.diff-line-number {
text-align: center;
padding: 0.3em 1em;
width: 1%;
color: #AAA;
padding: 0.3em 1em;
text-align: center;
color: #aaa;
border-right: 1px #e6e4df solid;
}
......@@ -7,8 +7,8 @@
}
.diff-responsive-table-wrapper {
min-height: 0%;
overflow-x: auto;
min-height: 0;
}
.diff-responsive-table {
max-width: 100%;
......@@ -33,8 +33,8 @@
.diff-controls {
display: flex;
margin-bottom: 1em;
width: 100%;
margin-bottom: 1em;
}
.diff-controls__item {
padding-right: 1em;
......@@ -50,16 +50,16 @@
@media screen and (min-width: 560px) {
.diff-revision__items {
display: table;
margin-left: -1em;
margin-right: -1em;
margin-left: -1em;
}
.diff-revision__items-group {
display: table-row;
}
.diff-revision__item {
display: table-cell;
padding-left: 1em;
padding-right: 1em;
padding-left: 1em;
}
.diff-revision__item-date {
float: none;
......
......@@ -4,9 +4,9 @@
*/
td.diff-section-title,
div.diff-section-title {
padding: 0.1em 1em;
font-size: 0.83em;
font-weight: bold;
padding: 0.1em 1em;
}
td.diff-prevlink {
text-align: left;
......@@ -35,17 +35,17 @@ td.diff-context {
vertical-align: top;
}
td.diff-marker {
text-align: center;
padding: 0.3em 1em;
width: 1%;
padding: 0.3em 1em;
text-align: center;
}
td.diff td {
padding: 0 1em;
}
td.diff-line-number {
text-align: center;
padding: 0.3em 1em;
width: 1%;
color: #AAA;
padding: 0.3em 1em;
text-align: center;
color: #aaa;
border-right: 1px #e6e4df solid;
}
\ No newline at end of file
}
<?php
declare(strict_types=1);
/**
* @file
* Hooks and documentation related to diff module.
*/
declare(strict_types=1);
/**
* @defgroup diff Diff API
*
......
<?php
declare(strict_types=1);
/**
* @file
* Installation hooks for diff module.
*/
declare(strict_types=1);
use Drupal\Core\Url;
/**
......
diff.settings:
title: 'Diff'
title: "Diff"
parent: system.admin_config_content
description: 'Configure how entity fields are compared.'
route_name: diff.general_settings
\ No newline at end of file
description: "Configure how entity fields are compared."
route_name: diff.general_settings
<?php
/**
* @file
*/
declare(strict_types=1);
use Drupal\Core\Routing\RouteMatchInterface;
......
diff.revisions_diff:
path: '/node/{node}/revisions/view/{left_revision}/{right_revision}/{filter}'
path: "/node/{node}/revisions/view/{left_revision}/{right_revision}/{filter}"
defaults:
_controller: '\Drupal\diff\Controller\NodeRevisionController::compareNodeRevisions'
_title: Diff General Settings
requirements:
_entity_access: 'node.view all revisions'
_entity_access: "node.view all revisions"
options:
_admin_route: TRUE
diff.general_settings:
path: '/admin/config/content/diff/general'
path: "/admin/config/content/diff/general"
defaults:
_form: '\Drupal\diff\Form\GeneralSettingsForm'
_title: Diff General Settings
requirements:
_permission: 'administer site configuration'
_permission: "administer site configuration"
diff.fields_list:
path: '/admin/config/content/diff/fields'
path: "/admin/config/content/diff/fields"
defaults:
_form: '\Drupal\diff\Form\FieldsSettingsForm'
_title: Fields Settings
requirements:
_permission: 'administer site configuration'
_permission: "administer site configuration"
......@@ -6,33 +6,43 @@ services:
diff.diff.formatter:
class: Drupal\diff\DiffFormatter
arguments: ['@config.factory']
arguments: ["@config.factory"]
plugin.manager.diff.builder:
class: Drupal\diff\DiffBuilderManager
parent: default_plugin_manager
arguments: ['@entity_type.manager', '@config.factory']
arguments: ["@entity_type.manager", "@config.factory"]
plugin.manager.diff.layout:
class: Drupal\diff\DiffLayoutManager
parent: default_plugin_manager
arguments: ['@entity_type.manager', '@config.factory']
arguments: ["@entity_type.manager", "@config.factory"]
diff.entity_parser:
class: Drupal\diff\DiffEntityParser
arguments: ['@plugin.manager.diff.builder', '@config.factory']
arguments: ["@plugin.manager.diff.builder", "@config.factory"]
diff.entity_comparison:
class: Drupal\diff\DiffEntityComparison
arguments: ['@config.factory', '@diff.diff.formatter','@plugin.manager.field.field_type', '@diff.entity_parser', '@plugin.manager.diff.builder']
arguments:
[
"@config.factory",
"@diff.diff.formatter",
"@plugin.manager.field.field_type",
"@diff.entity_parser",
"@plugin.manager.diff.builder",
]
calls:
- [setModerationInformation, ['@?content_moderation.moderation_information']]
- [
setModerationInformation,
["@?content_moderation.moderation_information"],
]
diff.html_diff:
class: HtmlDiffAdvanced
theme.negotiator.visual_diff:
class: Drupal\diff\VisualDiffThemeNegotiator
arguments: ['@config.factory']
arguments: ["@config.factory"]
tags:
- { name: theme_negotiator, priority: 0 }
<?php
/**
* @file
*/
declare(strict_types=1);
/**
......
(function ($, Drupal, drupalSettings, once) {
'use strict';
/**
* @file
* Defines JavaScript behaviors for the diff module.
*/
(function ($, Drupal, drupalSettings, once) {
Drupal.behaviors.diffRevisions = {
attach: function (context, settings) {
// drupalSettings in not anymore bound to attached functions.
// It is available outside the scope of this anonymous function also.
var rows = once('diff-revisions', 'table.diff-revisions tbody tr');
var $rows = $(rows);
attach() {
const rows = once('diff-revisions', 'table.diff-revisions tbody tr');
const $rows = $(rows);
if ($rows.length === 0) {
return;
}
function updateDiffRadios() {
var newTd = false;
var oldTd = false;
let newTd = false;
let oldTd = false;
if (!$rows.length) {
return true;
}
$rows.each(function () {
var $row = $(this);
var $inputs = $row.find('input[type="radio"]');
var $oldRadio = $inputs.filter('[name="radios_left"]').eq(0);
var $newRadio = $inputs.filter('[name="radios_right"]').eq(0);
const $row = $(this);
const $inputs = $row.find('input[type="radio"]');
const $oldRadio = $inputs.filter('[name="radios_left"]').eq(0);
const $newRadio = $inputs.filter('[name="radios_right"]').eq(0);
if (!$oldRadio.length || !$newRadio.length) {
return true;
}
if ($oldRadio.prop('checked')) {
oldTd = true;
$oldRadio.css('visibility', 'visible');
$newRadio.css('visibility', 'hidden');
}
else if ($newRadio.prop('checked')) {
$oldRadio[0].style.display = 'block';
$newRadio[0].style.display = 'none';
} else if ($newRadio.prop('checked')) {
newTd = true;
$oldRadio.css('visibility', 'hidden');
$newRadio.css('visibility', 'visible');
}
else {
if (drupalSettings.diffRevisionRadios === 'linear') {
if (newTd && oldTd) {
$oldRadio.css('visibility', 'visible');
$newRadio.css('visibility', 'hidden');
}
else if (newTd) {
$newRadio.css('visibility', 'visible');
$oldRadio.css('visibility', 'visible');
}
else {
$newRadio.css('visibility', 'visible');
$oldRadio.css('visibility', 'hidden');
}
}
else {
$newRadio.css('visibility', 'visible');
$oldRadio.css('visibility', 'visible');
$oldRadio[0].style.display = 'none';
$newRadio[0].style.display = 'block';
} else if (drupalSettings.diffRevisionRadios === 'linear') {
if (newTd && oldTd) {
$oldRadio[0].style.display = 'block';
$newRadio[0].style.display = 'none';
} else if (newTd) {
$oldRadio[0].style.display = 'block';
$newRadio[0].style.display = 'block';
} else {
$newRadio[0].style.display = 'block';
$oldRadio[0].style.display = 'none';
}
} else {
$oldRadio[0].style.display = 'block';
$newRadio[0].style.display = 'block';
}
});
return true;
}
if (drupalSettings.diffRevisionRadios) {
$rows.find('input[name="radios_left"], input[name="radios_right"]').click(updateDiffRadios);
$rows
.find('input[name="radios_left"], input[name="radios_right"]')
.click(updateDiffRadios);
updateDiffRadios();
}
}
},
};
})(jQuery, Drupal, drupalSettings, once);
......@@ -10,11 +10,6 @@ parameters:
count: 1
path: diff.module
-
message: "#^Method Drupal\\\\Core\\\\Form\\\\FormBuilderInterface\\:\\:getForm\\(\\) invoked with 2 parameters, 1 required\\.$#"
count: 1
path: src/Controller/NodeRevisionController.php
-
message: "#^\\\\Drupal calls should be avoided in classes, use dependency injection instead$#"
count: 1
......
......@@ -191,12 +191,10 @@ class PluginRevisionController extends ControllerBase {
unset($links[$active_filter]);
\array_unshift($links, $filter);
$filter = [
return [
'#type' => 'operations',
'#links' => $links,
];
return $filter;
}
/**
......@@ -223,48 +221,47 @@ class PluginRevisionController extends ControllerBase {
$layout_options = UrlHelper::filterQueryParameters($this->requestStack->getCurrentRequest()->query->all(), ['page']);
}
// If there are only 2 revision return an empty row.
if ($revisions_count == 2) {
if ($revisions_count === 2) {
return [];
}
else {
$left_link = $right_link = '';
$element = [
'#type' => 'item',
'#title' => $this->t('Navigation'),
'#wrapper_attributes' => ['class' => 'diff-navigation'],
];
$i = 0;
// Find the previous revision.
while (!empty($revision_ids[$i]) && $left_revision_id > $revision_ids[$i]) {
$i += 1;
}
if ($i != 0) {
// Build the left link.
$left_link = Link::fromTextAndUrl($this->t('Previous change'), static::diffRoute($entity, $revision_ids[$i - 1], $left_revision_id, $filter, $layout_options))->toString();
}
$element['left'] = [
'#type' => 'markup',
'#markup' => $left_link,
'#prefix' => '<div class="diff-navigation__link prev-link">',
'#suffix' => '</div>',
];
// Find the next revision.
$i = 0;
while (!empty($revision_ids[$i]) && $right_revision_id >= $revision_ids[$i]) {
$i += 1;
}
if ($revisions_count != $i && $revision_ids[$i - 1] != $revision_ids[$revisions_count - 1]) {
// Build the right link.
$right_link = Link::fromTextAndUrl($this->t('Next change'), static::diffRoute($entity, $right_revision_id, $revision_ids[$i], $filter, $layout_options))->toString();
}
$element['right'] = [
'#type' => 'markup',
'#markup' => $right_link,
'#prefix' => '<div class="diff-navigation__link next-link">',
'#suffix' => '</div>',
];
return $element;
$left_link = $right_link = '';
$element = [
'#type' => 'item',
'#title' => $this->t('Navigation'),
'#wrapper_attributes' => ['class' => 'diff-navigation'],
];
$i = 0;
// Find the previous revision.
while (\array_key_exists($i, $revision_ids) && $left_revision_id > $revision_ids[$i]) {
++$i;
}
if ($i !== 0) {
// Build the left link.
$left_link = Link::fromTextAndUrl($this->t('Previous change'), static::diffRoute($entity, $revision_ids[$i - 1], $left_revision_id, $filter, $layout_options))->toString();
}
$element['left'] = [
'#type' => 'markup',
'#markup' => $left_link,
'#prefix' => '<div class="diff-navigation__link prev-link">',
'#suffix' => '</div>',
];
// Find the next revision.
$i = 0;
while (\array_key_exists($i, $revision_ids) && $right_revision_id >= $revision_ids[$i]) {
++$i;
}
if ($revisions_count !== $i && $revision_ids[$i - 1] !== $revision_ids[$revisions_count - 1]) {
// Build the right link.
$right_link = Link::fromTextAndUrl($this->t('Next change'), static::diffRoute($entity, $right_revision_id, $revision_ids[$i], $filter, $layout_options))->toString();
}
$element['right'] = [
'#type' => 'markup',
'#markup' => $right_link,
'#prefix' => '<div class="diff-navigation__link next-link">',
'#suffix' => '</div>',
];
return $element;
}
/**
......
......@@ -7,11 +7,11 @@ namespace Drupal\diff;
use Drupal\Component\Diff\Diff;
use Drupal\Component\Plugin\PluginManagerInterface;
use Drupal\Component\Utility\Xss;
use Drupal\content_moderation\ModerationInformationInterface;
use Drupal\Core\Config\ConfigFactory;
use Drupal\Core\Config\ImmutableConfig;
use Drupal\Core\Entity\ContentEntityInterface;
use Drupal\Core\Entity\RevisionLogInterface;
use Drupal\content_moderation\ModerationInformationInterface;
/**
* Entity comparison service that prepares a diff of a pair of entities.
......@@ -264,7 +264,7 @@ class DiffEntityComparison {
$result[$key] = $build;
$delta = $show_delta ? '<sub>' . ($entity_key + 1) . '</sub> ' : ' - ';
$result[$key]['label'] = $field_items->getFieldDefinition()->getLabel() . $delta . $result[$key]['label'];
};
}
}
}
else {
......
......@@ -65,11 +65,11 @@ class DiffEntityParser {
// Create the array with the fields of the entity. Recursive if the
// field contains entities.
if ($plugin instanceof FieldReferenceInterface) {
foreach ($plugin->getEntitiesToDiff($field_items) as $entity_key => $reference_entity) {
foreach ($plugin->getEntitiesToDiff($field_items) as $reference_entity) {
foreach ($this->parseEntity($reference_entity) as $key => $build) {
$result[$key] = $build;
$result[$key]['label'] = $field_items->getFieldDefinition()->getLabel() . ' > ' . $result[$key]['label'];
};
}
}
}
else {
......
......@@ -4,9 +4,9 @@ declare(strict_types=1);
namespace Drupal\diff\Plugin\diff\Field;
use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface;
use Drupal\Core\Field\FieldItemListInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface;
use Drupal\diff\FieldDiffBuilderBase;
/**
......
......@@ -6,6 +6,7 @@ namespace Drupal\diff\Plugin\diff\Field;
use Drupal\Core\Field\FieldItemListInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\StringTranslation\TranslatableMarkup;
use Drupal\diff\FieldDiffBuilderBase;
const COMPARE_ENTITY_REFERENCE_ID = 0;
......@@ -60,7 +61,10 @@ class EntityReferenceFieldBuilder extends FieldDiffBuilderBase {
$form['compare_entity_reference'] = [
'#type' => 'select',
'#title' => $this->t('Compare'),
'#options' => [COMPARE_ENTITY_REFERENCE_ID => \t('ID'), COMPARE_ENTITY_REFERENCE_LABEL => \t('Label')],
'#options' => [
COMPARE_ENTITY_REFERENCE_ID => new TranslatableMarkup('ID'),
COMPARE_ENTITY_REFERENCE_LABEL => new TranslatableMarkup('Label'),
],
'#default_value' => $this->configuration['compare_entity_reference'],
];
......
format: basic_html
name: 'Basic HTML'
name: "Basic HTML"
status: true
weight: 0
roles:
......@@ -11,7 +11,7 @@ filters:
status: true
weight: -10
settings:
allowed_html: '<a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd> <h4> <h5> <h6> <p> <br> <span> <img>'
allowed_html: "<a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd> <h4> <h5> <h6> <p> <br> <span> <img>"
filter_html_help: false
filter_html_nofollow: false
filter_align:
......@@ -19,31 +19,31 @@ filters:
provider: filter
status: true
weight: 7
settings: { }
settings: {}
filter_caption:
id: filter_caption
provider: filter
status: true
weight: 8
settings: { }
settings: {}
filter_html_image_secure:
id: filter_html_image_secure
provider: filter
status: true
weight: 9
settings: { }
settings: {}
filter_htmlcorrector:
id: filter_htmlcorrector
provider: filter
status: true
weight: 10
settings: { }
settings: {}
editor_file_reference:
id: editor_file_reference
provider: editor
status: true
weight: 11
settings: { }
settings: {}
langcode: en
dependencies:
module:
......
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