Skip to content

Commit 182dc1e

Browse files
committed
Merge branch '4.0' into 4
2 parents ba55510 + 21d23d6 commit 182dc1e

12 files changed

Lines changed: 110 additions & 5 deletions

.editorconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ indent_style = space
1010
insert_final_newline = true
1111
trim_trailing_whitespace = true
1212

13-
[{*.yml,*.js,*.scss,package.json}]
13+
[{*.yml,*.js,*.scss,package.json,*.feature}]
1414
indent_size = 2
1515
indent_style = space
1616

behat.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
default:
2+
suites:
3+
lumberjack:
4+
paths:
5+
- "%paths.modules.lumberjack%/tests/behat/features"
6+
contexts:
7+
- SilverStripe\Framework\Tests\Behaviour\FeatureContext
8+
- SilverStripe\Framework\Tests\Behaviour\CmsFormsContext
9+
- SilverStripe\Framework\Tests\Behaviour\CmsUiContext
10+
- SilverStripe\BehatExtension\Context\BasicContext
11+
- SilverStripe\BehatExtension\Context\LoginContext
12+
-
13+
SilverStripe\BehatExtension\Context\FixtureContext:
14+
- '%paths.modules.lumberjack%/tests/behat/features/files/'
15+
-
16+
SilverStripe\Framework\Tests\Behaviour\ConfigContext:
17+
- '%paths.modules.lumberjack%/tests/behat/features/files/'
18+
19+
extensions:
20+
SilverStripe\BehatExtension\MinkExtension:
21+
default_session: facebook_web_driver
22+
javascript_session: facebook_web_driver
23+
facebook_web_driver:
24+
browser: chrome
25+
wd_host: "http://127.0.0.1:9515" #chromedriver port
26+
browser_name: chrome
27+
28+
SilverStripe\BehatExtension\Extension:
29+
screenshot_path: "%paths.base%/artifacts/screenshots"
30+
bootstrap_file: "vendor/silverstripe/framework/tests/behat/serve-bootstrap.php"

