VMware {code} Community
sujeetmkalaskar
Enthusiast
Enthusiast

Add Action/Link/Button

Hi  _vladi_, laurentsd, Denis_Chorbadzhiyski, Daryll, Kris

Is there any option to add the Action/Link/Button as specified in the screenshot?

In this space, once we click on Action/Link/Button display the modal dialog and add the system.

And the added system should be displayed under the list in More object.

As this workflow seems to proper for our plugin.

Can you please suggest?

vSphere - Host.png

Thanks,

Sujeet Kalaskar

14 Replies
_vladi_
VMware Employee
VMware Employee

Hi Sujeet,

I believe what you are asking for is having global / context-less actions.

With the currently recommended extensibility (without custom objects defined in the plugin.xml) you define the whole custom object list in a global view so you can choose any UI elements to show, including actions and menus.

With the custom object extensibility used in the screenshot below you can define the action in the ActionSpec as <privateAction> and add this action to another vmware.prioritization.listActions extension which enables the global actions on a list's action button bar.

This use case is again demonstrated in the ChassisB sample part of the 6.5U1 SDK. Just have a look at that for reference.

Cheers,

Vladi

sujeetmkalaskar
Enthusiast
Enthusiast

Hi  _vladi_​,

Thanks for the update, I was able to add the custom action "Add" and "Delete" button.

But the problem is that when there is not Host or Host=0, I want to disable/ hide the "Delete" button.

Is there any option, where we can send the request properties to the service layer as similar to IconLabelSpec?

<conditions>

                  <com.vmware.data.query.PropertyConstraint>

                     <propertyName>iconStatus</propertyName>

                     <comparator>EQUALS</comparator>

                     <comparableValue>

                        <String>normal</String>

                     </comparableValue>

                  </com.vmware.data.query.PropertyConstraint>

               </conditions>

So how we can do it?

Thanks,

Sujeet Kalaskar

0 Kudos
_vladi_
VMware Employee
VMware Employee

Hi Sujeet,

Global (context-less) actions like Add require vmware.prioritization.listActions extension point.

Context-specific actions like Delete require vmware.prioritization.actions extension point.

This allows you to discriminate the 2 cases and apply filtering on the second one only.

Cheers,

Vladi

0 Kudos
sujeetmkalaskar
Enthusiast
Enthusiast

Hi _vladi_

I tried using "vmware.prioritization.actions", "Delete" button is not visible at all, without adding any filtering

If I use "vmware.prioritization.ListActions" both buttons are visible, but unable to disable the "Delete" button

<extension id="com.pmc.maxview.host.listActionSet">

      <extendedPoint>vise.actions.sets</extendedPoint>

      <object>

         <actions>

            <!-- Delete Chassis -->

            <com.vmware.actionsfw.ActionSpec>

               <uid>com.pmc.maxview.host.deleteHost</uid>

               <icon>#{hostDelete}</icon>

               <delegate>

                  <className>com.vmware.vsphere.client.HtmlPluginModalAction</className>

                  <object>

                     <root>

                        <!-- execute the action on client-side (html view in a modal dialog) -->

                        <actionUrl>/ui/maxViewVSphere/index.html?view=delete-system-modal</actionUrl>

                        <dialogTitle>Delete Host</dialogTitle>

                        <dialogSize>500,325</dialogSize>

                        <dialogIcon>#{hostDelete}</dialogIcon>

                     </root>

                  </object>

               </delegate>

               <!-- All context-less actions should be marked as private to prevent themfrom showing up in all menus.-->

               <privateAction>true</privateAction>

            </com.vmware.actionsfw.ActionSpec>

            <!-- Create Chassis -->

            <com.vmware.actionsfw.ActionSpec>

               <uid>com.pmc.maxview.host.addHost</uid>

               <icon>#{hostAdd}</icon>

               <delegate>

                  <className>com.vmware.vsphere.client.HtmlPluginModalAction</className>

                  <object>

                     <root>

                        <!-- execute the action on client-side (html view in a modal dialog) -->

                        <actionUrl>/ui/maxViewVSphere/index.html?view=add-system-modal</actionUrl>

                        <dialogTitle>Add Host</dialogTitle>

                        <dialogSize>500,250</dialogSize>

                        <dialogIcon>#{hostAdd}</dialogIcon>

                     </root>

                  </object>

               </delegate>

               <!-- All context-less actions should be marked as private to prevent themfrom showing up in all menus.-->

               <privateAction>true</privateAction>

            </com.vmware.actionsfw.ActionSpec>

         </actions>

      </object>

   </extension>

   <extension id="com.pmc.maxview.host.promotedActions">

      <extendedPoint>vmware.prioritization.listActions</extendedPoint>

      <object>

         <prioritizedIds>

            <String>com.pmc.maxview.host.addHost</String>

            <String>com.pmc.maxview.host.deleteHost</String>

         </prioritizedIds>

         <regionId>com.pmc.maxview.host.list</regionId>

         <actionTargetTypes>

            <String>maxView:Host</String>

         </actionTargetTypes>

      </object>

   </extension>

