@backstage/plugin-home 0.4.27 → 0.4.28-next.1
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 +27 -0
- package/dist/esm/{index-44f889a3.esm.js → index-23e684fc.esm.js} +2 -4
- package/dist/esm/{index-44f889a3.esm.js.map → index-23e684fc.esm.js.map} +1 -1
- package/dist/esm/{index-9df9f31e.esm.js → index-36ac98a7.esm.js} +20 -23
- package/dist/esm/{index-9df9f31e.esm.js.map → index-36ac98a7.esm.js.map} +1 -1
- package/dist/esm/{index-d68897bc.esm.js → index-40d9ffac.esm.js} +9 -16
- package/dist/esm/{index-d68897bc.esm.js.map → index-40d9ffac.esm.js.map} +1 -1
- package/dist/esm/index-476343c1.esm.js +12 -0
- package/dist/esm/{index-0caca094.esm.js.map → index-476343c1.esm.js.map} +1 -1
- package/dist/esm/{index-d8d74555.esm.js → index-640dfb11.esm.js} +9 -6
- package/dist/esm/{index-d8d74555.esm.js.map → index-640dfb11.esm.js.map} +1 -1
- package/dist/esm/{index-5c9d403a.esm.js → index-c5a3c510.esm.js} +1 -1
- package/dist/esm/{index-5c9d403a.esm.js.map → index-c5a3c510.esm.js.map} +1 -1
- package/dist/esm/{index-345d4e44.esm.js → index-d929e87c.esm.js} +17 -22
- package/dist/esm/{index-345d4e44.esm.js.map → index-d929e87c.esm.js.map} +1 -1
- package/dist/esm/index-f9c2c511.esm.js +85 -0
- package/dist/esm/{index-4dad0f4e.esm.js.map → index-f9c2c511.esm.js.map} +1 -1
- package/dist/index.esm.js +64 -62
- package/dist/index.esm.js.map +1 -1
- package/package.json +12 -12
- package/dist/esm/index-0caca094.esm.js +0 -16
- package/dist/esm/index-4dad0f4e.esm.js +0 -84
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,32 @@
|
|
|
1
1
|
# @backstage/plugin-home
|
|
2
2
|
|
|
3
|
+
## 0.4.28-next.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies
|
|
8
|
+
- @backstage/core-components@0.12.1-next.1
|
|
9
|
+
- @backstage/plugin-stack-overflow@0.1.8-next.1
|
|
10
|
+
- @backstage/core-plugin-api@1.1.1-next.1
|
|
11
|
+
- @backstage/plugin-catalog-react@1.2.2-next.1
|
|
12
|
+
- @backstage/config@1.0.5-next.1
|
|
13
|
+
- @backstage/catalog-model@1.1.4-next.1
|
|
14
|
+
- @backstage/theme@0.2.16
|
|
15
|
+
|
|
16
|
+
## 0.4.28-next.0
|
|
17
|
+
|
|
18
|
+
### Patch Changes
|
|
19
|
+
|
|
20
|
+
- 3280711113: Updated dependency `msw` to `^0.49.0`.
|
|
21
|
+
- Updated dependencies
|
|
22
|
+
- @backstage/core-components@0.12.1-next.0
|
|
23
|
+
- @backstage/core-plugin-api@1.1.1-next.0
|
|
24
|
+
- @backstage/plugin-stack-overflow@0.1.8-next.0
|
|
25
|
+
- @backstage/plugin-catalog-react@1.2.2-next.0
|
|
26
|
+
- @backstage/catalog-model@1.1.4-next.0
|
|
27
|
+
- @backstage/config@1.0.5-next.0
|
|
28
|
+
- @backstage/theme@0.2.16
|
|
29
|
+
|
|
3
30
|
## 0.4.27
|
|
4
31
|
|
|
5
32
|
### Patch Changes
|
|
@@ -620,10 +620,8 @@ const WelcomeTitle = () => {
|
|
|
620
620
|
});
|
|
621
621
|
}
|
|
622
622
|
}, [error, alertApi]);
|
|
623
|
-
return /* @__PURE__ */ React.createElement(Tooltip, {
|
|
624
|
-
title: greeting.language
|
|
625
|
-
}, /* @__PURE__ */ React.createElement("span", null, `${greeting.greeting}${(profile == null ? void 0 : profile.displayName) ? `, ${profile == null ? void 0 : profile.displayName}` : ""}!`));
|
|
623
|
+
return /* @__PURE__ */ React.createElement(Tooltip, { title: greeting.language }, /* @__PURE__ */ React.createElement("span", null, `${greeting.greeting}${(profile == null ? void 0 : profile.displayName) ? `, ${profile == null ? void 0 : profile.displayName}` : ""}!`));
|
|
626
624
|
};
|
|
627
625
|
|
|
628
626
|
export { WelcomeTitle };
|
|
629
|
-
//# sourceMappingURL=index-
|
|
627
|
+
//# sourceMappingURL=index-23e684fc.esm.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index-
|
|
1
|
+
{"version":3,"file":"index-23e684fc.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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EAAA,MAAM,WAAW,OAAQ,CAAA,MAAM,oBAAqB,EAAA,EAAG,EAAE,CAAA,CAAA;AAEzD,EAAA,MAAM,EAAE,KAAA,EAAO,OAAS,EAAA,KAAA,EAAU,GAAA,QAAA;AAAA,IAAS,MACzC,YAAY,cAAe,EAAA;AAAA,GAC7B,CAAA;AAEA,EAAA,SAAA,CAAU,MAAM;AACd,IAAA,IAAI,KAAO,EAAA;AACT,MAAA,QAAA,CAAS,IAAK,CAAA;AAAA,QACZ,SAAS,CAAiC,8BAAA,EAAA,KAAA,CAAA,CAAA;AAAA,QAC1C,QAAU,EAAA,OAAA;AAAA,OACX,CAAA,CAAA;AAAA,KACH;AAAA,GACC,EAAA,CAAC,KAAO,EAAA,QAAQ,CAAC,CAAA,CAAA;AAEpB,EAAA,2CACG,OAAQ,EAAA,EAAA,KAAA,EAAO,QAAS,CAAA,QAAA,EAAA,sCACtB,MAAM,EAAA,IAAA,EAAA,CAAA,EAAG,QAAS,CAAA,QAAA,CAAA,EAAA,CACjB,mCAAS,WAAc,IAAA,CAAA,EAAA,EAAK,OAAS,IAAA,IAAA,GAAA,KAAA,CAAA,GAAA,OAAA,CAAA,WAAA,CAAA,CAAA,GAAgB,KACnD,CACN,CAAA,CAAA;AAEJ;;;;"}
|
|
@@ -36,9 +36,7 @@ const ContextProvider = (props) => {
|
|
|
36
36
|
rerollJoke,
|
|
37
37
|
handleChangeType
|
|
38
38
|
};
|
|
39
|
-
return /* @__PURE__ */ React.createElement(Context.Provider, {
|
|
40
|
-
value
|
|
41
|
-
}, children);
|
|
39
|
+
return /* @__PURE__ */ React.createElement(Context.Provider, { value }, children);
|
|
42
40
|
};
|
|
43
41
|
const useRandomJoke = () => {
|
|
44
42
|
const value = React.useContext(Context);
|
|
@@ -50,11 +48,7 @@ const useRandomJoke = () => {
|
|
|
50
48
|
|
|
51
49
|
const Actions = () => {
|
|
52
50
|
const { rerollJoke } = useRandomJoke();
|
|
53
|
-
return /* @__PURE__ */ React.createElement(Button, {
|
|
54
|
-
variant: "contained",
|
|
55
|
-
color: "primary",
|
|
56
|
-
onClick: () => rerollJoke()
|
|
57
|
-
}, "Reroll");
|
|
51
|
+
return /* @__PURE__ */ React.createElement(Button, { variant: "contained", color: "primary", onClick: () => rerollJoke() }, "Reroll");
|
|
58
52
|
};
|
|
59
53
|
|
|
60
54
|
const Content = () => {
|
|
@@ -67,21 +61,24 @@ const Content = () => {
|
|
|
67
61
|
const Settings = () => {
|
|
68
62
|
const { type, handleChangeType } = useRandomJoke();
|
|
69
63
|
const JOKE_TYPES = ["any", "programming"];
|
|
70
|
-
return /* @__PURE__ */ React.createElement(FormControl, {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
64
|
+
return /* @__PURE__ */ React.createElement(FormControl, { component: "fieldset" }, /* @__PURE__ */ React.createElement(FormLabel, { component: "legend" }, "Joke Type"), /* @__PURE__ */ React.createElement(
|
|
65
|
+
RadioGroup,
|
|
66
|
+
{
|
|
67
|
+
"aria-label": "joke type",
|
|
68
|
+
value: type,
|
|
69
|
+
onChange: (e) => handleChangeType(e.target.value)
|
|
70
|
+
},
|
|
71
|
+
JOKE_TYPES.map((t) => /* @__PURE__ */ React.createElement(
|
|
72
|
+
FormControlLabel,
|
|
73
|
+
{
|
|
74
|
+
key: t,
|
|
75
|
+
value: t,
|
|
76
|
+
control: /* @__PURE__ */ React.createElement(Radio, null),
|
|
77
|
+
label: upperFirst(t)
|
|
78
|
+
}
|
|
79
|
+
))
|
|
80
|
+
));
|
|
84
81
|
};
|
|
85
82
|
|
|
86
83
|
export { Actions, Content, ContextProvider, Settings };
|
|
87
|
-
//# sourceMappingURL=index-
|
|
84
|
+
//# sourceMappingURL=index-36ac98a7.esm.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index-
|
|
1
|
+
{"version":3,"file":"index-36ac98a7.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,IAClB,KAAA,KAAA;AAAA,EACE,CACE,2CAAA,EAAA,IAAA,KAAS,KAAQ,GAAA,CAAA,CAAA,EAAI,IAAS,CAAA,CAAA,GAAA,EAAA,CAAA,OAAA,CAAA;AAElC,CAAA,CACG,IAAK,CAAA,CAAA,GAAA,KAAO,GAAI,CAAA,IAAA,EAAM,CACtB,CAAA,IAAA,CAAK,CAAS,IAAA,KAAA,KAAA,CAAM,OAAQ,CAAA,IAAI,CAAI,GAAA,IAAA,CAAK,KAAK,IAAK,CAAA,CAAA;AAE3C,MAAA,eAAA,GAAkB,CAAC,KAG1B,KAAA;AACJ,EAAM,MAAA,EAAE,QAAU,EAAA,eAAA,EAAoB,GAAA,KAAA,CAAA;AAEtC,EAAA,MA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A,KAAA,CAAA,aAAA;AAAA,IAAC,UAAA;AAAA,IAAA;AAAA,MACC,YAAW,EAAA,WAAA;AAAA,MACX,KAAO,EAAA,IAAA;AAAA,MACP,QAAU,EAAA,CAAA,CAAA,KAAK,gBAAiB,CAAA,CAAA,CAAE,OAAO,KAAK,CAAA;AAAA,KAAA;AAAA,IAE7C,UAAA,CAAW,IAAI,CACd,CAAA,qBAAA,KAAA,CAAA,aAAA;AAAA,MAAC,gBAAA;AAAA,MAAA;AAAA,QACC,GAAK,EAAA,CAAA;AAAA,QACL,KAAO,EAAA,CAAA;AAAA,QACP,OAAA,sCAAU,KAAM,EAAA,IAAA,CAAA;AAAA,QAChB,KAAA,EAAO,WAAW,CAAC,CAAA;AAAA,OAAA;AAAA,KAEtB,CAAA;AAAA,GAEL,CAAA,CAAA;AAEJ;;;;"}
|
|
@@ -9,9 +9,7 @@ const ContextProvider = (props) => {
|
|
|
9
9
|
const value = {
|
|
10
10
|
tools: toolsValue
|
|
11
11
|
};
|
|
12
|
-
return /* @__PURE__ */ React.createElement(Context.Provider, {
|
|
13
|
-
value
|
|
14
|
-
}, children);
|
|
12
|
+
return /* @__PURE__ */ React.createElement(Context.Provider, { value }, children);
|
|
15
13
|
};
|
|
16
14
|
const useToolkit = () => {
|
|
17
15
|
const value = React.useContext(Context);
|
|
@@ -50,19 +48,14 @@ const Content = (props) => {
|
|
|
50
48
|
const classes = useStyles();
|
|
51
49
|
const toolkit = useToolkit();
|
|
52
50
|
const tools = (_a = toolkit == null ? void 0 : toolkit.tools) != null ? _a : props.tools;
|
|
53
|
-
return /* @__PURE__ */ React.createElement(List, {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
className: classes.icon
|
|
61
|
-
}, tool.icon), /* @__PURE__ */ React.createElement(ListItemText, {
|
|
62
|
-
secondaryTypographyProps: { className: classes.label },
|
|
63
|
-
secondary: tool.label
|
|
64
|
-
}))));
|
|
51
|
+
return /* @__PURE__ */ React.createElement(List, { className: classes.toolkit }, tools.map((tool) => /* @__PURE__ */ React.createElement(Link, { key: tool.url, to: tool.url, className: classes.tool }, /* @__PURE__ */ React.createElement(ListItemIcon, { className: classes.icon }, tool.icon), /* @__PURE__ */ React.createElement(
|
|
52
|
+
ListItemText,
|
|
53
|
+
{
|
|
54
|
+
secondaryTypographyProps: { className: classes.label },
|
|
55
|
+
secondary: tool.label
|
|
56
|
+
}
|
|
57
|
+
))));
|
|
65
58
|
};
|
|
66
59
|
|
|
67
60
|
export { Content, ContextProvider };
|
|
68
|
-
//# sourceMappingURL=index-
|
|
61
|
+
//# sourceMappingURL=index-40d9ffac.esm.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index-
|
|
1
|
+
{"version":3,"file":"index-40d9ffac.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\n/** @public */\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 width: '72px',\n fontSize: '0.9em',\n lineHeight: '1.25',\n overflowWrap: 'break-word',\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 * 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\n/**\n * Props for Toolkit Content component.\n *\n * @public\n */\nexport type ToolkitContentProps = {\n tools: Tool[];\n};\n"],"names":[],"mappings":";;;;AA6BA,MAAM,OAAA,GAAU,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
1
|
+
import { Typography } from '@material-ui/core';
|
|
2
|
+
import { useApi, configApiRef } from '@backstage/core-plugin-api';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
|
|
5
|
+
const CompanyLogo = (props) => {
|
|
6
|
+
const { logo, className } = props;
|
|
7
|
+
const configApi = useApi(configApiRef);
|
|
8
|
+
return /* @__PURE__ */ React.createElement("div", { className }, logo ? /* @__PURE__ */ React.createElement(React.Fragment, null, logo) : /* @__PURE__ */ React.createElement(Typography, { variant: "h1" }, configApi.getString("app.title")));
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export { CompanyLogo };
|
|
12
|
+
//# sourceMappingURL=index-476343c1.esm.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index-
|
|
1
|
+
{"version":3,"file":"index-476343c1.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,IAAM,EAAA,SAAA,EAAc,GAAA,KAAA,CAAA;AAC5B,EAAM,MAAA,SAAA,GAAY,OAAO,YAAY,CAAA,CAAA;AAErC,EAAA,uBACG,KAAA,CAAA,aAAA,CAAA,KAAA,EAAA,EAAI,SACF,EAAA,EAAA,IAAA,6DACI,IAAK,CAAA,mBAEP,KAAA,CAAA,aAAA,CAAA,UAAA,EAAA,EAAW,SAAQ,IAAM,EAAA,EAAA,SAAA,CAAU,SAAU,CAAA,WAAW,CAAE,CAE/D,CAAA,CAAA;AAEJ;;;;"}
|
|
@@ -46,14 +46,17 @@ const HeaderWorldClock = (props) => {
|
|
|
46
46
|
};
|
|
47
47
|
}, [clockConfigs, customTimeFormat]);
|
|
48
48
|
if (clocks.length !== 0) {
|
|
49
|
-
return /* @__PURE__ */ React.createElement(React.Fragment, null, clocks.map((clock) => /* @__PURE__ */ React.createElement(
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
49
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, clocks.map((clock) => /* @__PURE__ */ React.createElement(
|
|
50
|
+
HeaderLabel,
|
|
51
|
+
{
|
|
52
|
+
label: clock.label,
|
|
53
|
+
value: clock.time,
|
|
54
|
+
key: clock.label
|
|
55
|
+
}
|
|
56
|
+
)));
|
|
54
57
|
}
|
|
55
58
|
return null;
|
|
56
59
|
};
|
|
57
60
|
|
|
58
61
|
export { HeaderWorldClock };
|
|
59
|
-
//# sourceMappingURL=index-
|
|
62
|
+
//# sourceMappingURL=index-640dfb11.esm.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index-
|
|
1
|
+
{"version":3,"file":"index-640dfb11.esm.js","sources":["../../src/homePageComponents/HeaderWorldClock/HeaderWorldClock.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 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\n/** @public */\nexport type ClockConfig = {\n label: string;\n timeZone: string;\n};\n\nfunction getTimes(\n clockConfigs: ClockConfig[],\n customTimeFormat?: Intl.DateTimeFormatOptions,\n) {\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 ...(customTimeFormat ?? 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/**\n * A component to display a configurable list of clocks for various time zones.\n *\n * @example\n * Here's a simple example:\n * ```\n * // This will give you a clock for the time zone that Stockholm is in\n * // you can add more than one but keep in mind space may be limited\n * const clockConfigs: ClockConfig[] = [\n * {\n * label: 'STO',\n * timeZone: 'Europe/Stockholm',\n * },\n * ];\n *\n * // Setting hour12 to false will make all the clocks show in the 24hr format\n * const timeFormat: Intl.DateTimeFormatOptions = {\n * hour: '2-digit',\n * minute: '2-digit',\n * hour12: false,\n * };\n *\n * // Here is the component in use:\n * <HeaderWorldClock\n * clockConfigs={clockConfigs}\n * customTimeFormat={timeFormat}\n * />\n * ```\n *\n * @public\n */\nexport const HeaderWorldClock = (props: {\n clockConfigs: ClockConfig[];\n customTimeFormat?: Intl.DateTimeFormatOptions;\n}) => {\n const { clockConfigs, customTimeFormat } = props;\n\n const defaultTimes: TimeObj[] = [];\n const [clocks, setTimes] = React.useState(defaultTimes);\n\n React.useEffect(() => {\n setTimes(getTimes(clockConfigs, customTimeFormat));\n\n const intervalId = setInterval(() => {\n setTimes(getTimes(clockConfigs, customTimeFormat));\n }, 1000);\n\n return () => {\n clearInterval(intervalId);\n };\n }, [clockConfigs, customTimeFormat]);\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"],"names":[],"mappings":";;;AAmBA,MAAM,UAAyC,GAAA;AAAA,EAC7C,IAAM,EAAA,SAAA;AAAA,EACN,MAAQ,EAAA,SAAA;AACV,CAAA,CAAA;AAaA,SAAS,QAAA,CACP,cACA,gBACA,EAAA;AACA,EAAM,MAAA,CAAA,GAAI,IAAI,IAAK,EAAA,CAAA;AACnB,EAAM,MAAA,IAAA,GAAO,OAAO,SAAU,CAAA,QAAA,CAAA;AAE9B,EAAA,MAAM,SAAoB,EAAC,CAAA;AAE3B,EAAA,IAAI,CAAC,YAAc,EAAA;AACjB,IAAO,OAAA,MAAA,CAAA;AAAA,GACT;AAEA,EAAA,KAAA,MAAW,eAAe,YAAc,EAAA;AACtC,IAAA,IAAI,QAAQ,WAAY,CAAA,KAAA,CAAA;AAExB,IAAA,MAAM,OAAsC,GAAA;AAAA,MAC1C,UAAU,WAAY,CAAA,QAAA;AAAA,MACtB,GAAI,gBAAoB,IAAA,IAAA,GAAA,gBAAA,GAAA,UAAA;AAAA,KAC1B,CAAA;AAEA,IAAI,IAAA;AACF,MAAA,IAAI,IAAK,EAAA,CAAE,cAAe,CAAA,IAAA,EAAM,OAAO,CAAA,CA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AAO,CAAA,GAAA,CAAI,CACV,KAAA,qBAAA,KAAA,CAAA,aAAA;AAAA,MAAC,WAAA;AAAA,MAAA;AAAA,QACC,OAAO,KAAM,CAAA,KAAA;AAAA,QACb,OAAO,KAAM,CAAA,IAAA;AAAA,QACb,KAAK,KAAM,CAAA,KAAA;AAAA,OAAA;AAAA,KAEd,CACH,CAAA,CAAA;AAAA,GAEJ;AACA,EAAO,OAAA,IAAA,CAAA;AACT;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index-
|
|
1
|
+
{"version":3,"file":"index-c5a3c510.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,GAAA,CAAW,EAAM,GAAA,KAAA,CAAA,QAAA,KAAN,IAAkB,GAAA,EAAA,GAAA,MAAA,CAAA;AACnC,EAAA,iEAAU,QAAS,CAAA,CAAA;AACrB;;;;"}
|
|
@@ -32,15 +32,11 @@ const Content = () => {
|
|
|
32
32
|
})).items;
|
|
33
33
|
}, [catalogApi, starredEntities]);
|
|
34
34
|
if (starredEntities.size === 0)
|
|
35
|
-
return /* @__PURE__ */ React.createElement(Typography, {
|
|
36
|
-
variant: "body1"
|
|
37
|
-
}, "You do not have any starred entities yet!");
|
|
35
|
+
return /* @__PURE__ */ React.createElement(Typography, { variant: "body1" }, "You do not have any starred entities yet!");
|
|
38
36
|
if (entities.loading) {
|
|
39
37
|
return /* @__PURE__ */ React.createElement(Progress, null);
|
|
40
38
|
}
|
|
41
|
-
return entities.error ? /* @__PURE__ */ React.createElement(ResponseErrorPanel, {
|
|
42
|
-
error: entities.error
|
|
43
|
-
}) : /* @__PURE__ */ React.createElement(List, null, (_a = entities.value) == null ? void 0 : _a.sort(
|
|
39
|
+
return entities.error ? /* @__PURE__ */ React.createElement(ResponseErrorPanel, { error: entities.error }) : /* @__PURE__ */ React.createElement(List, null, (_a = entities.value) == null ? void 0 : _a.sort(
|
|
44
40
|
(a, b) => {
|
|
45
41
|
var _a2, _b;
|
|
46
42
|
return ((_a2 = a.metadata.title) != null ? _a2 : a.metadata.name).localeCompare(
|
|
@@ -49,23 +45,22 @@ const Content = () => {
|
|
|
49
45
|
}
|
|
50
46
|
).map((entity) => {
|
|
51
47
|
var _a2;
|
|
52
|
-
return /* @__PURE__ */ React.createElement(ListItem, {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
})))));
|
|
48
|
+
return /* @__PURE__ */ React.createElement(ListItem, { key: stringifyEntityRef(entity) }, /* @__PURE__ */ React.createElement(Link, { to: catalogEntityRoute(entityRouteParams(entity)) }, /* @__PURE__ */ React.createElement(
|
|
49
|
+
ListItemText,
|
|
50
|
+
{
|
|
51
|
+
primary: (_a2 = entity.metadata.title) != null ? _a2 : entity.metadata.name
|
|
52
|
+
}
|
|
53
|
+
)), /* @__PURE__ */ React.createElement(ListItemSecondaryAction, null, /* @__PURE__ */ React.createElement(Tooltip, { title: "Remove from starred" }, /* @__PURE__ */ React.createElement(
|
|
54
|
+
IconButton,
|
|
55
|
+
{
|
|
56
|
+
edge: "end",
|
|
57
|
+
"aria-label": "unstar",
|
|
58
|
+
onClick: () => toggleStarredEntity(entity)
|
|
59
|
+
},
|
|
60
|
+
/* @__PURE__ */ React.createElement(StarIcon, { style: { color: "#f3ba37" } })
|
|
61
|
+
))));
|
|
67
62
|
}));
|
|
68
63
|
};
|
|
69
64
|
|
|
70
65
|
export { Content };
|
|
71
|
-
//# sourceMappingURL=index-
|
|
66
|
+
//# sourceMappingURL=index-d929e87c.esm.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index-
|
|
1
|
+
{"version":3,"file":"index-d929e87c.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 catalogApiRef,\n useStarredEntities,\n entityRouteParams,\n entityRouteRef,\n} from '@backstage/plugin-catalog-react';\nimport { parseEntityRef, stringifyEntityRef } from '@backstage/catalog-model';\nimport { useApi, useRouteRef } from '@backstage/core-plugin-api';\nimport { Link, Progress, ResponseErrorPanel } 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';\nimport useAsync from 'react-use/lib/useAsync';\n\n/**\n * A component to display a list of starred entities for the user.\n *\n * @public\n */\nexport const Content = () => {\n const catalogApi = useApi(catalogApiRef);\n const catalogEntityRoute = useRouteRef(entityRouteRef);\n const { starredEntities, toggleStarredEntity } = useStarredEntities();\n\n // Grab starred entities from catalog to ensure they still exist and also retrieve display titles\n const entities = useAsync(async () => {\n if (!starredEntities.size) {\n return [];\n }\n\n const filter = [...starredEntities]\n .map(ent => parseEntityRef(ent))\n .map(ref => ({\n kind: ref.kind,\n 'metadata.namespace': ref.namespace,\n 'metadata.name': ref.name,\n }));\n\n return (\n await catalogApi.getEntities({\n filter,\n fields: [\n 'kind',\n 'metadata.namespace',\n 'metadata.name',\n 'metadata.title',\n ],\n })\n ).items;\n }, [catalogApi, starredEntities]);\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 if (entities.loading) {\n return <Progress />;\n }\n\n return entities.error ? (\n <ResponseErrorPanel error={entities.error} />\n ) : (\n <List>\n {entities.value\n ?.sort((a, b) =>\n (a.metadata.title ?? a.metadata.name).localeCompare(\n b.metadata.title ?? b.metadata.name,\n ),\n )\n .map(entity => (\n <ListItem key={stringifyEntityRef(entity)}>\n <Link to={catalogEntityRoute(entityRouteParams(entity))}>\n <ListItemText\n primary={entity.metadata.title ?? entity.metadata.name}\n />\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 style={{ color: '#f3ba37' }} />\n </IconButton>\n </Tooltip>\n </ListItemSecondaryAction>\n </ListItem>\n ))}\n </List>\n );\n};\n"],"names":["_a"],"mappings":";;;;;;;;;AA2CO,MAAM,UAAU,MAAM;AA3C7B,EAAA,IAAA,EAAA,CAAA;AA4CE,EAAM,MAAA,UAAA,GAAa,OAAO,aAAa,CAAA,CAAA;AACvC,EAAM,MAAA,kBAAA,GAAqB,YAAY,cAAc,CAAA,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,0CAExC,QAAS,EAAA,EAAA,KAAA,EAAO,EAAE,KAAA,EAAO,WAAa,EAAA,CAAA;AAAA,KAE3C,CACF,CACF,CAAA,CAAA;AAAA,GAEN,CAAA,CAAA,CAAA;AAEJ;;;;"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Accordion, AccordionSummary, IconButton, Typography, AccordionDetails, Tabs, Tab } from '@material-ui/core';
|
|
3
|
+
import { makeStyles } from '@material-ui/core/styles';
|
|
4
|
+
import ExpandMoreIcon from '@material-ui/icons/ExpandMore';
|
|
5
|
+
import SettingsIcon from '@material-ui/icons/Settings';
|
|
6
|
+
import 'react-router';
|
|
7
|
+
import { SettingsModal } from '../index.esm.js';
|
|
8
|
+
import { InfoCard } from '@backstage/core-components';
|
|
9
|
+
import '@backstage/core-plugin-api';
|
|
10
|
+
|
|
11
|
+
const useStyles = makeStyles((theme) => ({
|
|
12
|
+
settingsIconButton: {
|
|
13
|
+
padding: theme.spacing(0, 1, 0, 0)
|
|
14
|
+
},
|
|
15
|
+
contentContainer: {
|
|
16
|
+
width: "100%"
|
|
17
|
+
}
|
|
18
|
+
}));
|
|
19
|
+
const ComponentAccordion = (props) => {
|
|
20
|
+
const {
|
|
21
|
+
title,
|
|
22
|
+
expanded = false,
|
|
23
|
+
Content,
|
|
24
|
+
Actions,
|
|
25
|
+
Settings,
|
|
26
|
+
ContextProvider,
|
|
27
|
+
...childProps
|
|
28
|
+
} = props;
|
|
29
|
+
const classes = useStyles();
|
|
30
|
+
const [settingsIsExpanded, setSettingsIsExpanded] = React.useState(false);
|
|
31
|
+
const [isExpanded, setIsExpanded] = React.useState(expanded);
|
|
32
|
+
const handleOpenSettings = (e) => {
|
|
33
|
+
e.stopPropagation();
|
|
34
|
+
setSettingsIsExpanded((prevState) => !prevState);
|
|
35
|
+
};
|
|
36
|
+
const innerContent = /* @__PURE__ */ React.createElement(React.Fragment, null, Settings && /* @__PURE__ */ React.createElement(
|
|
37
|
+
SettingsModal,
|
|
38
|
+
{
|
|
39
|
+
open: settingsIsExpanded,
|
|
40
|
+
close: () => setSettingsIsExpanded(false),
|
|
41
|
+
componentName: title
|
|
42
|
+
},
|
|
43
|
+
/* @__PURE__ */ React.createElement(Settings, null)
|
|
44
|
+
), /* @__PURE__ */ React.createElement(
|
|
45
|
+
Accordion,
|
|
46
|
+
{
|
|
47
|
+
expanded: isExpanded,
|
|
48
|
+
onChange: (_e, expandedValue) => setIsExpanded(expandedValue)
|
|
49
|
+
},
|
|
50
|
+
/* @__PURE__ */ React.createElement(AccordionSummary, { expandIcon: /* @__PURE__ */ React.createElement(ExpandMoreIcon, null) }, Settings && /* @__PURE__ */ React.createElement(
|
|
51
|
+
IconButton,
|
|
52
|
+
{
|
|
53
|
+
onClick: handleOpenSettings,
|
|
54
|
+
className: classes.settingsIconButton
|
|
55
|
+
},
|
|
56
|
+
/* @__PURE__ */ React.createElement(SettingsIcon, null)
|
|
57
|
+
), /* @__PURE__ */ React.createElement(Typography, null, title)),
|
|
58
|
+
/* @__PURE__ */ React.createElement(AccordionDetails, null, /* @__PURE__ */ React.createElement("div", { className: classes.contentContainer }, /* @__PURE__ */ React.createElement(Content, null), Actions && /* @__PURE__ */ React.createElement(Actions, null)))
|
|
59
|
+
));
|
|
60
|
+
return ContextProvider ? /* @__PURE__ */ React.createElement(ContextProvider, { ...childProps }, innerContent) : innerContent;
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
const ComponentTabs = (props) => {
|
|
64
|
+
const { title, tabs } = props;
|
|
65
|
+
const [value, setValue] = React.useState(0);
|
|
66
|
+
const handleChange = (_event, newValue) => {
|
|
67
|
+
setValue(newValue);
|
|
68
|
+
};
|
|
69
|
+
return /* @__PURE__ */ React.createElement(InfoCard, { title }, /* @__PURE__ */ React.createElement(Tabs, { value, onChange: handleChange }, tabs.map((t) => /* @__PURE__ */ React.createElement(Tab, { key: t.label, label: t.label }))), tabs.map(({ Component }, idx) => /* @__PURE__ */ React.createElement(
|
|
70
|
+
"div",
|
|
71
|
+
{
|
|
72
|
+
key: idx,
|
|
73
|
+
...idx !== value ? { style: { display: "none" } } : {}
|
|
74
|
+
},
|
|
75
|
+
/* @__PURE__ */ React.createElement(Component, null)
|
|
76
|
+
)));
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
const ComponentTab = (props) => {
|
|
80
|
+
const { title, Content, ContextProvider, ...childProps } = props;
|
|
81
|
+
return ContextProvider ? /* @__PURE__ */ React.createElement(ContextProvider, { ...childProps }, /* @__PURE__ */ React.createElement(Content, null)) : /* @__PURE__ */ React.createElement(Content, null);
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
export { ComponentAccordion, ComponentTab, ComponentTabs };
|
|
85
|
+
//# sourceMappingURL=index-f9c2c511.esm.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index-
|
|
1
|
+
{"version":3,"file":"index-f9c2c511.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,CAAA,OAAA,CAAQ,CAAG,EAAA,CAAA,EAAG,GAAG,CAAC,CAAA;AAAA,GACnC;AAAA,EACA,gBAAkB,EAAA;AAAA,IAChB,KAAO,EAAA,MAAA;AAAA,GACT;AACF,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