Skip to content
Snippets Groups Projects
Commit c24feeee authored by Angie Byron's avatar Angie Byron
Browse files

Issue #2156853 by olli, quicksketch: Views UI Save and Cancel buttons break...

Issue #2156853 by olli, quicksketch: Views UI Save and Cancel buttons break existing locks by other users.
parent b9a978d2
No related branches found
No related tags found
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
......@@ -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')));
......
......@@ -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);
......
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