neos / neos-development-collection

The unified repository containing the Neos core packages, used for Neos development.
https://www.neos.io/
GNU General Public License v3.0
259 stars 220 forks source link

BUG: Endless loading orange line in Neos 7.3 backend with custom controller with Fusion view #4121

Open alexander-nitsche opened 1 year ago

alexander-nitsche commented 1 year ago

Is there an existing issue for this?

Current Behavior

In Neos 7.3 a custom controller with Fusion view and including the Neos core Fusion libraries via

include: resource://neos.fusion/Private/Fusion/Root.fusion
include: resource://neos.neos/Private/Fusion/Root.fusion

breaks the Neos UI in that it is endlessly loading the orange line at the top.

Expected Behavior

It should be possible to implement a controller with Fusion view and using the core Fusion libraries comfortably with the above mentioned aggregation includes.

Steps To Reproduce

DistributionPackages/MyWebsite.Site/Configuration/Settings.yaml

Neos:
  Flow:
    mvc:
      routes:
        ..
        'MyWebsite.Site':
          position: 'before Neos.Neos'

DistributionPackages/MyWebsite.Site/Configuration/Policy.yaml

privilegeTargets:
  'Neos\Flow\Security\Authorization\Privilege\Method\MethodPrivilege':
    'MyWebsite.Site:Articles':
      label: Articles API
      matcher: 'method(MyWebsite\Site\Controller\Service\ArticlesController->listAction())'

roles:
  'Neos.Flow:Everybody':
    privileges:
      -
        privilegeTarget: 'MyWebsite.Site:Articles'
        permission: GRANT

DistributionPackages/MyWebsite.Site/Configuration/Routes.yaml

-
  name:  'My Website :: Articles API'
  uriPattern: 'articles/{@action}'
  defaults:
    '@package': 'MyWebsite.Site'
    '@controller': 'Service\Articles'
  appendExceedingArguments: true

DistributionPackages/MyWebsite.Site/Classes/Controller/Service/ArticlesController.php

<?php
namespace MyWebsite\Site\Controller\Service;

use Neos\Flow\Annotations as Flow;
use Neos\Flow\Mvc\Controller\ActionController;
use Neos\Fusion\View\FusionView;

/**
 * @Flow\Scope("singleton")
 */
class ArticlesController extends ActionController
{
    protected $defaultViewObjectName = FusionView::class;

    public function listAction(): void {}
}

DistributionPackages/MyWebsite.Site/Resources/Private/Fusion/Controller/ArticlesController.fusion

include: resource://neos.fusion/Private/Fusion/Root.fusion
include: resource://neos.neos/Private/Fusion/Root.fusion

MyWebsite.Site.Service.ArticlesController.list = Neos.Fusion:Component {
  renderer = Neos.Neos:ContentComponent {
    renderer = 'Causes an endless loading animation in the Neos 7.3 backend.'
  }
}

Environment

- Flow: 7.3
- Neos: 7.3
- PHP: 7.4

Anything else?

In-depth analysis revealed that

prototype(Neos.Neos:Page) >

in Packages/Application/Neos.Neos/Resources/Private/Fusion/Prototypes/Page.fusion is responsible here and commenting it in fixes the endless loading.

A temporary fix is to replace the generic

include: resource://neos.fusion/Private/Fusion/Root.fusion
include: resource://neos.neos/Private/Fusion/Root.fusion

with the specifically required Fusion files of the Neos.Neos package, e.g.

include: resource://neos.fusion/Private/Fusion/Root.fusion
include: resource://neos.neos/Private/Fusion/Prototypes/ContentComponent.fusion
include: resource://neos.neos/Private/Fusion/Prototypes/ContentElementWrapping.fusion
include: resource://neos.neos/Private/Fusion/Prototypes/NodeUri.fusion
include: resource://neos.neos/Private/Fusion/Prototypes/NodeLink.fusion

which hopefully do not include the Page.fusion :)

mhsdesign commented 1 year ago

Are you sure the existence of the Neos.Neos:Page Prototyp is the problem? As long as you don’t use it it should not be run and cause any issues.

im more confused by your Neos.Neos:ContentComponent in your custom view without nodes … you won’t need it and it might actually be a problem if you don’t have the context node defined.

Also do I see this correctly that you want to open Inside of the NeosUi iFrame your custom flow route? Isn’t this odd?

and does the view works if it’s not loaded in the iFrame but in a normal tab? - could you provide a screenshare?

btw I just realised that you will upset the ui if you’re navigating inside the iFrame to a page which is not a node document, but this is okay - as the backend is only meant for nodes… does this explain everything?