@backstage/plugin-home-react 0.1.42-next.0 → 0.1.42
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +21 -0
- package/dist/extensions.esm.js +33 -17
- package/dist/extensions.esm.js.map +1 -1
- package/package.json +9 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,26 @@
|
|
|
1
1
|
# @backstage/plugin-home-react
|
|
2
2
|
|
|
3
|
+
## 0.1.42
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- cd4a9c7: Fixed `CardExtension` to avoid requiring app context when a custom `Renderer` is provided.
|
|
8
|
+
- Updated dependencies
|
|
9
|
+
- @backstage/core-components@0.18.14
|
|
10
|
+
- @backstage/frontend-plugin-api@0.18.1
|
|
11
|
+
- @backstage/core-compat-api@0.5.15
|
|
12
|
+
- @backstage/core-plugin-api@1.12.10
|
|
13
|
+
|
|
14
|
+
## 0.1.42-next.1
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- Updated dependencies
|
|
19
|
+
- @backstage/core-components@0.18.14-next.1
|
|
20
|
+
- @backstage/frontend-plugin-api@0.18.1-next.0
|
|
21
|
+
- @backstage/core-compat-api@0.5.15-next.1
|
|
22
|
+
- @backstage/core-plugin-api@1.12.10-next.0
|
|
23
|
+
|
|
3
24
|
## 0.1.42-next.0
|
|
4
25
|
|
|
5
26
|
### Patch Changes
|
package/dist/extensions.esm.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
2
|
-
import {
|
|
2
|
+
import { Suspense, useState } from 'react';
|
|
3
|
+
import CircularProgress from '@material-ui/core/CircularProgress';
|
|
3
4
|
import IconButton from '@material-ui/core/IconButton';
|
|
4
5
|
import SettingsIcon from '@material-ui/icons/Settings';
|
|
5
6
|
import { InfoCard } from '@backstage/core-components';
|
|
@@ -32,7 +33,7 @@ function createCardExtension(options) {
|
|
|
32
33
|
}
|
|
33
34
|
});
|
|
34
35
|
}
|
|
35
|
-
function
|
|
36
|
+
function CardExtensionWithCustomRenderer(props) {
|
|
36
37
|
const {
|
|
37
38
|
Renderer,
|
|
38
39
|
Content,
|
|
@@ -43,25 +44,34 @@ function CardExtension(props) {
|
|
|
43
44
|
title,
|
|
44
45
|
...childProps
|
|
45
46
|
} = props;
|
|
47
|
+
return /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx(CircularProgress, {}), children: /* @__PURE__ */ jsx(
|
|
48
|
+
Renderer,
|
|
49
|
+
{
|
|
50
|
+
...title && { title },
|
|
51
|
+
...{
|
|
52
|
+
Content,
|
|
53
|
+
...Actions ? { Actions } : {},
|
|
54
|
+
...Settings && !isCustomizable ? { Settings } : {},
|
|
55
|
+
...ContextProvider ? { ContextProvider } : {},
|
|
56
|
+
...childProps
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
) });
|
|
60
|
+
}
|
|
61
|
+
function DefaultCardExtension(props) {
|
|
62
|
+
const {
|
|
63
|
+
Content,
|
|
64
|
+
Settings,
|
|
65
|
+
Actions,
|
|
66
|
+
ContextProvider,
|
|
67
|
+
isCustomizable,
|
|
68
|
+
title,
|
|
69
|
+
...childProps
|
|
70
|
+
} = props;
|
|
46
71
|
const app = useApp();
|
|
47
72
|
const { Progress } = app.getComponents();
|
|
48
73
|
const [settingsOpen, setSettingsOpen] = useState(false);
|
|
49
74
|
const { t } = useTranslationRef(homeReactTranslationRef);
|
|
50
|
-
if (Renderer) {
|
|
51
|
-
return /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx(Progress, {}), children: /* @__PURE__ */ jsx(
|
|
52
|
-
Renderer,
|
|
53
|
-
{
|
|
54
|
-
...title && { title },
|
|
55
|
-
...{
|
|
56
|
-
Content,
|
|
57
|
-
...Actions ? { Actions } : {},
|
|
58
|
-
...Settings && !isCustomizable ? { Settings } : {},
|
|
59
|
-
...ContextProvider ? { ContextProvider } : {},
|
|
60
|
-
...childProps
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
) });
|
|
64
|
-
}
|
|
65
75
|
const cardProps = {
|
|
66
76
|
divider: !!title,
|
|
67
77
|
...title && { title },
|
|
@@ -86,6 +96,12 @@ function CardExtension(props) {
|
|
|
86
96
|
] });
|
|
87
97
|
return /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx(Progress, {}), children: ContextProvider ? /* @__PURE__ */ jsx(ContextProvider, { ...childProps, children: innerContent }) : innerContent });
|
|
88
98
|
}
|
|
99
|
+
function CardExtension(props) {
|
|
100
|
+
if (props.Renderer) {
|
|
101
|
+
return /* @__PURE__ */ jsx(CardExtensionWithCustomRenderer, { ...props, Renderer: props.Renderer });
|
|
102
|
+
}
|
|
103
|
+
return /* @__PURE__ */ jsx(DefaultCardExtension, { ...props });
|
|
104
|
+
}
|
|
89
105
|
|
|
90
106
|
export { CardExtension, createCardExtension };
|
|
91
107
|
//# sourceMappingURL=extensions.esm.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extensions.esm.js","sources":["../src/extensions.tsx"],"sourcesContent":["/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useState, Suspense } from 'react';\nimport IconButton from '@material-ui/core/IconButton';\nimport SettingsIcon from '@material-ui/icons/Settings';\nimport { InfoCard } from '@backstage/core-components';\nimport { SettingsModal } from './components';\nimport { createReactExtension, useApp } from '@backstage/core-plugin-api';\nimport { RJSFSchema, UiSchema } from '@rjsf/utils';\nimport { useTranslationRef } from '@backstage/frontend-plugin-api';\nimport { homeReactTranslationRef } from './translation';\n\n/**\n * @public\n */\nexport type ComponentRenderer = {\n Renderer?: (props: RendererProps) => JSX.Element;\n};\n\n/**\n * @public\n */\nexport type ComponentParts = {\n Content: (props?: any) => JSX.Element;\n Actions?: () => JSX.Element;\n Settings?: () => JSX.Element;\n ContextProvider?: (props: any) => JSX.Element;\n};\n\n/**\n * @public\n */\nexport type RendererProps = { title?: string } & ComponentParts;\n\n/**\n * @public\n */\nexport type CardExtensionProps<T> = ComponentRenderer & {\n title?: string;\n} & T;\n\n/**\n * @public\n */\nexport type CardLayout = {\n width?: { minColumns?: number; maxColumns?: number; defaultColumns?: number };\n height?: { minRows?: number; maxRows?: number; defaultRows?: number };\n};\n\n/**\n * @public\n */\nexport type CardSettings = {\n schema?: RJSFSchema;\n uiSchema?: UiSchema;\n};\n\n/**\n * @public\n */\nexport type CardConfig = {\n layout?: CardLayout;\n settings?: CardSettings;\n};\n\n/**\n * An extension creator to create card based components for the homepage\n *\n * @public\n */\nexport function createCardExtension<T>(options: {\n title?: string;\n components: () => Promise<ComponentParts>;\n name?: string;\n description?: string;\n layout?: CardLayout;\n settings?: CardSettings;\n}) {\n const { title, components, name, description, layout, settings } = options;\n // If widget settings schema is defined, we don't want to show the Settings icon or dialog\n const isCustomizable = settings?.schema !== undefined;\n\n return createReactExtension({\n name,\n data: { title, description, 'home.widget.config': { layout, settings } },\n component: {\n lazy: () =>\n components().then(componentParts => {\n return (props: CardExtensionProps<T>) => {\n return (\n <CardExtension\n {...props}\n {...componentParts}\n title={props.title || title}\n isCustomizable={isCustomizable}\n />\n );\n };\n }),\n },\n });\n}\n\ntype CardExtensionComponentProps<T> = CardExtensionProps<T> &\n ComponentParts & {\n isCustomizable?: boolean;\n overrideTitle?: string;\n };\n\
|
|
1
|
+
{"version":3,"file":"extensions.esm.js","sources":["../src/extensions.tsx"],"sourcesContent":["/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useState, Suspense } from 'react';\nimport CircularProgress from '@material-ui/core/CircularProgress';\nimport IconButton from '@material-ui/core/IconButton';\nimport SettingsIcon from '@material-ui/icons/Settings';\nimport { InfoCard } from '@backstage/core-components';\nimport { SettingsModal } from './components';\nimport { createReactExtension, useApp } from '@backstage/core-plugin-api';\nimport { RJSFSchema, UiSchema } from '@rjsf/utils';\nimport { useTranslationRef } from '@backstage/frontend-plugin-api';\nimport { homeReactTranslationRef } from './translation';\n\n/**\n * @public\n */\nexport type ComponentRenderer = {\n Renderer?: (props: RendererProps) => JSX.Element;\n};\n\n/**\n * @public\n */\nexport type ComponentParts = {\n Content: (props?: any) => JSX.Element;\n Actions?: () => JSX.Element;\n Settings?: () => JSX.Element;\n ContextProvider?: (props: any) => JSX.Element;\n};\n\n/**\n * @public\n */\nexport type RendererProps = { title?: string } & ComponentParts;\n\n/**\n * @public\n */\nexport type CardExtensionProps<T> = ComponentRenderer & {\n title?: string;\n} & T;\n\n/**\n * @public\n */\nexport type CardLayout = {\n width?: { minColumns?: number; maxColumns?: number; defaultColumns?: number };\n height?: { minRows?: number; maxRows?: number; defaultRows?: number };\n};\n\n/**\n * @public\n */\nexport type CardSettings = {\n schema?: RJSFSchema;\n uiSchema?: UiSchema;\n};\n\n/**\n * @public\n */\nexport type CardConfig = {\n layout?: CardLayout;\n settings?: CardSettings;\n};\n\n/**\n * An extension creator to create card based components for the homepage\n *\n * @public\n */\nexport function createCardExtension<T>(options: {\n title?: string;\n components: () => Promise<ComponentParts>;\n name?: string;\n description?: string;\n layout?: CardLayout;\n settings?: CardSettings;\n}) {\n const { title, components, name, description, layout, settings } = options;\n // If widget settings schema is defined, we don't want to show the Settings icon or dialog\n const isCustomizable = settings?.schema !== undefined;\n\n return createReactExtension({\n name,\n data: { title, description, 'home.widget.config': { layout, settings } },\n component: {\n lazy: () =>\n components().then(componentParts => {\n return (props: CardExtensionProps<T>) => {\n return (\n <CardExtension\n {...props}\n {...componentParts}\n title={props.title || title}\n isCustomizable={isCustomizable}\n />\n );\n };\n }),\n },\n });\n}\n\ntype CardExtensionComponentProps<T> = CardExtensionProps<T> &\n ComponentParts & {\n isCustomizable?: boolean;\n overrideTitle?: string;\n };\n\nfunction CardExtensionWithCustomRenderer<T>(\n props: CardExtensionComponentProps<T> & {\n Renderer: NonNullable<ComponentRenderer['Renderer']>;\n },\n) {\n const {\n Renderer,\n Content,\n Settings,\n Actions,\n ContextProvider,\n isCustomizable,\n title,\n ...childProps\n } = props;\n\n return (\n <Suspense fallback={<CircularProgress />}>\n <Renderer\n {...(title && { title })}\n {...{\n Content,\n ...(Actions ? { Actions } : {}),\n ...(Settings && !isCustomizable ? { Settings } : {}),\n ...(ContextProvider ? { ContextProvider } : {}),\n ...childProps,\n }}\n />\n </Suspense>\n );\n}\n\nfunction DefaultCardExtension<T>(props: CardExtensionComponentProps<T>) {\n const {\n Content,\n Settings,\n Actions,\n ContextProvider,\n isCustomizable,\n title,\n ...childProps\n } = props;\n const app = useApp();\n const { Progress } = app.getComponents();\n const [settingsOpen, setSettingsOpen] = useState(false);\n const { t } = useTranslationRef(homeReactTranslationRef);\n\n const cardProps = {\n divider: !!title,\n ...(title && { title }),\n ...(Settings && !isCustomizable\n ? {\n action: (\n <IconButton onClick={() => setSettingsOpen(true)}>\n <SettingsIcon>\n {t('cardExtension.settingsButtonTitle')}\n </SettingsIcon>\n </IconButton>\n ),\n }\n : {}),\n ...(Actions\n ? {\n actions: <Actions />,\n }\n : {}),\n };\n\n const innerContent = (\n <InfoCard {...cardProps}>\n {Settings && !isCustomizable && (\n <SettingsModal\n open={settingsOpen}\n componentName={title}\n close={() => setSettingsOpen(false)}\n >\n <Settings />\n </SettingsModal>\n )}\n <Content {...childProps} />\n </InfoCard>\n );\n\n return (\n <Suspense fallback={<Progress />}>\n {ContextProvider ? (\n <ContextProvider {...childProps}>{innerContent}</ContextProvider>\n ) : (\n innerContent\n )}\n </Suspense>\n );\n}\n\nexport function CardExtension<T>(props: CardExtensionComponentProps<T>) {\n if (props.Renderer) {\n return (\n <CardExtensionWithCustomRenderer {...props} Renderer={props.Renderer} />\n );\n }\n\n return <DefaultCardExtension {...props} />;\n}\n"],"names":[],"mappings":";;;;;;;;;;;;AAqFO,SAAS,oBAAuB,OAAA,EAOpC;AACD,EAAA,MAAM,EAAE,KAAA,EAAO,UAAA,EAAY,MAAM,WAAA,EAAa,MAAA,EAAQ,UAAS,GAAI,OAAA;AAEnE,EAAA,MAAM,cAAA,GAAiB,UAAU,MAAA,KAAW,MAAA;AAE5C,EAAA,OAAO,oBAAA,CAAqB;AAAA,IAC1B,IAAA;AAAA,IACA,IAAA,EAAM,EAAE,KAAA,EAAO,WAAA,EAAa,sBAAsB,EAAE,MAAA,EAAQ,UAAS,EAAE;AAAA,IACvE,SAAA,EAAW;AAAA,MACT,IAAA,EAAM,MACJ,UAAA,EAAW,CAAE,KAAK,CAAA,cAAA,KAAkB;AAClC,QAAA,OAAO,CAAC,KAAA,KAAiC;AACvC,UAAA,uBACE,GAAA;AAAA,YAAC,aAAA;AAAA,YAAA;AAAA,cACE,GAAG,KAAA;AAAA,cACH,GAAG,cAAA;AAAA,cACJ,KAAA,EAAO,MAAM,KAAA,IAAS,KAAA;AAAA,cACtB;AAAA;AAAA,WACF;AAAA,QAEJ,CAAA;AAAA,MACF,CAAC;AAAA;AACL,GACD,CAAA;AACH;AAQA,SAAS,gCACP,KAAA,EAGA;AACA,EAAA,MAAM;AAAA,IACJ,QAAA;AAAA,IACA,OAAA;AAAA,IACA,QAAA;AAAA,IACA,OAAA;AAAA,IACA,e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-home-react",
|
|
3
|
-
"version": "0.1.42
|
|
3
|
+
"version": "0.1.42",
|
|
4
4
|
"description": "A Backstage plugin that contains react components helps you build a home page",
|
|
5
5
|
"backstage": {
|
|
6
6
|
"role": "web-library",
|
|
@@ -63,16 +63,19 @@
|
|
|
63
63
|
"test": "backstage-cli package test"
|
|
64
64
|
},
|
|
65
65
|
"dependencies": {
|
|
66
|
-
"@backstage/core-compat-api": "0.5.15
|
|
67
|
-
"@backstage/core-components": "0.18.14
|
|
68
|
-
"@backstage/core-plugin-api": "1.12.
|
|
69
|
-
"@backstage/frontend-plugin-api": "0.18.
|
|
66
|
+
"@backstage/core-compat-api": "^0.5.15",
|
|
67
|
+
"@backstage/core-components": "^0.18.14",
|
|
68
|
+
"@backstage/core-plugin-api": "^1.12.10",
|
|
69
|
+
"@backstage/frontend-plugin-api": "^0.18.1",
|
|
70
70
|
"@material-ui/core": "^4.12.2",
|
|
71
71
|
"@material-ui/icons": "^4.9.1",
|
|
72
72
|
"@rjsf/utils": "5.24.13"
|
|
73
73
|
},
|
|
74
74
|
"devDependencies": {
|
|
75
|
-
"@backstage/cli": "0.36.6
|
|
75
|
+
"@backstage/cli": "^0.36.6",
|
|
76
|
+
"@backstage/test-utils": "^1.7.22",
|
|
77
|
+
"@testing-library/jest-dom": "^6.0.0",
|
|
78
|
+
"@testing-library/react": "^16.0.0",
|
|
76
79
|
"@types/react": "^18.0.0",
|
|
77
80
|
"@types/react-grid-layout": "^1.3.2",
|
|
78
81
|
"react": "^18.0.2",
|