From 19e9dc49208a9d3480ad5b34d9c5f660090baf22 Mon Sep 17 00:00:00 2001 From: Sabina Talipova Date: Tue, 6 Sep 2022 08:44:46 +1200 Subject: [PATCH 1/3] ENH Replace ADMIN permissions with less permissions in Behat test --- tests/behat/features/apply-formatting.feature | 3 +- tests/behat/features/create-a-page.feature | 14 ++++++---- tests/behat/features/duplicate-a-page.feature | 5 ++-- tests/behat/features/edit-a-page.feature | 8 +++++- tests/behat/features/insert-a-link.feature | 3 +- .../behat/features/insert-anchor-link.feature | 3 +- .../features/manage-page-permissions.feature | 28 ++++++++++--------- tests/behat/features/preview-a-page.feature | 4 +-- tests/behat/features/publish-a-page.feature | 12 ++++---- tests/behat/features/redirector-page.feature | 3 +- .../behat/features/search-for-a-page.feature | 3 +- tests/behat/features/sitetree.feature | 4 +-- tests/behat/features/view-reports.feature | 3 +- 13 files changed, 54 insertions(+), 39 deletions(-) diff --git a/tests/behat/features/apply-formatting.feature b/tests/behat/features/apply-formatting.feature index 2a96ebc0..a7e7dfff 100644 --- a/tests/behat/features/apply-formatting.feature +++ b/tests/behat/features/apply-formatting.feature @@ -5,7 +5,8 @@ Feature: Apply rich formatting to content Background: Given a "page" "About Us" has the "Content" "

My awesome headline

Some amazing content

" - And I am logged in with "ADMIN" permissions + Given the "group" "EDITOR" has permissions "Access to 'Pages' section" + And I am logged in as a member of "EDITOR" group And I go to "/admin/pages" Then I click on "About Us" in the tree diff --git a/tests/behat/features/create-a-page.feature b/tests/behat/features/create-a-page.feature index e8f8ae74..a7c16566 100644 --- a/tests/behat/features/create-a-page.feature +++ b/tests/behat/features/create-a-page.feature @@ -6,12 +6,12 @@ Feature: Create a page Background: Given a "page" "MyPage" And a "virtual page" "MyVirtualPage" - And a "group" "AUTHOR group" has permissions "Access to 'Pages' section" - And I am logged in with "ADMIN" permissions + And the "group" "EDITOR" has permissions "Access to 'Pages' section" @javascript Scenario: I can create a page from the pages section - When I go to "/admin/pages" + When I am logged in as a member of "EDITOR" group + And I go to "/admin/pages" Then I should see "MyPage" in the tree And I should see a "Add new" button in CMS Content Toolbar When I press the "Add new" button @@ -21,7 +21,8 @@ Feature: Create a page @javascript Scenario: I can create a page under another page - When I go to "/admin/pages" + When I am logged in as a member of "EDITOR" group + And I go to "/admin/pages" Then I should see "MyPage" in the tree And I should see a "Add new" button in CMS Content Toolbar When I press the "Add new" button @@ -39,12 +40,13 @@ Feature: Create a page Then I should see an edit page form Scenario: I cannot add root level pages without permission - When I go to "/admin/settings" + When I am logged in with "ADMIN" permissions + And I go to "/admin/settings" And I click the "Access" CMS tab And I click on the "#Form_EditForm_CanCreateTopLevelType_OnlyTheseUsers" element And I press the "Save" button And I click on the ".cms-login-status__logout-link" element - When I am logged in with "AUTHOR" permissions + When I am logged in as a member of "EDITOR" group And I press the "Add new" button Then I see the "Top level" radio button "disabled" attribute equals "1" And I see the "Under another page" radio button "checked" attribute equals "1" diff --git a/tests/behat/features/duplicate-a-page.feature b/tests/behat/features/duplicate-a-page.feature index 07cc477b..486bad37 100644 --- a/tests/behat/features/duplicate-a-page.feature +++ b/tests/behat/features/duplicate-a-page.feature @@ -4,8 +4,9 @@ Feature: Duplicate a page So that I can grow my website Background: - Given I am logged in with "ADMIN" permissions - Given a "page" "Page1" + Given the "group" "EDITOR" has permissions "Access to 'Pages' section" + And I am logged in as a member of "EDITOR" group + And a "page" "Page1" And the "page" "Page1a" is a child of the "page" "Page1" And the "page" "Page1b" is a child of the "page" "Page1" And the "page" "Page1b1" is a child of the "page" "Page1b" diff --git a/tests/behat/features/edit-a-page.feature b/tests/behat/features/edit-a-page.feature index 90ec8a09..1d12d47e 100644 --- a/tests/behat/features/edit-a-page.feature +++ b/tests/behat/features/edit-a-page.feature @@ -7,7 +7,9 @@ Feature: Edit a page Given a "page" "About Us" has the "Content" "

