Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NEW Showing framework/CMS version on module report #55

Conversation

ScopeyNZ
Copy link
Contributor

@ScopeyNZ ScopeyNZ commented May 22, 2018

This adds a paragraph to display the version of SilverStripe CMS and Framework on the installed module report

Unfortunately the work done for SS3.7 is not available for providing the version so this looks at the contents of the report to find the relevant versions. It allows for extension in CWP. I tested it with an extension too:

class CwpSiteSummaryExtension extends Extension
{
    public function getVersionModules()
    {
        return array(
            'cwp/cwp' => 'CWP',
            'silverstripe/cms' => 'SilverStripe CMS',
        );
    }
}

Resolves #35
Resolves #60

Copy link
Contributor

@robbieaverill robbieaverill left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good overall! Just a couple of points regarding the extensibility of these changes


$fields->insertAfter('ReportDescription', new LiteralField(
'Version', '<p><strong>' . _t(__CLASS__ . '.VERSION', 'Version: ') . $this->resolveCmsVersion() . '</strong></p>'
));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only concern I have with this is that you're adding the field after the extension point, so the update method won't affect it for other devs who might want to remove or modify this field.

Can you switch to using the beforeUpdateCMSFields callback?

$this->beforeUpdateCMSFields(function (FieldList $fields) {
    $fields->insertAfter...
});
return parent::getCMSFields();

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

beforeUpdateCMSFields isn't available in SS_Report which doesn't extend DataObject but I can use $this->beforeExtending('updateCMSFields', $callback); I guess?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfect, cheers

'silverstripe/framework' => 'Framework',
'silverstripe/cms' => 'CMS',
);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it'd be good to provide this array to extensions, rather than define it as a fallback, e.g.:

$versionModules = array(...);
$this->extend('updateVersionModules', $versionModules);
...

We could expect extensions to modify the array by reference

@ScopeyNZ ScopeyNZ force-pushed the pulls/1.0/show-version-on-module-report branch from 2e5878c to 033abfd Compare May 22, 2018 03:36
@robbieaverill robbieaverill self-assigned this May 22, 2018
@ScopeyNZ ScopeyNZ force-pushed the pulls/1.0/show-version-on-module-report branch from 033abfd to d8fde1f Compare May 22, 2018 04:30
@robbieaverill
Copy link
Contributor

We also need a CWP pull request for this. I'd suggest you make it against the 1 (next minor) branch of the cwp/cwp module. We need to ensure that the framework version is removed in the CWP extension, so it'd read something like SilverStripe CMS 3.7.0, CWP 1.9.0 if you had that installed.

$this->beforeExtending('updateCMSFields', function (FieldList $fields) {
$fields->insertAfter('ReportDescription', new LiteralField(
'Version',
'<p><strong>' . _t(__CLASS__ . '.VERSION', 'Version: ') . $this->resolveCmsVersion() . '</strong></p>'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should make this an <h3> tag. There's an h2 in the report heading, so this would make sense as the next semantic step (and might align a little more closely with the designs)

@robbieaverill
Copy link
Contributor

We also need this to appear between the actions toolbar (added in #36) and the main GridField rather than above the actions toolbar.

@robbieaverill robbieaverill removed their assignment May 22, 2018
@ScopeyNZ ScopeyNZ force-pushed the pulls/1.0/show-version-on-module-report branch 3 times, most recently from 1ea1b10 to 2b7e20c Compare May 22, 2018 23:30
@ScopeyNZ
Copy link
Contributor Author

I have moved the version to be below the action buttons now.

I've also addressed #60 in this PR too.

@ScopeyNZ ScopeyNZ force-pushed the pulls/1.0/show-version-on-module-report branch from 2b7e20c to de4aac7 Compare May 22, 2018 23:37
@@ -0,0 +1,35 @@
<?php

class GridFieldHtmlFragment implements GridField_HTMLProvider
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add a phpdoc for this class please to explain what it does? Also I think the "button" references are misleading


/**
* @param string Fragment to write the button to.
* @param string An HTML fragment to render
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing PHPDoc variable names

)
->getComponentByType(GridFieldExportButton::class)
->setExportColumns(
Package::create()->summaryFields()
);
return $grid;
}

/**
* @return string
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a description of what this is doing

@ScopeyNZ ScopeyNZ force-pushed the pulls/1.0/show-version-on-module-report branch 2 times, most recently from 9b01050 to a70ffdc Compare May 23, 2018 00:20
Copy link
Contributor

@NightJar NightJar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One minor change, but otherwise looks great :)

];
$this->extend('updateVersionModules', $versionModules);

$records = $this->sourceRecords()->filter('name', array_keys($versionModules));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe name should be Name

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done 👍

@ScopeyNZ ScopeyNZ force-pushed the pulls/1.0/show-version-on-module-report branch from a70ffdc to 424af55 Compare May 23, 2018 00:48
@ScopeyNZ
Copy link
Contributor Author

Added a CWP PR: silverstripe/cwp#85

@@ -2,6 +2,11 @@
display:block;
}

.cms .ss-gridfield > div.site-summary__clearfix {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We use BEM in order to avoid having this kind of specificity - can you please just reference .site-summary__clearfix instead?

Copy link
Contributor Author

@ScopeyNZ ScopeyNZ May 23, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately there's a margin being added to .cms .ss-gridfield > div that wins out on specificity. I could reduce the selector to something like .cms div.site-summary__clearfix or I could put an !important in. What do you think?

Copy link
Contributor

@NightJar NightJar May 23, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use an aside instead? :>

(I'm not sure if I'm being all that serious here, but would that be semantically correct, out of interest?)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok in that case keep it as it is. Can you maybe add a wee comment saying that?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done 👍 . @NightJar Asides should be "tangentially related" so I guess it could be appropriate...

@ScopeyNZ ScopeyNZ force-pushed the pulls/1.0/show-version-on-module-report branch 2 times, most recently from c14c5c2 to e1643e4 Compare May 23, 2018 02:18
@@ -67,21 +54,61 @@ public function columns()
public function getReportField()
{
Requirements::css('silverstripe-maintenance/css/sitesummary.css');

/** @var GridField $gridField */
$gridField = parent::getReportField();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please add this doc block back in?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Bad merge conflict resolution I guess :\ - Adding a docblock for the $config var right below it too.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is less necessary, but won't hurt

@ScopeyNZ ScopeyNZ force-pushed the pulls/1.0/show-version-on-module-report branch from e1643e4 to f886720 Compare May 23, 2018 02:54
->getComponentByType(GridFieldExportButton::class)
->setExportColumns(
Package::create()->summaryFields()
);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These two lines are merge conflict resolution errors - they're on 65/66 now

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep I'm blind. Thanks

@ScopeyNZ ScopeyNZ force-pushed the pulls/1.0/show-version-on-module-report branch from f886720 to f338089 Compare May 23, 2018 03:35
@robbieaverill robbieaverill merged commit 1ccf490 into bringyourownideas:master May 23, 2018
@robbieaverill robbieaverill deleted the pulls/1.0/show-version-on-module-report branch May 23, 2018 03:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants