diff --git a/packages/dashboard-core-plugins/src/panels/ConsolePanel.tsx b/packages/dashboard-core-plugins/src/panels/ConsolePanel.tsx
index f5889039c6..25998a7dd6 100644
--- a/packages/dashboard-core-plugins/src/panels/ConsolePanel.tsx
+++ b/packages/dashboard-core-plugins/src/panels/ConsolePanel.tsx
@@ -23,7 +23,7 @@ import {
RootState,
} from '@deephaven/redux';
import { assertNotNull } from '@deephaven/utils';
-import { getIconForType, pluginSupportsType } from '@deephaven/plugin';
+import { getIconForPlugin, pluginSupportsType } from '@deephaven/plugin';
import type { JSZipObject } from 'jszip';
import { ConsoleEvent } from '../events';
import Panel from './Panel';
@@ -326,9 +326,9 @@ export class ConsolePanel extends PureComponent<
const { plugins } = this.props;
const plugin = [...plugins.values()].find(p => pluginSupportsType(p, type));
if (plugin != null) {
- return getIconForType(plugin, type);
+ return getIconForPlugin(plugin);
}
- // TODO: #1573 Remove this default and always return getIconForType
+ // TODO: #1573 Remove this default and always return getIconForPlugin
return ;
}
diff --git a/packages/plugin/src/PluginUtils.test.tsx b/packages/plugin/src/PluginUtils.test.tsx
new file mode 100644
index 0000000000..27bbac972e
--- /dev/null
+++ b/packages/plugin/src/PluginUtils.test.tsx
@@ -0,0 +1,60 @@
+import React from 'react';
+import { dhTruck, vsPreview } from '@deephaven/icons';
+import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
+import { DashboardPlugin, PluginType, type WidgetPlugin } from './PluginTypes';
+import { pluginSupportsType, getIconForPlugin } from './PluginUtils';
+
+function TestWidget() {
+ return
TestWidget
;
+}
+
+const widgetPlugin: WidgetPlugin = {
+ name: 'test-widget-plugin',
+ type: PluginType.WIDGET_PLUGIN,
+ component: TestWidget,
+ supportedTypes: ['test-widget', 'test-widget-two'],
+};
+
+const dashboardPlugin: DashboardPlugin = {
+ name: 'test-widget-plugin',
+ type: PluginType.DASHBOARD_PLUGIN,
+ component: TestWidget,
+};
+
+test('pluginSupportsType', () => {
+ expect(pluginSupportsType(widgetPlugin, 'test-widget')).toBe(true);
+ expect(pluginSupportsType(widgetPlugin, 'test-widget-two')).toBe(true);
+ expect(pluginSupportsType(widgetPlugin, 'test-widget-three')).toBe(false);
+ expect(pluginSupportsType(dashboardPlugin, 'test-widget')).toBe(false);
+ expect(pluginSupportsType(undefined, 'test-widget')).toBe(false);
+});
+
+const DEFAULT_ICON = ;
+
+describe('getIconForPlugin', () => {
+ test('default icon', () => {
+ expect(getIconForPlugin(widgetPlugin)).toEqual(DEFAULT_ICON);
+ });
+
+ test('default icon for non-widget plugin', () => {
+ expect(getIconForPlugin(dashboardPlugin)).toEqual(DEFAULT_ICON);
+ });
+
+ test('custom icon', () => {
+ const customIcon = ;
+ const customWidgetPlugin: WidgetPlugin = {
+ ...widgetPlugin,
+ icon: dhTruck,
+ };
+ expect(getIconForPlugin(customWidgetPlugin)).toEqual(customIcon);
+ });
+
+ test('custom icon element', () => {
+ const customIcon = Test
;
+ const customWidgetPlugin: WidgetPlugin = {
+ ...widgetPlugin,
+ icon: customIcon,
+ };
+ expect(getIconForPlugin(customWidgetPlugin)).toEqual(customIcon);
+ });
+});
diff --git a/packages/plugin/src/PluginUtils.tsx b/packages/plugin/src/PluginUtils.tsx
index 1798450a15..6fa9024153 100644
--- a/packages/plugin/src/PluginUtils.tsx
+++ b/packages/plugin/src/PluginUtils.tsx
@@ -14,19 +14,15 @@ export function pluginSupportsType(
return [plugin.supportedTypes].flat().some(t => t === type);
}
-export function getIconForType(
- plugin: PluginModule | undefined,
- type: string
-): React.ReactElement {
+export function getIconForPlugin(plugin: PluginModule): React.ReactElement {
const defaultIcon = ;
- if (plugin == null || !isWidgetPlugin(plugin)) {
+ if (!isWidgetPlugin(plugin)) {
return defaultIcon;
}
- const supportsType = pluginSupportsType(plugin, type);
const { icon } = plugin;
- if (!supportsType || icon == null) {
+ if (icon == null) {
return defaultIcon;
}