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: Add JS Plugin Information #2002

Merged
merged 5 commits into from
May 15, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 2 additions & 2 deletions packages/app-utils/src/plugins/PluginUtils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,13 @@ export async function loadModulePlugins(
const pluginMap: PluginModuleMap = new Map();
for (let i = 0; i < pluginModules.length; i += 1) {
const module = pluginModules[i];
const { name } = manifest.plugins[i];
const { name, version } = manifest.plugins[i];
if (module.status === 'fulfilled') {
const moduleValue = getPluginModuleValue(module.value);
if (moduleValue == null) {
log.error(`Plugin '${name}' is missing an exported value.`);
} else {
pluginMap.set(name, moduleValue);
pluginMap.set(name, { ...moduleValue, version });
}
} else {
log.error(`Unable to load plugin '${name}'`, module.reason);
Expand Down
1 change: 1 addition & 0 deletions packages/code-studio/src/main/AppMainContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1002,6 +1002,7 @@ export class AppMainContainer extends Component<
<SlideTransition in={isSettingsMenuShown} mountOnEnter unmountOnExit>
<SettingsMenu
serverConfigValues={serverConfigValues}
pluginData={plugins}
onDone={this.handleSettingsMenuHide}
user={user}
/>
Expand Down
43 changes: 38 additions & 5 deletions packages/code-studio/src/settings/SettingsMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,22 @@ import {
makeMessage,
} from '@deephaven/jsapi-utils';
import { assertNotNull } from '@deephaven/utils';
import { PluginModuleMap } from '@deephaven/plugin';
import FormattingSectionContent from './FormattingSectionContent';
import LegalNotice from './LegalNotice';
import SettingsMenuSection from './SettingsMenuSection';
import ShortcutSectionContent from './ShortcutsSectionContent';
import { exportLogs } from '../log/LogExport';
import './SettingsMenu.scss';
import ColumnSpecificSectionContent from './ColumnSpecificSectionContent';
import { getFormattedVersionInfo } from './SettingsUtils';
import {
getFormattedPluginInfo,
getFormattedVersionInfo,
} from './SettingsUtils';

interface SettingsMenuProps {
serverConfigValues: ServerConfigValues;
pluginData: PluginModuleMap;
user: User;
onDone: () => void;
}
Expand Down Expand Up @@ -125,16 +130,21 @@ export class SettingsMenu extends Component<
}

handleExportSupportLogs(): void {
const { serverConfigValues } = this.props;
exportLogs(undefined, Object.fromEntries(serverConfigValues));
const { serverConfigValues, pluginData } = this.props;
const pluginInfo = getFormattedPluginInfo(pluginData);
exportLogs(undefined, {
...Object.fromEntries(serverConfigValues),
pluginInfo,
});
}

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

const { serverConfigValues, user } = this.props;
const { serverConfigValues, pluginData, user } = this.props;
const versionInfo = getFormattedVersionInfo(serverConfigValues);
const pluginInfo = getFormattedPluginInfo(pluginData);
const deephavenVersion = serverConfigValues.get('deephaven.version');
const copyShortcut = GLOBAL_SHORTCUTS.COPY_VERSION_INFO.getDisplayText();

Expand Down Expand Up @@ -335,7 +345,10 @@ export class SettingsMenu extends Component<
<CopyButton
kind="inline"
tooltip="Copy version numbers"
copy={Object.entries(versionInfo)
copy={Object.entries({
...versionInfo,
...pluginInfo,
})
.map(([key, value]) => `${key}: ${value}`)
.join('\n')}
>
Expand All @@ -345,6 +358,26 @@ export class SettingsMenu extends Component<
</Tooltip>
</span>
</div>
<div className="app-settings-footer-item">
<div className="font-weight-bold">Plugins</div>
<div className="container">
{Array.from(pluginData.entries())
.filter(plugin => plugin[1].version !== undefined)
.map(([key, value]) => (
<div
key={key}
className="row justify-content-start align-items-center"
>
<div className="col pl-0">
<span className="my-0 text-truncate">{key}</span>
</div>
<div className="col-auto">
<span>{value?.version}</span>
</div>
</div>
))}
</div>
</div>
<div className="app-settings-footer-item">
<LegalNotice />
</div>
Expand Down
14 changes: 14 additions & 0 deletions packages/code-studio/src/settings/SettingsUtils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import type { dh as DhType } from '@deephaven/jsapi-types';
import Log from '@deephaven/log';
import type { ServerConfigValues } from '@deephaven/redux';
import Bowser from 'bowser';
import { PluginModuleMap } from '@deephaven/plugin';

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

Expand Down Expand Up @@ -58,6 +59,19 @@ export function getFormattedVersionInfo(
};
}

/**
* Get an object containing all JS plugin information formatted for display
* @param serverConfigValues The information for all plugins
* @returns The formatted mapping from plugin name to version
*/
export function getFormattedPluginInfo(
pluginDataValues: PluginModuleMap
): Record<string, string> {
return Array.from(pluginDataValues.entries())
.filter(plugin => plugin[1].version !== undefined)
.reduce((acc, [key, value]) => ({ ...acc, [key]: value.version }), {});
}

export function focusFirstInputInContainer(
container: HTMLElement | null
): void {
Expand Down
4 changes: 3 additions & 1 deletion packages/plugin/src/PluginTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export function isLegacyAuthPlugin(
return 'AuthPlugin' in plugin;
}

export type PluginModuleMap = Map<string, PluginModule>;
export type PluginModuleMap = Map<string, VersionedPluginModule>;

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

export type PluginModule = Plugin | LegacyPlugin;

export type VersionedPluginModule = PluginModule & { version?: string };

export interface Plugin {
/**
* The name of the plugin. This will be used as an identifier for the plugin and should be unique.
Expand Down
Loading