sapui5sap-fiorisap-web-ide

WebIDE: How to Create Shell Plugin for Fiori Launchpad?


This is to:

Other guides have pockets of outdated information such as the no-longer-existing option to create a 'Fiori Launchpad Plugin' from 'New Project from Template'


Solution

  • 2020 Updated

    Steps:

    init: function () {
        // call the base component's init function
        UIComponent.prototype.init.apply(this, arguments);
        
        var rendererPromise= this._getRenderer();
        rendererPromise.then(function(oRenderer){
            // var bFull= jQuery.sap.getUriParameters().get("plugin-full");
            oRenderer.addHeaderItem("sap.ushell.ui.shell.ShellHeadItem", {
                icon:"sap-icon://add"
                ,tooltip:"Current Stage"
            },true,true);
        });
        
        // var oRenderer= sap.ushell.Container.getRenderer('fiori2');
        // oRenderer.addHeaderItem({icon:'sap-icon://add'},true,true);
        
        // enable routing
        // this.getRouter().initialize();
        // set the device model
        // this.setModel(models.createDeviceModel(), "device");
    },
    _getRenderer:function(){
        var that=this,
            oDeferred= new jQuery.Deferred(),
            oRenderer;
        that._oShellContainer= jQuery.sap.getObject("sap.ushell.Container");
        if(!that._oShellContainer){
            oDeferred.reject("Illegal state: shell container not available. This component must be executed in a unified shell runtime context.");
        } else{
            oRenderer= that._oShellContainer.getRenderer();
            if(oRenderer){oDeferred.resolve(oRenderer);}
            else{ //renderer not initialized yet, listen to rendererCreated event
                that._onRendererCreated= function(oEvent){
                    oRenderer= oEvent.getParameter('renderer');
                    if(oRenderer){oDeferred.resolve(oRenderer);}
                    else{oDeferred.reject('Illegal state: shell renderer not available after receiving rendererLoaded event');}
                };
                that._oShellContainer.attachRendererCreatedEvent(that._onRendererCreated);
            }
        }
        return oDeferred.promise();
    }

    1. Properties: *App Resource: select your deployed app > *App Type: select Shell Plugin
    2. Catalogs: *select a Catalog to place your plugin in
    3. Save

    How it Looks: *Note the additional '+' button on top ribbon. Success! enter image description here

    References:

    1. Sample Plugin: this sample shows how to add header action items, footer, parameters, etc.
    2. Activating plugin: see ONLY the "Configuring a Shell Plugin App" section
    3. API Reference on what can be modified in FLP