Skip to content

Commit

Permalink
Merge branch 'release/2.2.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
garbast committed Dec 4, 2024
2 parents 65d41f3 + ffbd04d commit 37c5290
Show file tree
Hide file tree
Showing 19 changed files with 530 additions and 79 deletions.
3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
/.github/ export-ignore
/Build/ export-ignore
/Tests/ export-ignore
/.gitattributes export-ignore
/.gitignore export-ignore
14 changes: 7 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,13 @@ jobs:
-p ${{ matrix.packages.php }} \
-s composerValidate
# - name: Functional tests with sqlite
# run: |
# Build/Scripts/runTests.sh \
# -p ${{ matrix.packages.php }} \
# -d sqlite \
# -s functional ${{ matrix.packages.testpath }}
#
- name: Functional tests with sqlite
run: |
Build/Scripts/runTests.sh \
-p ${{ matrix.packages.php }} \
-d sqlite \
-s functional ${{ matrix.packages.testpath }}
# - name: Unit tests with sqlite
# run: |
# Build/Scripts/runTests.sh \
Expand Down
1 change: 0 additions & 1 deletion Build/Scripts/additionalTests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,6 @@ additionalCleanTestFiles() {
rm -rf \
.cache \
bin/ \
Build/phpunit \
Build/vendor/ \
Build/Web/ \
Documentation-GENERATED-temp/ \
Expand Down
10 changes: 5 additions & 5 deletions Build/Scripts/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,11 @@ runFunctionalTests () {
-s composerValidate || exit 1 ; \
EXIT_CODE_VALIDATE=$?

# ./runTests.sh \
# -p ${PHP_VERSION} \
# -d sqlite \
# -s functional ${TEST_PATH} || exit 1 ; \
# EXIT_CODE_FUNCTIONAL=$?
./runTests.sh \
-p ${PHP_VERSION} \
-d sqlite \
-s functional ${TEST_PATH} || exit 1 ; \
EXIT_CODE_FUNCTIONAL=$?

echo "###########################################################################" >&2
echo " Finished unit and/or functional tests with" >&2
Expand Down
46 changes: 46 additions & 0 deletions Build/phpunit/FunctionalTests.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?xml version="1.0"?>
<!--
Boilerplate for a functional test suite setup.
This file is loosely maintained within TYPO3 testing-framework, extensions
are encouraged to not use it directly, but to copy it to an own place,
for instance Build/FunctionalTests.xml.
Note FunctionalTestsBootstrap.php should be copied along the way.
Functional tests should extend \TYPO3\TestingFramework\Core\Tests\FunctionalTestCase,
take a look at this class for further documentation on how to run the suite.
TYPO3 CMS functional test suite also needs phpunit bootstrap code, the
file is located next to this .xml as FunctionalTestsBootstrap.php
-->
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/11.2/phpunit.xsd"
backupGlobals="true"
bootstrap="FunctionalTestsBootstrap.php"
cacheDirectory=".phpunit.cache"
cacheResult="false"
colors="true"
displayDetailsOnTestsThatTriggerDeprecations="false"
displayDetailsOnTestsThatTriggerErrors="true"
displayDetailsOnTestsThatTriggerNotices="true"
displayDetailsOnTestsThatTriggerWarnings="true"
failOnDeprecation="false"
failOnNotice="true"
failOnRisky="true"
failOnWarning="true"
requireCoverageMetadata="false"
>
<testsuites>
<testsuite name="Functional tests">
<!--
This path either needs an adaption in extensions, or an extension's
test location path needs to be given to phpunit.
-->
<directory>../../../../../../typo3/sysext/*/Tests/Functional/</directory>
</testsuite>
</testsuites>
<php>
<ini name="display_errors" value="1"/>
<env name="TYPO3_CONTEXT" value="Testing"/>
</php>
</phpunit>
31 changes: 31 additions & 0 deletions Build/phpunit/FunctionalTestsBootstrap.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/

/**
* Boilerplate for a functional test phpunit boostrap file.
*
* This file is loosely maintained within TYPO3 testing-framework, extensions
* are encouraged to not use it directly, but to copy it to an own place,
* usually in parallel to a FunctionalTests.xml file.
*
* This file is defined in FunctionalTests.xml and called by phpunit
* before instantiating the test suites.
*/
(static function () {
$testbase = new \TYPO3\TestingFramework\Core\Testbase();
$testbase->defineOriginalRootPath();
$testbase->createDirectory(ORIGINAL_ROOT . 'typo3temp/var/tests');
$testbase->createDirectory(ORIGINAL_ROOT . 'typo3temp/var/transient');
})();
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,8 @@ class BeforeContainerConfigurationIsAppliedListener
#[AsEventListener('collapsible-container-beforecontainer', BeforeContainerConfigurationIsAppliedEvent::class)]
public function __invoke(BeforeContainerConfigurationIsAppliedEvent $event): void
{
$containerConfiguration = $event->getContainerConfiguration();

$containerConfiguration->setGridTemplate(
'EXT:ew_collapsible_container/Resources/Private/Templates/Grid.html'
$event->getContainerConfiguration()->addGridPartialPath(
'EXT:ew_collapsible_container/Resources/Private/Partials/'
);

$containerConfiguration->setGridPartialPaths([
'EXT:backend/Resources/Private/Partials/',
'EXT:container/Resources/Private/Partials/',
'EXT:ew_collapsible_container/Resources/Private/Partials/',
]);
}
}
16 changes: 16 additions & 0 deletions Classes/EventListener/BeforeContainerPreviewIsRenderedListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,15 @@
use Evoweb\EwCollapsibleContainer\Xclass\ContainerGridColumn;
use TYPO3\CMS\Core\Attribute\AsEventListener;
use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
use TYPO3\CMS\Core\Page\JavaScriptModuleInstruction;
use TYPO3\CMS\Core\Page\PageRenderer;

class BeforeContainerPreviewIsRenderedListener
{
public function __construct(protected PageRenderer $pageRenderer)
{
}

#[AsEventListener('collapsible-container-beforepreview', BeforeContainerPreviewIsRenderedEvent::class)]
public function __invoke(BeforeContainerPreviewIsRenderedEvent $event): void
{
Expand All @@ -38,6 +44,8 @@ public function __invoke(BeforeContainerPreviewIsRenderedEvent $event): void
'showMinItemsWarning' => $this->getShowMinItemsWarning($column, $countOfHiddenItems)
]);
}

$this->addFrontendResources();
}

