diff --git a/.travis.yml b/.travis.yml index 82f006460..b53415834 100644 --- a/.travis.yml +++ b/.travis.yml @@ -82,7 +82,7 @@ install: # Execute database updates, if there are any. - drupal update:execute # Execute manual updates. - - drupal update:lightning --no-interaction + - drupal update:lightning --no-interaction --since=$VERSION before_script: - drush runserver --default-server=builtin 8080 &>/dev/null & diff --git a/UPDATE.md b/UPDATE.md index f1bdd0fe9..2cf8b116d 100644 --- a/UPDATE.md +++ b/UPDATE.md @@ -76,6 +76,11 @@ are currently running Beta 1 and are trying to update to Beta 3, you will need to follow the instructions for updating from Beta 1 to Beta 2, then from Beta 2 to Beta 3, in that order. +### 2.2.0 to 2.2.1 +* Visit *Structure > Content types*. For each moderated content type, click + "Manage form display", then drag the "Publishing status" field into the + "Disabled" section and press "Save". + ### 2.1.8 to 2.2.0 There are no manual update steps for this version. diff --git a/modules/lightning_features/lightning_core/modules/lightning_page/config/install/core.entity_form_display.node.page.default.yml b/modules/lightning_features/lightning_core/modules/lightning_page/config/install/core.entity_form_display.node.page.default.yml index 2040b19de..6f03b2065 100644 --- a/modules/lightning_features/lightning_core/modules/lightning_page/config/install/core.entity_form_display.node.page.default.yml +++ b/modules/lightning_features/lightning_core/modules/lightning_page/config/install/core.entity_form_display.node.page.default.yml @@ -64,13 +64,6 @@ content: placeholder: '' third_party_settings: { } region: content - status: - type: boolean_checkbox - settings: - display_label: true - weight: 120 - region: content - third_party_settings: { } scheduled_update: type: inline_entity_form_complex weight: 8 @@ -83,4 +76,5 @@ content: match_operator: CONTAINS third_party_settings: { } region: content -hidden: { } +hidden: + status: true diff --git a/modules/lightning_features/lightning_layout/modules/lightning_landing_page/config/install/core.entity_form_display.node.landing_page.default.yml b/modules/lightning_features/lightning_layout/modules/lightning_landing_page/config/install/core.entity_form_display.node.landing_page.default.yml index 5c258078c..4162ad267 100644 --- a/modules/lightning_features/lightning_layout/modules/lightning_landing_page/config/install/core.entity_form_display.node.landing_page.default.yml +++ b/modules/lightning_features/lightning_layout/modules/lightning_landing_page/config/install/core.entity_form_display.node.landing_page.default.yml @@ -58,13 +58,7 @@ content: placeholder: '' third_party_settings: { } region: content - status: - type: boolean_checkbox - settings: - display_label: true - weight: 120 - region: content - third_party_settings: { } hidden: promote: true + status: true sticky: true diff --git a/modules/lightning_features/lightning_workflow/lightning_workflow.module b/modules/lightning_features/lightning_workflow/lightning_workflow.module index faf68430d..9769e8836 100644 --- a/modules/lightning_features/lightning_workflow/lightning_workflow.module +++ b/modules/lightning_features/lightning_workflow/lightning_workflow.module @@ -18,6 +18,27 @@ use Drupal\views\ViewEntityInterface; use Drupal\views\ViewExecutable; use Drupal\workbench_moderation\Entity\ModerationState; +/** + * Implements hook_form_FORM_ID_alter(). + */ +function lightning_workflow_form_node_type_moderation_form_alter(array &$form, FormStateInterface $form_state) { + $form['actions']['submit']['#submit'][] = 'lightning_workflow_submit_node_type_moderation_form'; +} + +function lightning_workflow_submit_node_type_moderation_form(array &$form, FormStateInterface $form_state) { + $was_moderated = (bool) $form['enable_moderation_state']['#default_value']; + $now_moderated = (bool) $form_state->getValue('enable_moderation_state'); + + if (!$was_moderated && $now_moderated) { + /** @var \Drupal\Core\Entity\EntityFormInterface $form_object */ + $form_object = $form_state->getFormObject(); + + entity_get_form_display('node', $form_object->getEntity()->id(), 'default') + ->removeComponent('status') + ->save(); + } +} + /** * Implements hook_theme_registry_alter(). */ diff --git a/modules/lightning_features/lightning_workflow/src/Update/Update221.php b/modules/lightning_features/lightning_workflow/src/Update/Update221.php new file mode 100644 index 000000000..647376b1f --- /dev/null +++ b/modules/lightning_features/lightning_workflow/src/Update/Update221.php @@ -0,0 +1,94 @@ +nodeTypeStorage = $node_type_storage; + $this->nodeDefinition = $node_definition; + $this->moderationInfo = $moderation_info; + $this->setStringTranslation($translation); + } + + /** + * {@inheritdoc} + */ + public static function create(ContainerInterface $container) { + return new static( + $container->get('entity_type.manager')->getStorage('node_type'), + $container->get('entity_type.manager')->getDefinition('node'), + $container->get('workbench_moderation.moderation_information'), + $container->get('string_translation') + ); + } + + /** + * Returns all moderated node types. + * + * @return NodeTypeInterface[] + */ + protected function getNodeTypes() { + $filter = function (NodeTypeInterface $node_type) { + return $this->moderationInfo->isModeratableBundle($this->nodeDefinition, $node_type->id()); + }; + return array_filter($this->nodeTypeStorage->loadMultiple(), $filter); + } + + /** + * @update + */ + public function hideStatusCheckboxes(DrupalStyle $io) { + /** @var NodeTypeInterface $node_type */ + foreach ($this->getNodeTypes() as $node_type) { + $question = (string) $this->t('Do you want to ensure the "Publishing status" checkbox is hidden on the @node_type content type form?', [ + '@node_type' => $node_type->label(), + ]); + + if ($io->confirm($question)) { + entity_get_form_display('node', $node_type->id(), 'default') + ->removeComponent('status') + ->save(); + } + } + } + +} diff --git a/src/Command/UpdateCommand.php b/src/Command/UpdateCommand.php index b6a571c87..5efd29a9b 100644 --- a/src/Command/UpdateCommand.php +++ b/src/Command/UpdateCommand.php @@ -93,7 +93,7 @@ protected function getProviderVersion($provider) { return isset($versions[$provider]) ? $versions[$provider] - : '0.0.0'; + : '2.2.0'; } protected function getDefinitions() { @@ -158,13 +158,14 @@ protected function runTasks($handler, DrupalStyle $io) { /** @var DocBlock $doc_block */ list ($reflector, $doc_block) = $task; + $proceed = TRUE; if ($doc_block->hasTag('ask')) { $tags = $doc_block->getTagsByName('ask'); - $proceed = $io->confirm(reset($tags)->getContent()); - if ($proceed) { - $reflector->invoke($handler, $io); - } + } + + if ($proceed) { + $reflector->invoke($handler, $io); } } } diff --git a/tests/config/core.entity_form_display.node.landing_page.default.yml b/tests/config/core.entity_form_display.node.landing_page.default.yml index 602cff222..ef7675fc8 100644 --- a/tests/config/core.entity_form_display.node.landing_page.default.yml +++ b/tests/config/core.entity_form_display.node.landing_page.default.yml @@ -36,7 +36,7 @@ content: field_meta_tags: type: metatag_firehose region: content - weight: 121 + weight: 26 settings: { } third_party_settings: { } panelizer: @@ -51,13 +51,6 @@ content: settings: { } third_party_settings: { } region: content - status: - type: boolean_checkbox - settings: - display_label: true - weight: 120 - region: content - third_party_settings: { } title: type: string_textfield weight: 0 @@ -77,4 +70,5 @@ content: region: content hidden: promote: true + status: true sticky: true diff --git a/tests/config/core.entity_form_display.node.page.default.yml b/tests/config/core.entity_form_display.node.page.default.yml index 57dd73faa..9526bfe47 100644 --- a/tests/config/core.entity_form_display.node.page.default.yml +++ b/tests/config/core.entity_form_display.node.page.default.yml @@ -36,7 +36,7 @@ content: field_meta_tags: type: metatag_firehose region: content - weight: 122 + weight: 27 settings: { } third_party_settings: { } path: @@ -62,16 +62,9 @@ content: allow_existing: false match_operator: CONTAINS form_mode: default - weight: 121 + weight: 26 third_party_settings: { } region: content - status: - type: boolean_checkbox - settings: - display_label: true - weight: 120 - region: content - third_party_settings: { } sticky: type: boolean_checkbox settings: @@ -96,4 +89,5 @@ content: placeholder: '' third_party_settings: { } region: content -hidden: { } +hidden: + status: true diff --git a/tests/features/workflow/moderation_states.feature b/tests/features/workflow/moderation_states.feature index 9b52594ba..0ae25d19d 100644 --- a/tests/features/workflow/moderation_states.feature +++ b/tests/features/workflow/moderation_states.feature @@ -94,6 +94,21 @@ Feature: Workflow moderation states When I visit "admin/content" Then I should see "Lazy Lummox" + @084ca18d + Scenario: Content types do not display the Published checkbox once they are moderated + Given node_type entities: + | type | name | + | foobar | Foobar | + And I am logged in as a user with the administrator role + When I visit "/admin/structure/types/manage/foobar/moderation" + And I check the box "Enable moderation states." + And I press "Save" + And I visit "/node/add/foobar" + Then I should see the "Save" button + But I should not see a "status[value]" field + And I should not see the "Save and publish" button + And I should not see the "Save as unpublished" button + @d0f9aaa8 Scenario: Unmoderated content types have normal submit buttons Given node_type entities: @@ -102,9 +117,26 @@ Feature: Workflow moderation states And I am logged in as a user with the "administer nodes,create not_moderated content" permissions When I visit "/node/add/not_moderated" Then I should see the "Save" button + And the "Published" checkbox should be checked + And I should not see the "Save and publish" button + And I should not see the "Save as unpublished" button + + @14ddcc9d + Scenario Outline: Moderated content types do not show the Published checkbox + Given I am logged in as a user with the role + When I visit "/node/add/" + Then I should see the "Save" button + But I should not see a "status[value]" field And I should not see the "Save and publish" button And I should not see the "Save as unpublished" button + Examples: + | node_type | role | + | page | page_creator | + | page | administrator | + | landing_page | landing_page_creator | + | landing_page | administrator | + @7cef449b Scenario: Unmoderated content types have the "Create new revision" Checkbox Given node_type entities: