Skip to content
This repository was archived by the owner on Nov 16, 2021. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php

namespace Drupal\lightning_workflow\Form;

use Drupal\node\Form\NodeRevisionRevertForm as BaseForm;

/**
* Changes verbiage in the core node revision revert form.
*/
class NodeRevisionRevertForm extends BaseForm {

/**
* Determines if the revision is a forward revision.
*
* @return bool
* TRUE if the revision is a forward revision, FALSE otherwise.
*/
protected function isForwardRevision() {
/** @var \Drupal\node\NodeInterface $node */
$node = $this->nodeStorage->load($this->revision->id());
return $this->revision->getRevisionId() > $node->getRevisionId();
}

/**
* {@inheritdoc}
*/
public function getQuestion() {
if ($this->isForwardRevision()) {
$date = $this->dateFormatter->format($this->revision->getRevisionCreationTime());
return $this->t('Are you sure you want to switch to the revision from %revision-date?', ['%revision-date' => $date]);
}
else {
return parent::getQuestion();
}
}

/**
* {@inheritdoc}
*/
public function getConfirmText() {
return $this->isForwardRevision() ? $this->t('Switch') : parent::getConfirmText();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Drupal\Core\Routing\RouteSubscriberBase;
use Drupal\lightning_workflow\Controller\PanelizerIPEController;
use Drupal\lightning_workflow\Form\NodeRevisionRevertForm;
use Symfony\Component\Routing\RouteCollection;

/**
Expand All @@ -19,6 +20,11 @@ protected function alterRoutes(RouteCollection $collection) {
if ($route) {
$route->setDefault('_controller', PanelizerIPEController::class . '::revertToDefault');
}

$route = $collection->get('node.revision_revert_confirm');
if ($route) {
$route->setDefault('_form', NodeRevisionRevertForm::class);
}
}

}
4 changes: 4 additions & 0 deletions tests/features/media/browser_embed_code.feature
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ Feature: Creating media assets from within the media browser using embed codes
When I visit "/entity-browser/iframe/media_browser"
And I click "Create embed"
And I enter "The quick brown fox gets eaten by hungry lions." for "input"
# The change event, which triggers AJAX, is fired after 600 milliseconds.
And I wait 1 second
And I wait for AJAX to finish
And I press "Place"
Then I should see the error message "No media types can be matched to this input."
Expand All @@ -63,5 +65,7 @@ Feature: Creating media assets from within the media browser using embed codes
When I visit "/entity-browser/iframe/media_browser"
And I click "Create embed"
And I enter "https://twitter.com/webchick/status/824051274353999872" for "input"
# The change event, which triggers AJAX, is fired after 600 milliseconds.
And I wait 1 second
And I wait for AJAX to finish
Then the "#entity" element should be empty