protected function getCountOfHiddenItems(ContainerGridColumn $columnObject): int
Expand Down Expand Up @@ -71,6 +79,14 @@ protected function getShowMinItemsWarning(ContainerGridColumn $columnObject, int
return $itemCount > 0 && ($itemCount - $hiddenItemCount) < $minItems;
}

protected function addFrontendResources(): void
{
$this->pageRenderer->addCssFile('EXT:ew_collapsible_container/Resources/Public/Css/container.css');
$this->pageRenderer->getJavaScriptRenderer()->addJavaScriptModuleInstruction(
JavaScriptModuleInstruction::create('@evoweb/ew-collapsible-container/container.js')
);
}

protected function getBackendUser(): BackendUserAuthentication
{
return $GLOBALS['BE_USER'];
Expand Down
4 changes: 2 additions & 2 deletions Documentation/guides.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
interlink-shortcode="evoweb/sf-books"
/>
<project title="Collapsible container"
release="2.1.0"
version="2.1.0"
release="2.2.0"
version="2.2.0"
copyright="since 2024 by evoWeb"
/>
<inventory id="t3tsref" url="https://docs.typo3.org/m/typo3/reference-typoscript/main/en-us/"/>
Expand Down
44 changes: 20 additions & 24 deletions Resources/Private/Partials/PageLayout/Grid/ColumnHeader.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,22 +39,20 @@
<f:render section="collapsibleExpandIcon" arguments="{_all}"/>

<f:section name="collapsibleToggleIcon">
<f:if condition="{collapsable}">
<a href="#"
class="btn btn-sm btn-default btn-borderless t3js-toggle-container-column"
title="{f:translate(key: 'LLL:EXT:ew_collapsible_container/Resources/Private/Language/locallang.xlf:expandcontent')}"
data-toggle-title="{f:translate(key: 'LLL:EXT:ew_collapsible_container/Resources/Private/Language/locallang.xlf:collapsecontent')}"
data-collapse-state="collapsed">
<core:icon identifier="actions-view-list-expand" />
</a>
<a href="#"
class="btn btn-sm btn-default btn-borderless t3js-toggle-container-column"
title="{f:translate(key: 'LLL:EXT:ew_collapsible_container/Resources/Private/Language/locallang.xlf:collapsecontent')}"
data-toggle-title="{f:translate(key: 'LLL:EXT:ew_collapsible_container/Resources/Private/Language/locallang.xlf:expandcontent')}"
data-collapse-state="expanded">
<core:icon identifier="actions-view-list-collapse" />
</a>
</f:if>
<a href="#"
class="btn btn-sm btn-default btn-borderless t3js-toggle-container-column"
title="{f:translate(key: 'LLL:EXT:ew_collapsible_container/Resources/Private/Language/locallang.xlf:expandcontent')}"
data-toggle-title="{f:translate(key: 'LLL:EXT:ew_collapsible_container/Resources/Private/Language/locallang.xlf:collapsecontent')}"
data-collapse-state="collapsed">
<core:icon identifier="actions-view-list-expand" />
</a>
<a href="#"
class="btn btn-sm btn-default btn-borderless t3js-toggle-container-column"
title="{f:translate(key: 'LLL:EXT:ew_collapsible_container/Resources/Private/Language/locallang.xlf:collapsecontent')}"
data-toggle-title="{f:translate(key: 'LLL:EXT:ew_collapsible_container/Resources/Private/Language/locallang.xlf:expandcontent')}"
data-collapse-state="expanded">
<core:icon identifier="actions-view-list-collapse" />
</a>
</f:section>

<f:section name="collapsibleMinitemWarning">
Expand All @@ -73,14 +71,12 @@
</f:section>

<f:section name="collapsibleExpandIcon">
<f:if condition="{collapsable}">
<div class="m-3 container-collapsed-column-marker t3js-expand-column">
<button type="button" class="btn btn-default btn-sm me-2">
<core:icon identifier="actions-view-list-expand"/>
</button>
{f:translate(key: 'LLL:EXT:ew_collapsible_container/Resources/Private/Language/locallang.xlf:contentcollapsed')}
</div>
</f:if>
<div class="m-3 container-collapsed-column-marker t3js-expand-column">
<button type="button" class="btn btn-default btn-sm me-2">
<core:icon identifier="actions-view-list-expand"/>
</button>
{f:translate(key: 'LLL:EXT:ew_collapsible_container/Resources/Private/Language/locallang.xlf:contentcollapsed')}
</div>
</f:section>

</html>
15 changes: 0 additions & 15 deletions Resources/Private/Templates/Grid.html

This file was deleted.

16 changes: 8 additions & 8 deletions Resources/Public/JavaScript/container.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,29 @@
* LICENSE.txt file that was distributed with this source code.
*/

import DocumentService from '@typo3/core/document-service.js';
import PersistentStorage from '@typo3/backend/storage/persistent.js';

class ContainerToggle {
containerColumnToggle = '.t3js-toggle-container-column';

columnExpand = '.t3js-expand-column';

/**
* @type {PersistentStorage}
*/
persistentStorage = null;

storageKey = 'moduleData.list.containerExpanded';

constructor() {
this.persistentStorage = PersistentStorage;
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', () => {
this.initialized();
});
} else {
this.initialized();
}
DocumentService.ready().then(() => {
this.initialize();
});
}

