Skip to content

Commit fd25c8c

Browse files
committed
fix(dynamic-plugins-info): remove scalprum dep
This change swaps out the direct usage of useScalprum to the useMountPoints hook provided by the dynamic plugins frontend API. This change also ensures the useMountPoints hook is exported from the API package. Signed-off-by: Stan Lewis <[email protected]>
1 parent 94f9edc commit fd25c8c

File tree

4 files changed

+9
-22
lines changed

4 files changed

+9
-22
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
export { useDynamicPluginConfig } from './useDynamicPlugin';
2+
export { default as useMountPoints } from './useMountPoints';

plugins/dynamic-plugins-info/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
"@material-table/core": "3.2.5",
4040
"@mui/icons-material": "5.18.0",
4141
"@mui/material": "5.18.0",
42-
"@scalprum/react-core": "0.9.5",
42+
"@red-hat-developer-hub/plugin-utils": "workspace:*",
4343
"react-use": "17.6.0"
4444
},
4545
"peerDependencies": {

plugins/dynamic-plugins-info/src/components/DynamicPluginsInfoPage.tsx

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
TabbedLayout,
88
} from '@backstage/core-components';
99

10-
import { useScalprum } from '@scalprum/react-core';
10+
import { useMountPoints } from '@red-hat-developer-hub/plugin-utils';
1111

1212
export interface PluginTab {
1313
Component: React.ComponentType;
@@ -17,31 +17,17 @@ export interface PluginTab {
1717
};
1818
}
1919

20-
export interface ScalprumState {
21-
api?: {
22-
dynamicRootConfig?: {
23-
mountPoints?: {
24-
'internal.plugins/tab': PluginTab[];
25-
};
26-
};
27-
};
28-
}
29-
3020
export const DynamicPluginsInfoPage = () => {
31-
const scalprum = useScalprum<ScalprumState>();
32-
33-
const tabs =
34-
scalprum.api?.dynamicRootConfig?.mountPoints?.['internal.plugins/tab'] ||
35-
[];
36-
21+
// this coercion is necessary to preserve compatability with
22+
// the original configuration definition
23+
const tabs = useMountPoints('internal.plugins/tab') as unknown as PluginTab[];
3724
const FirstComponent = tabs[0]?.Component;
38-
3925
return (
4026
<Page themeId="extensions">
4127
<Header title="Extensions" />
4228
{tabs.length > 1 ? (
4329
<TabbedLayout>
44-
{tabs.map(({ Component, config }) => (
30+
{tabs.map(({ Component, config }: PluginTab) => (
4531
<TabbedLayout.Route
4632
key={config.path}
4733
path={config.path}

yarn.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7734,7 +7734,7 @@ __metadata:
77347734
"@material-table/core": 3.2.5
77357735
"@mui/icons-material": 5.18.0
77367736
"@mui/material": 5.18.0
7737-
"@scalprum/react-core": 0.9.5
7737+
"@red-hat-developer-hub/plugin-utils": "workspace:*"
77387738
"@testing-library/jest-dom": 6.6.4
77397739
"@testing-library/react": 14.3.1
77407740
"@testing-library/user-event": 14.6.1
@@ -12081,7 +12081,7 @@ __metadata:
1208112081
languageName: node
1208212082
linkType: hard
1208312083

12084-
"@red-hat-developer-hub/[email protected], @red-hat-developer-hub/plugin-utils@workspace:packages/plugin-utils":
12084+
"@red-hat-developer-hub/[email protected], @red-hat-developer-hub/plugin-utils@workspace:*, @red-hat-developer-hub/plugin-utils@workspace:packages/plugin-utils":
1208512085
version: 0.0.0-use.local
1208612086
resolution: "@red-hat-developer-hub/plugin-utils@workspace:packages/plugin-utils"
1208712087
dependencies:

0 commit comments

Comments
 (0)