Commit a7a0d04a authored by Thomas Löffler's avatar Thomas Löffler

Show all supported versions in list and only from latest extension version in detail view

parent 2b577ccd
Pipeline #7537 failed with stages
in 24 seconds
......@@ -615,4 +615,15 @@ class Extension extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
{
$this->notifications = $notifications;
}
public function getMatrixOfSupportedTypo3Versions(): array
{
$supportedTypo3Versions = [];
foreach ($this->versions as $version) {
$version->getMatrixOfSupportedTypo3Versions($supportedTypo3Versions);
}
return $supportedTypo3Versions;
}
}
......@@ -22,6 +22,9 @@ use TYPO3\CMS\Extbase\Persistence\ObjectStorage;
class Version extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
{
const VERSION_IS_INSECURE = -1;
const VERSION_IS_OUTDATED = -2;
/**
* Title of the extension
*
......@@ -1151,18 +1154,18 @@ class Version extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
}
/**
* @param array $supportedTypo3Versions
* @return array
*/
public function getMatrixOfSupportedTypo3Versions(): array
public function getMatrixOfSupportedTypo3Versions(array $supportedTypo3Versions = []): array
{
$ltsVersionService = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\T3o\TerFe2\Service\LTSVersionService::class);
$supportedTypo3Versions = [];
$oldLTSVersions = $ltsVersionService->getOldLTSVersions();
foreach ($oldLTSVersions as $versionNumber) {
$mainVersion = floor($versionNumber / $ltsVersionService::FACTOR_MINOR_VERSION * $ltsVersionService::FACTOR_MINOR_VERSION);
$label = 'v' . $ltsVersionService->getVersionLabelOfRelease($versionNumber) . ' LTS';
if (\T3o\TerFe2\Utility\VersionUtility::doesExtensionSupportTypo3Version($this->getExtension(), $mainVersion)) {
$supportedTypo3Versions[] = [
$label = $ltsVersionService->getVersionLabelOfRelease($versionNumber) . ' LTS';
if ($this->doesSupportTypo3Version($mainVersion)) {
$supportedTypo3Versions[$ltsVersionService->getVersionLabelOfRelease($versionNumber)] = [
'label' => $label,
'badgeClass' => 'warning'
];
......@@ -1172,18 +1175,18 @@ class Version extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
$oldLTSVersions = $ltsVersionService->getCurrentStableVersions(true);
foreach ($oldLTSVersions as $versionNumber) {
$mainVersion = floor($versionNumber / $ltsVersionService::FACTOR_MINOR_VERSION * $ltsVersionService::FACTOR_MINOR_VERSION);
$label = 'v' . $ltsVersionService->getVersionLabelOfRelease($versionNumber) . ' LTS';
if (\T3o\TerFe2\Utility\VersionUtility::doesExtensionSupportTypo3Version($this->getExtension(), $mainVersion)) {
$supportedTypo3Versions[] = [
$label = $ltsVersionService->getVersionLabelOfRelease($versionNumber) . ' LTS';
if ($this->doesSupportTypo3Version($mainVersion)) {
$supportedTypo3Versions[$ltsVersionService->getVersionLabelOfRelease($versionNumber)] = [
'label' => $label,
'badgeClass' => 'success'
];
}
}
if (\T3o\TerFe2\Utility\VersionUtility::doesExtensionSupportTypo3Version($this->getExtension(), $ltsVersionService->getLatestDevelopmentVersion(true))) {
$supportedTypo3Versions[] = [
'label' => 'v' . $ltsVersionService->getVersionLabelOfRelease($ltsVersionService->getLatestDevelopmentVersion(true)) . ' dev',
if ($this->doesSupportTypo3Version($ltsVersionService->getLatestDevelopmentVersion(true))) {
$supportedTypo3Versions[$ltsVersionService->getVersionLabelOfRelease($ltsVersionService->getLatestDevelopmentVersion(true))] = [
'label' => $ltsVersionService->getVersionLabelOfRelease($ltsVersionService->getLatestDevelopmentVersion(true)) . '-dev',
'badgeClass' => 'info'
];
}
......@@ -1191,12 +1194,22 @@ class Version extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
return $supportedTypo3Versions;
}
/**
* @return bool
*/
public function hasTypo3Dependency()
public function doesSupportTypo3Version(int $versionNumber): bool
{
return $this->getTypo3Dependency() !== null;
if ($this->getTypo3Dependency() === null || $this->getReviewState() === \T3o\TerFe2\Domain\Model\Version::VERSION_IS_INSECURE) {
return false;
}
// reset from e.g. 7.6.21 to 7.6.0 for valid check
$resetMinimumVersion = (int)($this->getTypo3Dependency()->getMinimumVersion() / \T3o\TerFe2\Service\LTSVersionService::FACTOR_MINOR_VERSION) * \T3o\TerFe2\Service\LTSVersionService::FACTOR_MINOR_VERSION;
$supportsTypo3Version = $resetMinimumVersion <= $versionNumber && $this->getTypo3Dependency()->getMaximumVersion() >= $versionNumber;
if ($supportsTypo3Version) {
return true;
}
return false;
}
/**
......
......@@ -145,8 +145,7 @@ class LTSVersionService
public function getVersionLabelOfRelease(int $release): string
{
$versionLabel = '';
if ($release >= 7000000) {
if ($release >= (self::FIRST_LTS_VERSION_WITH_MAIN_VERSION_NUMBER * self::FACTOR_MAIN_VERSION)) {
$versionLabel = (string)floor($release / self::FACTOR_MAIN_VERSION);
} else {
$fullVersionLabelParts = explode('.', VersionNumberUtility::convertIntegerToVersionNumber($release));
......
......@@ -116,16 +116,16 @@ class TerIndexer extends \ApacheSolrForTypo3\Solr\IndexQueue\Indexer
$ltsVersionService = GeneralUtility::makeInstance(\T3o\TerFe2\Service\LTSVersionService::class);
foreach ($ltsVersionService->getCurrentStableVersions(true) as $versionNumber) {
if (VersionUtility::doesExtensionSupportTypo3Version($extension, $versionNumber)) {
$supportMaintainedVersions[] = 'v' . $ltsVersionService->getVersionLabelOfRelease($versionNumber) . ' LTS';
$supportMaintainedVersions[] = $ltsVersionService->getVersionLabelOfRelease($versionNumber) . ' LTS';
}
}
if ($ltsVersionService->getLatestDevelopmentVersion() !== $ltsVersionService->getLatestLTS() && VersionUtility::doesExtensionSupportTypo3Version($extension, $ltsVersionService->getLatestDevelopmentVersion(true))) {
$supportDevVersion = 'v' . $ltsVersionService->getLatestDevelopmentVersion() . ' dev';
$supportDevVersion = $ltsVersionService->getLatestDevelopmentVersion() . '-dev';
}
foreach ($ltsVersionService->getOldLTSVersions() as $versionNumber) {
if (VersionUtility::doesExtensionSupportTypo3Version($extension, $versionNumber)) {
$supportOlderVersions[] = 'v' . $ltsVersionService->getVersionLabelOfRelease($versionNumber) . ' LTS';
$supportOlderVersions[] = $ltsVersionService->getVersionLabelOfRelease($versionNumber) . ' LTS';
}
}
......
......@@ -49,7 +49,7 @@ class VersionUtility
public static function doesExtensionSupportTypo3Version(\T3o\TerFe2\Domain\Model\Extension $extension, int $mainVersion): bool
{
foreach ($extension->getVersions() as $version) {
if ($version->hasTypo3Dependency() === false || $version->isLive() === false) {
if ($version->hasTypo3Dependency() === false || $version->getReviewState() === \T3o\TerFe2\Domain\Model\Version::VERSION_IS_INSECURE) {
continue;
}
......
<html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers" data-namespace-typo3-fluid="true">
<f:if condition="{version.matrixOfSupportedTypo3Versions}">
<div class="btn-group btn-group-sm d-flex" role="group">
<f:if condition="{version.typo3Dependency}">
<h4>This version supports TYPO3</h4>
<p>
<f:for each="{version.matrixOfSupportedTypo3Versions}" as="version">
<button class="btn btn-{version.badgeClass} w-100" disabled>{version.label}</button>
<button class="btn btn-{version.badgeClass} btn-sm" disabled>{version.label}</button>
</f:for>
</div>
</p>
</f:if>
</html>
......@@ -90,7 +90,6 @@
<div class="row mb-3">
<div class="col-md-8">
<p itemprop="description">{extension.lastVersion.description}</p>
<h4>This version supports TYPO3</h4>
<f:render partial="VersionSupportForTypo3" arguments="{version: extension.lastVersion}" />
<f:if condition="{extension.composerName}">
<p class="mb-3">
......
......@@ -40,7 +40,7 @@ class LTSVersionServiceTest extends UnitTestCase
*/
public function getCurrentStableVersions()
{
$this->assertSame([8, 9], $this->subject->getCurrentStableVersions());
self::assertSame([8, 9], $this->subject->getCurrentStableVersions());
}
/**
......@@ -48,7 +48,7 @@ class LTSVersionServiceTest extends UnitTestCase
*/
public function getCurrentStableVersionsAsFullVersionNumber()
{
$this->assertSame([8007009, 9005005], $this->subject->getCurrentStableVersions(true));
self::assertSame([8007009, 9005005], $this->subject->getCurrentStableVersions(true));
}
/**
......@@ -56,7 +56,7 @@ class LTSVersionServiceTest extends UnitTestCase
*/
public function getAllMaintainedVersions()
{
$this->assertSame([8, 9, 10], $this->subject->getAllMaintainedVersions());
self::assertSame([8, 9, 10], $this->subject->getAllMaintainedVersions());
}
/**
......@@ -64,7 +64,7 @@ class LTSVersionServiceTest extends UnitTestCase
*/
public function getAllMaintainedVersionsAsFullVersionNumber()
{
$this->assertSame([8007009, 9005005, 10000000], $this->subject->getAllMaintainedVersions(true));
self::assertSame([8007009, 9005005, 10000000], $this->subject->getAllMaintainedVersions(true));
}
/**
......@@ -72,7 +72,7 @@ class LTSVersionServiceTest extends UnitTestCase
*/
public function getLatestVersionOfRelease()
{
$this->assertSame('7.6.21', $this->subject->getLatestVersionOfRelease(7));
self::assertSame('7.6.21', $this->subject->getLatestVersionOfRelease(7));
}
/**
......@@ -80,7 +80,7 @@ class LTSVersionServiceTest extends UnitTestCase
*/
public function getLatestDevelopmentVersion()
{
$this->assertSame(10, $this->subject->getLatestDevelopmentVersion());
self::assertSame(10, $this->subject->getLatestDevelopmentVersion());
}
/**
......@@ -88,7 +88,7 @@ class LTSVersionServiceTest extends UnitTestCase
*/
public function getLatestDevelopmentVersionAsFullVersionNumber()
{
$this->assertSame(10000000, $this->subject->getLatestDevelopmentVersion(true));
self::assertSame(10000000, $this->subject->getLatestDevelopmentVersion(true));
}
/**
......@@ -96,7 +96,7 @@ class LTSVersionServiceTest extends UnitTestCase
*/
public function getAllLTSVersionsAsFullVersionNumber()
{
$this->assertSame(
self::assertSame(
[
4005000,
6002000,
......@@ -113,7 +113,7 @@ class LTSVersionServiceTest extends UnitTestCase
*/
public function getOldLTSVersionsAsFullVersionNumber()
{
$this->assertSame(
self::assertSame(
[
4005000,
6002000,
......@@ -128,7 +128,7 @@ class LTSVersionServiceTest extends UnitTestCase
*/
public function getVersionLabelOfNewVersion()
{
$this->assertSame(
self::assertSame(
'8',
$this->subject->getVersionLabelOfRelease(8007004)
);
......@@ -139,7 +139,7 @@ class LTSVersionServiceTest extends UnitTestCase
*/
public function getVersionLabelOfLegacyVersion()
{
$this->assertSame(
self::assertSame(
'4.5',
$this->subject->getVersionLabelOfRelease(4005031)
);
......
......@@ -60,13 +60,18 @@
</p>
</div>
</div>
<div class="btn-group btn-group-sm d-flex" role="group">
<f:for each="{document.typo3support_stringM}" as="maintainedVersion">
<button class="btn btn-success w-100" disabled>{maintainedVersion}</button>
</f:for>
<f:if condition="{document.typo3supportdev_stringS}">
<button class="btn btn-info w-100" disabled>{document.typo3supportdev_stringS}</button>
</f:if>
<div >
<p class="col-sm-12">
<f:for each="{document.typo3supportold_stringM}" as="oldVersion">
<button class="btn btn-warning btn-sm mr-2" disabled>{oldVersion}</button>
</f:for>
<f:for each="{document.typo3support_stringM}" as="maintainedVersion">
<button class="btn btn-success btn-sm mr-2" disabled>{maintainedVersion}</button>
</f:for>
<f:if condition="{document.typo3supportdev_stringS}">
<button class="btn btn-info btn-sm" disabled>{document.typo3supportdev_stringS}</button>
</f:if>
</p>
</div>
<div class="btn-group d-flex" role="group">
<f:if condition="{document.insecure_boolS}">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment