Deployed c609ea1d9 to master with MkDocs 1.1.2 and mike 0.5.5

This commit is contained in:
GitHub Action committed 2020-12-15 04:05:16 +00:00
1 parent 3c37cd52fa
commit b0d93df5a4
196 files changed
+3475 -3433

No files matched your search

@@ -603,6 +603,13 @@
<nav class="md-nav" aria-label="LensMainExtension Class">
<ul class="md-nav__list">
<li class="md-nav__item">
<a href="#onactivate-and-ondeactivate-methods" class="md-nav__link">
onActivate() and onDeactivate() Methods
</a>
</li>
<li class="md-nav__item">
<a href="#appmenus" class="md-nav__link">
appMenus
@@ -876,6 +883,13 @@
<nav class="md-nav" aria-label="LensMainExtension Class">
<ul class="md-nav__list">
<li class="md-nav__item">
<a href="#onactivate-and-ondeactivate-methods" class="md-nav__link">
onActivate() and onDeactivate() Methods
</a>
</li>
<li class="md-nav__item">
<a href="#appmenus" class="md-nav__link">
appMenus
@@ -903,8 +917,9 @@
<h1 id="main-extension">Main Extension<a class="headerlink" href="#main-extension" title="Permanent link">#</a></h1>
<p>The main extension api is the interface to Lens' main process (Lens runs in main and renderer processes). It allows you to access, configure, and customize Lens data, add custom application menu items, and generally run custom code in Lens' main process.</p>
<p>The Main Extension API is the interface to Lens's main process. Lens runs in both main and renderer processes. The Main Extension API allows you to access, configure, and customize Lens data, add custom application menu items, and run custom code in Lens's main process.</p>
<h2 id="lensmainextension-class"><code>LensMainExtension</code> Class<a class="headerlink" href="#lensmainextension-class" title="Permanent link">#</a></h2>
<h3 id="onactivate-and-ondeactivate-methods"><code>onActivate()</code> and <code>onDeactivate()</code> Methods<a class="headerlink" href="#onactivate-and-ondeactivate-methods" title="Permanent link">#</a></h3>
<p>To create a main extension simply extend the <code>LensMainExtension</code> class:</p>
<div class="highlight"><pre><span></span><code><span class="kr">import</span> <span class="p">{</span> <span class="nx">LensMainExtension</span> <span class="p">}</span> <span class="nx">from</span> <span class="s2">&quot;@k8slens/extensions&quot;</span><span class="p">;</span>
@@ -918,8 +933,14 @@
<span class="p">}</span>
<span class="p">}</span>
</code></pre></div>
<p>There are two methods that you can implement to facilitate running your custom code. <code>onActivate()</code> is called when your extension has been successfully enabled. By implementing <code>onActivate()</code> you can initiate your custom code. <code>onDeactivate()</code> is called when the extension is disabled (typically from the <a href="">Lens Extensions Page</a>) and when implemented gives you a chance to clean up after your extension, if necessary. The example above simply logs messages when the extension is enabled and disabled. Note that to see standard output from the main process there must be a console connected to it. This is typically achieved by starting Lens from the command prompt.</p>
<p>The following example is a little more interesting in that it accesses some Lens state data and periodically logs the name of the currently active cluster in Lens.</p>
<p>Two methods enable you to run custom code: <code>onActivate()</code> and <code>onDeactivate()</code>. Enabling your extension calls <code>onActivate()</code> and disabling your extension calls <code>onDeactivate()</code>. You can initiate custom code by implementing <code>onActivate()</code>. Implementing <code>onDeactivate()</code> gives you the opportunity to clean up after your extension.</p>
<p>Disable extensions from the Lens Extensions page:</p>
<ol>
<li>Navigate to <strong>File</strong> &gt; <strong>Extensions</strong> in the top menu bar. (On Mac, it is <strong>Lens</strong> &gt; <strong>Extensions</strong>.)</li>
<li>Click <strong>Disable</strong> on the extension you want to disable.</li>
</ol>
<p>The example above logs messages when the extension is enabled and disabled. To see standard output from the main process there must be a console connected to it. Achieve this by starting Lens from the command prompt.</p>
<p>The following example is a little more interesting. It accesses some Lens state data, and it periodically logs the name of the cluster that is currently active in Lens.</p>
<div class="highlight"><pre><span></span><code><span class="kr">import</span> <span class="p">{</span> <span class="nx">LensMainExtension</span><span class="p">,</span> <span class="nx">Store</span> <span class="p">}</span> <span class="nx">from</span> <span class="s2">&quot;@k8slens/extensions&quot;</span><span class="p">;</span>
<span class="kr">const</span> <span class="nx">clusterStore</span> <span class="o">=</span> <span class="nx">Store</span><span class="p">.</span><span class="nx">clusterStore</span>
@@ -945,9 +966,9 @@
<span class="p">}</span>
<span class="p">}</span>
</code></pre></div>
<p>See the <a href="../stores">Stores</a> guide for more details on accessing Lens state data.</p>
<p>For more details on accessing Lens state data, please see the <a href="../stores">Stores</a> guide.</p>
<h3 id="appmenus"><code>appMenus</code><a class="headerlink" href="#appmenus" title="Permanent link">#</a></h3>
<p>The only UI feature customizable in the main extension api is the application menu. Custom menu items can be inserted and linked to custom functionality, such as navigating to a specific page. The following example demonstrates adding a menu item to the Help menu.</p>
<p>The Main Extension API allows you to customize the UI application menu. Note that this is the only UI feature that the Main Extension API allows you to customize. The following example demonstrates adding an item to the <strong>Help</strong> menu.</p>
<div class="highlight"><pre><span></span><code><span class="kr">import</span> <span class="p">{</span> <span class="nx">LensMainExtension</span> <span class="p">}</span> <span class="nx">from</span> <span class="s2">&quot;@k8slens/extensions&quot;</span><span class="p">;</span>
<span class="kr">export</span> <span class="k">default</span> <span class="kr">class</span> <span class="nx">SamplePageMainExtension</span> <span class="kr">extends</span> <span class="nx">LensMainExtension</span> <span class="p">{</span>
@@ -962,7 +983,12 @@
<span class="p">]</span>
<span class="p">}</span>
</code></pre></div>
<p><code>appMenus</code> is an array of objects satisfying the <code>MenuRegistration</code> interface. <code>MenuRegistration</code> extends React's <code>MenuItemConstructorOptions</code> interface. <code>parentId</code> is the id of the menu to put this menu item under (todo: is this case sensitive and how do we know what the available ids are?), <code>label</code> is the text to show on the menu item, and <code>click()</code> is called when the menu item is selected. In this example we simply log a message, but typically you would navigate to a specific page or perform some operation. Pages are associated with the <a href="../renderer-extension/"><code>LensRendererExtension</code></a> class and can be defined when you extend it. </p>
<p><code>appMenus</code> is an array of objects that satisfy the <code>MenuRegistration</code> interface. <code>MenuRegistration</code> extends React's <code>MenuItemConstructorOptions</code> interface. The properties of the appMenus array objects are defined as follows:</p>
<ul>
<li><code>parentId</code> is the name of the menu where your new menu item will be listed. Valid values include: <code>"file"</code>, <code>"edit"</code>, <code>"view"</code>, and <code>"help"</code>. <code>"lens"</code> is valid on Mac only.</li>
<li><code>label</code> is the name of your menu item.</li>
<li><code>click()</code> is called when the menu item is selected. In this example, we simply log a message. However, you would typically have this navigate to a specific page or perform another operation. Note that pages are associated with the <a href="../renderer-extension/"><code>LensRendererExtension</code></a> class and can be defined in the process of extending it. </li>
</ul>