Skip to content

Commit

Permalink
Disallow creation of section editor panel on large page trees (#41)
Browse files Browse the repository at this point in the history
Stopgap solution until a better UI is found for this.
Also backports an additional canCreate() check which
is already in place for master.
  • Loading branch information
chillu committed Aug 29, 2013
1 parent e944c5a commit 30a36d9
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
2 changes: 1 addition & 1 deletion code/Dashboard.php
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ public function AllPanels() {
foreach(SS_ClassLoader::instance()->getManifest()->getDescendantsOf("DashboardPanel") as $class) {
$SNG = Injector::inst()->get($class);
$SNG->Priority = Config::inst()->get($class, "priority", Config::INHERITED);
$set->push($SNG);
if($SNG->canCreate()) $set->push($SNG);
}
return $set->sort("Priority");
}
Expand Down
19 changes: 16 additions & 3 deletions code/panels/DashboardSectionEditorPanel.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,14 @@ class DashboardSectionEditorPanel extends DashboardPanel {

static $configure_on_create = true;



/**
* @config Maximum number of records which should be displayed in this component.
* If the number is too high, the dashboard can time out or run out of PHP memory.
* @todo Temporary configuration value, to be replaced by a more flexible UI component
* for viewing the hierarchy without preloading all of it.
* @var integer
*/
static $record_limit = 250;

public function getLabel() {
return _t('Dashboard.SECTIONEDTIORLABEL','Section Editor');
Expand All @@ -38,7 +44,14 @@ public function getDescription() {
return _t('Dashbaord.SECTIONEDITORDESCRIPTION','Pulls pages from a section of the website for viewing and creation');
}


public function canCreate($member = null) {
$count = SiteTree::get()->Count();
if($count > $this->config()->record_limit) {
return false;
} else {
return parent::canCreate($member);
}
}

/**
* Gets the icon for the panel. Use the icon of the subject page when possible, otherwise
Expand Down

0 comments on commit 30a36d9

Please sign in to comment.