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 22, 2018
1 parent ef38d2e commit de4aac7
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 16 deletions.
35 changes: 35 additions & 0 deletions src/Forms/GridFieldHtmlFragment.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

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

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

/**
* @param string Fragment to write the button to.
* @param string 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];
}
}
27 changes: 11 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,18 @@ public function getReportField()
Requirements::css('silverstripe-maintenance/css/sitesummary.css');
$grid = parent::getReportField();
$config = $grid->getConfig();

$versionHtml = '<div style="clear: both; margin: 0"></div><h3>' .
_t(__CLASS__ . '.VERSION', 'Version: ') . $this->resolveCmsVersion() . '</h3>';

$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

0 comments on commit de4aac7

Please sign in to comment.