diff --git a/core/modules/views_ui/lib/Drupal/views_ui/Tests/CachedDataUITest.php b/core/modules/views_ui/lib/Drupal/views_ui/Tests/CachedDataUITest.php index 6d39784b2d7269180dc0f45b39c8e745d284623b..9bfde8eed046718b83911a342ff56c9d228edeaf 100644 --- a/core/modules/views_ui/lib/Drupal/views_ui/Tests/CachedDataUITest.php +++ b/core/modules/views_ui/lib/Drupal/views_ui/Tests/CachedDataUITest.php @@ -60,10 +60,17 @@ public function testCacheData() { $this->drupalLogin($this->adminUser); $this->drupalGet('admin/structure/views/view/test_view/edit'); + // Test that save and cancel buttons are not shown. + $this->assertNoFieldById('edit-actions-submit', t('Save')); + $this->assertNoFieldById('edit-actions-cancel', t('Cancel')); // Test we have the break lock link. $this->assertLinkByHref('admin/structure/views/view/test_view/break-lock'); // Break the lock. $this->clickLink(t('break this lock')); + $this->drupalPostForm(NULL, array(), t('Break lock')); + // Test that save and cancel buttons are shown. + $this->assertFieldById('edit-actions-submit', t('Save')); + $this->assertFieldById('edit-actions-cancel', t('Cancel')); // Test we can save the view. $this->drupalPostForm('admin/structure/views/view/test_view/edit', array(), t('Save')); $this->assertRaw(t('The view %view has been saved.', array('%view' => 'Test view'))); diff --git a/core/modules/views_ui/lib/Drupal/views_ui/ViewEditFormController.php b/core/modules/views_ui/lib/Drupal/views_ui/ViewEditFormController.php index a05e0ade99cf40440ee6bff7e117b3f1c971a1af..3c803d8459f1e21482ac86a0999e0f4a8133e3c6 100644 --- a/core/modules/views_ui/lib/Drupal/views_ui/ViewEditFormController.php +++ b/core/modules/views_ui/lib/Drupal/views_ui/ViewEditFormController.php @@ -225,6 +225,10 @@ protected function actions(array $form, array &$form_state) { array($this, 'cancel'), ), ); + if ($this->entity->isLocked()) { + $actions['submit']['#access'] = FALSE; + $actions['cancel']['#access'] = FALSE; + } return $actions; } @@ -235,6 +239,9 @@ public function validate(array $form, array &$form_state) { parent::validate($form, $form_state); $view = $this->entity; + if ($view->isLocked()) { + $this->setFormError('', $form_state, $this->t('Changes cannot be made to a locked view.')); + } foreach ($view->getExecutable()->validate() as $display_errors) { foreach ($display_errors as $error) { $this->setFormError('', $form_state, $error);