Skip to content
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

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

trusz
Copy link
Member

@trusz trusz commented Dec 15, 2024

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 the src 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.

@@ -311,57 +181,22 @@ export class OpenSCD extends LitElement {

connectedCallback(): void {
super.connectedCallback();
this.loadPlugins()
Copy link
Member Author

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: () => {
Copy link
Member Author

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}
Copy link
Member Author

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
Copy link
Member Author

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';
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

file was missing.

Copy link
Contributor

PR Preview Action v1.4.8
🚀 Deployed preview to https://openscd.github.io/open-scd/pr-preview/pr-1611/
on branch gh-pages at 2024-12-16 22:33 UTC

Comment on lines +6 to +13
{
name: 'Launcher',
src: 'http://localhost:50714/index.js',
icon: 'launch',
default: true,
kind: 'editor',
requireDoc: true,
},
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove this

@Sander3003 Sander3003 requested a review from clepski January 8, 2025 09:41
Comment on lines +3 to +6
function getDataModelChildren(parent: Element): Element[] {
if (['LDevice', 'Server'].includes(parent.tagName))
return Array.from(parent.children).filter(
child =>
Copy link
Collaborator

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``,
Copy link
Collaborator

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?

Comment on lines +397 to +425
// 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);
// }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this be removed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants