-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat: Programatic Plugin Activation #1611
base: main
Are you sure you want to change the base?
Conversation
@@ -311,57 +181,22 @@ export class OpenSCD extends LitElement { | |||
|
|||
connectedCallback(): void { | |||
super.connectedCallback(); | |||
this.loadPlugins() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
initial loading of plugins has been revamped
return { | ||
...plugin, | ||
content: staticTagHtml`<${tag} | ||
content: () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the content is now a function so we regenerate the content if params change
.doc=${this.doc} | ||
.docName=${this.docName} | ||
.editCount=${this.historyState.editCount} | ||
.plugins=${this.storedPlugins} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we pass in the whole plugins config, so plugins can access their own and others plugins' config
@@ -52,176 +53,45 @@ import { InstalledOfficialPlugin, MenuPosition, PluginKind, Plugin } from "./plu | |||
import { ConfigurePluginEvent, ConfigurePluginDetail, newConfigurePluginEvent } from './plugin.events.js'; | |||
import { newLogEvent } from '@openscd/core/foundation/deprecated/history'; | |||
|
|||
// HOSTING INTERFACES |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This has been moved to the end of the file and other stuff got moved to up to promote quicker understanding of the structure and purpose of the file
@@ -0,0 +1,89 @@ | |||
import { crossProduct } from '../foundation.js'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
file was missing.
|
{ | ||
name: 'Launcher', | ||
src: 'http://localhost:50714/index.js', | ||
icon: 'launch', | ||
default: true, | ||
kind: 'editor', | ||
requireDoc: true, | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove this
function getDataModelChildren(parent: Element): Element[] { | ||
if (['LDevice', 'Server'].includes(parent.tagName)) | ||
return Array.from(parent.children).filter( | ||
child => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How is this file related to activating plugins?
@@ -155,6 +158,7 @@ export class OscdLayout extends LitElement { | |||
}, | |||
disabled: (): boolean => !this.historyState.canUndo, | |||
kind: 'static', | |||
content: () => html``, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the default for content
, so we don't have to set it right?
// private updatePlugins() { | ||
|
||
// const stored: Plugin[] = this.storedPlugins; | ||
// const officialStored = stored.filter(p => p.official); | ||
// const newOfficial: Array<Plugin | InstalledOfficialPlugin> = ( | ||
// builtinPlugins as Plugin[] | ||
// ) | ||
// .concat(this.parsedPlugins) | ||
// .filter(p => !officialStored.find(o => o.src === p.src)) | ||
// .map(plugin => { | ||
// return { | ||
// src: plugin.src, | ||
// installed: plugin.default ?? false, | ||
// official: true as const, | ||
// }; | ||
// }); | ||
|
||
// const oldOfficial = officialStored.filter( | ||
// p => | ||
// !(builtinPlugins as Plugin[]) | ||
// .concat(this.parsedPlugins) | ||
// .find(o => p.src === o.src) | ||
// ); | ||
// const newPlugins: Array<Plugin | InstalledOfficialPlugin> = stored.filter( | ||
// p => !oldOfficial.find(o => p.src === o.src) | ||
// ); | ||
// newOfficial.map(p => newPlugins.push(p)); | ||
// this.storePlugins(newPlugins); | ||
// } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this be removed?
The goal of the pull request is to allow plugins to switch to specific plugins.
For this an event was created that accepts the
name
and thesrc
of a plugin, as this is how we identify them.Furthermore, an additional event was created to allow plugins to "run" menu plugins.
Because menu plugins render inside the menu sidebar and they are only visible when the sidebar is open we open it too before running the menu plugin to make sure the users see the content. This is somewhat hacky and a better solution should be implemented in the future.