Skip to content

Commit

Permalink
ENH Update code to reflect changes in silverstripe/admin (#3024)
Browse files Browse the repository at this point in the history
  • Loading branch information
GuySartorelli authored Nov 19, 2024
1 parent 72a5cc8 commit 33e1556
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
8 changes: 4 additions & 4 deletions code/Controllers/CMSPageEditController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Page;
use SilverStripe\Admin\LeftAndMain;
use SilverStripe\Admin\ModalController;
use SilverStripe\CampaignAdmin\AddToCampaignHandler;
use SilverStripe\CMS\Model\SiteTree;
use SilverStripe\Control\Controller;
Expand Down Expand Up @@ -36,18 +37,17 @@ class CMSPageEditController extends CMSMain

public function getClientConfig(): array
{
$modalController = ModalController::singleton();
return ArrayLib::array_merge_recursive(parent::getClientConfig(), [
'form' => [
'AddToCampaignForm' => [
'schemaUrl' => $this->Link('schema/AddToCampaignForm'),
],
'editorInternalLink' => [
'schemaUrl' => LeftAndMain::singleton()
->Link('methodSchema/Modals/editorInternalLink'),
'schemaUrl' => $modalController->Link('schema/editorInternalLink'),
],
'editorAnchorLink' => [
'schemaUrl' => LeftAndMain::singleton()
->Link('methodSchema/Modals/editorAnchorLink/:pageid'),
'schemaUrl' => $modalController->Link('schema/editorAnchorLink/:pageid'),
],
],
]);
Expand Down
4 changes: 2 additions & 2 deletions code/Forms/InternalLinkModalExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
class InternalLinkModalExtension extends Extension
{
private static $url_handlers = [
'editorAnchorLink/$ItemID' => 'editorAnchorLink', // Matches LeftAndMain::methodSchema args
'editorAnchorLink/$ItemID' => 'editorAnchorLink', // Matches FormSchemaController::schema args
];

private static $allowed_actions = [
Expand All @@ -41,7 +41,7 @@ public function editorInternalLink()

public function editorAnchorLink()
{
// Note: Should work both via MethodSchema and as direct request
// Note: Should work both via schema() and as direct request
$request = $this->getOwner()->getRequest();
$showLinkText = $request->getVar('requireLinkText');
$pageID = $request->param('ItemID');
Expand Down
6 changes: 3 additions & 3 deletions tests/behat/features/insert-a-link.feature
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ So that I can link to a external website or a page on my site
Given I select "awesome" in the "Content" HTML field
And I press the "Insert link" HTML field button
When I click "Link to external URL" in the ".tox-collection__group" element
And I should see an "form#Form_ModalsEditorExternalLink" element
And I should see an "form#Form_EditorExternalLink" element
When I fill in "http://silverstripe.org" for "URL"
And I check "Open in new window/tab"
And I press the "Insert link" button
Expand All @@ -80,7 +80,7 @@ So that I can link to a external website or a page on my site
When I select the image "file1.jpg" in the "Content" HTML field
And I press the "Insert link" HTML field button
When I click "Link to external URL" in the ".tox-collection__group" element
And I should see an "form#Form_ModalsEditorExternalLink" element
And I should see an "form#Form_EditorExternalLink" element
And I should not see "Link text"
When I fill in "http://silverstripe.org" for "URL"
And I press the "Insert link" button
Expand All @@ -94,7 +94,7 @@ So that I can link to a external website or a page on my site
And I select "awesome" in the "Content" HTML field
When I press the "Insert link" HTML field button
And I click "Link to external URL" in the ".tox-collection__group" element
And I should see an "form#Form_ModalsEditorExternalLink" element
And I should see an "form#Form_EditorExternalLink" element
Then the "URL" field should contain "http://silverstripe.org"
# This doesn't seem to suffer from that issue
When I fill in "http://google.com" for "URL"
Expand Down

0 comments on commit 33e1556

Please sign in to comment.