Skip to content

Commit

Permalink
FIX Moving the version tag to below the action buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
ScopeyNZ committed May 23, 2018
1 parent ef38d2e commit 9b01050
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 16 deletions.
5 changes: 5 additions & 0 deletions css/sitesummary.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
display:block;
}

.cms .ss-gridfield > div.site-summary__clearfix {
margin: 0;
clear: both;
}

.gridfield-button-link {
margin-bottom: 12px;
}
42 changes: 42 additions & 0 deletions src/Forms/GridFieldHtmlFragment.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

/**
* Facilitates adding arbitrary HTML to grid fields
*
* @package forms
* @subpackage fields-gridfield
*/

class GridFieldHtmlFragment implements GridField_HTMLProvider
{
/**
* Fragment to write the html fragment to.
* @var string
*/
protected $targetFragment;

/**
* An HTML fragment to render
* @var string
*/
protected $htmlFragment;

/**
* @param string $targetFragment Fragment to write the html fragment to.
* @param string $htmlFragment An HTML fragment to render
*/
public function __construct($targetFragment, $htmlFragment)
{
$this->targetFragment = $targetFragment;
$this->htmlFragment = $htmlFragment;
}

/**
* @param GridField $gridField
* @return array
*/
public function getHTMLFragments($gridField)
{
return [$this->targetFragment => $this->htmlFragment];
}
}
29 changes: 13 additions & 16 deletions src/Reports/SiteSummary.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,6 @@ public function title()
return _t(__CLASS__ . '.TITLE', 'Installed modules');
}

public function getCMSFields()
{
$fields = parent::getCMSFields();

$this->beforeExtending('updateCMSFields', function (FieldList $fields) {
$fields->unshift(new LiteralField(
'Version',
'<h3>' . _t(__CLASS__ . '.VERSION', 'Version: ') . $this->resolveCmsVersion() . '</h3>'
));
});

return $fields;
}

public function sourceRecords()
{
$packageList = Package::get();
Expand Down Expand Up @@ -58,9 +44,20 @@ public function getReportField()
Requirements::css('silverstripe-maintenance/css/sitesummary.css');
$grid = parent::getReportField();
$config = $grid->getConfig();

$versionHtml = ArrayData::create([
'Title' => _t(__CLASS__ . '.VERSION', 'Version'),
'Version' => $this->resolveCmsVersion(),
])->renderWith('SiteSummary_VersionHeader');

$config->addComponents(
Injector::inst()->create('GridFieldButtonRow', 'before'),
Injector::inst()->create('GridFieldLinkButton', 'https://addons.silverstripe.org', 'buttons-before-left')
Injector::inst()->create(GridFieldButtonRow::class, 'before'),
Injector::inst()->create(
GridFieldLinkButton::class,
'https://addons.silverstripe.org',
'buttons-before-left'
),
Injector::inst()->create(GridFieldHtmlFragment::class, 'header', $versionHtml)
)
->getComponentByType(GridFieldExportButton::class)
->setExportColumns(
Expand Down
2 changes: 2 additions & 0 deletions templates/SiteSummary_VersionHeader.ss
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<div class="site-summary__clearfix"></div>
<h3>{$Title.XML}: {$Version.XML}</h3>

0 comments on commit 9b01050

Please sign in to comment.