initialized() {
initialize() {
this.initializeContainerToggle();
this.initializeExpandColumn();
}
Expand Down
6 changes: 6 additions & 0 deletions Tests/Fixtures/be_users.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
be_users,,,,,,,,,,,,,,,,,
,uid,pid,tstamp,username,password,admin,disable,starttime,endtime,options,crdate,workspace_perms,deleted,TSconfig,lastlogin,workspace_id,usergroup,
,1,0,1366642540,admin,$1$tCrlLajZ$C0sikFQQ3SWaFAZ1Me0Z/1,1,0,0,0,0,1366642540,1,0,,1371033743,0,,
,2,0,1366642540,editor_no_group,$1$tCrlLajZ$C0sikFQQ3SWaFAZ1Me0Z/1,0,0,0,0,3,1366642540,1,0,,1371033743,0,,
,3,0,1366642540,editor_with_both_groups,$1$tCrlLajZ$C0sikFQQ3SWaFAZ1Me0Z/1,0,0,0,0,3,1366642540,1,0,,1371033743,0,"1,2",
,4,0,1366642540,editor_with_one_group,$1$tCrlLajZ$C0sikFQQ3SWaFAZ1Me0Z/1,0,0,0,0,3,1366642540,1,0,,1371033743,0,"2",
9 changes: 9 additions & 0 deletions Tests/Fixtures/tt_content.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
pages,,,,
,uid,pid,title,slug,
,1,0,Startpage,/startpage,
tt_content,,,,,,
,uid,pid,header,CType,colPos,tx_container_parent,hidden,
,1,1,Test Container,test-container,0,0,0,
,2,1,Test Child 1,test-child,200,1,0,
,3,1,Test Child 2,test-child,200,1,0,
,4,1,Test Child 3,test-child,200,1,1,
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php

declare(strict_types=1);

/*
* This file is developed by evoWeb.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*/

namespace Evoweb\EwCollapsibleContainer\Tests\Functional\EventListener;

use B13\Container\Events\BeforeContainerConfigurationIsAppliedEvent;
use B13\Container\Tca\ContainerConfiguration;
use Evoweb\EwCollapsibleContainer\EventListener\BeforeContainerConfigurationIsAppliedListener;
use PHPUnit\Framework\Attributes\Test;
use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;

class BeforeContainerConfigurationIsAppliedListenerTest extends FunctionalTestCase
{
protected array $testExtensionsToLoad = [
'typo3conf/ext/container',
'typo3conf/ext/ew_collapsible_container',
];

#[Test]
public function invokeAddsPartial(): void
{
$fixture = new ContainerConfiguration('a', 'a', 'a', []);
$event = new BeforeContainerConfigurationIsAppliedEvent($fixture);

$subject = new BeforeContainerConfigurationIsAppliedListener();
$subject->__invoke($event);

$this->assertContains(
'EXT:ew_collapsible_container/Resources/Private/Partials/',
$event->getContainerConfiguration()->getGridPartialPaths()
);
}
}
Loading

0 comments on commit 37c5290

Please sign in to comment.