Commit fe48728b authored by Gábor Hojtsy's avatar Gábor Hojtsy

Issue #2953376 by Eli-T, anmolgoyal74, John Cook, chr.fritsch, markconroy:...

Issue #2953376 by Eli-T, anmolgoyal74, John Cook, chr.fritsch, markconroy: Adopt Content Moderation in Umami

(cherry picked from commit 8dc4c5a2)
parent 80818954
......@@ -56,4 +56,5 @@ content:
size: 60
placeholder: ''
third_party_settings: { }
hidden: { }
hidden:
moderation_state: true
......@@ -28,4 +28,5 @@ content:
size: 60
placeholder: ''
third_party_settings: { }
hidden: { }
hidden:
moderation_state: true
......@@ -36,4 +36,5 @@ content:
size: 60
placeholder: ''
third_party_settings: { }
hidden: { }
hidden:
moderation_state: true
......@@ -56,4 +56,5 @@ content:
size: 60
placeholder: ''
third_party_settings: { }
hidden: { }
hidden:
moderation_state: true
......@@ -55,4 +55,5 @@ content:
placeholder: ''
region: content
third_party_settings: { }
hidden: { }
hidden:
moderation_state: true
......@@ -55,4 +55,5 @@ content:
placeholder: ''
region: content
third_party_settings: { }
hidden: { }
hidden:
moderation_state: true
......@@ -57,4 +57,5 @@ content:
placeholder: ''
region: content
third_party_settings: { }
hidden: { }
hidden:
moderation_state: true
......@@ -41,7 +41,7 @@ content:
third_party_settings: { }
uid:
type: entity_reference_autocomplete
weight: 5
weight: 4
settings:
match_operator: CONTAINS
size: 60
......@@ -49,4 +49,5 @@ content:
region: content
third_party_settings: { }
hidden:
moderation_state: true
name: true
......@@ -55,4 +55,5 @@ content:
placeholder: ''
region: content
third_party_settings: { }
hidden: { }
hidden:
moderation_state: true
......@@ -8,6 +8,7 @@ dependencies:
- image.style.thumbnail
- node.type.article
module:
- content_moderation
- image
- path
- text
......@@ -27,13 +28,13 @@ content:
third_party_settings: { }
created:
type: datetime_timestamp
weight: 10
weight: 5
region: content
settings: { }
third_party_settings: { }
field_image:
type: image_image
weight: 4
weight: 3
region: content
settings:
progress_indicator: throbber
......@@ -41,13 +42,22 @@ content:
third_party_settings: { }
field_tags:
type: entity_reference_autocomplete_tags
weight: 3
weight: 2
region: content
settings:
match_operator: CONTAINS
size: 60
placeholder: ''
third_party_settings: { }
moderation_state:
type: moderation_state_default
weight: 10
region: content
settings: { }
third_party_settings: { }
path:
type: path
weight: 30
weight: 8
region: content
settings: { }
third_party_settings: { }
......@@ -55,21 +65,21 @@ content:
type: boolean_checkbox
settings:
display_label: true
weight: 15
weight: 6
region: content
third_party_settings: { }
status:
type: boolean_checkbox
settings:
display_label: true
weight: 120
weight: 9
region: content
third_party_settings: { }
sticky:
type: boolean_checkbox
settings:
display_label: true
weight: 16
weight: 7
region: content
third_party_settings: { }
title:
......@@ -82,7 +92,7 @@ content:
third_party_settings: { }
uid:
type: entity_reference_autocomplete
weight: 5
weight: 4
region: content
settings:
match_operator: CONTAINS
......
......@@ -5,6 +5,7 @@ dependencies:
- field.field.node.page.body
- node.type.page
module:
- content_moderation
- path
- text
id: node.page.default
......@@ -14,7 +15,7 @@ mode: default
content:
body:
type: text_textarea_with_summary
weight: 31
weight: 6
region: content
settings:
rows: 9
......@@ -23,13 +24,19 @@ content:
third_party_settings: { }
created:
type: datetime_timestamp
weight: 10
weight: 2
region: content
settings: { }
third_party_settings: { }
moderation_state:
type: moderation_state_default
weight: 8
region: content
settings: { }
third_party_settings: { }
path:
type: path
weight: 30
weight: 5
region: content
settings: { }
third_party_settings: { }
......@@ -37,26 +44,26 @@ content:
type: boolean_checkbox
settings:
display_label: true
weight: 15
weight: 3
region: content
third_party_settings: { }
status:
type: boolean_checkbox
settings:
display_label: true
weight: 120
weight: 7
region: content
third_party_settings: { }
sticky:
type: boolean_checkbox
settings:
display_label: true
weight: 16
weight: 4
region: content
third_party_settings: { }
title:
type: string_textfield
weight: -5
weight: 0
region: content
settings:
size: 60
......@@ -64,7 +71,7 @@ content:
third_party_settings: { }
uid:
type: entity_reference_autocomplete
weight: 5
weight: 1
region: content
settings:
match_operator: CONTAINS
......
......@@ -16,6 +16,7 @@ dependencies:
- image.style.thumbnail
- node.type.recipe
module:
- content_moderation
- image
- path
- text
......@@ -116,6 +117,12 @@ content:
third_party_settings: { }
type: entity_reference_autocomplete_tags
region: content
moderation_state:
type: moderation_state_default
weight: 18
region: content
settings: { }
third_party_settings: { }
path:
type: path
weight: 16
......
......@@ -45,4 +45,5 @@ content:
region: content
settings: { }
third_party_settings: { }
hidden: { }
hidden:
content_moderation_control: true
......@@ -46,4 +46,5 @@ content:
region: content
settings: { }
third_party_settings: { }
hidden: { }
hidden:
content_moderation_control: true
......@@ -27,5 +27,6 @@ content:
label: hidden
hidden:
body: true
content_moderation_control: true
field_tags: true
links: true
......@@ -27,5 +27,6 @@ content:
label: hidden
hidden:
body: true
content_moderation_control: true
field_tags: true
links: true
......@@ -27,5 +27,6 @@ content:
label: hidden
hidden:
body: true
content_moderation_control: true
field_tags: true
links: true
......@@ -27,5 +27,6 @@ content:
label: hidden
hidden:
body: true
content_moderation_control: true
field_tags: true
links: true
......@@ -19,5 +19,6 @@ content:
region: content
hidden:
body: true
content_moderation_control: true
field_image: true
field_tags: true
......@@ -47,4 +47,5 @@ content:
region: content
settings: { }
third_party_settings: { }
hidden: { }
hidden:
content_moderation_control: true
......@@ -22,4 +22,5 @@ content:
links:
weight: 101
region: content
hidden: { }
hidden:
content_moderation_control: true
......@@ -24,4 +24,5 @@ content:
links:
weight: 101
region: content
hidden: { }
hidden:
content_moderation_control: true
......@@ -112,4 +112,5 @@ content:
settings: { }
third_party_settings: { }
hidden:
content_moderation_control: true
field_author: true
......@@ -113,4 +113,5 @@ content:
settings: { }
third_party_settings: { }
hidden:
content_moderation_control: true
field_author: true
......@@ -34,6 +34,7 @@ content:
type: responsive_image
region: content
hidden:
content_moderation_control: true
field_author: true
field_cooking_time: true
field_difficulty: true
......
......@@ -47,6 +47,7 @@ content:
settings: { }
third_party_settings: { }
hidden:
content_moderation_control: true
field_author: true
field_cooking_time: true
field_ingredients: true
......
......@@ -47,6 +47,7 @@ content:
settings: { }
third_party_settings: { }
hidden:
content_moderation_control: true
field_author: true
field_cooking_time: true
field_ingredients: true
......
......@@ -34,6 +34,7 @@ content:
type: responsive_image
region: content
hidden:
content_moderation_control: true
field_author: true
field_cooking_time: true
field_difficulty: true
......
......@@ -26,6 +26,7 @@ content:
weight: 100
region: content
hidden:
content_moderation_control: true
field_author: true
field_cooking_time: true
field_difficulty: true
......
langcode: en
status: true
dependencies: { }
id: author
label: Author
weight: 3
is_admin: null
permissions:
- 'access content overview'
- 'access contextual links'
- 'access files overview'
- 'access in-place editing'
- 'access toolbar'
- 'cancel account'
- 'change own username'
- 'create article content'
- 'create page content'
- 'create recipe content'
- 'create terms in ingredients'
- 'create terms in recipe_category'
- 'create terms in recipe_cuisine'
- 'create terms in tags'
- 'create url aliases'
- 'delete article revisions'
- 'delete own article content'
- 'delete own page content'
- 'delete own recipe content'
- 'delete page revisions'
- 'delete recipe revisions'
- 'delete terms in ingredients'
- 'delete terms in recipe_category'
- 'delete terms in recipe_cuisine'
- 'delete terms in tags'
- 'edit own article content'
- 'edit own page content'
- 'edit own recipe content'
- 'edit terms in ingredients'
- 'edit terms in recipe_category'
- 'edit terms in recipe_cuisine'
- 'edit terms in tags'
- 'use editorial transition create_new_draft'
- 'view all revisions'
- 'view article revisions'
- 'view latest version'
- 'view own unpublished content'
- 'view page revisions'
- 'view recipe revisions'
- 'view the administration theme'
langcode: en
status: true
dependencies: { }
id: editor
label: Editor
weight: 4
is_admin: null
permissions:
- 'access content overview'
- 'access contextual links'
- 'access files overview'
- 'access in-place editing'
- 'access toolbar'
- 'cancel account'
- 'change own username'
- 'create terms in ingredients'
- 'create terms in recipe_category'
- 'create terms in recipe_cuisine'
- 'create terms in tags'
- 'create url aliases'
- 'delete all revisions'
- 'delete any article content'
- 'delete any page content'
- 'delete any recipe content'
- 'delete article revisions'
- 'delete page revisions'
- 'delete recipe revisions'
- 'delete terms in ingredients'
- 'delete terms in recipe_category'
- 'delete terms in recipe_cuisine'
- 'delete terms in tags'
- 'edit any article content'
- 'edit any page content'
- 'edit any recipe content'
- 'edit terms in ingredients'
- 'edit terms in recipe_category'
- 'edit terms in recipe_cuisine'
- 'edit terms in tags'
- 'revert all revisions'
- 'revert article revisions'
- 'revert page revisions'
- 'revert recipe revisions'
- 'use editorial transition archive'
- 'use editorial transition archived_published'
- 'use editorial transition publish'
- 'view all revisions'
- 'view any unpublished content'
- 'view article revisions'
- 'view latest version'
- 'view page revisions'
- 'view recipe revisions'
- 'view the administration theme'
langcode: en
status: true
dependencies:
config:
- node.type.article
- node.type.page
- node.type.recipe
module:
- content_moderation
id: editorial
label: Editorial
type: content_moderation
type_settings:
states:
archived:
label: Archived
weight: 5
published: false
default_revision: true
draft:
label: Draft
published: false
default_revision: false
weight: -5
published:
label: Published
published: true
default_revision: true
weight: 0
transitions:
archive:
label: Archive
from:
- published
to: archived
weight: 2
archived_draft:
label: 'Restore to Draft'
from:
- archived
to: draft
weight: 3
archived_published:
label: Restore
from:
- archived
to: published
weight: 4
create_new_draft:
label: 'Create New Draft'
to: draft
weight: 0
from:
- draft
- published
publish:
label: Publish
to: published
weight: 1
from:
- draft
- published
entity_types:
node:
- article
- page
- recipe
......@@ -40,6 +40,8 @@ install:
- tour
- automated_cron
- responsive_image
- content_moderation
- workflows
themes:
- seven
- umami
......@@ -81,12 +81,41 @@ public static function create(ContainerInterface $container) {
* Imports default contents.
*/
public function importContent() {
$this->importArticles()
$this->importEditors()
->importArticles()
->importRecipes()
->importPages()
->importBlockContent();
}
/**
* Imports editors.
*
* Other users are created as their content is imported. However, editors
* don't have their own content so are created here instead.
*
* @return $this
*/
protected function importEditors() {
$user_storage = $this->entityTypeManager->getStorage('user');
$editors = [
'Margaret Hopper',
'Grace Hamilton',
];
foreach ($editors as $name) {
$user = $user_storage->create([
'name' => $name,
'status' => 1,
'roles' => ['editor'],
'mail' => mb_strtolower(str_replace(' ', '.', $name)) . '@example.com',
]);
$user->enforceIsNew();
$user->save();
$this->storeCreatedContentUuids([$user->uuid() => 'user']);
}
return $this;
}
/**
* Imports articles.
*
......@@ -104,6 +133,7 @@ protected function importArticles() {
$values = [
'type' => 'article',
'title' => $data['title'],
'moderation_state' => 'published',
];
// Fields mapping starts.
// Set Body Field.
......@@ -167,6 +197,7 @@ protected function importRecipes() {
'type' => 'recipe',
// Title field.
'title' => $data['title'],
'moderation_state' => 'published',
];
// Set article author.
if (!empty($data['author'])) {
......@@ -264,6 +295,7 @@ protected function importPages() {
$values = [
'type' => 'page',
'title' => $data['title'],
'moderation_state' => 'published',
];
// Fields mapping starts.
// Set Body Field.
......@@ -401,10 +433,11 @@ protected function getUser($name) {
$user_storage = $this->entityTypeManager->getStorage('user');
$users = $user_storage->loadByProperties(['name' => $name]);;
if (empty($users)) {
// Creating user without any email/password.
// Creating user without any password.
$user = $user_storage->create([
'name' => $name,
'status' => 1,
'roles' => ['author'],
'mail' => mb_strtolower(str_replace(' ', '.', $name)) . '@example.com',
]);
$user->enforceIsNew();
......
......@@ -89,7 +89,12 @@ protected function assertDefaultConfig(StorageInterface $default_config_storage,
* Tests the successful editing of nodes by admin.
*/
public function testEditNodesByAdmin() {
$account = $this->drupalCreateUser(['administer nodes', 'edit any recipe content']);
$permissions = [
'administer nodes',
'edit any recipe content',
'use editorial transition create_new_draft',
];
$account = $this->drupalCreateUser($permissions);
$this->drupalLogin($account);
$webassert = $this->assertSession();
......@@ -122,10 +127,11 @@ public function testAppearance() {
public function testDemonstrationWarningMessage() {
$permissions = [
'access content overview',
'access toolbar',
'administer nodes',
'create recipe content',
'edit any recipe content',
'access toolbar',
'create recipe content',
'use editorial transition create_new_draft',
];
$account = $this->drupalCreateUser($permissions);
$this->drupalLogin($account);
......
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