Thanks,

Sujeet Kalaskar

0 Kudos
_vladi_
VMware Employee
VMware Employee

Hi Sujeet,

I don't see any reference of vmware.prioritization.actions in the provided example that doesn't work for you.

Could you please follow closely the ChassisB sample which is demonstrating this extension point and provide your xml if it still does not work?

Thanks.

Cheers,

Vladi

0 Kudos
sujeetmkalaskar
Enthusiast
Enthusiast

Hi _vladi_

The above example does not have, just adding the below extension should work right?

<extension id="com.pmc.maxview.host.promotedDeleteActions">

      <extendedPoint>vmware.prioritization.actions</extendedPoint>

      <object>

         <prioritizedIds>

            <String>com.pmc.maxview.host.deleteHost</String>

         </prioritizedIds>

         <regionId>com.pmc.maxview.host.list</regionId>

      </object>

   </extension>

Using this I am unable to see the "Delete" button.

Thanks,

Sujeet Kalaskar

0 Kudos
_vladi_
VMware Employee
VMware Employee

Hi Sujeet,

I think you are missing the target type specification:

<actionTargetTypes>

  <String>samples:ChassisB</String>

</actionTargetTypes>

Please try this out.

Cheers,

Vladi

0 Kudos
sujeetmkalaskar
Enthusiast
Enthusiast

So this should be the

  1. <actionTargetTypes> 
  2.   <String>maxView:Host</String> 
  3. </actionTargetTypes>

I tried that, not sure why its not displaying.

If at least one system is available, "Delete" button should be enabled/rendered

0 Kudos
_vladi_
VMware Employee
VMware Employee

Please search for "samples:ChassisB" in the plugin.xml of the ChassisB example. You need to 1) define your object type in the templates, 2) use it in your filtering metadata and 3) use it in the target type sections. Some of these are probably missing from your plugin.xml.

Most likely, you are missing the vsphere.core.objectTypes extension which is required in conjunction with the prioritization extensions (as documented in the sample plugin.xml).

Cheers,

Vladi

0 Kudos
sujeetmkalaskar
Enthusiast
Enthusiast

Hi _vladi_​,

Below is the code

