From 92542741abc9f60f33e9886e5f73cdb4865db5af Mon Sep 17 00:00:00 2001 From: Nils Haagen Date: Mon, 6 Jan 2025 16:06:43 +0100 Subject: [PATCH] UI/Legacy: rebase --- .../IntLink/class.ilInternalLinkGUI.php | 2 +- .../classes/class.ilDashboardBlockGUI.php | 13 ----- .../classes/class.ilSelectedItemsBlockGUI.php | 24 -------- .../ConsumerSlots/ModifyFooter.php | 2 +- .../tests/Provide/ProvideDocumentTest.php | 25 ++------ .../tests/Table/DocumentTableTest.php | 50 ---------------- .../ILIAS/UI/tests/UITestHelperTest.php | 57 ------------------- 7 files changed, 7 insertions(+), 166 deletions(-) delete mode 100755 components/ILIAS/UI/tests/UITestHelperTest.php diff --git a/components/ILIAS/COPage/IntLink/class.ilInternalLinkGUI.php b/components/ILIAS/COPage/IntLink/class.ilInternalLinkGUI.php index e72bd665d176..719238cb583d 100755 --- a/components/ILIAS/COPage/IntLink/class.ilInternalLinkGUI.php +++ b/components/ILIAS/COPage/IntLink/class.ilInternalLinkGUI.php @@ -941,7 +941,7 @@ public static function getInitHTML(string $a_url): string $mt = self::getModalTemplate(); $tpl->addOnLoadCode('il.IntLink.setModalTemplate("' . addslashes(json_encode($mt["template"])) . '");'); - $html = "
"; + $html = "
"; return $html; } diff --git a/components/ILIAS/Dashboard/Block/classes/class.ilDashboardBlockGUI.php b/components/ILIAS/Dashboard/Block/classes/class.ilDashboardBlockGUI.php index 82d0619c8640..305d5f95fa25 100755 --- a/components/ILIAS/Dashboard/Block/classes/class.ilDashboardBlockGUI.php +++ b/components/ILIAS/Dashboard/Block/classes/class.ilDashboardBlockGUI.php @@ -396,19 +396,6 @@ public function addCommandActions(): void } if ($this->removeMultipleEnabled()) { -<<<<<<< HEAD -======= - $roundtrip_modal = $this->ui->factory()->modal()->roundtrip( - $this->getRemoveMultipleActionText(), - $this->ui->factory()->legacy()->content('PH') - ); - $roundtrip_modal = $roundtrip_modal->withAsyncRenderUrl( - $this->ctrl->getLinkTarget( - $this, - 'removeFromDeskRoundtrip' - ) . '&page=manage&replaceSignal=' . $roundtrip_modal->getReplaceSignal()->getId() - ); ->>>>>>> 636a31c90da (UI/Legacy: rename LegacyContent to Content) $this->addBlockCommand( $this->ctrl->getLinkTarget($this, 'manage'), $this->getRemoveMultipleActionText(), diff --git a/components/ILIAS/Dashboard/Block/classes/class.ilSelectedItemsBlockGUI.php b/components/ILIAS/Dashboard/Block/classes/class.ilSelectedItemsBlockGUI.php index e69c4d596076..4253df5e8d2c 100755 --- a/components/ILIAS/Dashboard/Block/classes/class.ilSelectedItemsBlockGUI.php +++ b/components/ILIAS/Dashboard/Block/classes/class.ilSelectedItemsBlockGUI.php @@ -106,28 +106,4 @@ public function getRemoveMultipleActionText(): string { return $this->lng->txt('pd_remove_multiple'); } - - public function getConfigureModal(): RoundTrip - { - $roundtrip_modal = $this->ui->factory()->modal()->roundtrip( - $this->lng->txt('rep_configure'), - $this->ui->factory()->legacy()->content('PH') - )->withAdditionalOnLoadCode(function ($id) { - return "document.body.appendChild(document.getElementById('$id')); - let configure_modal_script = document.body.appendChild(document.createElement('script')); - configure_modal_script.src = 'Services/Dashboard/Block/js/ReplaceModalContent.js'; - document.body.appendChild(configure_modal_script); - let modal_js_script = document.body.appendChild(document.createElement('script')); - modal_js_script.src = 'src/UI/templates/js/Modal/modal.js'; - document.body.appendChild(modal_js_script); - "; - }); - - return $roundtrip_modal->withAsyncRenderUrl( - $this->ctrl->getLinkTargetByClass( - [ilDashboardGUI::class, ilColumnGUI::class, $this::class], - 'removeFromDeskRoundtrip' - ) . '&page=manage&replaceSignal=' . $roundtrip_modal->getReplaceSignal()->getId() - ); - } } diff --git a/components/ILIAS/LegalDocuments/classes/ConsumerToolbox/ConsumerSlots/ModifyFooter.php b/components/ILIAS/LegalDocuments/classes/ConsumerToolbox/ConsumerSlots/ModifyFooter.php index 46a333947bf6..7199875fb941 100755 --- a/components/ILIAS/LegalDocuments/classes/ConsumerToolbox/ConsumerSlots/ModifyFooter.php +++ b/components/ILIAS/LegalDocuments/classes/ConsumerToolbox/ConsumerSlots/ModifyFooter.php @@ -64,7 +64,7 @@ public function __invoke(Closure $footer): Closure public function renderModal(DocumentContent $content): Modal { return $this->ui->create()->modal()->roundtrip($content->title(), [ - $this->ui->create()->legacy->legacyContent($this->ui->txt('usr_agreement_footer_intro')), + $this->ui->create()->legacy()->content($this->ui->txt('usr_agreement_footer_intro')), $this->ui->create()->divider()->horizontal(), $this->legal_documents->document()->contentAsComponent($content), $this->ui->create()->divider()->horizontal(), diff --git a/components/ILIAS/LegalDocuments/tests/Provide/ProvideDocumentTest.php b/components/ILIAS/LegalDocuments/tests/Provide/ProvideDocumentTest.php index c370c97f0a25..111dab703d9f 100755 --- a/components/ILIAS/LegalDocuments/tests/Provide/ProvideDocumentTest.php +++ b/components/ILIAS/LegalDocuments/tests/Provide/ProvideDocumentTest.php @@ -31,8 +31,7 @@ use ILIAS\LegalDocuments\Value\Criterion; use ILIAS\LegalDocuments\Value\Document; use ILIAS\LegalDocuments\EditLinks; -use ILIAS\LegalDocuments\Table\EditableDocumentTable; -use ILIAS\UI\Component\Legacy; +use ILIAS\UI\Component\Legacy\Legacy; use ILIAS\LegalDocuments\Legacy\Table as LegacyTable; use ILIAS\LegalDocuments\Table as TableInterface; use ILIAS\LegalDocuments\Table\DocumentTable; @@ -75,17 +74,10 @@ public function testTableReadOnly(): void $uri = 'http://myIlias/ilias.php?baseClass=iladministrationgui&cmdNode=2g:qo:gq&cmdClass=ilLegalDocumentsAdministrationGUI&cmd=documents&ref_id=50'; - $legacy = $this->mock(Legacy\Content::class); - $legacy_factory = $this->mock(Legacy\Factory::class); - $legacy_factory - ->expects($this->once()) - ->method('content') - ->willReturn($legacy); - $container = $this->mockTree(Container::class, [ 'ui' => [ - 'factory' => $this->mockMethod(UIFactory::class, 'legacy', [], $legacy_factory), - 'mainTemplate' => $this->mock(ilGlobalTemplateInterface::class), + 'factory' => [], + 'mainTemplate' => [], ], 'language' => [], 'http' => ['request' => ['getUri' => ['__toString' => $uri]]], @@ -107,17 +99,10 @@ public function testTableEditable(): void $uri = 'http://myIlias/ilias.php?baseClass=iladministrationgui&cmdNode=2g:qo:gq&cmdClass=ilLegalDocumentsAdministrationGUI&cmd=documents&ref_id=50'; - $legacy = $this->mock(Legacy\Content::class); - $legacy_factory = $this->mock(Legacy\Factory::class); - $legacy_factory - ->expects($this->once()) - ->method('content') - ->willReturn($legacy); - $container = $this->mockTree(Container::class, [ 'ui' => [ - 'factory' => $this->mockMethod(UIFactory::class, 'legacy', [], $legacy_factory), - 'mainTemplate' => $this->mock(ilGlobalTemplateInterface::class), + 'factory' => ['table' => ['action' => ['multi' => []]]], + 'mainTemplate' => [], ], 'language' => [], 'http' => ['request' => ['getUri' => ['__toString' => $uri]]], diff --git a/components/ILIAS/LegalDocuments/tests/Table/DocumentTableTest.php b/components/ILIAS/LegalDocuments/tests/Table/DocumentTableTest.php index 586eae8d6124..cd4d04ab1e7c 100755 --- a/components/ILIAS/LegalDocuments/tests/Table/DocumentTableTest.php +++ b/components/ILIAS/LegalDocuments/tests/Table/DocumentTableTest.php @@ -24,7 +24,6 @@ use ILIAS\Data\Factory; use ILIAS\LegalDocuments\EditLinks; use ILIAS\UI\Component\Component; -use ILIAS\UI\Component\Legacy; use ILIAS\UI\Factory as UIFactory; use ILIAS\LegalDocuments\Value\CriterionContent; use ILIAS\LegalDocuments\Value\Criterion; @@ -73,55 +72,6 @@ public function testConstruct(): void )); } - public function testShowCriteria(): void - { - $ui = $this->mock(UI::class); - $ui->method('txt')->willReturnCallback(fn($s) => 'txt: ' . $s); - - $instance = new DocumentTable( - $this->fail(...), - $this->mock(DocumentRepository::class), - $ui, - $this->mock(DocumentModal::class) - ); - - $criteria = [ - $this->mock(Criterion::class), - $this->mock(Criterion::class), - ]; - - $this->assertSame(['a', 'b', 'a', 'b'], $instance->showCriteria( - $this->mockTree(Document::class, ['criteria' => $criteria]), - function (Criterion $criterion) use ($criteria) { - $this->assertTrue(in_array($criterion, $criteria, true)); - return ['a', 'b']; - } - )); - } - - public function testShowCriterion(): void - { - $content = $this->mock(CriterionContent::class); - $legacy = $this->mock(Legacy\Factory::class); - $component = $this->mock(Component::class); - - $ui = $this->mockTree(UI::class, ['create' => $this->mockMethod(UIFactory::class, 'legacy', ['
'], $legacy)]); - - $instance = new DocumentTable( - function (CriterionContent $c) use ($content, $component) { - $this->assertSame($content, $c); - return $component; - }, - $this->mock(DocumentRepository::class), - $ui, - $this->mock(DocumentModal::class) - ); - - $criterion = $this->mockTree(Criterion::class, ['content' => $content]); - - $this->assertSame([$component, $legacy], $instance->showCriterion($criterion)); - } - public function testCriterionName(): void { $uri = $this->mock(UriInterface::class); diff --git a/components/ILIAS/UI/tests/UITestHelperTest.php b/components/ILIAS/UI/tests/UITestHelperTest.php deleted file mode 100755 index a8a7695c2879..000000000000 --- a/components/ILIAS/UI/tests/UITestHelperTest.php +++ /dev/null @@ -1,57 +0,0 @@ -assertInstanceOf("UITestHelper", new UITestHelper()); - } - - public function testGetFactory(): void - { - $this->assertInstanceOf(Factory::class, (new UITestHelper())->factory()); - } - - public function testGetRenderer(): void - { - $this->assertInstanceOf(Renderer::class, (new UITestHelper())->renderer()); - } - - public function testGetMainTemplate(): void - { - $this->assertInstanceOf(ilIndependentGlobalTemplate::class, (new UITestHelper())->mainTemplate()); - } - - public function testRenderExample(): void - { - $helper = new UITestHelper(); - $c = $helper->factory()->legacy()->content("hello world"); - $this->assertEquals("hello world", $helper->renderer()->render($c)); - } -}