Use local-plugin in plugin manager

pull/3094/head
Grandschtroumpf 6 years ago committed by yann300
parent 89c47c789c
commit c552b3bdaf
  1. 29
      src/app/components/plugin-manager-component.js

@ -1,16 +1,23 @@
const yo = require('yo-yo') const yo = require('yo-yo')
const csjs = require('csjs-inject') const csjs = require('csjs-inject')
const EventEmitter = require('events') const EventEmitter = require('events')
const LocalPlugin = require('./local-plugin')
import { Plugin } from 'remix-plugin'
const css = csjs` const css = csjs`
.pluginSearch { .pluginSearch {
display: flex;
flex-direction: column;
align-items: center;
background-color: var(--light); background-color: var(--light);
padding: 10px; padding: 10px;
position: sticky; position: sticky;
top: 0; top: 0;
z-index: 2; z-index: 2;
} }
.localPluginBtn {
margin-top: 10px;
}
.displayName { .displayName {
text-transform: capitalize; text-transform: capitalize;
} }
@ -35,6 +42,7 @@ class PluginManagerComponent {
root: null, root: null,
items: {} items: {}
} }
this.localPlugin = new LocalPlugin()
this.filter = '' this.filter = ''
} }
@ -89,6 +97,20 @@ class PluginManagerComponent {
` `
} }
/***************
* SUB-COMPONENT
*/
/**
* Add a local plugin to the list of plugins
*/
async openLocalPlugin() {
const profile = await this.localPlugin.open(this.store.getAll())
const resolveLocaton = (iframe) => this.appManager.resolveLocation(profile, iframe)
const api = new Plugin(profile, { resolveLocaton })
this.appManager.init([{profile, api}])
console.log(this.store)
}
render () { render () {
// Filtering helpers // Filtering helpers
const isFiltered = ({profile}) => profile.name.toLowerCase().includes(this.filter) const isFiltered = ({profile}) => profile.name.toLowerCase().includes(this.filter)
@ -128,7 +150,10 @@ class PluginManagerComponent {
const rootView = yo` const rootView = yo`
<div id='pluginManager'> <div id='pluginManager'>
<div class="form-group ${css.pluginSearch}"> <div class="form-group ${css.pluginSearch}">
<input onkeyup="${e => this.filterPlugins(e)}" class="form-control" placeholder='Search'> <input onkeyup="${e => this.filterPlugins(e)}" class="form-control" placeholder="Search">
<button onclick="${_ => this.openLocalPlugin()}" class="btn btn-sm ${css.localPluginBtn}">
Connect to a Local Plugin
</button>
</div> </div>
<section> <section>
${activeTile} ${activeTile}

Loading…
Cancel
Save