AEM 6 SP2 - Disable Search Boxes in CRXDE Lite

This is an unconventional way of extending CRXDE Lite; for desperate situations only

Goal


Disable search fields in CRXDE Lite. This extension does not disable Tools -> Query. Users may want to disable repository wide search in lite to stop random performance degrading searches on CRX

Demo | Package install



Solution


Follow the two steps below to extend CRXDE Lite and add necessary JS to disable search. First step is Not Upgrade-Proof, so when CQ is upgraded, the first step may have to be repeated

Step 1 - Update CRXDE Lite Jar

All we do in this step is copy (back it up just in case if something goes wrong) the serialized CRXDE lite jar, open it and add a small chunk of JS code so that any extensions we code are loaded by the added JS logic when lite is opened in browser.

1) Access bundles console http://localhost:4502/system/console/bundles and find the CRXDE Support bundle



2) Search for the serialized bundle on filesystem and copy it to a temp location (take a backup before modifying). On my AEM 6 SP2 its available in author\crx-quickstart\launchpad\installer (rsrc-com.adobe.granite.crxde-lite-1.0.66-CQ600-B0001.jar-1415034571045.ser)

3) Rename the copied .ser file to .jar (eg. rsrc-com.adobe.granite.crxde-lite-1.0.66-CQ600-B0001.jar-1415034571045.ser -> rsrc-com.adobe.granite.crxde-lite-1.0.66-CQ600-B0001.jar)

4) Open the jar using zip executable (say winrar), open file docroot\js\start.js in any text editor and add following code at the end. Save file and a winrar confirmation should popup asking if the jar should be updated with saved file.

Ext.onReady(function() {
    var loadLiteExtns = function(){
        Ext.Ajax.request({
            url: "/apps/ext-crxde-lite/files.txt",
            success: function(response, options) {
                var js = response.responseText;
 
                if(!js){
                    return;
                }
 
                js = js.split("\n");
 
                Ext.each(js, function(jsPath) {
                    Ext.Ajax.request({
                        url: jsPath,
                        success: function(response, options) {
                            eval(response.responseText);
                        }
                    });
                });
            }
        });
    };
 
    loadLiteExtns();
});


5) In the above steps we add necessary code to load the extension files entered in /apps/ext-crxde-lite/files.txt. So whenever a new CRXDE Lite extension is needed a new line with extension file path can be added in /apps/ext-crxde-lite/files.txt

6) Access http://localhost:4502/system/console/bundles, click Install/Update... to upload and update CQ with the new CRXDE Support jar having necessary code to load the CRXDE Lite extension files.

Step 2 - Add extension files in CRX

In this step we add the JS file containing logic to disable search fields

1) Access http://localhost:4502/crx/de

2) Create node /apps/ext-crxde-lite of type nt:folder

3) Create node /apps/ext-crxde-lite/files.txt of type nt:file and add the following line. The logic added in Step 1 reads this file for loading JS extension files added as paths

                                 /apps/ext-crxde-lite/disable-search.js

4) Create node /apps/ext-crxde-lite/disable-search.js of type nt:file and add the following code

Ext.onReady(function(){
    var INTERVAL = setInterval(function(){
        var searchField = Ext.getCmp(CRX.ide.REPO_PATH_ID);

        if(searchField){
            clearInterval(INTERVAL);

            searchField.setDisabled(true);
        }
    }, 250);

    var SB_INTERVAL = setInterval(function(){
        var homePanel = Ext.getCmp("editors");

        if(homePanel){
            clearInterval(SB_INTERVAL);

            homePanel.findByType("panel")[0].setDisabled(true);
        }
    }, 250);
});





No comments:

Post a Comment