From 879b1aa6f5871502553d43e3673030191ec396e0 Mon Sep 17 00:00:00 2001 From: Philipp Hugenroth Date: Tue, 18 Jul 2023 11:38:33 +0200 Subject: [PATCH] use @backstage/autodetect for DevTools Plugin Co-authored-by: Vincenzo Scamporlino Signed-off-by: Philipp Hugenroth --- .../Content/InfoContent/InfoContent.tsx | 27 +++++++------------ 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/plugins/devtools/src/components/Content/InfoContent/InfoContent.tsx b/plugins/devtools/src/components/Content/InfoContent/InfoContent.tsx index 2379df8b60..b40d2ce1df 100644 --- a/plugins/devtools/src/components/Content/InfoContent/InfoContent.tsx +++ b/plugins/devtools/src/components/Content/InfoContent/InfoContent.tsx @@ -43,8 +43,6 @@ import { } from '@backstage/plugin-devtools-common'; import * as autodetect from '@backstage/autodetect'; -const PACKAGES_GLOBAL = '__backstage_detected_packages__'; - const useStyles = makeStyles((theme: Theme) => createStyles({ paperStyle: { @@ -79,22 +77,17 @@ const copyToClipboard = ({ about }: { about: DevToolsInfo | undefined }) => { export const InfoContent = () => { const classes = useStyles(); const { about, loading, error } = useInfo(); - console.log('ooo', autodetect.getAvailablePlugins()); - const availablePlugins: PackageDependency[] = (window as any)[PACKAGES_GLOBAL] - ? ( - (window as any)[PACKAGES_GLOBAL].modules as Array> - ).map(({ name, module }) => { - const pluginImpl: any = Object.values(module).find( - (v: any) => !!v?.getId, - ); - - return { - name, - versions: (pluginImpl?.getId() as string) || '', - }; - }) - : []; + const plugins = autodetect.getAvailablePlugins(); + const availablePlugins: PackageDependency[] = ( + plugins.modules as Array> + ).map(({ name, module }) => { + const pluginImpl: any = Object.values(module).find((v: any) => !!v?.getId); + return { + name, + versions: (pluginImpl?.getId() as string) || '', + }; + }); if (loading) { return ; } else if (error) {