Organizing Your Actions in the User Interface
You can control some aspects of how the actions you add appear in the vSphere Web Client user interface. In addition to choosing the objects for which your actions appear, you can display actions in nested menus, add nested menus and separators to action menus, and prioritize which actions appear highest in an action menu.
Extending an Action Menu
You can extend an object’s action menu by adding a nested solution menu. The solution menu can contain actions, additional nested menus, and separators. You can extend an action menu by defining a Solution Menu extension in your plug-in module’s plugin.xml manifest file.
Defining a Solution Menu Extension
All Solution Menu extensions that you create use a common extension point in the vSphere Web Client extension framework, called vsphere.core.menus.solutionMenus. The extension definition must provide an extension object of type com.vmware.actionsfw.ActionMenuItemSpec.
The ActionMenuItemSpec object represents the new solution menu nested in an object’s action menu. In the solution menu object, you define an array of additional ActionMenuItemSpec objects to represent actions, nested menus, and separators.
ActionMenuItemSpec Extension Object Properties for a Nested Solution Menu lists the properties of the ActionMenuItemSpec object that you must set for your nested solution menu extension.
An array of additional ActionMenuItemSpec objects. Each ActionMenuItemSpec child object can represent an action, a nested menu, or a separator.
You associate your Solution Menu extension with a particular type of vSphere or custom object. It is a best practice to use the vSphere Web Client extension filtering mechanism to ensure that the actions are only visible when the user selects the relevant type of vSphere object. See Filtering Extensions.
Important If you omit the <metadata> element for extension filtering in your Solution Menu extension definition, your Solution Menu is shown for all vSphere objects. Use the <metadata> element in your Solution Menu extension definition to ensure that your Solution Menu appears only for the correct type of vSphere or custom objects.
Example 7-3, on page 71, shows an example Solution Menu extension definition. In the example, the extension adds a nested solution menu to the action menu for VirtualMachine objects.
Example: Example Solution Menu Extension Definition
<!-- Defines a solution sub-menu on VirtualMachine objects -->
<extension id="com.vmware.samples.actions.submenus">
<extendedPoint>vsphere.core.menus.solutionMenus</extendedPoint>
<object>
<label>#{allSampleActions.label}</label>
<uid>allSampleVMActions</uid>
<children>
<Array>
<!-- array of ActionMenuItemSpec objects, which are items in the Solution Menu -->
<com.vmware.actionsfw.ActionMenuItemSpec>
...
</com.vmware.actionsfw.ActionMenuItemSpec>
<com.vmware.actionsfw.ActionMenuItemSpec>
...
</com.vmware.actionsfw.ActionMenuItemSpec>
</Array>
</children>
</object>
<metadata>
<objectType>VirtualMachine</objectType>
</metadata>
</extension>
 
Adding Items to a Nested Solution Menu
You can add items to a nested solution menu by using the <children> property in your Solution Menu extension’s ActionMenuItemSpec object. In the <children> property, you can add one or more additional ActionMenuItemSpec objects to represent each item.
Adding an Action
To add an action to your solution sub-menu, you create a child ActionMenuItemSpec object with the properties listed in ActionMenuItemSpec Child Object Properties for an Action.
Example 7-4, on page 72, shows an example of a nested solution menu with two action items as child objects.
Example: Nested Solution Menu Extension with Actions
<!-- Defines a solution sub-menu on VirtualMachine objects -->
<extension id="com.vmware.samples.actions.submenus">
<extendedPoint>vsphere.core.menus.solutionMenus</extendedPoint>
<object>
<label>#{allSampleActions.label}</label>
<uid>allSampleVMActions</uid>
<children>
<Array>
<!-- array of ActionMenuItemSpec objects, which are items in the Solution Menu -->
<com.vmware.actionsfw.ActionMenuItemSpec>
<!-- first action -->
<type>action</type>
<uid>com.vmware.samples.actions.myVmAction1</uid>
<label>#{action1.label}</label>
</com.vmware.actionsfw.ActionMenuItemSpec>
<com.vmware.actionsfw.ActionMenuItemSpec>
<!-- second action -->
<type>action</type>
<uid>com.vmware.samples.actions.myVmAction1</uid>
<label>#{action1.label}</label>
</com.vmware.actionsfw.ActionMenuItemSpec>
</Array>
</children>
</object>
<metadata>
<objectType>VirtualMachine</objectType>
</metadata>
</extension>
 
Adding a Separator
To add a separator to your nested solution menu, you create a child ActionMenuItemSpec object with the properties listed in ActionMenuItemSpec Child Object Properties for a Separator.
Adding a Nested Menu
To add an action to your nested solution menu, you create a child ActionMenuItemSpec object with the properties listed in ActionMenuItemSpec Child Object Properties for a Nested Sub-Menu. For menus nested to another level, you must omit the <type> property and include a <children> property.
Array of additional ActionMenuItemSpec objects. Each ActionMenuItemSpec child object can represent an action, a nested menu, or a separator.
Example 7-5, on page 73, shows an example solution menu that adds a Solution Menu extension for VirtualMachine objects. The nested solution menu includes a subordinate nested menu called “Configuration” with two actions, a separator, and an additional action.
Example: Example Solution Menu Extension with Nested Menu and Separator
<!-- Defines a solution sub-menu on VirtualMachine objects -->
<extension id="com.vmware.samples.actions.submenus">
<extendedPoint>vsphere.core.menus.solutionMenus</extendedPoint>
<object>
<label>#{allSampleActions.label}</label>
<uid>allSampleVMActions</uid>
<children>
<Array>
<!-- array of ActionMenuItemSpec objects, which are items in the Solution Menu -->
 
