Skip to content

Commit 6ff378c

Browse files
authored
feat: Add JS Plugin Information (#2002)
Resolves #1374 Changes: - Added "Plugins" section to Settings sidebar, with the JS plugin and its corresponding version (see screenshot below) - Modified the `PluginMap` to be a mapping from a `string` to a `VersionedPluginModule`: which contains an optional `version` prop Screenshot of Change: ![image](https://github.com/deephaven/web-client-ui/assets/69530774/22f94c47-1d01-4dd4-b854-7f17576126dd)] The plugin information looks the same, just now, when we click "Copy versions", the info about the plugins is also copied
1 parent 3a6a439 commit 6ff378c

5 files changed

Lines changed: 58 additions & 8 deletions

File tree

packages/app-utils/src/plugins/PluginUtils.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,13 +110,13 @@ export async function loadModulePlugins(
110110
const pluginMap: PluginModuleMap = new Map();
111111
for (let i = 0; i < pluginModules.length; i += 1) {
112112
const module = pluginModules[i];
113-
const { name } = manifest.plugins[i];
113+
const { name, version } = manifest.plugins[i];
114114
if (module.status === 'fulfilled') {
115115
const moduleValue = getPluginModuleValue(module.value);
116116
if (moduleValue == null) {
117117
log.error(`Plugin '${name}' is missing an exported value.`);
118118
} else {
119-
pluginMap.set(name, moduleValue);
119+
pluginMap.set(name, { ...moduleValue, version });
120120
}
121121
} else {
122122
log.error(`Unable to load plugin '${name}'`, module.reason);

packages/code-studio/src/main/AppMainContainer.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1002,6 +1002,7 @@ export class AppMainContainer extends Component<
10021002
<SlideTransition in={isSettingsMenuShown} mountOnEnter unmountOnExit>
10031003
<SettingsMenu
10041004
serverConfigValues={serverConfigValues}
1005+
pluginData={plugins}
10051006
onDone={this.handleSettingsMenuHide}
10061007
user={user}
10071008
/>

packages/code-studio/src/settings/SettingsMenu.tsx

Lines changed: 38 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,22 @@ import {
2626
makeMessage,
2727
} from '@deephaven/jsapi-utils';
2828
import { assertNotNull } from '@deephaven/utils';
29+
import { PluginModuleMap } from '@deephaven/plugin';
2930
import FormattingSectionContent from './FormattingSectionContent';
3031
import LegalNotice from './LegalNotice';
3132
import SettingsMenuSection from './SettingsMenuSection';
3233
import ShortcutSectionContent from './ShortcutsSectionContent';
3334
import { exportLogs } from '../log/LogExport';
3435
import './SettingsMenu.scss';
3536
import ColumnSpecificSectionContent from './ColumnSpecificSectionContent';
36-
import { getFormattedVersionInfo } from './SettingsUtils';
37+
import {
38+
getFormattedPluginInfo,
39+
getFormattedVersionInfo,
40+
} from './SettingsUtils';
3741

3842
interface SettingsMenuProps {
3943
serverConfigValues: ServerConfigValues;
44+
pluginData: PluginModuleMap;
4045
user: User;
4146
onDone: () => void;
4247
}
@@ -125,16 +130,21 @@ export class SettingsMenu extends Component<
125130
}
126131

127132
handleExportSupportLogs(): void {
128-
const { serverConfigValues } = this.props;
129-
exportLogs(undefined, Object.fromEntries(serverConfigValues));
133+
const { serverConfigValues, pluginData } = this.props;
134+
const pluginInfo = getFormattedPluginInfo(pluginData);
135+
exportLogs(undefined, {
136+
...Object.fromEntries(serverConfigValues),
137+
pluginInfo,
138+
});
130139
}
131140

132141
render(): ReactElement {
133142
const supportLink = import.meta.env.VITE_SUPPORT_LINK;
134143
const docsLink = import.meta.env.VITE_DOCS_LINK;
135144

136-
const { serverConfigValues, user } = this.props;
145+
const { serverConfigValues, pluginData, user } = this.props;
137146
const versionInfo = getFormattedVersionInfo(serverConfigValues);
147+
const pluginInfo = getFormattedPluginInfo(pluginData);
138148
const deephavenVersion = serverConfigValues.get('deephaven.version');
139149
const copyShortcut = GLOBAL_SHORTCUTS.COPY_VERSION_INFO.getDisplayText();
140150

@@ -335,7 +345,10 @@ export class SettingsMenu extends Component<
335345
<CopyButton
336346
kind="inline"
337347
tooltip="Copy version numbers"
338-
copy={Object.entries(versionInfo)
348+
copy={Object.entries({
349+
...versionInfo,
350+
...pluginInfo,
351+
})
339352
.map(([key, value]) => `${key}: ${value}`)
340353
.join('\n')}
341354
>
@@ -345,6 +358,26 @@ export class SettingsMenu extends Component<
345358
</Tooltip>
346359
</span>
347360
</div>
361+
<div className="app-settings-footer-item">
362+
<div className="font-weight-bold">Plugins</div>
363+
<div className="container">
364+
{Array.from(pluginData.entries())
365+
.filter(plugin => plugin[1].version !== undefined)
366+
.map(([key, value]) => (
367+
<div
368+
key={key}
369+
className="row justify-content-start align-items-center"
370+
>
371+
<div className="col pl-0">
372+
<span className="my-0 text-truncate">{key}</span>
373+
</div>
374+
<div className="col-auto">
375+
<span>{value?.version}</span>
376+
</div>
377+
</div>
378+
))}
379+
</div>
380+
</div>
348381
<div className="app-settings-footer-item">
349382
<LegalNotice />
350383
</div>

packages/code-studio/src/settings/SettingsUtils.tsx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import type { dh as DhType } from '@deephaven/jsapi-types';
1010
import Log from '@deephaven/log';
1111
import type { ServerConfigValues } from '@deephaven/redux';
1212
import Bowser from 'bowser';
13+
import { PluginModuleMap } from '@deephaven/plugin';
1314

1415
const log = Log.module('SettingsUtils');
1516

@@ -58,6 +59,19 @@ export function getFormattedVersionInfo(
5859
};
5960
}
6061

62+
/**
63+
* Get an object containing all JS plugin information formatted for display
64+
* @param serverConfigValues The information for all plugins
65+
* @returns The formatted mapping from plugin name to version
66+
*/
67+
export function getFormattedPluginInfo(
68+
pluginDataValues: PluginModuleMap
69+
): Record<string, string> {
70+
return Array.from(pluginDataValues.entries())
71+
.filter(plugin => plugin[1].version !== undefined)
72+
.reduce((acc, [key, value]) => ({ ...acc, [key]: value.version }), {});
73+
}
74+
6175
export function focusFirstInputInContainer(
6276
container: HTMLElement | null
6377
): void {

packages/plugin/src/PluginTypes.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export function isLegacyAuthPlugin(
4242
return 'AuthPlugin' in plugin;
4343
}
4444

45-
export type PluginModuleMap = Map<string, PluginModule>;
45+
export type PluginModuleMap = Map<string, VersionedPluginModule>;
4646

4747
/**
4848
* @deprecated Use TablePlugin instead
@@ -75,6 +75,8 @@ export function isLegacyPlugin(plugin: unknown): plugin is LegacyPlugin {
7575

7676
export type PluginModule = Plugin | LegacyPlugin;
7777

78+
export type VersionedPluginModule = PluginModule & { version?: string };
79+
7880
export interface Plugin {
7981
/**
8082
* The name of the plugin. This will be used as an identifier for the plugin and should be unique.

0 commit comments

Comments
 (0)