My content

" And a "image" "assets/file1.jpg" #And a file "assets/file1.jpg" with changes "image"="assets/folder1/file2.jpg" and "page"="About Us" - And I am logged in with "ADMIN" permissions + And the "group" "AUTHOR" has permissions "Access to 'Pages' section" + And the "group" "EDITOR" has permissions "Access to 'Pages' section" and "SITETREE_GRANT_ACCESS" + And I am logged in as a member of "AUTHOR" group And I go to "/admin/pages" Then I should see "About Us" in the tree @@ -115,6 +117,10 @@ Feature: Edit a page Then I should see "Please choose a linked page in the main content fields in order to publish" Scenario: Change permission levels for who can view and edit the page, at an individual page level + Given I am not logged in + And I am logged in as a member of "EDITOR" group + And I go to "/admin/pages" + Then I should see "About Us" in the tree When I click on "About Us" in the tree And I click the "Settings" CMS tab And I select the "Form_EditForm_CanViewType_LoggedInUsers" radio button diff --git a/tests/behat/features/insert-a-link.feature b/tests/behat/features/insert-a-link.feature index 1783ba1d..8d83dc97 100644 --- a/tests/behat/features/insert-a-link.feature +++ b/tests/behat/features/insert-a-link.feature @@ -8,7 +8,8 @@ So that I can link to a external website or a page on my site Given a "page" "Home" And a "page" "About Us" has the "Content" "

My awesome content

" And a "file" "file1.jpg" - And I am logged in with "ADMIN" permissions + And the "group" "EDITOR" has permissions "Access to 'Pages' section" + And I am logged in as a member of "EDITOR" group And I go to "/admin/pages" And I click on "About Us" in the tree diff --git a/tests/behat/features/insert-anchor-link.feature b/tests/behat/features/insert-anchor-link.feature index 23468c12..a6f1ea17 100644 --- a/tests/behat/features/insert-anchor-link.feature +++ b/tests/behat/features/insert-anchor-link.feature @@ -9,7 +9,8 @@ So that I can link to a external website or a page on my site And a "page" "Home" And a "page" "About Us" has the "Content" "

My awesome content

" And a "page" "Details" has the "Content" "

My sub-par content

" - And I am logged in with "ADMIN" permissions + And the "group" "EDITOR" has permissions "Access to 'Pages' section" + And I am logged in as a member of "EDITOR" group And I go to "/admin/pages" And I click on "About Us" in the tree diff --git a/tests/behat/features/manage-page-permissions.feature b/tests/behat/features/manage-page-permissions.feature index 2a50e8b4..eee84f8f 100644 --- a/tests/behat/features/manage-page-permissions.feature +++ b/tests/behat/features/manage-page-permissions.feature @@ -5,8 +5,8 @@ Feature: Manage page permissions Background: Given a "page" "Home" with "Content"="

Welcome