<!-- add a nested sub-menu called "configuration" -->
<com.vmware.actionsfw.ActionMenuItemSpec>
<uid>configuration</uid>
<label>#{configurationMenu.label}
<children>
<array>
<!-- first action in sub-menu -->
<com.vmware.actionsfw.ActionMenuItemSpec>
<type>action</type>
<uid>com.vmware.samples.actions.myVmAction1</uid>
<label>#{action1.label}</label>
</com.vmware.actionsfw.ActionMenuItemSpec>
 
<!-- second action in sub-menu -->
<com.vmware.actionsfw.ActionMenuItemSpec>
<!-- second action -->
<type>action</type>
<uid>com.vmware.samples.actions.myVmAction1</uid>
<label>#{action1.label}</label>
</com.vmware.actionsfw.ActionMenuItemSpec>
</array>
</children>
</com.vmware.actionsfw.ActionMenuItemSpec>
 
<!-- add a separator after the sub-menu -->
<com.vmware.actionsfw.ActionMenuItemSpec>
<type>separator</type>
</com.vmware.actionsfw.ActionMenuItemSpec>
 
<!-- add an additional action -->
<com.vmware.actionsfw.ActionMenuItemSpec>
<type>action</type>
<uid>com.vmware.samples.actions.myVmAction3</uid>
<label>#{action3.label}</label>
</com.vmware.actionsfw.ActionMenuItemSpec>
</Array>
</children>
</object>
<metadata>
<objectType>VirtualMachine</objectType>
</metadata>
</extension>
 
Prioritizing Actions in the User Interface
If your plug-in module adds actions to the vSphere Web Client, you can change the order in which those actions appear at different points in the user interface. You can prioritize the action order in the global action menu for all vSphere actions, or in the context-specific action menu for a vSphere or custom object.
To change your actions’ display order, you must create a Prioritization extension. You must define the Prioritization extension in the same plug-in package that contains your action extensions. You must create different extensions depending on whether you want to promote actions in the action menu for a certain object type, or to set the action priority in the global action list.
Prioritizing Context-Specific Actions
To change how actions are prioritized in the action menu for a specific object type, you must create a Prioritization extension at the extension point vmware.prioritization.actions. Your extension must provide a data object of type com.vmware.vsphere.client.prioritization.ActionPriorityGroup.
The ActionPriorityGroup object defines the priority order for the actions in the action menu, and the target object type. The actions listed first in your extension definition appear at the top of the action menu and to the right side of the actions toolbar. You can promote a maximum of five actions on the actions toolbar.
ActionPriorityGroup Extension Object Properties lists the properties of the ActionPriorityGroup object that you must set in your Prioritization extension.
Array of <string> elements. Each <string> element contains the UID of an action. You list each action UID string in order from highest priority to lowest priority, depending on how you want the actions to appear in the action menu.
<string> element that contains the target object type, such as samples:Chassis or VirtualMachine. The Prioritization extension sets the display priority for the target object type’s action menu.
Example: Prioritizing Items in the Chassis Action Menu shows an example Prioritization action that sets the display priority for actions in the default actions menu for a custom object called a Chassis.
Example: Prioritizing Items in the Chassis Action Menu
<extension id="com.vmware.samples.chassis.actionMenuPrioritization.editAction">
<extendedPoint>vmware.prioritization.actions</extendedPoint>
<object>
<prioritizedIds>
<string>com.vmware.samples.chassis.editChassis</string>
<string>com.vmware.samples.chassis.deleteChassis</string>
<string>com.vmware.samples.chassis.moveChassis</string>
<string>com.vmware.samples.chassis.poweronChassis</string>
<string>com.vmware.samples.chassis.poweroffChassis</string>
</prioritizedIds>
<actionTargetTypes>
<string>samples:Chassis</string>
</actionTargetTypes>
</object>
</extension>
 
Prioritizing Global Actions Toolbar
To change how actions are prioritized in the global actions menu, you must create a Prioritization extension at the extension point vmware.prioritization.listActions. Your extension must provide a data object of type com.vmware.vsphere.client.prioritization.ActionPriorityGroup.
The ActionPriorityGroup object defines the priority order for the actions in the global actions toolbar, which is the toolbar that appears to the left of the context toolbar. The actions listed first in your extension definition appear farthest left in the global actions toolbar.
Table 7-7, on page 75, lists the properties of the ActionPriorityGroup object that you must set in your Prioritization extension.
Array of <string> elements. Each <string> element contains the UID of an action. You list each action UID string in order from highest priority to lowest priority, depending on how you want the actions to appear in the global action list.
Example: Prioritizing Items Added to Global Actions Toolbar for Chassis Objects shows an example Prioritization action that sets the display priority for actions in the default actions menu for a custom object called a Chassis.
Example: Prioritizing Items Added to Global Actions Toolbar for Chassis Objects
<extension id="com.vmware.samples.chassis.actionListPrioritization.createAction">
<extendedPoint>vmware.prioritization.listActions</extendedPoint>
<object>
<prioritizedIds>
<string>com.vmware.samples.chassis.createChassis</string>
<string>com.vmware.samples.chassis.createRack</string>
</prioritizedIds>
<regionId>com.vmware.samples.chassis.list</regionId>
</object>
</extension>