@backstage/plugin-home 0.4.19 → 0.4.20-next.2
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 +32 -0
- package/README.md +1 -2
- package/dist/esm/index-0caca094.esm.js.map +1 -1
- package/dist/esm/{index-d8d6d705.esm.js → index-102452e1.esm.js} +15 -20
- package/dist/esm/index-102452e1.esm.js.map +1 -0
- package/dist/esm/{index-97d987f3.esm.js → index-2cd1ac3a.esm.js} +3 -5
- package/dist/esm/index-2cd1ac3a.esm.js.map +1 -0
- package/dist/esm/{index-bc3d603a.esm.js → index-bf89e9e8.esm.js} +3 -5
- package/dist/esm/index-bf89e9e8.esm.js.map +1 -0
- package/dist/esm/{index-539ef173.esm.js → index-dc735eaa.esm.js} +1 -1
- package/dist/esm/{index-539ef173.esm.js.map → index-dc735eaa.esm.js.map} +1 -1
- package/dist/esm/index-de145e83.esm.js.map +1 -1
- package/dist/esm/index-f1d655aa.esm.js.map +1 -1
- package/dist/index.d.ts +17 -7
- package/dist/index.esm.js +12 -20
- package/dist/index.esm.js.map +1 -1
- package/package.json +12 -10
- package/dist/esm/index-97d987f3.esm.js.map +0 -1
- package/dist/esm/index-bc3d603a.esm.js.map +0 -1
- package/dist/esm/index-d8d6d705.esm.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,37 @@
|
|
|
1
1
|
# @backstage/plugin-home
|
|
2
2
|
|
|
3
|
+
## 0.4.20-next.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 99063c39ae: Minor API report cleanup
|
|
8
|
+
- Updated dependencies
|
|
9
|
+
- @backstage/core-components@0.9.3-next.1
|
|
10
|
+
- @backstage/plugin-catalog-react@1.0.1-next.2
|
|
11
|
+
- @backstage/catalog-model@1.0.1-next.1
|
|
12
|
+
|
|
13
|
+
## 0.4.20-next.1
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- ac323de4ad: - Adds new `HomePageStackOverflowQuestions` component which renders a list of stack overflow questions on your homepage.
|
|
18
|
+
|
|
19
|
+
- Exports `ComponentRenderer` type.
|
|
20
|
+
|
|
21
|
+
- Updated dependencies
|
|
22
|
+
- @backstage/plugin-catalog-react@1.0.1-next.1
|
|
23
|
+
- @backstage/plugin-stack-overflow@0.1.0-next.0
|
|
24
|
+
|
|
25
|
+
## 0.4.20-next.0
|
|
26
|
+
|
|
27
|
+
### Patch Changes
|
|
28
|
+
|
|
29
|
+
- Updated dependencies
|
|
30
|
+
- @backstage/catalog-model@1.0.1-next.0
|
|
31
|
+
- @backstage/plugin-search@0.7.5-next.0
|
|
32
|
+
- @backstage/plugin-catalog-react@1.0.1-next.0
|
|
33
|
+
- @backstage/core-components@0.9.3-next.0
|
|
34
|
+
|
|
3
35
|
## 0.4.19
|
|
4
36
|
|
|
5
37
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -10,8 +10,7 @@ If you have a standalone app (you didn't clone this repo), then do
|
|
|
10
10
|
|
|
11
11
|
```bash
|
|
12
12
|
# From the Backstage repository root
|
|
13
|
-
|
|
14
|
-
yarn add @backstage/plugin-home
|
|
13
|
+
yarn add --cwd packages/app @backstage/plugin-home
|
|
15
14
|
```
|
|
16
15
|
|
|
17
16
|
### Setting up the Home Page
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index-0caca094.esm.js","sources":["../../src/homePageComponents/CompanyLogo/CompanyLogo.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 */\nimport { Typography } from '@material-ui/core';\nimport { configApiRef, useApi } from '@backstage/core-plugin-api';\nimport React from 'react';\n\ntype CompanyLogoProps = {\n logo?: React.ReactNode;\n className?: string;\n};\n\n/**\n * A component to display a company logo for the user.\n *\n * @public\n */\nexport const CompanyLogo = (props: CompanyLogoProps) => {\n const { logo, className } = props;\n const configApi = useApi(configApiRef);\n\n return (\n <div className={className}>\n {logo ? (\n <>{logo}</>\n ) : (\n <Typography variant=\"h1\">{configApi.getString('app.title')}</Typography>\n )}\n </div>\n );\n};\n"],"names":[],"mappings":";;;;AA6Ba,MAAA,WAAA,GAAc,CAAC,KAA4B,KAAA;AACtD,EAAM,MAAA,EAAE,MAAM,SAAc,EAAA,GAAA,KAAA,CAAA;AAC5B,
|
|
1
|
+
{"version":3,"file":"index-0caca094.esm.js","sources":["../../src/homePageComponents/CompanyLogo/CompanyLogo.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 */\nimport { Typography } from '@material-ui/core';\nimport { configApiRef, useApi } from '@backstage/core-plugin-api';\nimport React from 'react';\n\ntype CompanyLogoProps = {\n logo?: React.ReactNode;\n className?: string;\n};\n\n/**\n * A component to display a company logo for the user.\n *\n * @public\n */\nexport const CompanyLogo = (props: CompanyLogoProps) => {\n const { logo, className } = props;\n const configApi = useApi(configApiRef);\n\n return (\n <div className={className}>\n {logo ? (\n <>{logo}</>\n ) : (\n <Typography variant=\"h1\">{configApi.getString('app.title')}</Typography>\n )}\n </div>\n );\n};\n"],"names":[],"mappings":";;;;AA6Ba,MAAA,WAAA,GAAc,CAAC,KAA4B,KAAA;AACtD,EAAM,MAAA,EAAE,MAAM,SAAc,EAAA,GAAA,KAAA,CAAA;AAC5B,EAAM,MAAA,SAAA,GAAY,OAAO,YAAY,CAAA,CAAA;AAErC,EAAA,uBACG,KAAA,CAAA,aAAA,CAAA,KAAA,EAAA;AAAA,IAAI,SAAA;AAAA,GAAA,EACF,IACC,mBAAA,KAAA,CAAA,aAAA,CAAA,KAAA,CAAA,QAAA,EAAA,IAAA,EAAG,IAAK,CAAA,mBAEP,KAAA,CAAA,aAAA,CAAA,UAAA,EAAA;AAAA,IAAW,OAAQ,EAAA,IAAA;AAAA,GAAA,EAAM,SAAU,CAAA,SAAA,CAAU,WAAW,CAAE,CAE/D,CAAA,CAAA;AAEJ;;;;"}
|
|
@@ -16,15 +16,16 @@ const useStyles = makeStyles((theme) => ({
|
|
|
16
16
|
width: "100%"
|
|
17
17
|
}
|
|
18
18
|
}));
|
|
19
|
-
const ComponentAccordion = ({
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
19
|
+
const ComponentAccordion = (props) => {
|
|
20
|
+
const {
|
|
21
|
+
title,
|
|
22
|
+
expanded = false,
|
|
23
|
+
Content,
|
|
24
|
+
Actions,
|
|
25
|
+
Settings,
|
|
26
|
+
ContextProvider,
|
|
27
|
+
...childProps
|
|
28
|
+
} = props;
|
|
28
29
|
const classes = useStyles();
|
|
29
30
|
const [settingsIsExpanded, setSettingsIsExpanded] = React.useState(false);
|
|
30
31
|
const [isExpanded, setIsExpanded] = React.useState(expanded);
|
|
@@ -52,10 +53,8 @@ const ComponentAccordion = ({
|
|
|
52
53
|
}, innerContent) : innerContent;
|
|
53
54
|
};
|
|
54
55
|
|
|
55
|
-
const ComponentTabs = ({
|
|
56
|
-
title,
|
|
57
|
-
tabs
|
|
58
|
-
}) => {
|
|
56
|
+
const ComponentTabs = (props) => {
|
|
57
|
+
const { title, tabs } = props;
|
|
59
58
|
const [value, setValue] = React.useState(0);
|
|
60
59
|
const handleChange = (_event, newValue) => {
|
|
61
60
|
setValue(newValue);
|
|
@@ -74,16 +73,12 @@ const ComponentTabs = ({
|
|
|
74
73
|
}, /* @__PURE__ */ React.createElement(Component, null))));
|
|
75
74
|
};
|
|
76
75
|
|
|
77
|
-
const ComponentTab = ({
|
|
78
|
-
title,
|
|
79
|
-
Content,
|
|
80
|
-
ContextProvider,
|
|
81
|
-
...childProps
|
|
82
|
-
}) => {
|
|
76
|
+
const ComponentTab = (props) => {
|
|
77
|
+
const { title, Content, ContextProvider, ...childProps } = props;
|
|
83
78
|
return ContextProvider ? /* @__PURE__ */ React.createElement(ContextProvider, {
|
|
84
79
|
...childProps
|
|
85
80
|
}, /* @__PURE__ */ React.createElement(Content, null)) : /* @__PURE__ */ React.createElement(Content, null);
|
|
86
81
|
};
|
|
87
82
|
|
|
88
83
|
export { ComponentAccordion, ComponentTab, ComponentTabs };
|
|
89
|
-
//# sourceMappingURL=index-
|
|
84
|
+
//# sourceMappingURL=index-102452e1.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-102452e1.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 contentContainer: {\n width: '100%',\n },\n}));\n\nexport const ComponentAccordion = (props: {\n title: string;\n expanded?: boolean;\n Content: () => JSX.Element;\n Actions?: () => JSX.Element;\n Settings?: () => JSX.Element;\n ContextProvider?: (props: any) => JSX.Element;\n}) => {\n const {\n title,\n expanded = false,\n Content,\n Actions,\n Settings,\n ContextProvider,\n ...childProps\n } = props;\n\n const classes = useStyles();\n const [settingsIsExpanded, setSettingsIsExpanded] = React.useState(false);\n const [isExpanded, setIsExpanded] = React.useState(expanded);\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, expandedValue: boolean) =>\n setIsExpanded(expandedValue)\n }\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 className={classes.contentContainer}>\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 = (props: { title: string; tabs: TabType[] }) => {\n const { title, tabs } = props;\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\n key={idx}\n {...(idx !== value ? { style: { display: 'none' } } : {})}\n >\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 = (props: {\n title: string;\n Content: () => JSX.Element;\n ContextProvider?: (props: any) => JSX.Element;\n}) => {\n const { title, Content, ContextProvider, ...childProps } = props;\n\n return ContextProvider ? (\n <ContextProvider {...childProps}>\n <Content />\n </ContextProvider>\n ) : (\n <Content />\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;AA+BA,MAAM,SAAA,GAAY,UAAW,CAAA,CAAC,KAAkB,MAAA;AAAA,EAC9C,kBAAoB,EAAA;AAAA,IAClB,SAAS,KAAM,C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A,GAAA,kBACP,KAAA,CAAA,aAAA,CAAA,IAAA,EAAA;AAAA,IAAK,KAAA;AAAA,IAAc,QAAU,EAAA,YAAA;AAAA,GAC3B,EAAA,IAAA,CAAK,GAAI,CAAA,CAAA,CAAA,qBACP,KAAA,CAAA,aAAA,CAAA,GAAA,EAAA;AAAA,IAAI,KAAK,CAAE,CAAA,KAAA;AAAA,IAAO,OAAO,CAAE,CAAA,KAAA;AAAA,GAAO,CACpC,CACH,CACC,EAAA,IAAA,CAAK,IAAI,CAAC,EAAE,SAAa,EAAA,EAAA,GAAA,qBACvB,KAAA,CAAA,aAAA,CAAA,KAAA,EAAA;AAAA,IACC,GAAK,EAAA,GAAA;AAAA,IACA,GAAA,GAAA,KAAQ,QAAQ,EAAE,KAAA,EAAO,EAAE,OAAS,EAAA,MAAA,EAAS,EAAA,GAAI,EAAC;AAAA,GAAA,kBAEtD,KAAA,CAAA,aAAA,CAAA,SAAA,EAAA,IAAU,CACb,CACD,CACH,CAAA,CAAA;AAEJ;;ACjCa,MAAA,YAAA,GAAe,CAAC,KAIvB,KAAA;AACJ,EAAA,MAAM,EAAE,KAAA,EAAO,OAAS,EAAA,eAAA,EAAA,GAAoB,UAAe,EAAA,GAAA,KAAA,CAAA;AAE3D,EAAA,OAAO,kCACJ,KAAA,CAAA,aAAA,CAAA,eAAA,EAAA;AAAA,IAAoB,GAAA,UAAA;AAAA,GAAA,kBAClB,KAAA,CAAA,aAAA,CAAA,OAAA,EAAA,IAAQ,CACX,CAAA,uCAEC,OAAQ,EAAA,IAAA,CAAA,CAAA;AAEb;;;;"}
|
|
@@ -4,10 +4,8 @@ import upperFirst from 'lodash/upperFirst';
|
|
|
4
4
|
|
|
5
5
|
const Context = createContext(void 0);
|
|
6
6
|
const getNewJoke = (type) => fetch(`https://official-joke-api.appspot.com/jokes${type !== "any" ? `/${type}` : ""}/random`).then((res) => res.json()).then((data) => Array.isArray(data) ? data[0] : data);
|
|
7
|
-
const ContextProvider = ({
|
|
8
|
-
children,
|
|
9
|
-
defaultCategory
|
|
10
|
-
}) => {
|
|
7
|
+
const ContextProvider = (props) => {
|
|
8
|
+
const { children, defaultCategory } = props;
|
|
11
9
|
const [loading, setLoading] = React.useState(true);
|
|
12
10
|
const [joke, setJoke] = React.useState({
|
|
13
11
|
setup: "",
|
|
@@ -82,4 +80,4 @@ const Settings = () => {
|
|
|
82
80
|
};
|
|
83
81
|
|
|
84
82
|
export { Actions, Content, ContextProvider, Settings };
|
|
85
|
-
//# sourceMappingURL=index-
|
|
83
|
+
//# sourceMappingURL=index-2cd1ac3a.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-2cd1ac3a.esm.js","sources":["../../src/homePageComponents/RandomJoke/Context.tsx","../../src/homePageComponents/RandomJoke/Actions.tsx","../../src/homePageComponents/RandomJoke/Content.tsx","../../src/homePageComponents/RandomJoke/Settings.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, { createContext } from 'react';\n\nexport type JokeType = 'any' | 'programming';\n\ntype Joke = {\n setup: string;\n punchline: string;\n};\n\ntype RandomJokeContextValue = {\n loading: boolean;\n joke: Joke;\n type: JokeType;\n rerollJoke: Function;\n handleChangeType: Function;\n};\n\nconst Context = createContext<RandomJokeContextValue | undefined>(undefined);\n\nconst getNewJoke = (type: string): Promise<Joke> =>\n fetch(\n `https://official-joke-api.appspot.com/jokes${\n type !== 'any' ? `/${type}` : ''\n }/random`,\n )\n .then(res => res.json())\n .then(data => (Array.isArray(data) ? data[0] : data));\n\nexport const ContextProvider = (props: {\n children: JSX.Element;\n defaultCategory?: JokeType;\n}) => {\n const { children, defaultCategory } = props;\n\n const [loading, setLoading] = React.useState(true);\n const [joke, setJoke] = React.useState<Joke>({\n setup: '',\n punchline: '',\n });\n const [type, setType] = React.useState<JokeType>(\n defaultCategory || ('programming' as JokeType),\n );\n\n const rerollJoke = React.useCallback(() => {\n setLoading(true);\n getNewJoke(type).then(newJoke => setJoke(newJoke));\n }, [type]);\n\n const handleChangeType = (newType: JokeType) => {\n setType(newType);\n };\n\n React.useEffect(() => {\n setLoading(false);\n }, [joke]);\n\n React.useEffect(() => {\n rerollJoke();\n }, [rerollJoke]);\n\n const value: RandomJokeContextValue = {\n loading,\n joke,\n type,\n rerollJoke,\n handleChangeType,\n };\n\n return <Context.Provider value={value}>{children}</Context.Provider>;\n};\n\nexport const useRandomJoke = () => {\n const value = React.useContext(Context);\n\n if (value === undefined) {\n throw new Error('useRandomJoke must be used within a RandomJokeProvider');\n }\n\n return value;\n};\n\nexport default Context;\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\nimport { Button } from '@material-ui/core';\nimport { useRandomJoke } from './Context';\n\nexport const Actions = () => {\n const { rerollJoke } = useRandomJoke();\n return (\n <Button variant=\"contained\" color=\"primary\" onClick={() => rerollJoke()}>\n Reroll\n </Button>\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 { useRandomJoke } from './Context';\n\nexport const Content = () => {\n const { joke, loading } = useRandomJoke();\n\n if (loading) return <p>Loading...</p>;\n\n return (\n <div>\n <p>{joke.setup}</p>\n <p>{joke.punchline}</p>\n </div>\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 {\n FormControl,\n FormLabel,\n RadioGroup,\n FormControlLabel,\n Radio,\n} from '@material-ui/core';\nimport React from 'react';\nimport { useRandomJoke, JokeType } from './Context';\nimport upperFirst from 'lodash/upperFirst';\n\nexport const Settings = () => {\n const { type, handleChangeType } = useRandomJoke();\n const JOKE_TYPES: JokeType[] = ['any' as JokeType, 'programming' as JokeType];\n return (\n <FormControl component=\"fieldset\">\n <FormLabel component=\"legend\">Joke Type</FormLabel>\n <RadioGroup\n aria-label=\"joke type\"\n value={type}\n onChange={e => handleChangeType(e.target.value)}\n >\n {JOKE_TYPES.map(t => (\n <FormControlLabel\n key={t}\n value={t}\n control={<Radio />}\n label={upperFirst(t)}\n />\n ))}\n </RadioGroup>\n </FormControl>\n );\n};\n"],"names":[],"mappings":";;;;AAiCA,MAAM,OAAA,GAAU,cAAkD,KAAS,CAAA,CAAA,CAAA;AAE3E,MAAM,UAAA,GAAa,CAAC,IAAA,KAClB,KACE,CAAA,CAAA,2CAAA,EACE,SAAS,KAAQ,GAAA,CAAA,CAAA,E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,GAAA,EAAA,IAAA,EAAG,IAAK,CAAA,SAAU,CACrB,CAAA,CAAA;AAEJ;;ACJO,MAAM,WAAW,MAAM;AAC5B,EAAM,MAAA,EAAE,IAAM,EAAA,gBAAA,EAAA,GAAqB,aAAc,EAAA,CAAA;AACjD,EAAM,MAAA,UAAA,GAAyB,CAAC,KAAA,EAAmB,aAAyB,CAAA,CAAA;AAC5E,EAAA,uBACG,KAAA,CAAA,aAAA,CAAA,WAAA,EAAA;AAAA,IAAY,SAAU,EAAA,UAAA;AAAA,GAAA,kBACpB,KAAA,CAAA,aAAA,CAAA,SAAA,EAAA;AAAA,IAAU,SAAU,EAAA,QAAA;AAAA,GAAS,EAAA,WAAS,mBACtC,KAAA,CAAA,aAAA,CAAA,UAAA,EAAA;AAAA,IACC,YAAW,EAAA,WAAA;AAAA,IACX,KAAO,EAAA,IAAA;AAAA,IACP,QAAU,EAAA,CAAA,CAAA,KAAK,gBAAiB,CAAA,CAAA,CAAE,OAAO,KAAK,CAAA;AAAA,GAE7C,EAAA,UAAA,CAAW,GAAI,CAAA,CAAA,CAAA,qBACb,KAAA,CAAA,aAAA,CAAA,gBAAA,EAAA;AAAA,IACC,GAAK,EAAA,CAAA;AAAA,IACL,KAAO,EAAA,CAAA;AAAA,IACP,OAAA,sCAAU,KAAM,EAAA,IAAA,CAAA;AAAA,IAChB,KAAA,EAAO,WAAW,CAAC,CAAA;AAAA,GACrB,CACD,CACH,CACF,CAAA,CAAA;AAEJ;;;;"}
|
|
@@ -3,10 +3,8 @@ import { makeStyles, List, ListItemIcon, ListItemText } from '@material-ui/core'
|
|
|
3
3
|
import React, { createContext } from 'react';
|
|
4
4
|
|
|
5
5
|
const Context = createContext(void 0);
|
|
6
|
-
const ContextProvider = ({
|
|
7
|
-
children,
|
|
8
|
-
tools
|
|
9
|
-
}) => {
|
|
6
|
+
const ContextProvider = (props) => {
|
|
7
|
+
const { children, tools } = props;
|
|
10
8
|
const [toolsValue, _setTools] = React.useState(tools);
|
|
11
9
|
const value = {
|
|
12
10
|
tools: toolsValue
|
|
@@ -65,4 +63,4 @@ const Content = (props) => {
|
|
|
65
63
|
};
|
|
66
64
|
|
|
67
65
|
export { Content, ContextProvider };
|
|
68
|
-
//# sourceMappingURL=index-
|
|
66
|
+
//# sourceMappingURL=index-bf89e9e8.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-bf89e9e8.esm.js","sources":["../../src/homePageComponents/Toolkit/Context.tsx","../../src/homePageComponents/Toolkit/Content.tsx"],"sourcesContent":["/*\n * Copyright 2022 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, { createContext } from 'react';\n\nexport type Tool = {\n label: string;\n url: string;\n icon: React.ReactNode;\n};\n\ntype ToolkitContextValue = {\n tools: Tool[];\n};\n\nconst Context = createContext<ToolkitContextValue | undefined>(undefined);\n\nexport const ContextProvider = (props: {\n children: JSX.Element;\n tools: Tool[];\n}) => {\n const { children, tools } = props;\n\n const [toolsValue, _setTools] = React.useState(tools);\n\n const value: ToolkitContextValue = {\n tools: toolsValue,\n };\n\n return <Context.Provider value={value}>{children}</Context.Provider>;\n};\n\nexport const useToolkit = () => {\n const value = React.useContext(Context);\n return value;\n};\n\nexport default Context;\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 { Link } from '@backstage/core-components';\nimport {\n makeStyles,\n List,\n ListItemIcon,\n ListItemText,\n} from '@material-ui/core';\nimport React from 'react';\nimport { useToolkit, Tool } from './Context';\n\nconst useStyles = makeStyles(theme => ({\n toolkit: {\n display: 'flex',\n flexWrap: 'wrap',\n textAlign: 'center',\n },\n tool: {\n margin: theme.spacing(0.5, 1),\n },\n label: {\n marginTop: theme.spacing(1),\n fontSize: '0.9em',\n lineHeight: '1.25',\n color: theme.palette.text.secondary,\n },\n icon: {\n width: '64px',\n height: '64px',\n borderRadius: '50px',\n justifyContent: 'center',\n alignItems: 'center',\n boxShadow: theme.shadows[1],\n backgroundColor: theme.palette.background.default,\n },\n}));\n\n/**\n * Props for Toolkit content component {@link Content}.\n *\n * @public\n */\nexport type ToolkitContentProps = {\n tools: Tool[];\n};\n\n/**\n * A component to display a list of tools for the user.\n *\n * @public\n */\nexport const Content = (props: ToolkitContentProps) => {\n const classes = useStyles();\n const toolkit = useToolkit();\n const tools = toolkit?.tools ?? props.tools;\n\n return (\n <List className={classes.toolkit}>\n {tools.map((tool: Tool) => (\n <Link key={tool.url} to={tool.url} className={classes.tool}>\n <ListItemIcon className={classes.icon}>{tool.icon}</ListItemIcon>\n <ListItemText\n secondaryTypographyProps={{ className: classes.label }}\n secondary={tool.label}\n />\n </Link>\n ))}\n </List>\n );\n};\n"],"names":[],"mappings":";;;;AA4BA,MAAM,OAAA,GAAU,cAA+C,KAAS,CAAA,CAAA,CAAA;AAE3D,MAAA,eAAA,GAAkB,CAAC,KAG1B,KAAA;AACJ,EAAM,MAAA,EAAE,UAAU,KAAU,EAAA,GAAA,KAAA,CAAA;AAE5B,EAAA,MAAM,CAAC,UAAA,EAAY,SAAa,CAAA,GAAA,KAAA,CAAM,SAAS,KAAK,CAAA,CAAA;AAEpD,EAAA,MAAM,KAA6B,GAAA;AAAA,IACjC,KAAO,EAAA,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,UAAU,SAAU,EAAA,CAAA;AAC1B,EAAA,MAAM,UAAU,UAAW,EAAA,CAAA;AAC3B,EAAA,MAAM,KAAQ,GAAA,CAAA,EAAA,GAAA,OAAA,IAAA,IAAA,GAAA,KAAA,CAAA,GAAA,OAAA,CAAS,KAAT,KAAA,IAAA,GAAA,EAAA,GAAkB,KAAM,CAAA,KAAA,CAAA;AAEtC,EAAA,uBACG,KAAA,CAAA,aAAA,CAAA,IAAA,EAAA;AAAA,IAAK,WAAW,OAAQ,CAAA,OAAA;AAAA,GAAA,EACtB,KAAM,CAAA,GAAA,CAAI,CAAC,IAAA,qBACT,KAAA,CAAA,aAAA,CAAA,IAAA,EAAA;AAAA,IAAK,KAAK,IAAK,CAAA,GAAA;AAAA,IAAK,IAAI,IAAK,CAAA,GAAA;AAAA,IAAK,WAAW,OAAQ,CAAA,IAAA;AAAA,GAAA,kBACnD,KAAA,CAAA,aAAA,CAAA,YAAA,EAAA;AAAA,IAAa,WAAW,OAAQ,CAAA,IAAA;AAAA,GAAO,EAAA,IAAA,CAAK,IAAK,CAAA,kBACjD,KAAA,CAAA,aAAA,CAAA,YAAA,EAAA;AAAA,IACC,wBAA0B,EAAA,EAAE,SAAW,EAAA,OAAA,CAAQ,KAAM,EAAA;AAAA,IACrD,WAAW,IAAK,CAAA,KAAA;AAAA,GAClB,CACF,CACD,CACH,CAAA,CAAA;AAEJ;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index-
|
|
1
|
+
{"version":3,"file":"index-dc735eaa.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":";;;;;;;;AAmBa,MAAA,uBAAA,GAA0B,CAAC,KAGlC,KAAA;AAtBN,EAAA,IAAA,EAAA,CAAA;AAuBE,EAAA,MAAM,SAAS,SAAU,EAAA,CAAA;AACzB,EAAM,MAAA,QAAA,GAAW,CAAM,EAAA,GAAA,KAAA,CAAA,QAAA,KAAN,IAAkB,GAAA,EAAA,GAAA,MAAA,CAAA;AACnC,EAAA,iEAAU,QAAS,CAAA,CAAA;AACrB;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index-de145e83.esm.js","sources":["../../src/homePageComponents/StarredEntities/Content.tsx"],"sourcesContent":["/*\n * Copyright 2022 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 {\n useStarredEntities,\n entityRouteRef,\n} from '@backstage/plugin-catalog-react';\nimport { parseEntityRef } from '@backstage/catalog-model';\nimport { useRouteRef } from '@backstage/core-plugin-api';\nimport { Link } from '@backstage/core-components';\nimport {\n List,\n ListItem,\n ListItemSecondaryAction,\n IconButton,\n ListItemText,\n Tooltip,\n Typography,\n} from '@material-ui/core';\nimport StarIcon from '@material-ui/icons/Star';\nimport React from 'react';\n\n/**\n * A component to display a list of starred entities for the user.\n *\n * @public\n */\n\nexport const Content = () => {\n const catalogEntityRoute = useRouteRef(entityRouteRef);\n const { starredEntities, toggleStarredEntity } = useStarredEntities();\n\n if (starredEntities.size === 0)\n return (\n <Typography variant=\"body1\">\n You do not have any starred entities yet!\n </Typography>\n );\n\n return (\n <List>\n {Array.from(starredEntities).map(entity => (\n <ListItem key={entity}>\n <Link to={catalogEntityRoute(parseEntityRef(entity))}>\n <ListItemText primary={parseEntityRef(entity).name} />\n </Link>\n <ListItemSecondaryAction>\n <Tooltip title=\"Remove from starred\">\n <IconButton\n edge=\"end\"\n aria-label=\"unstar\"\n onClick={() => toggleStarredEntity(entity)}\n >\n <StarIcon />\n </IconButton>\n </Tooltip>\n </ListItemSecondaryAction>\n </ListItem>\n ))}\n </List>\n );\n};\n"],"names":[],"mappings":";;;;;;;;AAyCO,MAAM,UAAU,MAAM;AAC3B,
|
|
1
|
+
{"version":3,"file":"index-de145e83.esm.js","sources":["../../src/homePageComponents/StarredEntities/Content.tsx"],"sourcesContent":["/*\n * Copyright 2022 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 {\n useStarredEntities,\n entityRouteRef,\n} from '@backstage/plugin-catalog-react';\nimport { parseEntityRef } from '@backstage/catalog-model';\nimport { useRouteRef } from '@backstage/core-plugin-api';\nimport { Link } from '@backstage/core-components';\nimport {\n List,\n ListItem,\n ListItemSecondaryAction,\n IconButton,\n ListItemText,\n Tooltip,\n Typography,\n} from '@material-ui/core';\nimport StarIcon from '@material-ui/icons/Star';\nimport React from 'react';\n\n/**\n * A component to display a list of starred entities for the user.\n *\n * @public\n */\n\nexport const Content = () => {\n const catalogEntityRoute = useRouteRef(entityRouteRef);\n const { starredEntities, toggleStarredEntity } = useStarredEntities();\n\n if (starredEntities.size === 0)\n return (\n <Typography variant=\"body1\">\n You do not have any starred entities yet!\n </Typography>\n );\n\n return (\n <List>\n {Array.from(starredEntities).map(entity => (\n <ListItem key={entity}>\n <Link to={catalogEntityRoute(parseEntityRef(entity))}>\n <ListItemText primary={parseEntityRef(entity).name} />\n </Link>\n <ListItemSecondaryAction>\n <Tooltip title=\"Remove from starred\">\n <IconButton\n edge=\"end\"\n aria-label=\"unstar\"\n onClick={() => toggleStarredEntity(entity)}\n >\n <StarIcon />\n </IconButton>\n </Tooltip>\n </ListItemSecondaryAction>\n </ListItem>\n ))}\n </List>\n );\n};\n"],"names":[],"mappings":";;;;;;;;AAyCO,MAAM,UAAU,MAAM;AAC3B,EAAM,MAAA,kBAAA,GAAqB,YAAY,cAAc,CAAA,CAAA;AACrD,EAAM,MAAA,EAAE,eAAiB,EAAA,mBAAA,EAAA,GAAwB,kBAAmB,EAAA,CAAA;AAEpE,EAAA,IAAI,gBAAgB,IAAS,KAAA,CAAA;AAC3B,IAAA,uBACG,KAAA,CAAA,aAAA,CAAA,UAAA,EAAA;AAAA,MAAW,OAAQ,EAAA,OAAA;AAAA,KAAA,EAAQ,2CAE5B,CAAA,CAAA;AAGJ,EACE,uBAAA,KAAA,CAAA,aAAA,CAAC,YACE,KAAM,CAAA,IAAA,CAAK,eAAe,CAAE,CAAA,GAAA,CAAI,4BAC9B,KAAA,CAAA,aAAA,CAAA,QAAA,EAAA;AAAA,IAAS,GAAK,EAAA,MAAA;AAAA,GAAA,kBACZ,KAAA,CAAA,aAAA,CAAA,IAAA,EAAA;AAAA,IAAK,EAAI,EAAA,kBAAA,CAAmB,cAAe,CAAA,MAAM,CAAC,CAAA;AAAA,GAAA,kBAChD,KAAA,CAAA,aAAA,CAAA,YAAA,EAAA;AAAA,IAAa,OAAA,EAAS,cAAe,CAAA,MAAM,CAAE,CAAA,IAAA;AAAA,GAAM,CACtD,CAAA,kBACC,KAAA,CAAA,aAAA,CAAA,uBAAA,EAAA,IAAA,kBACE,KAAA,CAAA,aAAA,CAAA,OAAA,EAAA;AAAA,IAAQ,KAAM,EAAA,qBAAA;AAAA,GAAA,kBACZ,KAAA,CAAA,aAAA,CAAA,UAAA,EAAA;AAAA,IACC,IAAK,EAAA,KAAA;AAAA,IACL,YAAW,EAAA,QAAA;AAAA,IACX,OAAA,EAAS,MAAM,mBAAA,CAAoB,MAAM,CAAA;AAAA,GAAA,sCAExC,QAAS,EAAA,IAAA,CACZ,CACF,CACF,CACF,CACD,CACH,CAAA,CAAA;AAEJ;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index-f1d655aa.esm.js","sources":["../../src/homePageComponents/WelcomeTitle/timeUtil.ts","../../src/homePageComponents/WelcomeTitle/WelcomeTitle.tsx"],"sourcesContent":["/*\n * Copyright 2020 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 goodMorning from './locales/goodMorning.locales.json';\nimport goodAfternoon from './locales/goodAfternoon.locales.json';\nimport goodEvening from './locales/goodEvening.locales.json';\n\n// Select a large random integer at startup, to prevent the greetings to change\n// every time the user navigates.\nconst greetingRandomSeed = Math.floor(Math.random() * 1000000);\n\nexport function getTimeBasedGreeting(): { language: string; greeting: string } {\n const random = (array: string[]) => array[greetingRandomSeed % array.length];\n\n const currentHour = new Date(Date.now()).getHours();\n if (currentHour >= 23) {\n return {\n language: 'Seriously',\n greeting: 'Get some rest',\n };\n }\n const timeOfDay = (hour: number): { [language: string]: string } => {\n if (hour < 12) return goodMorning;\n if (hour < 17) return goodAfternoon;\n return goodEvening;\n };\n const greetings = timeOfDay(currentHour);\n const greetingsKey = random(Object.keys(greetings));\n return {\n language: greetingsKey,\n greeting: greetings[greetingsKey],\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 {\n alertApiRef,\n identityApiRef,\n useApi,\n} from '@backstage/core-plugin-api';\nimport { Tooltip } from '@material-ui/core';\nimport React, { useEffect, useMemo } from 'react';\nimport useAsync from 'react-use/lib/useAsync';\nimport { getTimeBasedGreeting } from './timeUtil';\n\nexport const WelcomeTitle = () => {\n const identityApi = useApi(identityApiRef);\n const alertApi = useApi(alertApiRef);\n const greeting = useMemo(() => getTimeBasedGreeting(), []);\n\n const { value: profile, error } = useAsync(() =>\n identityApi.getProfileInfo(),\n );\n\n useEffect(() => {\n if (error) {\n alertApi.post({\n message: `Failed to load user identity: ${error}`,\n severity: 'error',\n });\n }\n }, [error, alertApi]);\n\n return (\n <Tooltip title={greeting.language}>\n <span>{`${greeting.greeting}${\n profile?.displayName ? `, ${profile?.displayName}` : ''\n }!`}</span>\n </Tooltip>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsBA,MAAM,
|
|
1
|
+
{"version":3,"file":"index-f1d655aa.esm.js","sources":["../../src/homePageComponents/WelcomeTitle/timeUtil.ts","../../src/homePageComponents/WelcomeTitle/WelcomeTitle.tsx"],"sourcesContent":["/*\n * Copyright 2020 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 goodMorning from './locales/goodMorning.locales.json';\nimport goodAfternoon from './locales/goodAfternoon.locales.json';\nimport goodEvening from './locales/goodEvening.locales.json';\n\n// Select a large random integer at startup, to prevent the greetings to change\n// every time the user navigates.\nconst greetingRandomSeed = Math.floor(Math.random() * 1000000);\n\nexport function getTimeBasedGreeting(): { language: string; greeting: string } {\n const random = (array: string[]) => array[greetingRandomSeed % array.length];\n\n const currentHour = new Date(Date.now()).getHours();\n if (currentHour >= 23) {\n return {\n language: 'Seriously',\n greeting: 'Get some rest',\n };\n }\n const timeOfDay = (hour: number): { [language: string]: string } => {\n if (hour < 12) return goodMorning;\n if (hour < 17) return goodAfternoon;\n return goodEvening;\n };\n const greetings = timeOfDay(currentHour);\n const greetingsKey = random(Object.keys(greetings));\n return {\n language: greetingsKey,\n greeting: greetings[greetingsKey],\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 {\n alertApiRef,\n identityApiRef,\n useApi,\n} from '@backstage/core-plugin-api';\nimport { Tooltip } from '@material-ui/core';\nimport React, { useEffect, useMemo } from 'react';\nimport useAsync from 'react-use/lib/useAsync';\nimport { getTimeBasedGreeting } from './timeUtil';\n\nexport const WelcomeTitle = () => {\n const identityApi = useApi(identityApiRef);\n const alertApi = useApi(alertApiRef);\n const greeting = useMemo(() => getTimeBasedGreeting(), []);\n\n const { value: profile, error } = useAsync(() =>\n identityApi.getProfileInfo(),\n );\n\n useEffect(() => {\n if (error) {\n alertApi.post({\n message: `Failed to load user identity: ${error}`,\n severity: 'error',\n });\n }\n }, [error, alertApi]);\n\n return (\n <Tooltip title={greeting.language}>\n <span>{`${greeting.greeting}${\n profile?.displayName ? `, ${profile?.displayName}` : ''\n }!`}</span>\n </Tooltip>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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
3
3
|
import * as React from 'react';
|
|
4
4
|
import React__default from 'react';
|
|
5
5
|
|
|
6
|
+
/**
|
|
7
|
+
* @public
|
|
8
|
+
*/
|
|
6
9
|
declare type ComponentRenderer = {
|
|
7
10
|
Renderer?: (props: RendererProps) => JSX.Element;
|
|
8
11
|
};
|
|
@@ -23,7 +26,7 @@ declare type CardExtensionProps<T> = ComponentRenderer & {
|
|
|
23
26
|
*
|
|
24
27
|
* @public
|
|
25
28
|
*/
|
|
26
|
-
declare function createCardExtension<T>(
|
|
29
|
+
declare function createCardExtension<T>(options: {
|
|
27
30
|
title: string;
|
|
28
31
|
components: () => Promise<ComponentParts>;
|
|
29
32
|
name?: string;
|
|
@@ -44,14 +47,17 @@ declare type ToolkitContentProps = {
|
|
|
44
47
|
tools: Tool[];
|
|
45
48
|
};
|
|
46
49
|
|
|
50
|
+
/** @public */
|
|
47
51
|
declare const homePlugin: _backstage_core_plugin_api.BackstagePlugin<{
|
|
48
52
|
root: _backstage_core_plugin_api.RouteRef<undefined>;
|
|
49
53
|
}, {}>;
|
|
54
|
+
/** @public */
|
|
50
55
|
declare const HomepageCompositionRoot: (props: {
|
|
51
56
|
title?: string | undefined;
|
|
52
57
|
children?: React.ReactNode;
|
|
53
58
|
}) => JSX.Element;
|
|
54
|
-
|
|
59
|
+
/** @public */
|
|
60
|
+
declare const ComponentAccordion: (props: {
|
|
55
61
|
title: string;
|
|
56
62
|
expanded?: boolean | undefined;
|
|
57
63
|
Content: () => JSX.Element;
|
|
@@ -59,14 +65,16 @@ declare const ComponentAccordion: ({ title, expanded, Content, Actions, Settings
|
|
|
59
65
|
Settings?: (() => JSX.Element) | undefined;
|
|
60
66
|
ContextProvider?: ((props: any) => JSX.Element) | undefined;
|
|
61
67
|
}) => JSX.Element;
|
|
62
|
-
|
|
68
|
+
/** @public */
|
|
69
|
+
declare const ComponentTabs: (props: {
|
|
63
70
|
title: string;
|
|
64
71
|
tabs: {
|
|
65
72
|
label: string;
|
|
66
73
|
Component: () => JSX.Element;
|
|
67
74
|
}[];
|
|
68
75
|
}) => JSX.Element;
|
|
69
|
-
|
|
76
|
+
/** @public */
|
|
77
|
+
declare const ComponentTab: (props: {
|
|
70
78
|
title: string;
|
|
71
79
|
Content: () => JSX.Element;
|
|
72
80
|
ContextProvider?: ((props: any) => JSX.Element) | undefined;
|
|
@@ -86,6 +94,7 @@ declare const HomePageCompanyLogo: (props: {
|
|
|
86
94
|
logo?: React.ReactNode;
|
|
87
95
|
className?: string | undefined;
|
|
88
96
|
}) => JSX.Element;
|
|
97
|
+
/** @public */
|
|
89
98
|
declare const HomePageRandomJoke: (props: ComponentRenderer & {
|
|
90
99
|
title?: string | undefined;
|
|
91
100
|
} & {
|
|
@@ -108,7 +117,7 @@ declare const HomePageStarredEntities: (props: ComponentRenderer & {
|
|
|
108
117
|
title?: string | undefined;
|
|
109
118
|
}) => JSX.Element;
|
|
110
119
|
|
|
111
|
-
declare const SettingsModal: (
|
|
120
|
+
declare const SettingsModal: (props: {
|
|
112
121
|
open: boolean;
|
|
113
122
|
close: Function;
|
|
114
123
|
componentName: string;
|
|
@@ -119,8 +128,9 @@ declare type ClockConfig = {
|
|
|
119
128
|
label: string;
|
|
120
129
|
timeZone: string;
|
|
121
130
|
};
|
|
122
|
-
|
|
131
|
+
/** @public */
|
|
132
|
+
declare const HeaderWorldClock: (props: {
|
|
123
133
|
clockConfigs: ClockConfig[];
|
|
124
134
|
}) => JSX.Element | null;
|
|
125
135
|
|
|
126
|
-
export { ClockConfig, ComponentAccordion, ComponentTab, ComponentTabs, HeaderWorldClock, HomePageCompanyLogo, HomePageRandomJoke, HomePageStarredEntities, HomePageToolkit, HomepageCompositionRoot, SettingsModal, WelcomeTitle, createCardExtension, homePlugin };
|
|
136
|
+
export { ClockConfig, ComponentAccordion, ComponentRenderer, ComponentTab, ComponentTabs, HeaderWorldClock, HomePageCompanyLogo, HomePageRandomJoke, HomePageStarredEntities, HomePageToolkit, HomepageCompositionRoot, SettingsModal, WelcomeTitle, createCardExtension, homePlugin };
|
package/dist/index.esm.js
CHANGED
|
@@ -5,12 +5,8 @@ import SettingsIcon from '@material-ui/icons/Settings';
|
|
|
5
5
|
import { HeaderLabel, InfoCard } from '@backstage/core-components';
|
|
6
6
|
import 'react-router';
|
|
7
7
|
|
|
8
|
-
const SettingsModal = ({
|
|
9
|
-
open,
|
|
10
|
-
close,
|
|
11
|
-
componentName,
|
|
12
|
-
children
|
|
13
|
-
}) => {
|
|
8
|
+
const SettingsModal = (props) => {
|
|
9
|
+
const { open, close, componentName, children } = props;
|
|
14
10
|
return /* @__PURE__ */ React.createElement(Dialog, {
|
|
15
11
|
open,
|
|
16
12
|
onClose: () => close()
|
|
@@ -50,9 +46,8 @@ function getTimes(clockConfigs) {
|
|
|
50
46
|
}
|
|
51
47
|
return clocks;
|
|
52
48
|
}
|
|
53
|
-
const HeaderWorldClock = ({
|
|
54
|
-
clockConfigs
|
|
55
|
-
}) => {
|
|
49
|
+
const HeaderWorldClock = (props) => {
|
|
50
|
+
const { clockConfigs } = props;
|
|
56
51
|
const defaultTimes = [];
|
|
57
52
|
const [clocks, setTimes] = React.useState(defaultTimes);
|
|
58
53
|
React.useEffect(() => {
|
|
@@ -74,11 +69,8 @@ const HeaderWorldClock = ({
|
|
|
74
69
|
return null;
|
|
75
70
|
};
|
|
76
71
|
|
|
77
|
-
function createCardExtension({
|
|
78
|
-
title,
|
|
79
|
-
components,
|
|
80
|
-
name
|
|
81
|
-
}) {
|
|
72
|
+
function createCardExtension(options) {
|
|
73
|
+
const { title, components, name } = options;
|
|
82
74
|
return createReactExtension({
|
|
83
75
|
name,
|
|
84
76
|
component: {
|
|
@@ -146,25 +138,25 @@ const homePlugin = createPlugin({
|
|
|
146
138
|
});
|
|
147
139
|
const HomepageCompositionRoot = homePlugin.provide(createRoutableExtension({
|
|
148
140
|
name: "HomepageCompositionRoot",
|
|
149
|
-
component: () => import('./esm/index-
|
|
141
|
+
component: () => import('./esm/index-dc735eaa.esm.js').then((m) => m.HomepageCompositionRoot),
|
|
150
142
|
mountPoint: rootRouteRef
|
|
151
143
|
}));
|
|
152
144
|
const ComponentAccordion = homePlugin.provide(createComponentExtension({
|
|
153
145
|
name: "ComponentAccordion",
|
|
154
146
|
component: {
|
|
155
|
-
lazy: () => import('./esm/index-
|
|
147
|
+
lazy: () => import('./esm/index-102452e1.esm.js').then((m) => m.ComponentAccordion)
|
|
156
148
|
}
|
|
157
149
|
}));
|
|
158
150
|
const ComponentTabs = homePlugin.provide(createComponentExtension({
|
|
159
151
|
name: "ComponentTabs",
|
|
160
152
|
component: {
|
|
161
|
-
lazy: () => import('./esm/index-
|
|
153
|
+
lazy: () => import('./esm/index-102452e1.esm.js').then((m) => m.ComponentTabs)
|
|
162
154
|
}
|
|
163
155
|
}));
|
|
164
156
|
const ComponentTab = homePlugin.provide(createComponentExtension({
|
|
165
157
|
name: "ComponentTab",
|
|
166
158
|
component: {
|
|
167
|
-
lazy: () => import('./esm/index-
|
|
159
|
+
lazy: () => import('./esm/index-102452e1.esm.js').then((m) => m.ComponentTab)
|
|
168
160
|
}
|
|
169
161
|
}));
|
|
170
162
|
const WelcomeTitle = homePlugin.provide(createComponentExtension({
|
|
@@ -182,12 +174,12 @@ const HomePageCompanyLogo = homePlugin.provide(createComponentExtension({
|
|
|
182
174
|
const HomePageRandomJoke = homePlugin.provide(createCardExtension({
|
|
183
175
|
name: "HomePageRandomJoke",
|
|
184
176
|
title: "Random Joke",
|
|
185
|
-
components: () => import('./esm/index-
|
|
177
|
+
components: () => import('./esm/index-2cd1ac3a.esm.js')
|
|
186
178
|
}));
|
|
187
179
|
const HomePageToolkit = homePlugin.provide(createCardExtension({
|
|
188
180
|
name: "HomePageToolkit",
|
|
189
181
|
title: "Toolkit",
|
|
190
|
-
components: () => import('./esm/index-
|
|
182
|
+
components: () => import('./esm/index-bf89e9e8.esm.js')
|
|
191
183
|
}));
|
|
192
184
|
const HomePageStarredEntities = homePlugin.provide(createCardExtension({
|
|
193
185
|
name: "HomePageStarredEntities",
|
package/dist/index.esm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.esm.js","sources":["../src/components/SettingsModal.tsx","../src/components/HeaderWorldClock/HeaderWorldClock.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 2020 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 { HeaderLabel } from '@backstage/core-components';\n\nconst timeFormat: Intl.DateTimeFormatOptions = {\n hour: '2-digit',\n minute: '2-digit',\n};\n\ntype TimeObj = {\n time: string;\n label: string;\n};\n\nexport type ClockConfig = {\n label: string;\n timeZone: string;\n};\n\nfunction getTimes(clockConfigs: ClockConfig[]) {\n const d = new Date();\n const lang = window.navigator.language;\n\n const clocks: TimeObj[] = [];\n\n if (!clockConfigs) {\n return clocks;\n }\n\n for (const clockConfig of clockConfigs) {\n let label = clockConfig.label;\n\n const options: Intl.DateTimeFormatOptions = {\n timeZone: clockConfig.timeZone,\n ...timeFormat,\n };\n\n try {\n new Date().toLocaleString(lang, options);\n } catch (e) {\n // eslint-disable-next-line no-console\n console.warn(\n `The timezone ${options.timeZone} is invalid. Defaulting to GMT`,\n );\n options.timeZone = 'GMT';\n label = 'GMT';\n }\n\n const time = d.toLocaleTimeString(lang, options);\n clocks.push({ time, label });\n }\n\n return clocks;\n}\n\nexport const HeaderWorldClock = ({\n clockConfigs,\n}: {\n clockConfigs: ClockConfig[];\n}) => {\n const defaultTimes: TimeObj[] = [];\n const [clocks, setTimes] = React.useState(defaultTimes);\n\n React.useEffect(() => {\n setTimes(getTimes(clockConfigs));\n\n const intervalId = setInterval(() => {\n setTimes(getTimes(clockConfigs));\n }, 1000);\n\n return () => {\n clearInterval(intervalId);\n };\n }, [clockConfigs]);\n\n if (clocks.length !== 0) {\n return (\n <>\n {clocks.map(clock => (\n <HeaderLabel\n label={clock.label}\n value={clock.time}\n key={clock.label}\n />\n ))}\n </>\n );\n }\n return null;\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: (props?: any) => JSX.Element;\n Actions?: () => JSX.Element;\n Settings?: () => JSX.Element;\n ContextProvider?: (props: any) => JSX.Element;\n};\n\ntype RendererProps = { title: string } & ComponentParts;\n\ntype CardExtensionProps<T> = ComponentRenderer & { title?: string } & T;\n\n/**\n * An extension creator to create card based components for the homepage\n *\n * @public\n */\nexport function createCardExtension<T>({\n title,\n components,\n name,\n}: {\n title: string;\n components: () => Promise<ComponentParts>;\n name?: string;\n}) {\n return createReactExtension({\n name,\n component: {\n lazy: () =>\n components().then(({ Content, Actions, Settings, ContextProvider }) => {\n const CardExtension = (props: CardExtensionProps<T>) => {\n const { Renderer, title: overrideTitle, ...childProps } = props;\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 {...childProps} />\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 id: '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';\nimport { ToolkitContentProps } from './homePageComponents';\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 name: 'HomepageCompositionRoot',\n component: () =>\n import('./components').then(m => m.HomepageCompositionRoot),\n mountPoint: rootRouteRef,\n }),\n);\n\nexport const ComponentAccordion = homePlugin.provide(\n createComponentExtension({\n name: 'ComponentAccordion',\n component: {\n lazy: () =>\n import('./componentRenderers').then(m => m.ComponentAccordion),\n },\n }),\n);\nexport const ComponentTabs = homePlugin.provide(\n createComponentExtension({\n name: 'ComponentTabs',\n component: {\n lazy: () => import('./componentRenderers').then(m => m.ComponentTabs),\n },\n }),\n);\nexport const ComponentTab = homePlugin.provide(\n createComponentExtension({\n name: 'ComponentTab',\n component: {\n lazy: () => import('./componentRenderers').then(m => m.ComponentTab),\n },\n }),\n);\n\n/**\n * A component to display a playful greeting for the user.\n *\n * @public\n */\nexport const WelcomeTitle = homePlugin.provide(\n createComponentExtension({\n name: 'WelcomeTitle',\n component: {\n lazy: () =>\n import('./homePageComponents/WelcomeTitle').then(m => m.WelcomeTitle),\n },\n }),\n);\n\n/**\n * A component to display a company logo for the user.\n *\n * @public\n */\nexport const HomePageCompanyLogo = homePlugin.provide(\n createComponentExtension({\n name: 'CompanyLogo',\n component: {\n lazy: () =>\n import('./homePageComponents/CompanyLogo').then(m => m.CompanyLogo),\n },\n }),\n);\n\nexport const HomePageRandomJoke = homePlugin.provide(\n createCardExtension<{ defaultCategory?: 'any' | 'programming' }>({\n name: 'HomePageRandomJoke',\n title: 'Random Joke',\n components: () => import('./homePageComponents/RandomJoke'),\n }),\n);\n\n/**\n * A component to display a list of tools for the user.\n *\n * @public\n */\nexport const HomePageToolkit = homePlugin.provide(\n createCardExtension<ToolkitContentProps>({\n name: 'HomePageToolkit',\n title: 'Toolkit',\n components: () => import('./homePageComponents/Toolkit'),\n }),\n);\n\n/**\n * A component to display a list of starred entities for the user.\n *\n * @public\n */\nexport const HomePageStarredEntities = homePlugin.provide(\n createCardExtension({\n name: 'HomePageStarredEntities',\n title: 'Your Starred Entities',\n components: () => import('./homePageComponents/StarredEntities'),\n }),\n);\n"],"names":[],"mappings":";;;;;;;AAyBO,MAAM,gBAAgB,CAAC;AAAA,EAC5B,IAAA;AAAA,EACA,KAAA;AAAA,EACA,aAAA;AAAA,EACA,QAAA;AAAA,CAMI,KAAA;AACJ,EAAA,2CACG,MAAD,EAAA;AAAA,IAAQ,IAAA;AAAA,IAAY,SAAS,MAAM,KAAA,EAAA;AAAA,GAAA,kBAChC,KAAA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A,GAAsB,UAAW,CAAA,OAAA,CAC5C,wBAAyB,CAAA;AAAA,EACvB,IAAM,EAAA,aAAA;AAAA,EACN,SAAW,EAAA;AAAA,IACT,MAAM,MACJ,OAAO,6BAAoC,CAAA,CAAA,IAAA,CAAK,OAAK,CAAE,CAAA,WAAA,CAAA;AAAA,GAAA;AAAA,CAAA,CAAA,EAAA;AAKlD,MAAA,kBAAA,GAAqB,UAAW,CAAA,OAAA,CAC3C,mBAAiE,CAAA;AAAA,EAC/D,IAAM,EAAA,oBAAA;AAAA,EACN,KAAO,EAAA,aAAA;AAAA,EACP,UAAA,EAAY,MAAM,OAAO,6BAAA,CAAA;AAAA,CAAA,CAAA,EAAA;AAShB,MAAA,eAAA,GAAkB,UAAW,CAAA,OAAA,CACxC,mBAAyC,CAAA;AAAA,EACvC,IAAM,EAAA,iBAAA;AAAA,EACN,KAAO,EAAA,SAAA;AAAA,EACP,UAAA,EAAY,MAAM,OAAO,6BAAA,CAAA;AAAA,CAAA,CAAA,EAAA;AAShB,MAAA,uBAAA,GAA0B,UAAW,CAAA,OAAA,CAChD,mBAAoB,CAAA;AAAA,EAClB,IAAM,EAAA,yBAAA;AAAA,EACN,KAAO,EAAA,uBAAA;AAAA,EACP,UAAA,EAAY,MAAM,OAAO,6BAAA,CAAA;AAAA,CAAA,CAAA;;;;"}
|
|
1
|
+
{"version":3,"file":"index.esm.js","sources":["../src/components/SettingsModal.tsx","../src/components/HeaderWorldClock/HeaderWorldClock.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 = (props: {\n open: boolean;\n close: Function;\n componentName: string;\n children: JSX.Element;\n}) => {\n const { open, close, componentName, children } = props;\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 2020 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 { HeaderLabel } from '@backstage/core-components';\n\nconst timeFormat: Intl.DateTimeFormatOptions = {\n hour: '2-digit',\n minute: '2-digit',\n};\n\ntype TimeObj = {\n time: string;\n label: string;\n};\n\nexport type ClockConfig = {\n label: string;\n timeZone: string;\n};\n\nfunction getTimes(clockConfigs: ClockConfig[]) {\n const d = new Date();\n const lang = window.navigator.language;\n\n const clocks: TimeObj[] = [];\n\n if (!clockConfigs) {\n return clocks;\n }\n\n for (const clockConfig of clockConfigs) {\n let label = clockConfig.label;\n\n const options: Intl.DateTimeFormatOptions = {\n timeZone: clockConfig.timeZone,\n ...timeFormat,\n };\n\n try {\n new Date().toLocaleString(lang, options);\n } catch (e) {\n // eslint-disable-next-line no-console\n console.warn(\n `The timezone ${options.timeZone} is invalid. Defaulting to GMT`,\n );\n options.timeZone = 'GMT';\n label = 'GMT';\n }\n\n const time = d.toLocaleTimeString(lang, options);\n clocks.push({ time, label });\n }\n\n return clocks;\n}\n\n/** @public */\nexport const HeaderWorldClock = (props: { clockConfigs: ClockConfig[] }) => {\n const { clockConfigs } = props;\n\n const defaultTimes: TimeObj[] = [];\n const [clocks, setTimes] = React.useState(defaultTimes);\n\n React.useEffect(() => {\n setTimes(getTimes(clockConfigs));\n\n const intervalId = setInterval(() => {\n setTimes(getTimes(clockConfigs));\n }, 1000);\n\n return () => {\n clearInterval(intervalId);\n };\n }, [clockConfigs]);\n\n if (clocks.length !== 0) {\n return (\n <>\n {clocks.map(clock => (\n <HeaderLabel\n label={clock.label}\n value={clock.time}\n key={clock.label}\n />\n ))}\n </>\n );\n }\n return null;\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\n/**\n * @public\n */\nexport type ComponentRenderer = {\n Renderer?: (props: RendererProps) => JSX.Element;\n};\n\ntype ComponentParts = {\n Content: (props?: any) => JSX.Element;\n Actions?: () => JSX.Element;\n Settings?: () => JSX.Element;\n ContextProvider?: (props: any) => JSX.Element;\n};\n\ntype RendererProps = { title: string } & ComponentParts;\n\ntype CardExtensionProps<T> = ComponentRenderer & { title?: string } & T;\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}) {\n const { title, components, name } = options;\n\n return createReactExtension({\n name,\n component: {\n lazy: () =>\n components().then(({ Content, Actions, Settings, ContextProvider }) => {\n const CardExtension = (props: CardExtensionProps<T>) => {\n const { Renderer, title: overrideTitle, ...childProps } = props;\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 {...childProps} />\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 id: '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';\nimport { ToolkitContentProps } from './homePageComponents';\n\nimport { rootRouteRef } from './routes';\n\n/** @public */\nexport const homePlugin = createPlugin({\n id: 'home',\n routes: {\n root: rootRouteRef,\n },\n});\n\n/** @public */\nexport const HomepageCompositionRoot = homePlugin.provide(\n createRoutableExtension({\n name: 'HomepageCompositionRoot',\n component: () =>\n import('./components').then(m => m.HomepageCompositionRoot),\n mountPoint: rootRouteRef,\n }),\n);\n\n/** @public */\nexport const ComponentAccordion = homePlugin.provide(\n createComponentExtension({\n name: 'ComponentAccordion',\n component: {\n lazy: () =>\n import('./componentRenderers').then(m => m.ComponentAccordion),\n },\n }),\n);\n\n/** @public */\nexport const ComponentTabs = homePlugin.provide(\n createComponentExtension({\n name: 'ComponentTabs',\n component: {\n lazy: () => import('./componentRenderers').then(m => m.ComponentTabs),\n },\n }),\n);\n\n/** @public */\nexport const ComponentTab = homePlugin.provide(\n createComponentExtension({\n name: 'ComponentTab',\n component: {\n lazy: () => import('./componentRenderers').then(m => m.ComponentTab),\n },\n }),\n);\n\n/**\n * A component to display a playful greeting for the user.\n *\n * @public\n */\nexport const WelcomeTitle = homePlugin.provide(\n createComponentExtension({\n name: 'WelcomeTitle',\n component: {\n lazy: () =>\n import('./homePageComponents/WelcomeTitle').then(m => m.WelcomeTitle),\n },\n }),\n);\n\n/**\n * A component to display a company logo for the user.\n *\n * @public\n */\nexport const HomePageCompanyLogo = homePlugin.provide(\n createComponentExtension({\n name: 'CompanyLogo',\n component: {\n lazy: () =>\n import('./homePageComponents/CompanyLogo').then(m => m.CompanyLogo),\n },\n }),\n);\n\n/** @public */\nexport const HomePageRandomJoke = homePlugin.provide(\n createCardExtension<{ defaultCategory?: 'any' | 'programming' }>({\n name: 'HomePageRandomJoke',\n title: 'Random Joke',\n components: () => import('./homePageComponents/RandomJoke'),\n }),\n);\n\n/**\n * A component to display a list of tools for the user.\n *\n * @public\n */\nexport const HomePageToolkit = homePlugin.provide(\n createCardExtension<ToolkitContentProps>({\n name: 'HomePageToolkit',\n title: 'Toolkit',\n components: () => import('./homePageComponents/Toolkit'),\n }),\n);\n\n/**\n * A component to display a list of starred entities for the user.\n *\n * @public\n */\nexport const HomePageStarredEntities = homePlugin.provide(\n createCardExtension({\n name: 'HomePageStarredEntities',\n title: 'Your Starred Entities',\n components: () => import('./homePageComponents/StarredEntities'),\n }),\n);\n"],"names":[],"mappings":";;;;;;;AAyBa,MAAA,aAAA,GAAgB,CAAC,KAKxB,KAAA;AACJ,EAAA,MAAM,EAAE,IAAA,EAAM,KAAO,EAAA,aAAA,EAAe,QAAa,EAAA,GAAA,KAAA,CAAA;AAEjD,EAAA,uBACG,KAAA,CAAA,aAAA,CAAA,MAAA,EAAA;AAAA,IAAO,IAAA;AAAA,IAAY,OAAA,EAAS,MAAM,KAAM,EAAA;AAAA,GACvC,kBAAA,KAAA,CAAA,aAAA,CAAC,WAAY,EAAA,IAAA,EAAA,aAAA,EAAY,aAAc,CAAA,kBACtC,KAAA,CAAA,aAAA,CAAA,aAAA,EAAA,IAAA,EAAe,QAAS,CAAA,kBACxB,KAAA,CAAA,aAAA,CAAA,aAAA,EAAA,IAAA,kBACE,KAAA,CAAA,aAAA,CAAA,MAAA,EAAA;AAAA,IAAO,OAAA,EAAS,MAAM,KAAM,EAAA;AAAA,IAAG,KAAM,EAAA,SAAA;AAAA,IAAU,OAAQ,EAAA,WAAA;AAAA,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,CAAA,KAAK,EAAE,WAAW,CAAA;AAAA,GACtE;AACF,CAAC,CACH,EAAA;AAGa,MAAA,kBAAA,GAAqB,UAAW,CAAA,OAAA,CAC3C,mBAAiE,CAAA;AAAA,EAC/D,IAAM,EAAA,oBAAA;AAAA,EACN,KAAO,EAAA,aAAA;AAAA,EACP,UAAA,EAAY,MAAM,OAAO,6BAAA,CAAA;AAC3B,CAAC,CACH,EAAA;AAOa,MAAA,eAAA,GAAkB,UAAW,CAAA,OAAA,CACxC,mBAAyC,CAAA;AAAA,EACvC,IAAM,EAAA,iBAAA;AAAA,EACN,KAAO,EAAA,SAAA;AAAA,EACP,UAAA,EAAY,MAAM,OAAO,6BAAA,CAAA;AAC3B,CAAC,CACH,EAAA;AAOa,MAAA,uBAAA,GAA0B,UAAW,CAAA,OAAA,CAChD,mBAAoB,CAAA;AAAA,EAClB,IAAM,EAAA,yBAAA;AAAA,EACN,KAAO,EAAA,uBAAA;AAAA,EACP,UAAA,EAAY,MAAM,OAAO,6BAAA,CAAA;AAC3B,CAAC,CACH;;;;"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
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.
|
|
4
|
+
"version": "0.4.20-next.2",
|
|
5
5
|
"main": "dist/index.esm.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"license": "Apache-2.0",
|
|
@@ -34,11 +34,13 @@
|
|
|
34
34
|
"clean": "backstage-cli package clean"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@backstage/catalog-model": "^1.0.
|
|
38
|
-
"@backstage/
|
|
37
|
+
"@backstage/catalog-model": "^1.0.1-next.1",
|
|
38
|
+
"@backstage/config": "^0.1.15",
|
|
39
|
+
"@backstage/core-components": "^0.9.3-next.1",
|
|
39
40
|
"@backstage/core-plugin-api": "^1.0.0",
|
|
40
|
-
"@backstage/plugin-catalog-react": "^1.0.
|
|
41
|
-
"@backstage/plugin-search": "^0.7.
|
|
41
|
+
"@backstage/plugin-catalog-react": "^1.0.1-next.2",
|
|
42
|
+
"@backstage/plugin-search": "^0.7.5-next.0",
|
|
43
|
+
"@backstage/plugin-stack-overflow": "^0.1.0-next.0",
|
|
42
44
|
"@backstage/theme": "^0.2.15",
|
|
43
45
|
"@material-ui/core": "^4.12.2",
|
|
44
46
|
"@material-ui/icons": "^4.9.1",
|
|
@@ -52,10 +54,10 @@
|
|
|
52
54
|
"react": "^16.13.1 || ^17.0.0"
|
|
53
55
|
},
|
|
54
56
|
"devDependencies": {
|
|
55
|
-
"@backstage/cli": "^0.
|
|
56
|
-
"@backstage/core-app-api": "^1.0.0",
|
|
57
|
-
"@backstage/dev-utils": "^1.0.0",
|
|
58
|
-
"@backstage/test-utils": "^1.0.
|
|
57
|
+
"@backstage/cli": "^0.17.0-next.2",
|
|
58
|
+
"@backstage/core-app-api": "^1.0.1-next.0",
|
|
59
|
+
"@backstage/dev-utils": "^1.0.1-next.0",
|
|
60
|
+
"@backstage/test-utils": "^1.0.1-next.1",
|
|
59
61
|
"@testing-library/jest-dom": "^5.10.1",
|
|
60
62
|
"@testing-library/react": "^12.1.3",
|
|
61
63
|
"@testing-library/user-event": "^13.1.8",
|
|
@@ -67,5 +69,5 @@
|
|
|
67
69
|
"files": [
|
|
68
70
|
"dist"
|
|
69
71
|
],
|
|
70
|
-
"gitHead": "
|
|
72
|
+
"gitHead": "0857aaef2040e1d6c0b8b2063f4c94c810d0a96a"
|
|
71
73
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index-97d987f3.esm.js","sources":["../../src/homePageComponents/RandomJoke/Context.tsx","../../src/homePageComponents/RandomJoke/Actions.tsx","../../src/homePageComponents/RandomJoke/Content.tsx","../../src/homePageComponents/RandomJoke/Settings.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, { createContext } from 'react';\n\nexport type JokeType = 'any' | 'programming';\n\ntype Joke = {\n setup: string;\n punchline: string;\n};\n\ntype RandomJokeContextValue = {\n loading: boolean;\n joke: Joke;\n type: JokeType;\n rerollJoke: Function;\n handleChangeType: Function;\n};\n\nconst Context = createContext<RandomJokeContextValue | undefined>(undefined);\n\nconst getNewJoke = (type: string): Promise<Joke> =>\n fetch(\n `https://official-joke-api.appspot.com/jokes${\n type !== 'any' ? `/${type}` : ''\n }/random`,\n )\n .then(res => res.json())\n .then(data => (Array.isArray(data) ? data[0] : data));\n\nexport const ContextProvider = ({\n children,\n defaultCategory,\n}: {\n children: JSX.Element;\n defaultCategory?: JokeType;\n}) => {\n const [loading, setLoading] = React.useState(true);\n const [joke, setJoke] = React.useState<Joke>({\n setup: '',\n punchline: '',\n });\n const [type, setType] = React.useState<JokeType>(\n defaultCategory || ('programming' as JokeType),\n );\n\n const rerollJoke = React.useCallback(() => {\n setLoading(true);\n getNewJoke(type).then(newJoke => setJoke(newJoke));\n }, [type]);\n\n const handleChangeType = (newType: JokeType) => {\n setType(newType);\n };\n\n React.useEffect(() => {\n setLoading(false);\n }, [joke]);\n\n React.useEffect(() => {\n rerollJoke();\n }, [rerollJoke]);\n\n const value: RandomJokeContextValue = {\n loading,\n joke,\n type,\n rerollJoke,\n handleChangeType,\n };\n\n return <Context.Provider value={value}>{children}</Context.Provider>;\n};\n\nexport const useRandomJoke = () => {\n const value = React.useContext(Context);\n\n if (value === undefined) {\n throw new Error('useRandomJoke must be used within a RandomJokeProvider');\n }\n\n return value;\n};\n\nexport default Context;\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\nimport { Button } from '@material-ui/core';\nimport { useRandomJoke } from './Context';\n\nexport const Actions = () => {\n const { rerollJoke } = useRandomJoke();\n return (\n <Button variant=\"contained\" color=\"primary\" onClick={() => rerollJoke()}>\n Reroll\n </Button>\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 { useRandomJoke } from './Context';\n\nexport const Content = () => {\n const { joke, loading } = useRandomJoke();\n\n if (loading) return <p>Loading...</p>;\n\n return (\n <div>\n <p>{joke.setup}</p>\n <p>{joke.punchline}</p>\n </div>\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 {\n FormControl,\n FormLabel,\n RadioGroup,\n FormControlLabel,\n Radio,\n} from '@material-ui/core';\nimport React from 'react';\nimport { useRandomJoke, JokeType } from './Context';\nimport upperFirst from 'lodash/upperFirst';\n\nexport const Settings = () => {\n const { type, handleChangeType } = useRandomJoke();\n const JOKE_TYPES: JokeType[] = ['any' as JokeType, 'programming' as JokeType];\n return (\n <FormControl component=\"fieldset\">\n <FormLabel component=\"legend\">Joke Type</FormLabel>\n <RadioGroup\n aria-label=\"joke type\"\n value={type}\n onChange={e => handleChangeType(e.target.value)}\n >\n {JOKE_TYPES.map(t => (\n <FormControlLabel\n key={t}\n value={t}\n control={<Radio />}\n label={upperFirst(t)}\n />\n ))}\n </RadioGroup>\n </FormControl>\n );\n};\n"],"names":[],"mappings":";;;;AAiCA,MAAM,UAAU,aAAkD,CAAA,KAAA,CAAA,CAAA,CAAA;AAElE,MAAM,UAAA,GAAa,CAAC,IAClB,KAAA,KAAA,CACE,8CACE,IAAS,KAAA,KAAA,GAAQ,IAAI,IAAS,CAAA,CAAA,GAAA,EAAA,CAAA,OAAA,CAAA,CAAA,CAG/B,KAAK,CAAO,GAAA,KAAA,GAAA,CAAI,QAChB,IAAK,CAAA,CAAA,IAAA,KAAS,MAAM,OAAQ,CAAA,IAAA,CAAA,GAAQ,KAAK,CAAK,CAAA,GAAA,IAAA,CAAA,CAAA;AAE5C,MAAM,kBAAkB,CAAC;AAAA,EAC9B,QAAA;AAAA,EACA,eAAA;AAAA,CAII,KAAA;AACJ,EAAA,MAAM,CAAC,OAAA,EAAS,UAAc,CAAA,GAAA,KAAA,CAAM,QAAS,CAAA,IAAA,CAAA,CAAA;AAC7C,EAAA,MAAM,CAAC,IAAA,EAAM,OAAW,CAAA,GAAA,KAAA,CAAM,QAAe,CAAA;AAAA,IAC3C,KAAO,EAAA,EAAA;AAAA,IACP,SAAW,EAAA,EAAA;AAAA,GAAA,CAAA,CAAA;AAEb,EAAA,MAAM,CAAC,IAAA,EAAM,OAAW,CAAA,GAAA,KAAA,CAAM,SAC5B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AA;AAAA,IACL,KAAO,EAAA,CAAA;AAAA,IACP,OAAA,sCAAU,KAAD,EAAA,IAAA,CAAA;AAAA,IACT,OAAO,UAAW,CAAA,CAAA,CAAA;AAAA,GAAA,CAAA,CAAA,CAAA,CAAA,CAAA;AAAA;;;;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index-bc3d603a.esm.js","sources":["../../src/homePageComponents/Toolkit/Context.tsx","../../src/homePageComponents/Toolkit/Content.tsx"],"sourcesContent":["/*\n * Copyright 2022 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, { createContext } from 'react';\n\nexport type Tool = {\n label: string;\n url: string;\n icon: React.ReactNode;\n};\n\ntype ToolkitContextValue = {\n tools: Tool[];\n};\n\nconst Context = createContext<ToolkitContextValue | undefined>(undefined);\n\nexport const ContextProvider = ({\n children,\n tools,\n}: {\n children: JSX.Element;\n tools: Tool[];\n}) => {\n const [toolsValue, _setTools] = React.useState(tools);\n\n const value: ToolkitContextValue = {\n tools: toolsValue,\n };\n\n return <Context.Provider value={value}>{children}</Context.Provider>;\n};\n\nexport const useToolkit = () => {\n const value = React.useContext(Context);\n return value;\n};\n\nexport default Context;\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 { Link } from '@backstage/core-components';\nimport {\n makeStyles,\n List,\n ListItemIcon,\n ListItemText,\n} from '@material-ui/core';\nimport React from 'react';\nimport { useToolkit, Tool } from './Context';\n\nconst useStyles = makeStyles(theme => ({\n toolkit: {\n display: 'flex',\n flexWrap: 'wrap',\n textAlign: 'center',\n },\n tool: {\n margin: theme.spacing(0.5, 1),\n },\n label: {\n marginTop: theme.spacing(1),\n fontSize: '0.9em',\n lineHeight: '1.25',\n color: theme.palette.text.secondary,\n },\n icon: {\n width: '64px',\n height: '64px',\n borderRadius: '50px',\n justifyContent: 'center',\n alignItems: 'center',\n boxShadow: theme.shadows[1],\n backgroundColor: theme.palette.background.default,\n },\n}));\n\n/**\n * Props for Toolkit content component {@link Content}.\n *\n * @public\n */\nexport type ToolkitContentProps = {\n tools: Tool[];\n};\n\n/**\n * A component to display a list of tools for the user.\n *\n * @public\n */\nexport const Content = (props: ToolkitContentProps) => {\n const classes = useStyles();\n const toolkit = useToolkit();\n const tools = toolkit?.tools ?? props.tools;\n\n return (\n <List className={classes.toolkit}>\n {tools.map((tool: Tool) => (\n <Link key={tool.url} to={tool.url} className={classes.tool}>\n <ListItemIcon className={classes.icon}>{tool.icon}</ListItemIcon>\n <ListItemText\n secondaryTypographyProps={{ className: classes.label }}\n secondary={tool.label}\n />\n </Link>\n ))}\n </List>\n );\n};\n"],"names":[],"mappings":";;;;AA4BA,MAAM,UAAU,aAA+C,CAAA,KAAA,CAAA,CAAA,CAAA;AAExD,MAAM,kBAAkB,CAAC;AAAA,EAC9B,QAAA;AAAA,EACA,KAAA;AAAA,CAII,KAAA;AACJ,EAAA,MAAM,CAAC,UAAA,EAAY,SAAa,CAAA,GAAA,KAAA,CAAM,QAAS,CAAA,KAAA,CAAA,CAAA;AAE/C,EAAA,MAAM,KAA6B,GAAA;AAAA,IACjC,KAAO,EAAA,UAAA;AAAA,GAAA,CAAA;AAGT,EAAO,uBAAA,KAAA,C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U,GAAA,UAAA,EAAA,CAAA;AAChB,EAAA,MAAM,KAAQ,GAAA,CAAA,EAAA,GAAA,OAAA,IAAA,IAAA,GAAA,KAAA,CAAA,GAAA,OAAA,CAAS,KAAT,KAAA,IAAA,GAAA,EAAA,GAAkB,KAAM,CAAA,KAAA,CAAA;AAEtC,EAAA,2CACG,IAAD,EAAA;AAAA,IAAM,WAAW,OAAQ,CAAA,OAAA;AAAA,GAAA,EACtB,KAAM,CAAA,GAAA,CAAI,CAAC,IAAA,yCACT,IAAD,EAAA;AAAA,IAAM,KAAK,IAAK,CAAA,GAAA;AAAA,IAAK,IAAI,IAAK,CAAA,GAAA;AAAA,IAAK,WAAW,OAAQ,CAAA,IAAA;AAAA,GAAA,sCACnD,YAAD,EAAA;AAAA,IAAc,WAAW,OAAQ,CAAA,IAAA;AAAA,GAAO,EAAA,IAAA,CAAK,IAC7C,CAAA,kBAAA,KAAA,CAAA,aAAA,CAAC,YAAD,EAAA;AAAA,IACE,wBAAA,EAA0B,EAAE,SAAA,EAAW,OAAQ,CAAA,KAAA,EAAA;AAAA,IAC/C,WAAW,IAAK,CAAA,KAAA;AAAA,GAAA,CAAA,CAAA,CAAA,CAAA,CAAA;AAAA;;;;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index-d8d6d705.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 contentContainer: {\n width: '100%',\n },\n}));\n\nexport const ComponentAccordion = ({\n title,\n expanded = false,\n Content,\n Actions,\n Settings,\n ContextProvider,\n ...childProps\n}: {\n title: string;\n expanded?: boolean;\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(expanded);\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, expandedValue: boolean) =>\n setIsExpanded(expandedValue)\n }\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 className={classes.contentContainer}>\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\n key={idx}\n {...(idx !== value ? { style: { display: 'none' } } : {})}\n >\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,SAAA,G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