" - And a "group" "AUTHOR group" has permissions "Access to 'Pages' section" - And a "group" "SECURITY group" has permissions "Access to 'Security' section" + And a "group" "EDITOR" has permissions "Access to 'Pages' section" + And a "group" "SECURITY" has permissions "Access to 'Security' section" And I am logged in with "ADMIN" permissions And I go to "/admin/pages" And I click on "Home" in the tree @@ -20,42 +20,44 @@ Feature: Manage page permissions # When I am not logged in # And I go to the homepage # Then I should see "Welcome" - Scenario: I can limit page view permissions to logged-in users Given I select "Logged-in users" from "Who can view this page?" input group And I press the "Publish" button When I am not logged in And I go to the homepage Then I should see a log-in form - When I am logged in with "AUTHOR" permissions + When I am logged in as a member of "EDITOR" group And I go to the homepage Then I should see "Welcome" - Scenario: I can limit page view permissions to certain groups Given I select "Only these groups (choose from list)" from "Who can view this page?" input group - And I select "AUTHOR group" in the "#Form_EditForm_ViewerGroups_Holder" tree dropdown + And I select "EDITOR" in the "#Form_EditForm_ViewerGroups_Holder" tree dropdown And I press the "Publish" button When I am not logged in And I go to the homepage Then I should see a log-in form - When I am logged in with "SECURITY" permissions + When I am logged in as a member of "SECURITY" group And I go to the homepage Then I will see a "warning" log-in message When I am not logged in - And I am logged in with "AUTHOR" permissions + And I am logged in as a member of "EDITOR" group And I go to the homepage Then I should see "Welcome" - Scenario: I can limit page edit permissions to logged-in users - Given I select "Logged-in users" from "Who can edit this page?" input group + Given I am not logged in + And I am logged in as a member of "EDITOR" group + And I go to "/admin/pages" + And I click on "Home" in the tree + Then I should see an edit page form + And I click the "Settings" CMS tab + And I select "Logged-in users" from "Who can edit this page?" input group And I press the "Publish" button - Then pages should be editable by "AUTHOR" + Then pages should be editable by "EDITOR" And pages should be editable by "ADMIN" - Scenario: I can limit page edit permissions to certain groups Given I select "Only these groups (choose from list)" from "Who can edit this page?" input group And I select "ADMIN group" in the "#Form_EditForm_EditorGroups_Holder" tree dropdown And I press the "Publish" button - Then pages should not be editable by "AUTHOR" + Then pages should not be editable by "EDITOR" But pages should be editable by "ADMIN" diff --git a/tests/behat/features/preview-a-page.feature b/tests/behat/features/preview-a-page.feature index 8769117b..c856803a 100644 --- a/tests/behat/features/preview-a-page.feature +++ b/tests/behat/features/preview-a-page.feature @@ -5,10 +5,11 @@ Feature: Preview a page Background: Given a "page" "About Us" + And the "group" "EDITOR" has permissions "Access to 'Pages' section" + And I am logged in as a member of "EDITOR" group @javascript Scenario: I can show a preview of the current page from the pages section - Given I am logged in with "ADMIN" permissions And I go to "/admin/pages" Then I should see "About Us" in the tree @@ -23,7 +24,6 @@ Feature: Preview a page # - We should continue testing against it after we have fixtures ready @javascript Scenario: I can see an updated preview when editing content - Given I am logged in with "ADMIN" permissions And I go to "/admin/pages" Then I should see "About Us" in the tree diff --git a/tests/behat/features/publish-a-page.feature b/tests/behat/features/publish-a-page.feature index 5181c914..5d863446 100644 --- a/tests/behat/features/publish-a-page.feature +++ b/tests/behat/features/publish-a-page.feature @@ -6,6 +6,8 @@ Feature: Publish a page Background: Given a "page" "My Page" with "URLSegment"="my-page" and "Content"="

initial content

