Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 28 additions & 5 deletions config.js
Original file line number Diff line number Diff line change
Expand Up @@ -374,19 +374,23 @@
* Plugin Support
* Example configuration:
* plugins: {
// Simple enable
// Simple enable:
// openmct.plugins.anotherPlugin()
anotherPlugin: {
enabled: true
},
// Enable with options
configuredPlugin: {
// Enable with options:
// openmct.plugins.ConfiguredPlugin({setting1: 'value1', setting2: 'value2'}, 1000)
// 1000 is passed as the second argument to the plugin constructor
ConfiguredPlugin: {
enabled: true,
// these are passed as arguments to the plugin constructor
configuration: [
{
setting1: 'value1',
setting2: 'value2'
}
},
1000
]
}
}
Expand All @@ -399,7 +403,26 @@
enabled: true
},
BarChart: {
enabled: false
enabled: true
},
ScatterPlot: {
enabled: true
},
Timeline: {
enabled: true
},
Timelist: {
enabled: true
},
PlanLayout: {
enabled: true,
configuration: [
{
name: 'Gantt Chart',
creatable: true,
namespace: '' // namespace to use for the activity state object
}
]
}
},

Expand Down
28 changes: 19 additions & 9 deletions loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ define([
IdentityProvider,
MCWSPersistenceProviderPlugin
) {
const ALLOWED_OPTIONAL_PLUGINS = ['BarChart'];
const TESTED_OPTIONAL_PLUGINS = ['BarChart', 'ScatterPlot', 'Timeline', 'Timelist', 'PlanLayout'];

function loader(config) {
let persistenceLoaded;
Expand Down Expand Up @@ -125,28 +125,38 @@ define([
}

const pluginErrors = [];
const untestedPlugins = [];
const pluginsToInstall = Object.entries(config.plugins).filter(([plugin, pluginConfig]) => {
const isSummaryWidget = plugin === 'summaryWidgets';
const allowedPlugin = ALLOWED_OPTIONAL_PLUGINS.includes(plugin);
const testedPlugin = TESTED_OPTIONAL_PLUGINS.includes(plugin);
const pluginExists = openmct.plugins[plugin] || openmct.plugins.example[plugin];
const pluginEnabled = pluginConfig?.enabled;
const isSummaryWidget = plugin === 'summaryWidgets';

if (!allowedPlugin && !isSummaryWidget) {
pluginErrors.push(plugin);
// summary widget is handled separately
if (!isSummaryWidget) {
if (!pluginExists) {
pluginErrors.push(plugin);
} else if (!testedPlugin) {
untestedPlugins.push(plugin);
}
}

return allowedPlugin && pluginEnabled && !isSummaryWidget;
return pluginExists && pluginEnabled && !isSummaryWidget;
});

// Warn if any plugins are not supported
if (pluginErrors.length > 0) {
console.warn(
`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(', ')}`
`Unable to install plugins: ${pluginErrors.join(', ')}. Please verify the plugin name is correct.`
);
}

pluginsToInstall.forEach(([plugin, pluginConfig]) => {
const { configuration = [] } = pluginConfig;
if (untestedPlugins.length > 0) {
console.warn(`Untested plugins: ${untestedPlugins.join(', ')}. Use at your own risk.`);
}

pluginsToInstall.forEach(([plugin, pluginConfig]) => {
const configuration = pluginConfig.configuration ?? [];
openmct.install(openmct.plugins[plugin](...configuration));
});
}
Expand Down