Share via


How to Add Items to the Add New Drawer in a Windows Azure Pack Management Portal Extension

 

Applies To: Windows Azure Pack

The Add New drawer is the central place in the management portal user interface to create new items. Extensions may contribute menu items to this drawer to allow users to create new resources through the extension.Items in the menu are added declaratively and cannot be changed or removed once added. They are available from anywhere in the management portal. The recommended place for the declaration is in your extension’s initialization JavaScript. For more information see Windows Azure Pack Management Portal Client-Side Extension JavaScript.

To Add a Standard Menu Item

  1. Add a standard menu item with the following code:

    menuItems: [
      {
        // ID of the menu item
        name: "WebDomain",
        // Text of the menu item
        displayName: "Web site domains",
        // ID of a template to show when the user hovers over the item (before they click it)
        preview: "createPreview",
        // Sub-menu (child menu) items take mostly the same parameters as parent menu items
        subMenu: [
          {
            name: "Create",
            displayName: "Create",
            // Function to run when the user clicks the item
            execute: global.DomainTenantExtension.CreateWizard.showCreateWizard,
            preview: "customCreatePreview"
          }
        ]
      }
    ]
    

Quick Create Menu Items

For Quick Create menu items (items that display a short form in the Add New drawer to create the item immediately) you must supply an ID of a template that will be rendered in the drawer, as well as functions that define the behavior (what to do when the template is shown, when the user clicks OK, etc.).

To Add a Quick Create Menu Item

  1. Using the code above, add the following code to the menuItems array to add a Quick Create menu item.

    {
      // ID of this menu item
      name: "QuickCreate",
      // Text displaye on top of the Quick Create template as a title
      displayName: "Quick Create a Domain",
      // Description text displayed when the user hovers over the item with their mouse
      description: "Quickly add a new ___domain by supplying a few details",
      // Template to render for the Quick Create form
      template: "quickcreate",
      // Menu item's text
      label:"Quick Create",
      // Context object for the template
      data: null,
    
      opening: function(object) {
        // Add logic here to run just before the template is rendered
      }
    
      open: function () {
        // Add logic here to run just after the template is rendered
        Shell.UI.Validation.setValidationContainer("#webDomainQuickCreateForm");
      },
    
      ok: function(object) {
        var dialogFields = object.fields;
    
        if (Shell.UI.Validation.validateContainer("#webDomainQuickCreateForm")) {
          createWebDomain(dialogFields);
        }
        return false;
      },
    
      cancel: function (object) {
        // Add logic here to run after the user dismisses the Quick Create form
        // Do nothing in this case
      }
    }
    

See Also

Performing Common Tasks in a Windows Azure Pack Management Portal Extension