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

8.0.x
webchick 2014-02-26 09:26:59 -08:00
parent b9a978d202
commit c24feeee54
2 changed files with 14 additions and 0 deletions

View File

@ -60,10 +60,17 @@ class CachedDataUITest extends UITestBase {
$this->drupalLogin($this->adminUser); $this->drupalLogin($this->adminUser);
$this->drupalGet('admin/structure/views/view/test_view/edit'); $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. // Test we have the break lock link.
$this->assertLinkByHref('admin/structure/views/view/test_view/break-lock'); $this->assertLinkByHref('admin/structure/views/view/test_view/break-lock');
// Break the lock. // Break the lock.
$this->clickLink(t('break this 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. // Test we can save the view.
$this->drupalPostForm('admin/structure/views/view/test_view/edit', array(), t('Save')); $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'))); $this->assertRaw(t('The view %view has been saved.', array('%view' => 'Test view')));

View File

@ -225,6 +225,10 @@ class ViewEditFormController extends ViewFormControllerBase {
array($this, 'cancel'), array($this, 'cancel'),
), ),
); );
if ($this->entity->isLocked()) {
$actions['submit']['#access'] = FALSE;
$actions['cancel']['#access'] = FALSE;
}
return $actions; return $actions;
} }
@ -235,6 +239,9 @@ class ViewEditFormController extends ViewFormControllerBase {
parent::validate($form, $form_state); parent::validate($form, $form_state);
$view = $this->entity; $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 ($view->getExecutable()->validate() as $display_errors) {
foreach ($display_errors as $error) { foreach ($display_errors as $error) {
$this->setFormError('', $form_state, $error); $this->setFormError('', $form_state, $error);