<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 14 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p
        {mso-style-priority:99;
        margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
span.EmailStyle20
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1F497D">Hi Vojtech,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1F497D"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1F497D">Sorry for the late reply. This API looks perfect for our needs. I look forward to getting access to it and trying it out.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1F497D"><o:p>&nbsp;</o:p></span></p>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1F497D">-Chris<o:p></o:p></span></p>
</div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1F497D"><o:p>&nbsp;</o:p></span></p>
<div>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:&quot;Tahoma&quot;,&quot;sans-serif&quot;">From:</span></b><span style="font-size:10.0pt;font-family:&quot;Tahoma&quot;,&quot;sans-serif&quot;"> engine-devel-bounces@ovirt.org [mailto:engine-devel-bounces@ovirt.org]
<b>On Behalf Of </b>Vojtech Szocs<br>
<b>Sent:</b> Friday, October 12, 2012 9:04 AM<br>
<b>To:</b> engine-devel<br>
<b>Subject:</b> [Engine-devel] Update on UI Plugins: context-sensitive button API preview<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
<div>
<p class="MsoNormal" style="margin-bottom:12.0pt"><span style="color:black">Hi guys,<br>
<br>
I've been working on implementing &quot;custom context-sensitive button / menu item&quot; plugin API feature recently, and wanted to share some code with you.<br>
<br>
Here's a sample code that adds &quot;Do something with selected host(s)&quot; button to Hosts main tab data grid:<br>
<br>
</span><span style="font-family:&quot;Courier New&quot;;color:black">api.register({<br>
&nbsp; UiInit: function() {</span><span style="color:black"><br>
</span><span style="font-family:&quot;Courier New&quot;;color:black"><br>
&nbsp;&nbsp;&nbsp; api.</span><b><span style="font-family:&quot;Courier New&quot;;color:#3333FF">addMainTabActionButton</span></b><span style="font-family:&quot;Courier New&quot;;color:black">('Host', 'Do something with selected host(s)', {</span><span style="color:black"><br>
</span><span style="font-family:&quot;Courier New&quot;;color:black"><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><b><span style="font-family:&quot;Courier New&quot;;color:#CC33CC">onClick</span></b><span style="font-family:&quot;Courier New&quot;;color:black">: function() {<br>
</span><span style="font-family:&quot;Courier New&quot;;color:#006600">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // 'arguments' contain host entities currently selected<br>
</span><span style="font-family:&quot;Courier New&quot;;color:black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; window.alert(arguments.length &#43; ' host(s) selected');<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; window.alert('first selected host ID = ' &#43; arguments[0].entityId);<br>
<br>
</span><span style="font-family:&quot;Courier New&quot;;color:#006600">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // Open new popup window<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // In future, we might use &quot;dialog UI&quot; plugin API here<br>
</span><span style="font-family:&quot;Courier New&quot;;color:black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; window.open('http://example.com', '_blank');<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; },</span><span style="color:black"><br>
</span><span style="font-family:&quot;Courier New&quot;;color:black"><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><b><span style="font-family:&quot;Courier New&quot;;color:#CC33CC">isEnabled</span></b><span style="font-family:&quot;Courier New&quot;;color:black">: function() {<br>
</span><span style="font-family:&quot;Courier New&quot;;color:#006600">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // 'true' means the button is enabled and clickable (default)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // 'false' means the button is disabled and non-clickable<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // Enable button only when the number of selected items &gt; 0<br>
</span><span style="font-family:&quot;Courier New&quot;;color:black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return arguments.length &gt; 0;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; },</span><span style="color:black"><br>
</span><span style="font-family:&quot;Courier New&quot;;color:black"><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><b><span style="font-family:&quot;Courier New&quot;;color:#CC33CC">isAccessible</span></b><span style="font-family:&quot;Courier New&quot;;color:black">: function() {<br>
</span><span style="font-family:&quot;Courier New&quot;;color:#006600">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // 'true' means the button is visible (default)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // 'false' means the button is hidden<br>
</span><span style="font-family:&quot;Courier New&quot;;color:black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return true;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</span><span style="color:black"><br>
</span><span style="font-family:&quot;Courier New&quot;;color:black"><br>
&nbsp;&nbsp;&nbsp; });</span><span style="color:black"><br>
</span><span style="font-family:&quot;Courier New&quot;;color:black"><br>
&nbsp; }<br>
});<br>
</span><span style="color:black"><br>
The signature of <strong>addMainTabActionButton</strong> plugin API function is following:<br>
<br>
</span><span style="font-family:&quot;Courier New&quot;;color:black">addMainTabActionButton(entityTypeName, label, actionButtonInterface)</span><span style="color:black"><br>
<br>
<em>entityTypeName</em> indicates which main tab the button should be added to, e.g. &quot;Host&quot; for Host main tab. [Quick question for NetApp guys: do we want to support all main tab entity types?]<br>
<br>
<i>label</i> is the title displayed on the button.<br>
<br>
<i>actionButtonInterface</i> represents an object that &quot;implements the button interface&quot; by declaring its functions:
<i>onClick</i>, <i>isEnabled</i>, <i>isAccessible</i>. Since JavaScript language uses different techniques and syntax to achieve OOP programming model, I've decided to keep things simple and stay with plain objects containing functions. While some JavaScript
 guru could advocate different approach, from WebAdmin vs. plugin integration perspective, the above mentioned approach is the easiest way. I'm also interested to hear your opinion on this.<br>
<br>
All functions of <i>actionButtonInterface</i> receive currently selected item(s) as function arguments. Within a JavaScript function, &quot;arguments&quot; represents an implicit array of its arguments.<br>
<br>
For now, WebAdmin will pass simple JSON-like objects to these functions, for example:<br>
<br>
</span><span style="font-family:&quot;Courier New&quot;;color:black">{ entityId: &quot;&lt;whatever&gt;&quot; }</span><span style="color:black"><br>
<br>
In future, we can extend or modify this concept to match the contract of various oVirt REST API entities.<br>
<br>
This feature will be part of UI Plugins PoC rev.6, which should come out next week.<br>
<br>
Regards,<br>
Vojtech<o:p></o:p></span></p>
</div>
</div>
</body>
</html>