@backstage/plugin-home 0.1.1 → 0.4.0
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 +75 -0
- package/dist/esm/{index-c74fbbf4.esm.js → index-a3eb0b00.esm.js} +4 -8
- package/dist/esm/{index-c74fbbf4.esm.js.map → index-a3eb0b00.esm.js.map} +1 -1
- package/dist/esm/{index-1aa6d55e.esm.js → index-e4aed0e4.esm.js} +2 -2
- package/dist/esm/{index-1aa6d55e.esm.js.map → index-e4aed0e4.esm.js.map} +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.esm.js +6 -6
- package/dist/index.esm.js.map +1 -1
- package/package.json +12 -11
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
# @backstage/plugin-home
|
|
2
|
+
|
|
3
|
+
## 0.4.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- bcf312fa52: The homepage `<Header />` is now part of the composable canvas (allowing you to add the <HomepageTimer />, for example).
|
|
8
|
+
|
|
9
|
+
You will need to wrap your existing composed `<HomePage />` component in `<Page />`, `<Header />`, and `<Content />` components, like this:
|
|
10
|
+
|
|
11
|
+
```diff
|
|
12
|
+
// app/src/components/home/HomePage.tsx
|
|
13
|
+
|
|
14
|
+
+ import { Content, Header, Page, HomePageTimer } from '@backstage/core-components';
|
|
15
|
+
|
|
16
|
+
export const HomePage = () => (
|
|
17
|
+
+ <Page themeId="home">
|
|
18
|
+
+ <Header title="Home">
|
|
19
|
+
+ <HomepageTimer />
|
|
20
|
+
+ </Header>
|
|
21
|
+
+ <Content>
|
|
22
|
+
<Grid container spacing={3}>
|
|
23
|
+
<Grid item xs={12}>
|
|
24
|
+
<HomePageSearchBar />
|
|
25
|
+
</Grid>
|
|
26
|
+
// ...
|
|
27
|
+
+ </Content>
|
|
28
|
+
+ </Page>
|
|
29
|
+
);
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
### Patch Changes
|
|
33
|
+
|
|
34
|
+
- 9f1362dcc1: Upgrade `@material-ui/lab` to `4.0.0-alpha.57`.
|
|
35
|
+
- 1da51fec2b: Adjust dependencies to `@types/react` and `react-router` to follow the pattern
|
|
36
|
+
used by all other Backstage packages.
|
|
37
|
+
- Updated dependencies
|
|
38
|
+
- @backstage/core-components@0.4.2
|
|
39
|
+
- @backstage/core-plugin-api@0.1.8
|
|
40
|
+
|
|
41
|
+
## 0.3.0
|
|
42
|
+
|
|
43
|
+
### Minor Changes
|
|
44
|
+
|
|
45
|
+
- 7f00902d9: Rename RandomJokeHomePageComponent to HomePageRandomJoke to fit convention, and update example app accordingly.
|
|
46
|
+
**NOTE**: If you're using the RandomJoke component in your instance, it now has to be renamed to `HomePageRandomJoke`
|
|
47
|
+
|
|
48
|
+
### Patch Changes
|
|
49
|
+
|
|
50
|
+
- Updated dependencies
|
|
51
|
+
- @backstage/core-components@0.4.1
|
|
52
|
+
- @backstage/core-plugin-api@0.1.7
|
|
53
|
+
|
|
54
|
+
## 0.2.1
|
|
55
|
+
|
|
56
|
+
### Patch Changes
|
|
57
|
+
|
|
58
|
+
- Updated dependencies
|
|
59
|
+
- @backstage/core-components@0.4.0
|
|
60
|
+
|
|
61
|
+
## 0.2.0
|
|
62
|
+
|
|
63
|
+
### Minor Changes
|
|
64
|
+
|
|
65
|
+
- 2b7d3455b: Create the `Home` plugin which exports some basic functionality that's used to compose a homepage. An example of a composed homepage is added to the example app.
|
|
66
|
+
|
|
67
|
+
This change also introduces the `createCardExtension` which creates a lazy loaded card that is intended to be used for homepage components.
|
|
68
|
+
|
|
69
|
+
Adoption of this homepage requires setup similar to what can be found in the example app.
|
|
70
|
+
|
|
71
|
+
### Patch Changes
|
|
72
|
+
|
|
73
|
+
- Updated dependencies
|
|
74
|
+
- @backstage/core-components@0.3.2
|
|
75
|
+
- @backstage/theme@0.2.10
|
|
@@ -1,21 +1,17 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { useOutlet } from 'react-router';
|
|
3
|
-
import { Page, Header, Content } from '@backstage/core-components';
|
|
4
3
|
export { SettingsModal } from '../index.esm.js';
|
|
5
4
|
import '@backstage/core-plugin-api';
|
|
6
5
|
import '@material-ui/core';
|
|
7
6
|
import '@material-ui/icons/Settings';
|
|
7
|
+
import '@backstage/core-components';
|
|
8
8
|
|
|
9
9
|
const HomepageCompositionRoot = (props) => {
|
|
10
|
-
var _a
|
|
10
|
+
var _a;
|
|
11
11
|
const outlet = useOutlet();
|
|
12
12
|
const children = (_a = props.children) != null ? _a : outlet;
|
|
13
|
-
return /* @__PURE__ */ React.createElement(
|
|
14
|
-
themeId: "home"
|
|
15
|
-
}, /* @__PURE__ */ React.createElement(Header, {
|
|
16
|
-
title: (_b = props.title) != null ? _b : "Home"
|
|
17
|
-
}), /* @__PURE__ */ React.createElement(Content, null, children));
|
|
13
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, children);
|
|
18
14
|
};
|
|
19
15
|
|
|
20
16
|
export { HomepageCompositionRoot };
|
|
21
|
-
//# sourceMappingURL=index-
|
|
17
|
+
//# sourceMappingURL=index-a3eb0b00.esm.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index-
|
|
1
|
+
{"version":3,"file":"index-a3eb0b00.esm.js","sources":["../../src/components/HomepageCompositionRoot.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 React, { ReactNode } from 'react';\nimport { useOutlet } from 'react-router';\n\nexport const HomepageCompositionRoot = (props: {\n title?: string;\n children?: ReactNode;\n}) => {\n const outlet = useOutlet();\n const children = props.children ?? outlet;\n return <>{children}</>;\n};\n"],"names":[],"mappings":";;;;;;;;MAmBa,0BAA0B,CAAC,UAGlC;AAtBN;AAuBE,QAAM,SAAS;AACf,QAAM,WAAW,YAAM,aAAN,YAAkB;AACnC,mEAAU;AAAA;;;;"}
|
|
@@ -4,8 +4,8 @@ import { makeStyles } from '@material-ui/core/styles';
|
|
|
4
4
|
import ExpandMoreIcon from '@material-ui/icons/ExpandMore';
|
|
5
5
|
import SettingsIcon from '@material-ui/icons/Settings';
|
|
6
6
|
import 'react-router';
|
|
7
|
-
import { InfoCard } from '@backstage/core-components';
|
|
8
7
|
import { SettingsModal } from '../index.esm.js';
|
|
8
|
+
import { InfoCard } from '@backstage/core-components';
|
|
9
9
|
import '@backstage/core-plugin-api';
|
|
10
10
|
|
|
11
11
|
const useStyles = makeStyles((theme) => ({
|
|
@@ -79,4 +79,4 @@ const ComponentTab = ({
|
|
|
79
79
|
};
|
|
80
80
|
|
|
81
81
|
export { ComponentAccordion, ComponentTab, ComponentTabs };
|
|
82
|
-
//# sourceMappingURL=index-
|
|
82
|
+
//# sourceMappingURL=index-e4aed0e4.esm.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index-
|
|
1
|
+
{"version":3,"file":"index-e4aed0e4.esm.js","sources":["../../src/componentRenderers/ComponentAccordion.tsx","../../src/componentRenderers/ComponentTabs/ComponentTabs.tsx","../../src/componentRenderers/ComponentTabs/ComponentTab.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 React from 'react';\nimport {\n Accordion,\n AccordionDetails,\n AccordionSummary,\n Typography,\n IconButton,\n Theme,\n} from '@material-ui/core';\nimport { makeStyles } from '@material-ui/core/styles';\nimport ExpandMoreIcon from '@material-ui/icons/ExpandMore';\nimport SettingsIcon from '@material-ui/icons/Settings';\n\nimport { SettingsModal } from '../components';\n\nconst useStyles = makeStyles((theme: Theme) => ({\n settingsIconButton: {\n padding: theme.spacing(0, 1, 0, 0),\n },\n}));\n\nexport const ComponentAccordion = ({\n title,\n Content,\n Actions,\n Settings,\n ContextProvider,\n ...childProps\n}: {\n title: string;\n Content: () => JSX.Element;\n Actions?: () => JSX.Element;\n Settings?: () => JSX.Element;\n ContextProvider?: (props: any) => JSX.Element;\n}) => {\n const classes = useStyles();\n const [settingsIsExpanded, setSettingsIsExpanded] = React.useState(false);\n const [isExpanded, setIsExpanded] = React.useState(false);\n\n const handleOpenSettings = (e: any) => {\n e.stopPropagation();\n setSettingsIsExpanded(prevState => !prevState);\n };\n\n const innerContent = (\n <>\n {Settings && (\n <SettingsModal\n open={settingsIsExpanded}\n close={() => setSettingsIsExpanded(false)}\n componentName={title}\n >\n <Settings />\n </SettingsModal>\n )}\n <Accordion\n expanded={isExpanded}\n onChange={(_e: any, expanded: boolean) => setIsExpanded(expanded)}\n >\n <AccordionSummary expandIcon={<ExpandMoreIcon />}>\n {Settings && (\n <IconButton\n onClick={handleOpenSettings}\n className={classes.settingsIconButton}\n >\n <SettingsIcon />\n </IconButton>\n )}\n <Typography>{title}</Typography>\n </AccordionSummary>\n <AccordionDetails>\n <div>\n <Content />\n {Actions && <Actions />}\n </div>\n </AccordionDetails>\n </Accordion>\n </>\n );\n\n return ContextProvider ? (\n <ContextProvider {...childProps}>{innerContent}</ContextProvider>\n ) : (\n innerContent\n );\n};\n","/*\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 React from 'react';\nimport { Tabs, Tab } from '@material-ui/core';\nimport { InfoCard } from '@backstage/core-components';\n\ntype TabType = {\n label: string;\n Component: () => JSX.Element;\n};\n\nexport const ComponentTabs = ({\n title,\n tabs,\n}: {\n title: string;\n tabs: TabType[];\n}) => {\n const [value, setValue] = React.useState(0);\n\n const handleChange = (_event: any, newValue: number) => {\n setValue(newValue);\n };\n\n return (\n <InfoCard title={title}>\n <Tabs value={value} onChange={handleChange}>\n {tabs.map(t => (\n <Tab key={t.label} label={t.label} />\n ))}\n </Tabs>\n {tabs.map(({ Component }, idx) => (\n <div {...(idx === value ? { style: { display: 'none' } } : {})}>\n <Component />\n </div>\n ))}\n </InfoCard>\n );\n};\n","/*\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 React from 'react';\n\nexport const ComponentTab = ({\n title,\n Content,\n ContextProvider,\n ...childProps\n}: {\n title: string;\n Content: () => JSX.Element;\n ContextProvider?: (props: any) => JSX.Element;\n}) => {\n return ContextProvider ? (\n <ContextProvider {...childProps}>\n <Content />\n </ContextProvider>\n ) : (\n <Content />\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;AA+BA,MAAM,YAAY,WAAW,CAAC;AAAkB,EAC9C,oBAAoB;AAAA,IAClB,SAAS,MAAM,QAAQ,GAAG,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A;;MC7BG,eAAe,CAAC;AAAA,EAC3B;AAAA,EACA;AAAA,EACA;AAAA,KACG;AAAA,MAKC;AACJ,SAAO,sDACJ,iBAAD;AAAA,OAAqB;AAAA,yCAClB,SAAD,6CAGD,SAAD;AAAA;;;;"}
|
package/dist/index.d.ts
CHANGED
|
@@ -47,7 +47,7 @@ declare const ComponentTab: ({ title, Content, ContextProvider, ...childProps }:
|
|
|
47
47
|
Content: () => JSX.Element;
|
|
48
48
|
ContextProvider?: ((props: any) => JSX.Element) | undefined;
|
|
49
49
|
}) => JSX.Element;
|
|
50
|
-
declare const
|
|
50
|
+
declare const HomePageRandomJoke: ({ Renderer, title: overrideTitle, ...childProps }: ComponentRenderer & {
|
|
51
51
|
title?: string | undefined;
|
|
52
52
|
} & {
|
|
53
53
|
defaultCategory?: "any" | "programming" | undefined;
|
|
@@ -60,4 +60,4 @@ declare const SettingsModal: ({ open, close, componentName, children, }: {
|
|
|
60
60
|
children: JSX.Element;
|
|
61
61
|
}) => JSX.Element;
|
|
62
62
|
|
|
63
|
-
export { ComponentAccordion, ComponentTab, ComponentTabs,
|
|
63
|
+
export { ComponentAccordion, ComponentTab, ComponentTabs, HomePageRandomJoke, HomepageCompositionRoot, SettingsModal, createCardExtension, homePlugin };
|
package/dist/index.esm.js
CHANGED
|
@@ -91,28 +91,28 @@ const homePlugin = createPlugin({
|
|
|
91
91
|
}
|
|
92
92
|
});
|
|
93
93
|
const HomepageCompositionRoot = homePlugin.provide(createRoutableExtension({
|
|
94
|
-
component: () => import('./esm/index-
|
|
94
|
+
component: () => import('./esm/index-a3eb0b00.esm.js').then((m) => m.HomepageCompositionRoot),
|
|
95
95
|
mountPoint: rootRouteRef
|
|
96
96
|
}));
|
|
97
97
|
const ComponentAccordion = homePlugin.provide(createComponentExtension({
|
|
98
98
|
component: {
|
|
99
|
-
lazy: () => import('./esm/index-
|
|
99
|
+
lazy: () => import('./esm/index-e4aed0e4.esm.js').then((m) => m.ComponentAccordion)
|
|
100
100
|
}
|
|
101
101
|
}));
|
|
102
102
|
const ComponentTabs = homePlugin.provide(createComponentExtension({
|
|
103
103
|
component: {
|
|
104
|
-
lazy: () => import('./esm/index-
|
|
104
|
+
lazy: () => import('./esm/index-e4aed0e4.esm.js').then((m) => m.ComponentTabs)
|
|
105
105
|
}
|
|
106
106
|
}));
|
|
107
107
|
const ComponentTab = homePlugin.provide(createComponentExtension({
|
|
108
108
|
component: {
|
|
109
|
-
lazy: () => import('./esm/index-
|
|
109
|
+
lazy: () => import('./esm/index-e4aed0e4.esm.js').then((m) => m.ComponentTab)
|
|
110
110
|
}
|
|
111
111
|
}));
|
|
112
|
-
const
|
|
112
|
+
const HomePageRandomJoke = homePlugin.provide(createCardExtension({
|
|
113
113
|
title: "Random Joke",
|
|
114
114
|
components: () => import('./esm/index-d004cf23.esm.js')
|
|
115
115
|
}));
|
|
116
116
|
|
|
117
|
-
export { ComponentAccordion, ComponentTab, ComponentTabs,
|
|
117
|
+
export { ComponentAccordion, ComponentTab, ComponentTabs, HomePageRandomJoke, HomepageCompositionRoot, SettingsModal, createCardExtension, homePlugin };
|
|
118
118
|
//# sourceMappingURL=index.esm.js.map
|
package/dist/index.esm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.esm.js","sources":["../src/components/SettingsModal.tsx","../src/extensions.tsx","../src/routes.ts","../src/plugin.ts"],"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 React from 'react';\nimport {\n Button,\n Dialog,\n DialogActions,\n DialogContent,\n DialogTitle,\n} from '@material-ui/core';\n\nexport const SettingsModal = ({\n open,\n close,\n componentName,\n children,\n}: {\n open: boolean;\n close: Function;\n componentName: string;\n children: JSX.Element;\n}) => {\n return (\n <Dialog open={open} onClose={() => close()}>\n <DialogTitle>Settings - {componentName}</DialogTitle>\n <DialogContent>{children}</DialogContent>\n <DialogActions>\n <Button onClick={() => close()} color=\"primary\" variant=\"contained\">\n Close\n </Button>\n </DialogActions>\n </Dialog>\n );\n};\n","/*\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 React, { Suspense } from 'react';\nimport { IconButton } from '@material-ui/core';\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';\n\nexport type ComponentRenderer = {\n Renderer?: (props: RendererProps) => JSX.Element;\n};\n\ntype ComponentParts = {\n Content: () => JSX.Element;\n Actions?: () => JSX.Element;\n Settings?: () => JSX.Element;\n ContextProvider?: (props: any) => JSX.Element;\n};\n\ntype RendererProps = { title: string } & ComponentParts;\n\nexport function createCardExtension<T>({\n title,\n components,\n}: {\n title: string;\n components: () => Promise<ComponentParts>;\n}) {\n return createReactExtension({\n component: {\n lazy: () =>\n components().then(({ Content, Actions, Settings, ContextProvider }) => {\n const CardExtension = ({\n Renderer,\n title: overrideTitle,\n ...childProps\n }: ComponentRenderer & { title?: string } & T) => {\n const app = useApp();\n const { Progress } = app.getComponents();\n const [settingsOpen, setSettingsOpen] = React.useState(false);\n\n if (Renderer) {\n return (\n <Suspense fallback={<Progress />}>\n <Renderer\n title={overrideTitle || title}\n {...{\n Content,\n ...(Actions ? { Actions } : {}),\n ...(Settings ? { Settings } : {}),\n ...(ContextProvider ? { ContextProvider } : {}),\n ...childProps,\n }}\n />\n </Suspense>\n );\n }\n\n const cardProps = {\n title: overrideTitle ?? title,\n ...(Settings\n ? {\n action: (\n <IconButton onClick={() => setSettingsOpen(true)}>\n <SettingsIcon>Settings</SettingsIcon>\n </IconButton>\n ),\n }\n : {}),\n ...(Actions\n ? {\n actions: <Actions />,\n }\n : {}),\n };\n\n const innerContent = (\n <InfoCard {...cardProps}>\n {Settings && (\n <SettingsModal\n open={settingsOpen}\n componentName={title}\n close={() => setSettingsOpen(false)}\n >\n <Settings />\n </SettingsModal>\n )}\n <Content />\n </InfoCard>\n );\n\n return (\n <Suspense fallback={<Progress />}>\n {ContextProvider ? (\n <ContextProvider {...childProps}>\n {innerContent}\n </ContextProvider>\n ) : (\n innerContent\n )}\n </Suspense>\n );\n };\n return CardExtension;\n }),\n },\n });\n}\n","/*\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 */\nimport { createRouteRef } from '@backstage/core-plugin-api';\n\nexport const rootRouteRef = createRouteRef({\n title: 'home',\n});\n","/*\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 */\nimport {\n createComponentExtension,\n createPlugin,\n createRoutableExtension,\n} from '@backstage/core-plugin-api';\nimport { createCardExtension } from './extensions';\n\nimport { rootRouteRef } from './routes';\n\nexport const homePlugin = createPlugin({\n id: 'home',\n routes: {\n root: rootRouteRef,\n },\n});\n\nexport const HomepageCompositionRoot = homePlugin.provide(\n createRoutableExtension({\n component: () =>\n import('./components').then(m => m.HomepageCompositionRoot),\n mountPoint: rootRouteRef,\n }),\n);\n\nexport const ComponentAccordion = homePlugin.provide(\n createComponentExtension({\n component: {\n lazy: () =>\n import('./componentRenderers').then(m => m.ComponentAccordion),\n },\n }),\n);\nexport const ComponentTabs = homePlugin.provide(\n createComponentExtension({\n component: {\n lazy: () => import('./componentRenderers').then(m => m.ComponentTabs),\n },\n }),\n);\nexport const ComponentTab = homePlugin.provide(\n createComponentExtension({\n component: {\n lazy: () => import('./componentRenderers').then(m => m.ComponentTab),\n },\n }),\n);\n\nexport const RandomJokeHomePageComponent = homePlugin.provide(\n createCardExtension<{ defaultCategory?: 'any' | 'programming' }>({\n title: 'Random Joke',\n components: () => import('./homePageComponents/RandomJoke'),\n }),\n);\n"],"names":[],"mappings":";;;;;;;MAyBa,gBAAgB,CAAC;AAAA,EAC5B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,MAMI;AACJ,6CACG,QAAD;AAAA,IAAQ;AAAA,IAAY,SAAS,MAAM;AAAA,yCAChC,aAAD,MAAa,eAAY,oDACxB,eAAD,MAAgB,+CACf,eAAD,0CACG,QAAD;AAAA,IAAQ,SAAS,MAAM;AAAA,IAAS,OAAM;AAAA,IAAU,SAAQ;AAAA,KAAY;AAAA;;6BCLrC;AAAA,EACrC;AAAA,EACA;AAAA,GAIC;AACD,SAAO,qBAAqB;AAAA,IAC1B,WAAW;AAAA,MACT,MAAM,MACJ,aAAa,KAAK,CAAC,CAAE,SAAS,SAAS,UAAU,qBAAsB;AACrE,cAAM,gBAAgB,CAAC;AAAA,UACr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M,MACG,sCAAwB,KAAK,OAAK,EAAE;AAAA;AAAA;MAItC,gBAAgB,WAAW,QACtC,yBAAyB;AAAA,EACvB,WAAW;AAAA,IACT,MAAM,MAAa,sCAAwB,KAAK,OAAK,EAAE;AAAA;AAAA;MAIhD,eAAe,WAAW,QACrC,yBAAyB;AAAA,EACvB,WAAW;AAAA,IACT,MAAM,MAAa,sCAAwB,KAAK,OAAK,EAAE;AAAA;AAAA;MAKhD,8BAA8B,WAAW,QACpD,oBAAiE;AAAA,EAC/D,OAAO;AAAA,EACP,YAAY,MAAa;AAAA;;;;"}
|
|
1
|
+
{"version":3,"file":"index.esm.js","sources":["../src/components/SettingsModal.tsx","../src/extensions.tsx","../src/routes.ts","../src/plugin.ts"],"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 React from 'react';\nimport {\n Button,\n Dialog,\n DialogActions,\n DialogContent,\n DialogTitle,\n} from '@material-ui/core';\n\nexport const SettingsModal = ({\n open,\n close,\n componentName,\n children,\n}: {\n open: boolean;\n close: Function;\n componentName: string;\n children: JSX.Element;\n}) => {\n return (\n <Dialog open={open} onClose={() => close()}>\n <DialogTitle>Settings - {componentName}</DialogTitle>\n <DialogContent>{children}</DialogContent>\n <DialogActions>\n <Button onClick={() => close()} color=\"primary\" variant=\"contained\">\n Close\n </Button>\n </DialogActions>\n </Dialog>\n );\n};\n","/*\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 React, { Suspense } from 'react';\nimport { IconButton } from '@material-ui/core';\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';\n\nexport type ComponentRenderer = {\n Renderer?: (props: RendererProps) => JSX.Element;\n};\n\ntype ComponentParts = {\n Content: () => JSX.Element;\n Actions?: () => JSX.Element;\n Settings?: () => JSX.Element;\n ContextProvider?: (props: any) => JSX.Element;\n};\n\ntype RendererProps = { title: string } & ComponentParts;\n\nexport function createCardExtension<T>({\n title,\n components,\n}: {\n title: string;\n components: () => Promise<ComponentParts>;\n}) {\n return createReactExtension({\n component: {\n lazy: () =>\n components().then(({ Content, Actions, Settings, ContextProvider }) => {\n const CardExtension = ({\n Renderer,\n title: overrideTitle,\n ...childProps\n }: ComponentRenderer & { title?: string } & T) => {\n const app = useApp();\n const { Progress } = app.getComponents();\n const [settingsOpen, setSettingsOpen] = React.useState(false);\n\n if (Renderer) {\n return (\n <Suspense fallback={<Progress />}>\n <Renderer\n title={overrideTitle || title}\n {...{\n Content,\n ...(Actions ? { Actions } : {}),\n ...(Settings ? { Settings } : {}),\n ...(ContextProvider ? { ContextProvider } : {}),\n ...childProps,\n }}\n />\n </Suspense>\n );\n }\n\n const cardProps = {\n title: overrideTitle ?? title,\n ...(Settings\n ? {\n action: (\n <IconButton onClick={() => setSettingsOpen(true)}>\n <SettingsIcon>Settings</SettingsIcon>\n </IconButton>\n ),\n }\n : {}),\n ...(Actions\n ? {\n actions: <Actions />,\n }\n : {}),\n };\n\n const innerContent = (\n <InfoCard {...cardProps}>\n {Settings && (\n <SettingsModal\n open={settingsOpen}\n componentName={title}\n close={() => setSettingsOpen(false)}\n >\n <Settings />\n </SettingsModal>\n )}\n <Content />\n </InfoCard>\n );\n\n return (\n <Suspense fallback={<Progress />}>\n {ContextProvider ? (\n <ContextProvider {...childProps}>\n {innerContent}\n </ContextProvider>\n ) : (\n innerContent\n )}\n </Suspense>\n );\n };\n return CardExtension;\n }),\n },\n });\n}\n","/*\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 */\nimport { createRouteRef } from '@backstage/core-plugin-api';\n\nexport const rootRouteRef = createRouteRef({\n title: 'home',\n});\n","/*\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 */\nimport {\n createComponentExtension,\n createPlugin,\n createRoutableExtension,\n} from '@backstage/core-plugin-api';\nimport { createCardExtension } from './extensions';\n\nimport { rootRouteRef } from './routes';\n\nexport const homePlugin = createPlugin({\n id: 'home',\n routes: {\n root: rootRouteRef,\n },\n});\n\nexport const HomepageCompositionRoot = homePlugin.provide(\n createRoutableExtension({\n component: () =>\n import('./components').then(m => m.HomepageCompositionRoot),\n mountPoint: rootRouteRef,\n }),\n);\n\nexport const ComponentAccordion = homePlugin.provide(\n createComponentExtension({\n component: {\n lazy: () =>\n import('./componentRenderers').then(m => m.ComponentAccordion),\n },\n }),\n);\nexport const ComponentTabs = homePlugin.provide(\n createComponentExtension({\n component: {\n lazy: () => import('./componentRenderers').then(m => m.ComponentTabs),\n },\n }),\n);\nexport const ComponentTab = homePlugin.provide(\n createComponentExtension({\n component: {\n lazy: () => import('./componentRenderers').then(m => m.ComponentTab),\n },\n }),\n);\n\nexport const HomePageRandomJoke = homePlugin.provide(\n createCardExtension<{ defaultCategory?: 'any' | 'programming' }>({\n title: 'Random Joke',\n components: () => import('./homePageComponents/RandomJoke'),\n }),\n);\n"],"names":[],"mappings":";;;;;;;MAyBa,gBAAgB,CAAC;AAAA,EAC5B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,MAMI;AACJ,6CACG,QAAD;AAAA,IAAQ;AAAA,IAAY,SAAS,MAAM;AAAA,yCAChC,aAAD,MAAa,eAAY,oDACxB,eAAD,MAAgB,+CACf,eAAD,0CACG,QAAD;AAAA,IAAQ,SAAS,MAAM;AAAA,IAAS,OAAM;AAAA,IAAU,SAAQ;AAAA,KAAY;AAAA;;6BCLrC;AAAA,EACrC;AAAA,EACA;AAAA,GAIC;AACD,SAAO,qBAAqB;AAAA,IAC1B,WAAW;AAAA,MACT,MAAM,MACJ,aAAa,KAAK,CAAC,CAAE,SAAS,SAAS,UAAU,qBAAsB;AACrE,cAAM,gBAAgB,CAAC;AAAA,UACrB;AAAA,UACA,OAAO;AAAA,aACJ;AAAA,cAC6C;AAChD,gBAAM,MAAM;AACZ,gBAAM,CAAE,YAAa,IAAI;AACzB,gBAAM,CAAC,cAAc,mBAAmB,MAAM,SAAS;AAEvD,cAAI,UAAU;AACZ,uDACG,UAAD;AAAA,cAAU,8CAAW,UAAD;AAAA,mDACjB,UAAD;AAAA,cACE,OAAO,iBAAiB;AAAA,iBACpB;AAAA,gBACF;AAAA,mBACI,UAAU,CAAE,WAAY;AAAA,mBACxB,WAAW,CAAE,YAAa;AAAA,mBAC1B,kBAAkB,CAAE,mBAAoB;AAAA,mBACzC;AAAA;AAAA;AAAA;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
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backstage/plugin-home",
|
|
3
|
-
"
|
|
3
|
+
"description": "A Backstage plugin that helps you build a home page",
|
|
4
|
+
"version": "0.4.0",
|
|
4
5
|
"main": "dist/index.esm.js",
|
|
5
6
|
"types": "dist/index.d.ts",
|
|
6
7
|
"license": "Apache-2.0",
|
|
@@ -20,22 +21,22 @@
|
|
|
20
21
|
"clean": "backstage-cli clean"
|
|
21
22
|
},
|
|
22
23
|
"dependencies": {
|
|
23
|
-
"@backstage/core-components": "^0.
|
|
24
|
-
"@backstage/core-plugin-api": "^0.1.
|
|
25
|
-
"@backstage/theme": "^0.2.
|
|
24
|
+
"@backstage/core-components": "^0.4.2",
|
|
25
|
+
"@backstage/core-plugin-api": "^0.1.8",
|
|
26
|
+
"@backstage/theme": "^0.2.10",
|
|
26
27
|
"@material-ui/core": "^4.12.2",
|
|
27
28
|
"@material-ui/icons": "^4.9.1",
|
|
28
|
-
"@material-ui/lab": "4.0.0-alpha.
|
|
29
|
-
"@types/react": "
|
|
29
|
+
"@material-ui/lab": "4.0.0-alpha.57",
|
|
30
|
+
"@types/react": "*",
|
|
30
31
|
"react": "^16.13.1",
|
|
31
32
|
"react-dom": "^16.13.1",
|
|
32
|
-
"react-router": "
|
|
33
|
+
"react-router": "6.0.0-beta.0",
|
|
33
34
|
"react-use": "^17.2.4"
|
|
34
35
|
},
|
|
35
36
|
"devDependencies": {
|
|
36
|
-
"@backstage/cli": "^0.7.
|
|
37
|
-
"@backstage/core-app-api": "^0.1.
|
|
38
|
-
"@backstage/dev-utils": "^0.2.
|
|
37
|
+
"@backstage/cli": "^0.7.12",
|
|
38
|
+
"@backstage/core-app-api": "^0.1.13",
|
|
39
|
+
"@backstage/dev-utils": "^0.2.9",
|
|
39
40
|
"@backstage/test-utils": "^0.1.17",
|
|
40
41
|
"@testing-library/jest-dom": "^5.10.1",
|
|
41
42
|
"@testing-library/react": "^11.2.5",
|
|
@@ -48,5 +49,5 @@
|
|
|
48
49
|
"files": [
|
|
49
50
|
"dist"
|
|
50
51
|
],
|
|
51
|
-
"gitHead": "
|
|
52
|
+
"gitHead": "4dc47ebe3c30e9bdba9c2239aed9ece1a4d479a0"
|
|
52
53
|
}
|