Commit 2cab2f40 authored by catch's avatar catch
Browse files

Issue #2977495 by alexfarr, Sam152, Neslee Canil Pinto, timmillwood, alexpott:...

Issue #2977495 by alexfarr, Sam152, Neslee Canil Pinto, timmillwood, alexpott: Content Moderation missing permission descriptions
parent 00b7574f
......@@ -4,6 +4,7 @@
use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\workflows\Entity\Workflow;
use Drupal\workflows\State;
/**
* Defines a class for dynamic permissions based on transitions.
......@@ -30,6 +31,14 @@ public function transitionPermissions() {
'%workflow' => $workflow->label(),
'%transition' => $transition->label(),
]),
'description' => $this->formatPlural(
count($transition->from()),
'Move content from %from state to %to state.',
'Move content from %from states to %to state.', [
'%from' => implode(', ', array_map([State::class, 'labelCallback'], $transition->from())),
'%to' => $transition->to()->label(),
]
),
];
}
}
......
......@@ -55,13 +55,69 @@ public function permissionsTestCases() {
'id' => 'simple_workflow',
'label' => 'Simple Workflow',
'type' => 'content_moderation',
'type_settings' => [
'states' => [
'draft' => [
'label' => 'Draft',
'published' => FALSE,
'default_revision' => FALSE,
'weight' => 0,
],
'published' => [
'label' => 'Published',
'published' => TRUE,
'default_revision' => TRUE,
'weight' => 1,
],
'archived' => [
'label' => 'Archived',
'published' => FALSE,
'default_revision' => TRUE,
'weight' => 2,
],
],
'transitions' => [
'create_new_draft' => [
'label' => 'Create New Draft',
'to' => 'draft',
'weight' => 0,
'from' => [
'draft',
'published',
],
],
'publish' => [
'label' => 'Publish',
'to' => 'published',
'weight' => 1,
'from' => [
'draft',
'published',
],
],
'archive' => [
'label' => 'Archive',
'to' => 'archived',
'weight' => 2,
'from' => [
'published',
],
],
],
],
],
[
'use simple_workflow transition publish' => [
'title' => '<em class="placeholder">Simple Workflow</em> workflow: Use <em class="placeholder">Publish</em> transition.',
'description' => 'Move content from <em class="placeholder">Draft, Published</em> states to <em class="placeholder">Published</em> state.',
],
'use simple_workflow transition create_new_draft' => [
'title' => '<em class="placeholder">Simple Workflow</em> workflow: Use <em class="placeholder">Create New Draft</em> transition.',
'description' => 'Move content from <em class="placeholder">Draft, Published</em> states to <em class="placeholder">Draft</em> state.',
],
'use simple_workflow transition archive' => [
'title' => '<em class="placeholder">Simple Workflow</em> workflow: Use <em class="placeholder">Archive</em> transition.',
'description' => 'Move content from <em class="placeholder">Published</em> state to <em class="placeholder">Archived</em> state.',
],
],
],
......
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