Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH Update code to reflect changes in silverstripe/admin #3024

Merged
merged 1 commit into from
Nov 19, 2024
Merged
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
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
Loading