Skip to content

Commit

Permalink
EZP-32097: Expose EzSystemInfo in Admin UI and SystemInfoDumpCommand (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
konradoboza authored and kacper-wieczorek-ibexa committed Sep 24, 2021
1 parent ecd8926 commit c3c50e2
Show file tree
Hide file tree
Showing 11 changed files with 197 additions and 55 deletions.
4 changes: 4 additions & 0 deletions src/bundle/Resources/config/default_settings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ parameters:
ezsettings.default.system_info_view: {}
ezsettings.global.system_info_view:
pjax_tab:
ibexa:
template: '@@ezdesign/system_info/my_ibexa.html.twig'
match:
SystemInfo\Identifier: 'ibexa'
composer:
template: '@@ezdesign/system_info/composer.html.twig'
match:
Expand Down
11 changes: 5 additions & 6 deletions src/bundle/Resources/config/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ parameters:
support_tools.system_info.ezc.wrapper.class: EzSystems\EzSupportToolsBundle\SystemInfo\EzcSystemInfoWrapper
support_tools.system_info.collector.composer.lock_file.class: EzSystems\EzSupportToolsBundle\SystemInfo\Collector\JsonComposerLockSystemInfoCollector
support_tools.system_info.collector.database.doctrine.class: EzSystems\EzSupportToolsBundle\SystemInfo\Collector\DoctrineDatabaseSystemInfoCollector
support_tools.system_info.collector.system.ez.class: EzSystems\EzSupportToolsBundle\SystemInfo\Collector\EzSystemInfoCollector
support_tools.system_info.collector.system.ibexa.class: EzSystems\EzSupportToolsBundle\SystemInfo\Collector\IbexaSystemInfoCollector
support_tools.system_info.collector.hardware.ezc.class: EzSystems\EzSupportToolsBundle\SystemInfo\Collector\EzcHardwareSystemInfoCollector
support_tools.system_info.collector.php.ezc.class: EzSystems\EzSupportToolsBundle\SystemInfo\Collector\EzcPhpSystemInfoCollector
support_tools.system_info.collector.symfony.kernel.config.class: EzSystems\EzSupportToolsBundle\SystemInfo\Collector\ConfigurationSymfonyKernelSystemInfoCollector
Expand Down Expand Up @@ -62,14 +62,13 @@ services:

# SystemInfoCollectors

support_tools.system_info.collector.system.ez:
class: "%support_tools.system_info.collector.system.ez.class%"
support_tools.system_info.collector.system.ibexa:
class: "%support_tools.system_info.collector.system.ibexa.class%"
arguments:
- "@support_tools.system_info.collector.composer.lock_file"
- "%kernel.debug%"
# Can't tag this before v0.3 (2.5?) as it will blow up in admin UI for missing templates there
# And it does not look like there is any way to add it from this package, so maybe it needs to be made extensible(?)
#tags: [{ name: "support_tools.system_info.collector", identifier: "ez" }]
tags:
- { name: "support_tools.system_info.collector", identifier: "ibexa" }

support_tools.system_info.collector.composer.lock_file:
class: "%support_tools.system_info.collector.composer.lock_file.class%"
Expand Down
2 changes: 1 addition & 1 deletion src/bundle/Resources/config/view.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ services:
autowire: true
arguments:
$template: '@@ezdesign/ui/dashboard/block/ez.html.twig'
$ezSystemInfo: "@=service('support_tools.system_info.collector.system.ez').collect()"
$ibexaSystemInfo: "@=service('support_tools.system_info.collector.system.ibexa').collect()"
$urlList: '%support_tools.ez_url_list%'
tags:
- { name: ezplatform.admin_ui.component, group: 'dashboard-blocks', priority: 200 }
45 changes: 45 additions & 0 deletions src/bundle/Resources/translations/systeminfo.en.xliff
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,46 @@
<target state="new">Disabled</target>
<note>key: disabled</note>
</trans-unit>
<trans-unit id="d87becd0d1497fe04536d2e9291290a8b07e9dfb" resname="ibexa.product">
<source>Product</source>
<target state="new">Product</target>
<note>key: ibexa.product</note>
</trans-unit>
<trans-unit id="b7ffaa791bbf39db2ea700efec5362a0bc4e2021" resname="ibexa.name">
<source>Name</source>
<target state="new">Name</target>
<note>key: ibexa.name</note>
</trans-unit>
<trans-unit id="d6025d67b03f12dac6c912f6224bb309347f6465" resname="ibexa.version">
<source>Version</source>
<target state="new">Version</target>
<note>key: ibexa.version</note>
</trans-unit>
<trans-unit id="4a9e6f9b28c3203784cb5f01ebe73e67661cc823" resname="ibexa.eom">
<source>End of Maintenance</source>
<target state="new">End of Maintenance</target>
<note>key: ibexa.eom</note>
</trans-unit>
<trans-unit id="ed1f723e05fbc74c1c90cfc6f64c2bcda6f4bb9d" resname="ibexa.eol">
<source>End of Life</source>
<target state="new">End of Life</target>
<note>key: ibexa.eol</note>
</trans-unit>
<trans-unit id="804e14084add4426182add3b4a0a710506ef742b" resname="ibexa.is_trial">
<source>Is Trial</source>
<target state="new">Is Trial</target>
<note>key: ibexa.is_trial</note>
</trans-unit>
<trans-unit id="341340ab8c700ad6fe83322ec29cb3977262f5df" resname="ibexa.stability">
<source>Stability</source>
<target state="new">Stability</target>
<note>key: ibexa.stability</note>
</trans-unit>
<trans-unit id="972bcf808b8ce2b0a08a21db7f0f15f520f4b87b" resname="ibexa.read_more">
<source>You can read more about Service Life for Ibexa DXP with a business license at</source>
<target state="new">You can read more about Service Life for Ibexa DXP with a business license at</target>
<note>key: ibexa.read_more</note>
</trans-unit>
<trans-unit id="608cb271bb7fb52c99a1a8e003e0f80f57fb41e1" resname="hardware">
<source>Hardware</source>
<target state="new">Hardware</target>
Expand Down Expand Up @@ -176,6 +216,11 @@
<target state="new">System Information</target>
<note>key: systeminfo</note>
</trans-unit>
<trans-unit id="7dd1b2ca71037e00112dfe0297383f47c6904c77" resname="tab.name.ibexa">
<source>My Ibexa</source>
<target state="new">My Ibexa</target>
<note>key: tab.name.ibexa</note>
</trans-unit>
<trans-unit id="a2a92e9d0e41ea4a14c99ab0f702d5df3ea017c3" resname="tab.name.composer">
<source>Composer</source>
<target state="new">Composer</target>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{% trans_default_domain "systeminfo" %}

<!-- Tab name: {{ 'tab.name.ibexa'|trans|desc('My Ibexa') }} -->

<section class="ez-fieldgroup">
<h2 class="ez-fieldgroup__name">{{ 'ibexa.product'|trans|desc('Product') }}</h2>
<div class="ez-fieldgroup__content">
<table class="table ez-table ez-table--list ez-table--to-left">
<tbody>
<tr class="ez-table__row">
<td class="ez-table__cell">{{ 'ibexa.name'|trans|desc('Name') }}</td>
<td class="ez-table__cell">{{ info.name }}</td>
</tr>
<tr class="ez-table__row">
<td class="ez-table__cell">{{ 'ibexa.version'|trans|desc('Version') }}</td>
<td class="ez-table__cell">{{ info.release }}</td>
</tr>
<tr class="ez-table__row">
<td class="ez-table__cell">{{ 'ibexa.is_trial'|trans|desc('Is Trial') }}</td>
<td class="ez-table__cell">
<svg class="ez-icon ez-icon--small">
<use xlink:href="{{ ez_icon_path(info.isTrial ? 'checkmark' : 'discard') }}"></use>
</svg>
</td>
</tr>
<tr class="ez-table__row">
<td class="ez-table__cell">{{ 'ibexa.stability'|trans|desc('Stability') }}</td>
<td class="ez-table__cell">{{ info.stability }}</td>
</tr>
{% if info.isEnterprise %}
<tr class="ez-table__row">
<td class="ez-table__cell">{{ 'ibexa.eom'|trans|desc('End of Maintenance') }}*</td>
<td class="ez-table__cell">
{{ info.endOfMaintenanceDate is empty ? '' : info.endOfMaintenanceDate|date('F Y') }}
</td>
</tr>
<tr class="ez-table__row">
<td class="ez-table__cell">{{ 'ibexa.eol'|trans|desc('End of Life') }}*</td>
<td class="ez-table__cell">
{{ info.endOfLifeDate is empty ? '' : info.endOfLifeDate|date('F Y') }}
</td>
</tr>
<tr class="ez-table__row">
<td colspan="2">
<hr/>
* {{ 'ibexa.read_more'|trans|desc('You can read more about Service Life for Ibexa DXP with a business license at') }}
<a target="_blank" href="https://support.ibexa.co/Public/Service-Life">
https://support.ibexa.co/Public/Service-Life
</a>
</td>
</tr>
{% endif %}
</tbody>
</table>
</div>
</section>
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
{% else %}
{{ 'dashboard.ez_version.non_stable_packages'|trans({'%stability%': ez.stability})|desc("Your setup is running with @%stability% composer packages. This is not recommended except when testing updates or during development.") }}
{% endif %}
{% if ez.isEnterpise %}
{% if ez.isEnterprise %}
{{ 'dashboard.ez_version.non_stable_ee'|trans({'%support_url%': urls['support']})|desc("If you need assistance, don't hesitate to <a target=\"_blank\" href=\"%support_url%\">get in touch with Ibexa support</a>.")|raw }}
{% endif %}
</div>
Expand Down Expand Up @@ -79,7 +79,7 @@
|raw }}
</div>
</div>
{% elseif not ez.isEnterpise %}
{% elseif not ez.isEnterprise %}
{% set badge = 'GPL' %}
{% if ez.isEndOfMaintenance %}
{# In the future with retrival of info from updates.ez.no we can detect missing (public) security fixes and then let this become an error #}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,27 @@

use EzSystems\EzSupportToolsBundle\SystemInfo\Exception\ComposerFileValidationException;
use EzSystems\EzSupportToolsBundle\SystemInfo\Exception\ComposerLockFileNotFoundException;
use EzSystems\EzSupportToolsBundle\SystemInfo\Value\EzSystemInfo;
use EzSystems\EzSupportToolsBundle\SystemInfo\Value\ComposerPackage;
use EzSystems\EzSupportToolsBundle\SystemInfo\Value\IbexaSystemInfo;
use DateTime;

/**
* Collects information about the eZ installation.
* Collects information about the Ibexa installation.
*
* @internal This class will greatly change in the future and should not be used as a api, planned:
* @internal This class will greatly change in the future and should not be used as an API, planned:
* - Get most of this information off updates.ez.no
* - Probably run this as a nightly cronjob to gather summary info
* - Be able to provide warnings to admins when something (config/system setup) is not optimal
* - Be able to give information if important updates are avaiable to install
* - Or be able to tell if install is greatly outdated
* - Be able to give heads up when install is approaching end of life.
* - Be able to give information if important updates are available to the installation
* - Or be able to tell if installation is greatly outdated
* - Be able to give heads up when installation is approaching its End of Life.
*/
class EzSystemInfoCollector implements SystemInfoCollector
class IbexaSystemInfoCollector implements SystemInfoCollector
{
/**
* Estimated release dates for given releases.
*
* Mainly for usage for trail to calculate TTL expiry.
* Mainly for usage for trial to calculate TTL expiry.
*/
const RELEASES = [
'2.5' => '2019-03-29T16:59:59+00:00',
Expand All @@ -36,17 +37,17 @@ class EzSystemInfoCollector implements SystemInfoCollector
];

/**
* Dates for when releases are considered end of maintenance.
* Dates for when releases are considered End of Maintenance.
*
* Open source releases are considered end of life when this date ias reached.
* Open source releases are considered End of Life when this date is reached.
*
* @Note: Only enterprise/commerce installs recives fixes for security
* issues before the issues are disclosed. Also be aware the link
* below is covering Enterprise/Commerce releases, lenght of
* @Note: Only Enterprise/Commerce installations receive fixes for security
* issues before the issues are disclosed. Also, be aware the link
* below is covering Enterprise/Commerce releases, length of
* maintenance for LTS releases may not be as long for open source
* releases as it depends on community maintenance efforts.
*
* @see: https://support.ez.no/Public/Service-Life
* @see: https://support.ibexa.co/Public/Service-Life
*/
const EOM = [
'2.5' => '2022-03-29T23:59:59+00:00',
Expand All @@ -55,11 +56,11 @@ class EzSystemInfoCollector implements SystemInfoCollector
];

/**
* Dates for when Enterprise/Commerce installs are considered end of life.
* Dates for when Enterprise/Commerce installations are considered End of Life.
*
* Meaning when they stop reciving security fixes and support.
* Meaning, when they stop receiving security fixes and support.
*
* @see: https://support.ez.no/Public/Service-Life
* @see: https://support.ibexa.co/Public/Service-Life
*/
const EOL = [
'2.5' => '2024-03-29T23:59:59+00:00',
Expand All @@ -73,16 +74,16 @@ class EzSystemInfoCollector implements SystemInfoCollector
const PACKAGE_WATCH_REGEX = '/^(doctrine|ezsystems|silversolutions|symfony)\//';

/**
* Packages that identifies install as Enterpirse install.
* Packages that identify installation as "Enterprise".
*/
const ENTERPISE_PACKAGES = [
const ENTERPRISE_PACKAGES = [
'ezsystems/ezplatform-page-builder',
'ezsystems/flex-workflow',
'ezsystems/landing-page-fieldtype-bundle',
];

/**
* Packages that identifies install as Commerce install.
* Packages that identify installation as "Commerce".
*/
const COMMERCE_PACKAGES = [
'ezsystems/ezcommerce-shop',
Expand Down Expand Up @@ -114,20 +115,22 @@ public function __construct(SystemInfoCollector $composerCollector, $debug = fal
}

/**
* Collects information about the eZ distrobution and version.
* Collects information about the Ibexa distribution and version.
*
* @return \EzSystems\EzSupportToolsBundle\SystemInfo\Value\EzSystemInfo
* @throws \Exception
*
* @return \EzSystems\EzSupportToolsBundle\SystemInfo\Value\IbexaSystemInfo
*/
public function collect()
public function collect(): IbexaSystemInfo
{
$ez = new EzSystemInfo(['debug' => $this->debug, 'composerInfo' => $this->composerInfo]);
$ibexa = new IbexaSystemInfo(['debug' => $this->debug, 'composerInfo' => $this->composerInfo]);
if ($this->composerInfo === null) {
return $ez;
return $ibexa;
}

$ez->release = EzPlatformCoreBundle::VERSION;

// In case someone switches from TTL to BUL, make sure we only identify install as Trial if this is present,
// In case someone switches from TTL to BUL, make sure we only identify installation as Trial if this is present,
// as well as TTL packages
$hasTTLComposerRepo = \in_array('https://updates.ez.no/ttl', $this->composerInfo->repositoryUrls);

Expand Down Expand Up @@ -163,12 +166,34 @@ public function collect()
}
}

$ez->stability = $this->getStability();
$ibexa->endOfMaintenanceDate = $this->getEOMDate($ibexaRelease);
$ibexa->endOfLifeDate = $this->getEOLDate($ibexaRelease);
$ibexa->stability = $this->getStability();

return $ibexa;
}

/**
* @throws \Exception
*/
private function getEOMDate(string $ibexaRelease): ?\DateTime
{
return isset(self::EOM[$ibexaRelease]) ?
new DateTime(self::EOM[$ibexaRelease]) :
null;
}

return $ez;
/**
* @throws \Exception
*/
private function getEOLDate(string $ibexaRelease): ?\DateTime
{
return isset(self::EOL[$ibexaRelease]) ?
new DateTime(self::EOL[$ibexaRelease]) :
null;
}

private function getStability()
private function getStability(): string
{
$stabilityFlags = array_flip(JsonComposerLockSystemInfoCollector::STABILITIES);

Expand All @@ -177,7 +202,7 @@ private function getStability()
$stabilityFlags[$this->composerInfo->minimumStability] :
$stabilityFlags['stable'];

// Check if any of the watche packages has lower stability then root
// Check if any of the watched packages has lower stability than root
foreach ($this->composerInfo->packages as $name => $package) {
if (!preg_match(self::PACKAGE_WATCH_REGEX, $name)) {
continue;
Expand All @@ -195,12 +220,14 @@ private function getStability()
return JsonComposerLockSystemInfoCollector::STABILITIES[$stabilityFlag];
}

private function getFirstPackage($packageNames)
private function getFirstPackage($packageNames): ?ComposerPackage
{
foreach ($packageNames as $packageName) {
if (isset($this->composerInfo->packages[$packageName])) {
return $this->composerInfo->packages[$packageName];
}
}

return null;
}
}
Loading

0 comments on commit c3c50e2

Please sign in to comment.