How to open my plugin contents in a new tab in the Mattermost desktop app

122 Views Asked by At

I’m developing a plugin for Mattermsot which shows an iframe and the contents I need inside the iframe, Currently, I have managed to register this as a product and now it shows in the product switcher, enter image description here

When I click the Iframe button it opens the Iframe in the same window as the channels, What I need is open it from a new tab similar to boards and playbooks in the Mattermost desktop app, in the web browser it can be as it is now.

Thank you for your support.

Here is my plugin code

import React from 'react';


let iframeURL = "https://codepen.io/rdesigncode/details/zYPzaqb"
const customRoute = '/myplugin';


class myplugin{
  

    initialize(registry, store) {

      

      const IframeComponent = () => {
        return (
          <iframe src={iframeURL} height="100%" width="100%" title="myplugin"></iframe> 
        );
      };


    registry.registerProduct(
      customRoute,
      'kanban',
      "IFrame",
      customRoute,
      IframeComponent,
      'headerCentreComponent',
      'headerRightComponent',
      true,
      true,
      true
    );

        }
      }
window.registerPlugin('myplugin', new myplugin());
1

There are 1 best solutions below

4
user1874594 On

When you click the Iframe button, it opens the Iframe in the same window as the channels. You would like to open it from a new tab similar to boards and playbooks in the Mattermost desktop app. Currently this isn't not supported by Mattermost desktop app. one alternative could be to open the contents of your plugin in a new window instead of a new tab, using JavaScript ( open a new window with the desired URL when the user clicks on the Iframe button ) . See below

const openInNewWindow = () => {
    window.open(iframeURL, '_blank', 'location=yes,height=570,width=520,scrollbars=yes,status=yes');
}

call this function when the user clicks on the Iframe button to open the contents of your plugin in a new window.