Skip to content

Commit 1697d6f

Browse files
authored
Enable Additional Plugins (#334)
1 parent 3f58be7 commit 1697d6f

File tree

3 files changed

+36
-28
lines changed

3 files changed

+36
-28
lines changed

config.js

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -353,19 +353,23 @@
353353
* Plugin Support
354354
* Example configuration:
355355
* plugins: {
356-
// Simple enable
356+
// Simple enable:
357+
// openmct.plugins.anotherPlugin()
357358
anotherPlugin: {
358359
enabled: true
359360
},
360-
// Enable with options
361-
configuredPlugin: {
361+
// Enable with options:
362+
// openmct.plugins.ConfiguredPlugin({setting1: 'value1', setting2: 'value2'}, 1000)
363+
// 1000 is passed as the second argument to the plugin constructor
364+
ConfiguredPlugin: {
362365
enabled: true,
363366
// these are passed as arguments to the plugin constructor
364367
configuration: [
365368
{
366369
setting1: 'value1',
367370
setting2: 'value2'
368-
}
371+
},
372+
1000
369373
]
370374
}
371375
}
@@ -379,6 +383,25 @@
379383
},
380384
BarChart: {
381385
enabled: false
386+
},
387+
ScatterPlot: {
388+
enabled: false
389+
},
390+
Timeline: {
391+
enabled: false
392+
},
393+
Timelist: {
394+
enabled: false
395+
},
396+
PlanLayout: {
397+
enabled: false,
398+
configuration: [
399+
{
400+
name: 'Gantt Chart',
401+
creatable: true,
402+
namespace: '' // namespace to use for the activity state object
403+
}
404+
]
382405
}
383406
},
384407

loader.js

Lines changed: 8 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@ define([
2929
IdentityProvider,
3030
MCWSPersistenceProviderPlugin
3131
) {
32-
const ALLOWED_OPTIONAL_PLUGINS = ['BarChart'];
33-
3432
function loader(config) {
3533
let persistenceLoaded;
3634
const persistenceLoadedPromise = new Promise((resolve) => {
@@ -124,30 +122,17 @@ define([
124122
openmct.install(openmct.plugins.SummaryWidget());
125123
}
126124

127-
const pluginErrors = [];
128-
const pluginsToInstall = Object.entries(config.plugins).filter(([plugin, pluginConfig]) => {
129-
const isSummaryWidget = plugin === 'summaryWidgets';
130-
const allowedPlugin = ALLOWED_OPTIONAL_PLUGINS.includes(plugin);
125+
Object.entries(config.plugins).forEach(([plugin, pluginConfig]) => {
126+
const pluginExists = openmct.plugins[plugin] || openmct.plugins.example[plugin];
131127
const pluginEnabled = pluginConfig?.enabled;
128+
const isSummaryWidget = plugin === 'summaryWidgets';
129+
const installPlugin = pluginExists && pluginEnabled && !isSummaryWidget;
132130

133-
if (!allowedPlugin && !isSummaryWidget) {
134-
pluginErrors.push(plugin);
131+
if (installPlugin) {
132+
openmct.install(openmct.plugins[plugin](...(pluginConfig.configuration ?? [])));
133+
} else if (!pluginExists) {
134+
console.warn(`Plugin ${plugin} does not exist. Check the plugin name and try again.`);
135135
}
136-
137-
return allowedPlugin && pluginEnabled && !isSummaryWidget;
138-
});
139-
140-
// Warn if any plugins are not supported
141-
if (pluginErrors.length > 0) {
142-
console.warn(
143-
`Unable to install plugins: ${pluginErrors.join(', ')}. Please verify the plugin name is correct and is included in the supported plugins list. Available plugins: ${ALLOWED_OPTIONAL_PLUGINS.join(', ')}`
144-
);
145-
}
146-
147-
pluginsToInstall.forEach(([plugin, pluginConfig]) => {
148-
const { configuration = [] } = pluginConfig;
149-
150-
openmct.install(openmct.plugins[plugin](...configuration));
151136
});
152137
}
153138

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
"mini-css-extract-plugin": "2.7.6",
4141
"moment": "2.30.1",
4242
"node-bourbon": "^4.2.3",
43-
"openmct": "github:nasa/openmct#omm-release/5.4.0",
43+
"openmct": "github:nasa/openmct#omm-r5.4.0-rc1",
4444
"prettier": "3.4.2",
4545
"printj": "1.3.1",
4646
"raw-loader": "^0.5.1",

0 commit comments

Comments
 (0)