<!-- ****************** HOST extensions *********************** -->

   <!-- Controller object view template instance,

   which creates the object workspace (right hand side) for Controller objects.

   -->

   <templateInstance id="com.pmc.maxview.host.viewTemplateInstance">

      <templateId>vsphere.core.inventory.objectViewTemplate</templateId>

      <variable name="namespace" value="com.pmc.maxview.host" />

      <variable name="objectType" value="maxView:Host" />

   </templateInstance>

   <!-- Getting started view. -->

   <extension id="com.pmc.maxview.host.SummaryView1">

      <extendedPoint>com.pmc.maxview.host.views</extendedPoint>

      <precedingExtension>NULL</precedingExtension>

      <object>

         <name>Getting Started</name>

         <contentSpec>

            <url>/ui/maxViewVSphere/index.html?view=managed-system</url>

         </contentSpec>

      </object>

   </extension>

   <!-- Controller objects collection template,

   which creates the Controller collection node in the inventory under "maxView".

   Variables:

      - namespace: The namespace used in the extension points and extension ids,

         it must be different than the one in vsphere.core.inventory.objectViewTemplate!

      - title: resourceId of the title of the collection.

      - icon: resourceId of the icon to use in the inventory list.

      - objectType: the same object type as in objectViewTemplate above.

      - listViewId: extension id of the object list view created by objectViewTemplate

      - parentUid: extension id of the category node under which this belongs.

   -->

   <templateInstance id="com.pmc.maxview.host.lists.allHosts">

      <templateId>vsphere.core.inventorylist.objectCollectionTemplate</templateId>

      <variable name="namespace" value="com.pmc.maxview.hostCollection" />

      <variable name="title" value="Host" />

      <variable name="icon" value="#{hostIcon}" />

      <variable name="objectType" value="maxView:Host" />

      <variable name="listViewId" value="com.pmc.maxview.host.list" />

      <variable name="parentUid" value="com.pmc.maxview.maxViewAppCategory" />

   </templateInstance>

   <!-- Controller relations displayed in the Related Objects tab.

   The extension point vise.relateditems.specs takes an ObjectRelationSetSpec.

   Here we are showing relations with logicals, physicals, enclosures and hosts.

   -->

   <extension id="com.pmc.maxview.relateditems.specs.host">

      <extendedPoint>vise.relateditems.specs</extendedPoint>

      <precedingExtension>NULL</precedingExtension>

      <object>

         <type>maxView:Host</type>

         <icon>#{hostIcon}</icon>

         <!-- relationsViewId references the "related items view" extension created

         by the objectViewTemplate -->

         <relationsViewId>com.pmc.maxview.host.related</relationsViewId>

         <relationSpecs>

            <com.vmware.ui.relateditems.model.RelationSpec>

               <id>controllerForHost</id>

               <icon>#{ctrlIcon}</icon>

               <label>#{controllerLabel}</label>

               <relation>controller</relation>

               <targetType>maxView:Controller</targetType>

               <!-- listViewId must be defined for the array device's Related Objects

               tab to show a list of related Controller -->

               <listViewId>com.pmc.maxview.controller.list</listViewId>

            </com.vmware.ui.relateditems.model.RelationSpec>

         </relationSpecs>

      </object>

   </extension>

   <!--

      Controller columns, displayed in the Objects tab list or the Logical, Physical and Enclosure's Related Objects.

      The ColumnSetContainer object is defined in xml instead of using a separate Flex

      class for upward compatibility with future versions.

   -->

   <extension id="com.pmc.maxview.host.list.sampleColumns">

      <!-- This extension point is created by objectViewTemplate above -->

      <extendedPoint>com.pmc.maxview.host.list.columns</extendedPoint>

      <precedingExtension>NULL</precedingExtension>

      <object>

         <!-- XML representation of com.vmware.ui.lists.ColumnSetContainer -->

         <items>

            <!-- Controller name column -->

            <com.vmware.ui.lists.ColumnContainer>

               <uid>com.pmc.maxview.host.column.name</uid>

               <dataInfo>

                  <com.vmware.ui.lists.ColumnDataSourceInfo>

                     <!-- Column header -->

                     <headerText>#{name}</headerText>

                     <!-- Object property whose text value will be displayed (array of 1 element) -->

                     <requestedProperties>

                        <String>name</String>

                     </requestedProperties>

                     <!-- Use sortProperty to allow column to be sorted with header click -->

                     <sortProperty>name</sortProperty>

                     <!-- Use exportProperty to allow column data to be exported -->

                     <exportProperty>name</exportProperty>

                  </com.vmware.ui.lists.ColumnDataSourceInfo>

               </dataInfo>

            </com.vmware.ui.lists.ColumnContainer>

            <!-- Controller Mode column -->

            <com.vmware.ui.lists.ColumnContainer>

               <uid>com.pmc.maxview.host.column.status</uid>

               <dataInfo>

                  <com.vmware.ui.lists.ColumnDataSourceInfo>

                     <headerText>Status</headerText>

                     <requestedProperties>

                        <String>status</String>

                     </requestedProperties>

                     <exportProperty>status</exportProperty>

                  </com.vmware.ui.lists.ColumnDataSourceInfo>

               </dataInfo>

            </com.vmware.ui.lists.ColumnContainer>

            <!-- Controller Status column -->

            <com.vmware.ui.lists.ColumnContainer>

               <uid>com.pmc.maxview.host.column.ipAddress</uid>

               <dataInfo>

                  <com.vmware.ui.lists.ColumnDataSourceInfo>

                     <requestedProperties>

                        <String>ipAddress</String>

                     </requestedProperties>

                     <exportProperty>ipAddress</exportProperty>

                     <headerText>IP Address</headerText>

                  </com.vmware.ui.lists.ColumnDataSourceInfo>

               </dataInfo>

            </com.vmware.ui.lists.ColumnContainer>

         </items>

      </object>

   </extension>

   <extension id="com.pmc.maxview.maxviewvsphere.host.iconLabelSpecCollection">

      <extendedPoint>vise.inventory.representationspecs</extendedPoint>

      <precedingExtension>NULL</precedingExtension>

      <object>

         <objectType>maxView:Host</objectType>

         <specCollection>

            <com.vmware.ui.objectrepresentation.model.IconLabelSpec>

               <iconId>#{hostOKIcon}</iconId>

               <conditions>

                  <com.vmware.data.query.PropertyConstraint>

                     <propertyName>iconStatus</propertyName>

                     <comparator>EQUALS</comparator>

                     <comparableValue>

                        <String>normal</String>

                     </comparableValue>

                  </com.vmware.data.query.PropertyConstraint>

               </conditions>

            </com.vmware.ui.objectrepresentation.model.IconLabelSpec>

            <com.vmware.ui.objectrepresentation.model.IconLabelSpec>

               <iconId>#{hostWarningIcon}</iconId>

               <conditions>

                  <com.vmware.data.query.PropertyConstraint>

                     <propertyName>iconStatus</propertyName>

                     <comparator>EQUALS</comparator>

                     <comparableValue>

                        <String>warning</String>

                     </comparableValue>

                  </com.vmware.data.query.PropertyConstraint>

               </conditions>

            </com.vmware.ui.objectrepresentation.model.IconLabelSpec>

            <com.vmware.ui.objectrepresentation.model.IconLabelSpec>

               <iconId>#{hostErrorIcon}</iconId>

               <conditions>

                  <com.vmware.data.query.PropertyConstraint>

                     <propertyName>iconStatus</propertyName>

                     <comparator>EQUALS</comparator>

                     <comparableValue>

                        <String>error</String>

                     </comparableValue>

                  </com.vmware.data.query.PropertyConstraint>

               </conditions>

            </com.vmware.ui.objectrepresentation.model.IconLabelSpec>

            <com.vmware.ui.objectrepresentation.model.IconLabelSpec>

               <iconId>#{hostIcon}</iconId>

               <conditions>

                  <com.vmware.data.query.PropertyConstraint>

                     <propertyName>iconStatus</propertyName>

                     <comparator>EQUALS</comparator>

                     <comparableValue>

                        <String>default</String>

                     </comparableValue>

                  </com.vmware.data.query.PropertyConstraint>

               </conditions>

            </com.vmware.ui.objectrepresentation.model.IconLabelSpec>

         </specCollection>

      </object>

   </extension>

   <extension id="com.pmc.maxview.host.listActionSet">

      <extendedPoint>vise.actions.sets</extendedPoint>

      <object>

         <actions>

            <!-- Create Chassis -->

            <com.vmware.actionsfw.ActionSpec>

               <uid>com.pmc.maxview.host.addHost</uid>

               <icon>#{hostAdd}</icon>

               <delegate>

                  <className>com.vmware.vsphere.client.HtmlPluginModalAction</className>

                  <object>

                     <root>

                        <!-- execute the action on client-side (html view in a modal dialog) -->

                        <actionUrl>/ui/maxViewVSphere/index.html?view=add-system-modal</actionUrl>

                        <dialogTitle>Add Host</dialogTitle>

                        <dialogSize>500,250</dialogSize>

                        <dialogIcon>#{hostAdd}</dialogIcon>

                     </root>

                  </object>

               </delegate>

               <!-- All context-less actions should be marked as private to prevent themfrom showing up in all menus.-->

               <privateAction>true</privateAction>

            </com.vmware.actionsfw.ActionSpec>

         </actions>

      </object>

   </extension>

   <extension id="com.pmc.maxview.host.actionSet">

      <extendedPoint>vise.actions.sets</extendedPoint>

      <object>

         <actions>

            <!-- Delete Chassis -->

            <com.vmware.actionsfw.ActionSpec>

               <uid>com.pmc.maxview.host.deleteHost</uid>

               <icon>#{hostDelete}</icon>

               <delegate>

                  <className>com.vmware.vsphere.client.HtmlPluginModalAction</className>

                  <object>

                     <root>

                        <!-- execute the action on client-side (html view in a modal dialog) -->

                        <actionUrl>/ui/maxViewVSphere/index.html?view=delete-system-modal</actionUrl>

                        <dialogTitle>Delete Host</dialogTitle>

                        <dialogSize>500,325</dialogSize>

                        <dialogIcon>#{hostDelete}</dialogIcon>

                     </root>

                  </object>

               </delegate>

               <!-- All context-less actions should be marked as private to prevent themfrom showing up in all menus.-->

               <privateAction>true</privateAction>

            </com.vmware.actionsfw.ActionSpec>

         </actions>

      </object>

      <metadata>

         <!-- This filters the actions to be visible only on Chassis -->

         <objectType>maxView:Host</objectType>

      </metadata>

   </extension>

<!-- UI info associated with the controller type owned by this plugin.

      This is mainly used in conjonction with prioritization extensions, to verify that

      only this plugin can modify prioritization settings on controller -->

   <extension id="com.pmc.maxview.host.objectType">

      <extendedPoint>vsphere.core.objectTypes</extendedPoint>

      <precedingExtension>NULL</precedingExtension>

      <object>

         <types>

            <String>maxView:Host</String>

         </types>

         <label>Host</label>

         <labelPlural>Hosts</labelPlural>

         <icon>#{hostIcon}</icon>

      </object>

   </extension>

   <extension id="com.pmc.maxview.host.listAction">

      <extendedPoint>vmware.prioritization.listActions</extendedPoint>

      <object>

         <prioritizedIds>

            <String>com.pmc.maxview.host.addHost</String>

         </prioritizedIds>

         <regionId>com.pmc.maxview.host.list</regionId>

      </object>

   </extension>

   <extension id="com.pmc.maxview.host.promotedActions">

      <extendedPoint>vmware.prioritization.actions</extendedPoint>

      <object>

         <prioritizedIds>

            <String>com.pmc.maxview.host.deleteHost</String>

         </prioritizedIds>

         <regionId>com.pmc.maxview.host.list</regionId>

         <actionTargetTypes>

            <String>maxView:Host</String>

         </actionTargetTypes>

      </object>

   </extension>

vSphere plugin HTML.png

0 Kudos
sujeetmkalaskar
Enthusiast
Enthusiast

Hi _vladi_​,

Can you please check the above code and tell me what I am missing?

Thanks,

Sujeet Kalaskar

0 Kudos
_vladi_
VMware Employee
VMware Employee

Hi Sujeet,

The other possibility is that you are missing the mapping to "samples:ChassisB" in the DataProvider:

@type("HostSystem,samples:Rack,samples:ChassisB") // declares the supported object types.

public class ChassisRackVSphereDataAdapter implements DataProviderAdapter { ...

This is required so that the DataService knows who delivers this object types and can execute any filtering.

Please let me know if this works.

Cheers,

Vladi

0 Kudos
sujeetmkalaskar
Enthusiast
Enthusiast

Hi _vladi_​,

This mapping is already done as "maxView:Host".

Untitled.png

Thanks,

Sujeet Kalaskar

0 Kudos
_vladi_
VMware Employee
VMware Employee

Then you need to see if your provider actually gets created and called. You can debug it or add logging to see if the DataService calls it.

0 Kudos