[BUGFIX] Allow any navigation component to load in BE 89/53489/2
authorBenni Mack <benni@typo3.org>
Tue, 28 Feb 2017 10:12:32 +0000 (11:12 +0100)
committerAndreas Fernandez <typo3@scripting-base.de>
Fri, 14 Jul 2017 20:43:19 +0000 (22:43 +0200)
Since the ExtJS viewport refactoring in 8.5, it is not possible
anymore to load any other registered navigation component,
which makes EXT:commerce to not work anymore.

The patch changes the hard-coded pagetree app component
to fetch it from the pool of available navigation components.

Resolves: #80058
Releases: master, 8.7
Change-Id: I49be1b0b231f6085a7a9e9d5c633b073a92ad301
Reviewed-on: https://review.typo3.org/53489
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Andreas Fernandez <typo3@scripting-base.de>
Tested-by: Andreas Fernandez <typo3@scripting-base.de>
typo3/sysext/backend/Resources/Public/JavaScript/ModuleMenu.js
typo3/sysext/backend/Resources/Public/JavaScript/extjs/components/pagetree/javascript/app.js

index 5b22615..b299fde 100644 (file)
@@ -211,24 +211,56 @@ require(
                                        return;
                                }
                                if (this.loadedNavigationComponentId !== '') {
-                                       Ext.getCmp(this.loadedNavigationComponentId).hide();
+                                       $('#navigationComponent-' + this.loadedNavigationComponentId).hide();
                                }
                                if ($('.t3js-scaffold-content-navigation [data-component="' + navigationComponentId + '"]').length < 1) {
                                        $('.t3js-scaffold-content-navigation')
                                                .append('<div class="scaffold-content-navigation-component" data-component="' + navigationComponentId + '" id="navigationComponent-' + navigationComponentId + '"></div>');
                                }
+                               // allow to render the pagetree hard-coded in order to have acceptance tests apply correctly
+                               // and to ensure that something is loaded
                                var component = Ext.getCmp(navigationComponentId);
-                               if (typeof component === 'undefined') {
-                                       /** @todo fix hard coded pagetree **/
+                               if (typeof this.availableNavigationComponents['typo3-pagetree'] === 'undefined') {
                                        component = new TYPO3.Components.PageTree.App();
                                        component.render('navigationComponent-' + navigationComponentId);
+                                       this.availableNavigationComponents['typo3-pagetree'] = component;
+                                       // re-evaluate the component
+                                       component = Ext.getCmp(navigationComponentId);
+                               }
+
+                               if (typeof component === 'undefined') {
+                                       var self = this,
+                                               deferredComponentExists = $.Deferred();
+
+                                       function checkIfComponentIdIsAvailable(componentId) {
+                                               if (typeof self.availableNavigationComponents[componentId] === 'undefined') {
+                                                       setTimeout(function (id) {
+                                                               checkIfComponentIdIsAvailable(id);
+                                                       }, 100, componentId);
+                                               } else {
+                                                       deferredComponentExists.resolve();
+                                               }
+                                       }
+                                       checkIfComponentIdIsAvailable(navigationComponentId);
+
+                                       deferredComponentExists.promise().done(function() {
+                                               component = self.availableNavigationComponents[navigationComponentId]();
+                                               component.render('navigationComponent-' + navigationComponentId);
+
+                                               TYPO3.Backend.NavigationContainer.show(navigationComponentId);
+                                               self.loadedNavigationComponentId = navigationComponentId;
+                                       });
+                               } else {
+                                       // Tree was previously rendered, and was hidden because a different component was displayed
+                                       TYPO3.Backend.NavigationContainer.show(navigationComponentId);
+                                       this.loadedNavigationComponentId = navigationComponentId;
                                }
-                               TYPO3.Backend.NavigationContainer.show(navigationComponentId);
-                               this.loadedNavigationComponentId = navigationComponentId;
                        },
 
                        registerNavigationComponent: function (componentId, initCallback) {
-                               this.availableNavigationComponents[componentId] = initCallback;
+                               if (typeof this.availableNavigationComponents[componentId] === 'undefined') {
+                                       this.availableNavigationComponents[componentId] = initCallback;
+                               }
                        },
 
                        openInNavFrame: function (url, params) {
index 8398fa8..e8e60b9 100644 (file)
@@ -381,24 +381,5 @@ TYPO3.Components.PageTree.App = Ext.extend(Ext.Panel, {
        }
 });
 
-/**
- * Callback method for the module menu
- *
- * @return {TYPO3.Components.PageTree.App}
- */
-require(
-       [
-               'TYPO3/CMS/Backend/ModuleMenu'
-       ],
-       function () {
-               // extjs loading bugfix
-               window.setTimeout(function() {
-                       TYPO3.ModuleMenu.App.registerNavigationComponent('typo3-pagetree', function () {
-                               return new TYPO3.Components.PageTree.App();
-                       });
-               }, 5000);
-       }
-);
-
 // XTYPE Registration
 Ext.reg('TYPO3.Components.PageTree.App', TYPO3.Components.PageTree.App);