" And the "page" "My Page" is not published + And the "group" "EDITOR" has permissions "Access to 'Pages' section" + And I am logged in as a member of "EDITOR" group @javascript Scenario: I can have a unpublished version of a page that is not publicly available @@ -14,8 +16,7 @@ Feature: Publish a page @javascript Scenario: I can publish a previously never published page - Given I am logged in with "ADMIN" permissions - And I go to "/admin/pages" + Given I go to "/admin/pages" And I should see "My Page" in the tree And I click on "My Page" in the tree And I press the "Publish" button @@ -27,8 +28,7 @@ Feature: Publish a page @javascript Scenario: I will get different options depending on the current publish state of the page - Given I am logged in with "ADMIN" permissions - And I go to "/admin/pages" + Given I go to "/admin/pages" And I should see "My Page" in the tree And I click on "My Page" in the tree @@ -58,7 +58,6 @@ Feature: Publish a page And I go to "/hello" Then I should see "hello world" - Given I am logged in with "ADMIN" permissions And I go to "/admin/pages" And I should see "Hello" in the tree And I click on "Hello" in the tree @@ -72,8 +71,7 @@ Feature: Publish a page @javascript Scenario: I can delete a page from live and draft stage to completely remove it - Given I am logged in with "ADMIN" permissions - And I go to "/admin/pages" + Given I go to "/admin/pages" And I should see "My Page" in the tree And I click on "My Page" in the tree And I press the "Publish" button diff --git a/tests/behat/features/redirector-page.feature b/tests/behat/features/redirector-page.feature index 9fb7b244..40eca4d6 100644 --- a/tests/behat/features/redirector-page.feature +++ b/tests/behat/features/redirector-page.feature @@ -8,7 +8,8 @@ Feature: Redirector Pages Given a "page" "Page 1" And a "page" "My Redirect" which redirects to a "page" "Page 1" And a "image" "assets/file1.jpg" - And I am logged in with "ADMIN" permissions + And the "group" "EDITOR" has permissions "Access to 'Pages' section" + And I am logged in as a member of "EDITOR" group And I go to "/admin/pages" Scenario: Only the appropriate fields are shown diff --git a/tests/behat/features/search-for-a-page.feature b/tests/behat/features/search-for-a-page.feature index 82f58812..34dfd7b8 100644 --- a/tests/behat/features/search-for-a-page.feature +++ b/tests/behat/features/search-for-a-page.feature @@ -8,7 +8,8 @@ Feature: Search for a page Given a "page" "Home" And a "page" "About Us" And a "page" "Contact Us" - And I am logged in with "ADMIN" permissions + And the "group" "EDITOR" has permissions "Access to 'Pages' section" + And I am logged in as a member of "EDITOR" group And I go to "/admin/pages" And I press the "Filter" button diff --git a/tests/behat/features/sitetree.feature b/tests/behat/features/sitetree.feature index 0bc356a6..c019d8a3 100644 --- a/tests/behat/features/sitetree.feature +++ b/tests/behat/features/sitetree.feature @@ -4,8 +4,8 @@ Feature: Sitetree So that I can operate my website Background: - Given the "group" "EDITOR group" has permissions "CMS_ACCESS_LeftAndMain" and "SITETREE_REORGANISE" - And I am logged in with "EDITOR" permissions + Given the "group" "EDITOR" has permissions "Access to 'Pages' section" and "SITETREE_REORGANISE" + And I am logged in as a member of "EDITOR" group And a "page" "One" And a "page" "Two" And a "page" "Three" diff --git a/tests/behat/features/view-reports.feature b/tests/behat/features/view-reports.feature index 4b071a2c..1192bd82 100644 --- a/tests/behat/features/view-reports.feature +++ b/tests/behat/features/view-reports.feature @@ -6,7 +6,8 @@ Feature: View Reports Background: Given a "page" "Empty Page" And a "page" "Filled Page" with "Content"="

Some Content