composer.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
"phpunit/phpunit": "^11.3",
1212
"squizlabs/php_codesniffer": "^3",
1313
"silverstripe/standards": "^1",
14-
"phpstan/extension-installer": "^1.3"
14+
"phpstan/extension-installer": "^1.3",
15+
"silverstripe/frameworktest": "^2"
1516
},
1617
"extra": {
1718
"expose": [
@@ -21,7 +22,7 @@
2122
"autoload": {
2223
"psr-4": {
2324
"SilverStripe\\Lumberjack\\": "src/",
24-
"SilverStripe\\Lumberjack\\Tests\\": "tests/"
25+
"SilverStripe\\Lumberjack\\Tests\\": "tests/php/"
2526
}
2627
},
2728
"license": "BSD-2-Clause",

src/Model/Lumberjack.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use SilverStripe\Forms\Tab;
1515
use SilverStripe\Lumberjack\Forms\GridFieldConfig_Lumberjack;
1616
use SilverStripe\Lumberjack\Forms\GridFieldSiteTreeViewButton;
17+
use SilverStripe\Model\List\SS_List;
1718
use SilverStripe\ORM\DataList;
1819
use SilverStripe\ORM\DataObject;
1920
use SilverStripe\Versioned\Versioned;
@@ -119,12 +120,20 @@ public function stageChildren($showAll = false)
119120
return $staged;
120121
}
121122

123+
/**
124+
* @param mixed $includeDeleted @deprecated - this parameter is unused and will be removed in a future major release
125+
*/
126+
protected function updateGetChildrenForTree(mixed $includeDeleted, SS_List &$children): void
127+
{
128+
$children = $this->excludeSiteTreeClassNames($children);
129+
}
130+
122131
/**
123132
* Excludes any hidden owner subclasses. Note that the returned DataList will be a different
124133
* instance from the original.
125134
*
126-
* @param DataList $list
127-
* @return DataList<SiteTree>
135+
* @param SS_List $list
136+
* @return SS_List<SiteTree>
128137
*/
129138
protected function excludeSiteTreeClassNames($list)
130139
{
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
TestFileUploadPage:
2+
show_in_sitetree: false
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
SilverStripe\CMS\Model\SiteTree:
2+
tree_children_method: 'AllChildrenIncludingDeleted'
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
@retry
2+
Feature: Main functionality
3+
As a content author
4+
I want lumberjack to hide some pages from the sitetree
5+
So that I have good performance for more frequently used pages
6+
7+
Background:
8+
Given I add an extension "SilverStripe\Lumberjack\Model\Lumberjack" to the "GridFieldTestPage" class
9+
And I have a config file "hide-upload-pages.yml"
10+
# Set up lumberjack pages
11+
And a "GridFieldTestPage" "Lumberjack parent page"
12+
And a "TestFileUploadPage" "Lumberjack hidden child"
13+
And a "GridFieldTestPage" "Lumberjack shown child 1"
14+
And a "page" "Lumberjack shown child 2"
15+
And the "TestFileUploadPage" "Lumberjack hidden child" is a child of a "GridFieldTestPage" "Lumberjack parent page"
16+
And the "GridFieldTestPage" "Lumberjack shown child 1" is a child of a "GridFieldTestPage" "Lumberjack parent page"
17+
And the "page" "Lumberjack shown child 2" is a child of a "GridFieldTestPage" "Lumberjack parent page"
18+
# Set up regular pages
19+
And a "page" "Regular parent"
20+
And a "TestFileUploadPage" "regular child 1"
21+
And a "GridFieldTestPage" "regular child 2"
22+
And a "page" "regular child 3"
23+
And the "TestFileUploadPage" "regular child 1" is a child of a "page" "Regular parent"
24+
And the "GridFieldTestPage" "regular child 2" is a child of a "page" "Regular parent"
25+
And the "page" "regular child 3" is a child of a "page" "Regular parent"
26+
# Set up user
27+
And the "group" "EDITOR" has permissions "Access to 'Pages' section"
28+
And I am logged in as a member of "EDITOR" group
29+
30+
Scenario: Sitetree tree view - default method
31+
Given I go to "/admin/pages"
32+
Then I should see "Regular parent" in the tree
33+
And I should see "regular child 1" in the tree
34+
And I should see "regular child 2" in the tree
35+
And I should see "regular child 3" in the tree
36+
And I should see "Lumberjack parent page" in the tree
37+
And I should see "Lumberjack shown child 1" in the tree
38+
And I should see "Lumberjack shown child 2" in the tree
39+
And I should not see "Lumberjack hidden child" in the tree
40+
When I click on "Lumberjack parent page" in the tree
41+
And I click the "Child Pages" CMS tab
42+
Then I should see "Lumberjack hidden child" in the "#Form_EditForm_ChildPages" element
43+
And I should not see "Lumberjack shown child 1" in the "#Form_EditForm_ChildPages" element
44+
And I should not see "Lumberjack shown child 2" in the "#Form_EditForm_ChildPages" element
45+
46+
Scenario: Sitetree tree view - legacy method
47+
Given I have a config file "legacy-tree-method.yml"
48+
And I go to "/admin/pages"
49+
Then I should see "Regular parent" in the tree
50+
And I should see "regular child 1" in the tree
51+
And I should see "regular child 2" in the tree
52+
And I should see "regular child 3" in the tree
53+
And I should see "Lumberjack parent page" in the tree
54+
And I should see "Lumberjack shown child 1" in the tree
55+
And I should see "Lumberjack shown child 2" in the tree
56+
And I should not see "Lumberjack hidden child" in the tree
57+
When I click on "Lumberjack parent page" in the tree
58+
And I click the "Child Pages" CMS tab
59+
Then I should see "Lumberjack hidden child" in the "#Form_EditForm_ChildPages" element
60+
And I should not see "Lumberjack shown child 1" in the "#Form_EditForm_ChildPages" element
61+
And I should not see "Lumberjack shown child 2" in the "#Form_EditForm_ChildPages" element
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)