Commit c24feeee authored by webchick's avatar webchick

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
......@@ -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);
......
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