" - And I am logged in with "ADMIN" permissions + And the "group" "EDITOR" has permissions "Access to 'Pages' section" and "Access to 'Reports' section" + And I am logged in as a member of "EDITOR" group And I go to "/admin/reports" Scenario: I can view the "Pages with no content" report From 1f360c9c2692f05b128bf29f2ee5456f00b9efb9 Mon Sep 17 00:00:00 2001 From: Guy Sartorelli <36352093+GuySartorelli@users.noreply.github.com> Date: Fri, 30 Sep 2022 15:10:49 +1300 Subject: [PATCH 2/3] ENH Use the new CMSEditLinkExtension on SiteTree (#2778) --- code/Controllers/CMSMain.php | 10 ++++++ code/Model/SiteTree.php | 19 +++++++---- composer.json | 2 +- .../BelongsToPage.php | 27 +++++++++++++++ .../PageWithChild.php | 25 ++++++++++++++ .../CMSEditLinkExtensionTest/fixtures.yml | 9 +++++ tests/php/Model/SiteTreeTest.php | 33 ++++++++++++++++++- 7 files changed, 116 insertions(+), 9 deletions(-) create mode 100644 tests/php/Model/CMSEditLinkExtensionTest/BelongsToPage.php create mode 100644 tests/php/Model/CMSEditLinkExtensionTest/PageWithChild.php create mode 100644 tests/php/Model/CMSEditLinkExtensionTest/fixtures.yml diff --git a/code/Controllers/CMSMain.php b/code/Controllers/CMSMain.php index 7f067a32..d582c25e 100644 --- a/code/Controllers/CMSMain.php +++ b/code/Controllers/CMSMain.php @@ -375,6 +375,16 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr return $this->Link('listview'); } + /** + * Get the link for editing a page. + * + * @see CMSEditLinkExtension::getCMSEditLinkForManagedDataObject() + */ + public function getCMSEditLinkForManagedDataObject(SiteTree $obj): string + { + return Controller::join_links(CMSPageEditController::singleton()->Link('show'), $obj->ID); + } + public function LinkPageEdit($id = null) { if (!$id) { diff --git a/code/Model/SiteTree.php b/code/Model/SiteTree.php index 2c19f445..4e6f0e7a 100755 --- a/code/Model/SiteTree.php +++ b/code/Model/SiteTree.php @@ -4,7 +4,9 @@ namespace SilverStripe\CMS\Model; use Page; use Psr\SimpleCache\CacheInterface; +use SilverStripe\Admin\CMSEditLinkExtension; use SilverStripe\Assets\Shortcodes\FileLinkTracking; +use SilverStripe\CMS\Controllers\CMSMain; use SilverStripe\CMS\Controllers\CMSPageEditController; use SilverStripe\CMS\Controllers\ContentController; use SilverStripe\CMS\Controllers\ModelAsController; @@ -113,7 +115,6 @@ use SilverStripe\View\SSViewer; */ class SiteTree extends DataObject implements PermissionProvider, i18nEntityProvider, CMSPreviewable, Resettable, Flushable, MemberCacheFlusher { - /** * Indicates what kind of children this page type can have. * This can be an array of allowed child classes, or the string "none" - @@ -215,6 +216,12 @@ class SiteTree extends DataObject implements PermissionProvider, i18nEntityProvi */ private static $controller_name = null; + /** + * The class of the LeftAndMain controller where this class is managed. + * @see CMSEditLinkExtension::getCMSEditOwner() + */ + private static string $cms_edit_owner = CMSMain::class; + /** * You can define the a map of Page namespaces to Controller namespaces here * This will apply after the magic of appending Controller, and in order @@ -316,6 +323,7 @@ class SiteTree extends DataObject implements PermissionProvider, i18nEntityProvi Hierarchy::class, Versioned::class, InheritedPermissionsExtension::class, + CMSEditLinkExtension::class, ]; private static $searchable_fields = [ @@ -734,14 +742,11 @@ class SiteTree extends DataObject implements PermissionProvider, i18nEntityProvi */ public function CMSEditLink() { - $link = Controller::join_links( - CMSPageEditController::singleton()->Link('show'), - $this->ID - ); - return Director::absoluteURL($link); + // This method has to be implemented here to satisfy the CMSPreviewable interface. + // See the actual implementation in CMSEditLinkExtension. + return $this->extend('CMSEditLink')[0]; } - /** * Return a CSS identifier generated from this page's link. * diff --git a/composer.json b/composer.json index 617e9250..e3186a66 100644 --- a/composer.json +++ b/composer.json @@ -19,7 +19,7 @@ } ], "require": { - "silverstripe/admin": "^1.9@dev", + "silverstripe/admin": "^1.12@dev", "silverstripe/campaign-admin": "^1.7@dev", "silverstripe/framework": "^4.11", "silverstripe/reports": "^4.7@dev", diff --git a/tests/php/Model/CMSEditLinkExtensionTest/BelongsToPage.php b/tests/php/Model/CMSEditLinkExtensionTest/BelongsToPage.php new file mode 100644 index 00000000..952987ae --- /dev/null +++ b/tests/php/Model/CMSEditLinkExtensionTest/BelongsToPage.php @@ -0,0 +1,27 @@ + 'Varchar(25)', + ]; + + private static $has_one = [ + 'Parent' => SiteTree::class, + ]; + + private static $extensions = [ + CMSEditLinkExtension::class, + ]; +} diff --git a/tests/php/Model/CMSEditLinkExtensionTest/PageWithChild.php b/tests/php/Model/CMSEditLinkExtensionTest/PageWithChild.php new file mode 100644 index 00000000..e6c7429f --- /dev/null +++ b/tests/php/Model/CMSEditLinkExtensionTest/PageWithChild.php @@ -0,0 +1,25 @@ + BelongsToPage::class, + ]; + + public function getCMSFields() + { + $fields = parent::getCMSFields(); + $fields->addFieldToTab( + 'Root.ChildObjects', + GridField::create('ChildObjects', 'ChildObjects', $this->ChildObjects(), GridFieldConfig_RelationEditor::create()) + ); + return $fields; + } +} diff --git a/tests/php/Model/CMSEditLinkExtensionTest/fixtures.yml b/tests/php/Model/CMSEditLinkExtensionTest/fixtures.yml new file mode 100644 index 00000000..8c7876e5 --- /dev/null +++ b/tests/php/Model/CMSEditLinkExtensionTest/fixtures.yml @@ -0,0 +1,9 @@ +SilverStripe\CMS\Tests\CMSEditLinkExtensionTest\BelongsToPage: + one: + Name: 'some name' + +SilverStripe\CMS\Tests\CMSEditLinkExtensionTest\PageWithChild: + root: + Title: 'page has child' + ChildObjects: + - '=>SilverStripe\CMS\Tests\CMSEditLinkExtensionTest\BelongsToPage.one' diff --git a/tests/php/Model/SiteTreeTest.php b/tests/php/Model/SiteTreeTest.php index 229b7ded..86880f7c 100644 --- a/tests/php/Model/SiteTreeTest.php +++ b/tests/php/Model/SiteTreeTest.php @@ -10,6 +10,8 @@ use SilverStripe\CMS\Model\RedirectorPage; use SilverStripe\CMS\Model\SiteTree; use SilverStripe\CMS\Model\VirtualPage; use SilverStripe\CMS\Tests\Controllers\SiteTreeTest_NamespaceMapTestController; +use SilverStripe\CMS\Tests\CMSEditLinkExtensionTest\BelongsToPage; +use SilverStripe\CMS\Tests\CMSEditLinkExtensionTest\PageWithChild; use SilverStripe\CMS\Tests\Page\SiteTreeTest_NamespaceMapTest; use SilverStripe\Control\ContentNegotiator; use SilverStripe\Control\Controller; @@ -40,7 +42,10 @@ use const RESOURCES_DIR; class SiteTreeTest extends SapphireTest { - protected static $fixture_file = 'SiteTreeTest.yml'; + protected static $fixture_file = [ + 'SiteTreeTest.yml', + 'CMSEditLinkExtensionTest/fixtures.yml', + ]; protected static $illegal_extensions = [ SiteTree::class => [ @@ -58,6 +63,8 @@ class SiteTreeTest extends SapphireTest SiteTreeTest_NotRoot::class, SiteTreeTest_StageStatusInherit::class, SiteTreeTest_DataObject::class, + PageWithChild::class, + BelongsToPage::class, ]; public function reservedSegmentsProvider() @@ -1986,4 +1993,28 @@ class SiteTreeTest extends SapphireTest ); // END ARCHIVED } + + public function testGetCMSEditLinkForManagedDataObject() + { + $page = $this->objFromFixture(PageWithChild::class, 'root'); + $child = $this->objFromFixture(BelongsToPage::class, 'one'); + $this->assertSame( + "http://localhost/admin/pages/edit/show/$page->ID/field/ChildObjects/item/$child->ID", + $page->getCMSEditLinkForManagedDataObject($child, 'Parent') + ); + } + + public function testCMSEditLink() + { + $page = $this->objFromFixture(PageWithChild::class, 'root'); + $child = $this->objFromFixture(BelongsToPage::class, 'one'); + $this->assertSame( + "http://localhost/admin/pages/edit/show/$page->ID", + $page->CMSEditLink() + ); + $this->assertSame( + "http://localhost/admin/pages/edit/show/$page->ID/field/ChildObjects/item/$child->ID", + $child->CMSEditLink() + ); + } } From 9ca4895f79a99492654402dfd3c6e328eaae22f9 Mon Sep 17 00:00:00 2001 From: Bram de Leeuw Date: Fri, 30 Sep 2022 12:19:49 +0200 Subject: [PATCH 3/3] Reset ExtraClass on ViewModeSelector include Since silverstripe/silverstripe-admin version 1.11 the include `SilverStripe\\Admin\\LeftAndMain_ViewModeSelector` uses an [ExtraClass parameter](https://github.com/silverstripe/silverstripe-admin/blob/6d1998707d7cb96e888a83053c9d34b09d842ed2/templates/SilverStripe/Admin/Includes/LeftAndMain_ViewModeSelector.ss#L1). When this parameter is not explicitly set it inherits the ExtraClass of the template it's included in. In CMSMain this causes the ViewMode button to stretch. --- .../SilverStripe/CMS/Controllers/Includes/CMSMain_EditForm.ss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/SilverStripe/CMS/Controllers/Includes/CMSMain_EditForm.ss b/templates/SilverStripe/CMS/Controllers/Includes/CMSMain_EditForm.ss index b087d46a..3a85076f 100644 --- a/templates/SilverStripe/CMS/Controllers/Includes/CMSMain_EditForm.ss +++ b/templates/SilverStripe/CMS/Controllers/Includes/CMSMain_EditForm.ss @@ -28,7 +28,7 @@ <% end_if %> - <% include SilverStripe\\Admin\\LeftAndMain_ViewModeSelector SelectID="preview-mode-dropdown-in-content" %> + <% include SilverStripe\\Admin\\LeftAndMain_ViewModeSelector SelectID="preview-mode-dropdown-in-content", ExtraClass='' %> <% end_if %>