@backstage/plugin-home 0.7.3-next.1 → 0.7.4-next.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +41 -0
- package/alpha/package.json +1 -1
- package/dist/alpha.esm.js +1 -1
- package/dist/alpha.esm.js.map +1 -1
- package/dist/api/VisitsApi.esm.js +11 -0
- package/dist/api/VisitsApi.esm.js.map +1 -0
- package/dist/api/VisitsStorageApi.esm.js +118 -0
- package/dist/api/VisitsStorageApi.esm.js.map +1 -0
- package/dist/api/VisitsWebStorageApi.esm.js +15 -0
- package/dist/api/VisitsWebStorageApi.esm.js.map +1 -0
- package/dist/api/config.esm.js +37 -0
- package/dist/api/config.esm.js.map +1 -0
- package/dist/assets/TemplateBackstageLogo.esm.js +22 -0
- package/dist/assets/TemplateBackstageLogo.esm.js.map +1 -0
- package/dist/assets/TemplateBackstageLogoIcon.esm.js +33 -0
- package/dist/assets/TemplateBackstageLogoIcon.esm.js.map +1 -0
- package/dist/{esm/index-BNfZuEhy.esm.js → componentRenderers/ComponentAccordion.esm.js} +2 -26
- package/dist/componentRenderers/ComponentAccordion.esm.js.map +1 -0
- package/dist/componentRenderers/ComponentTabs/ComponentTab.esm.js +9 -0
- package/dist/componentRenderers/ComponentTabs/ComponentTab.esm.js.map +1 -0
- package/dist/componentRenderers/ComponentTabs/ComponentTabs.esm.js +23 -0
- package/dist/componentRenderers/ComponentTabs/ComponentTabs.esm.js.map +1 -0
- package/dist/componentRenderers/index.esm.js +4 -0
- package/dist/componentRenderers/index.esm.js.map +1 -0
- package/dist/components/CustomHomepage/AddWidgetDialog.esm.js +45 -0
- package/dist/components/CustomHomepage/AddWidgetDialog.esm.js.map +1 -0
- package/dist/components/CustomHomepage/CustomHomepageButtons.esm.js +90 -0
- package/dist/components/CustomHomepage/CustomHomepageButtons.esm.js.map +1 -0
- package/dist/components/CustomHomepage/CustomHomepageGrid.esm.js +319 -0
- package/dist/components/CustomHomepage/CustomHomepageGrid.esm.js.map +1 -0
- package/dist/components/CustomHomepage/WidgetSettingsOverlay.esm.js +88 -0
- package/dist/components/CustomHomepage/WidgetSettingsOverlay.esm.js.map +1 -0
- package/dist/components/CustomHomepage/types.esm.js +48 -0
- package/dist/components/CustomHomepage/types.esm.js.map +1 -0
- package/dist/components/HomepageCompositionRoot.esm.js +12 -0
- package/dist/components/HomepageCompositionRoot.esm.js.map +1 -0
- package/dist/components/StarredEntityListItem/StarredEntityListItem.esm.js +31 -0
- package/dist/components/StarredEntityListItem/StarredEntityListItem.esm.js.map +1 -0
- package/dist/components/VisitList/ItemCategory.esm.js +63 -0
- package/dist/components/VisitList/ItemCategory.esm.js.map +1 -0
- package/dist/components/VisitList/ItemDetail.esm.js +26 -0
- package/dist/components/VisitList/ItemDetail.esm.js.map +1 -0
- package/dist/components/VisitList/ItemName.esm.js +27 -0
- package/dist/components/VisitList/ItemName.esm.js.map +1 -0
- package/dist/components/VisitList/VisitList.esm.js +46 -0
- package/dist/components/VisitList/VisitList.esm.js.map +1 -0
- package/dist/components/VisitList/VisitListEmpty.esm.js +7 -0
- package/dist/components/VisitList/VisitListEmpty.esm.js.map +1 -0
- package/dist/components/VisitList/VisitListFew.esm.js +7 -0
- package/dist/components/VisitList/VisitListFew.esm.js.map +1 -0
- package/dist/components/VisitList/VisitListItem.esm.js +31 -0
- package/dist/components/VisitList/VisitListItem.esm.js.map +1 -0
- package/dist/components/VisitList/VisitListSkeleton.esm.js +39 -0
- package/dist/components/VisitList/VisitListSkeleton.esm.js.map +1 -0
- package/dist/components/VisitListener.esm.js +62 -0
- package/dist/components/VisitListener.esm.js.map +1 -0
- package/dist/components/index.esm.js +4 -0
- package/dist/components/index.esm.js.map +1 -0
- package/dist/deprecated.esm.js +7 -0
- package/dist/deprecated.esm.js.map +1 -0
- package/dist/{esm/index-FqRX6ImF.esm.js → homePageComponents/CompanyLogo/CompanyLogo.esm.js} +1 -1
- package/dist/{esm/index-FqRX6ImF.esm.js.map → homePageComponents/CompanyLogo/CompanyLogo.esm.js.map} +1 -1
- package/dist/homePageComponents/CompanyLogo/index.esm.js +2 -0
- package/dist/homePageComponents/CompanyLogo/index.esm.js.map +1 -0
- package/dist/{esm/index-D7JTE1IL.esm.js → homePageComponents/FeaturedDocsCard/Content.esm.js} +1 -1
- package/dist/homePageComponents/FeaturedDocsCard/Content.esm.js.map +1 -0
- package/dist/homePageComponents/FeaturedDocsCard/index.esm.js +2 -0
- package/dist/homePageComponents/FeaturedDocsCard/index.esm.js.map +1 -0
- package/dist/{esm/index-BvvJGS3L.esm.js → homePageComponents/HeaderWorldClock/HeaderWorldClock.esm.js} +1 -1
- package/dist/homePageComponents/HeaderWorldClock/HeaderWorldClock.esm.js.map +1 -0
- package/dist/homePageComponents/HeaderWorldClock/index.esm.js +2 -0
- package/dist/homePageComponents/HeaderWorldClock/index.esm.js.map +1 -0
- package/dist/homePageComponents/RandomJoke/Actions.esm.js +11 -0
- package/dist/homePageComponents/RandomJoke/Actions.esm.js.map +1 -0
- package/dist/homePageComponents/RandomJoke/Content.esm.js +13 -0
- package/dist/homePageComponents/RandomJoke/Content.esm.js.map +1 -0
- package/dist/homePageComponents/RandomJoke/Context.esm.js +48 -0
- package/dist/homePageComponents/RandomJoke/Context.esm.js.map +1 -0
- package/dist/homePageComponents/RandomJoke/Settings.esm.js +33 -0
- package/dist/homePageComponents/RandomJoke/Settings.esm.js.map +1 -0
- package/dist/homePageComponents/RandomJoke/index.esm.js +5 -0
- package/dist/homePageComponents/RandomJoke/index.esm.js.map +1 -0
- package/dist/{esm/index-SfHoDIi1.esm.js → homePageComponents/StarredEntities/Content.esm.js} +4 -27
- package/dist/homePageComponents/StarredEntities/Content.esm.js.map +1 -0
- package/dist/homePageComponents/StarredEntities/index.esm.js +2 -0
- package/dist/homePageComponents/StarredEntities/index.esm.js.map +1 -0
- package/dist/{esm/index-CeXFfTX2.esm.js → homePageComponents/Toolkit/Content.esm.js} +4 -17
- package/dist/homePageComponents/Toolkit/Content.esm.js.map +1 -0
- package/dist/homePageComponents/Toolkit/Context.esm.js +18 -0
- package/dist/homePageComponents/Toolkit/Context.esm.js.map +1 -0
- package/dist/homePageComponents/Toolkit/index.esm.js +3 -0
- package/dist/homePageComponents/Toolkit/index.esm.js.map +1 -0
- package/dist/homePageComponents/VisitedByType/Actions.esm.js +18 -0
- package/dist/homePageComponents/VisitedByType/Actions.esm.js.map +1 -0
- package/dist/homePageComponents/VisitedByType/Content.esm.js +68 -0
- package/dist/homePageComponents/VisitedByType/Content.esm.js.map +1 -0
- package/dist/homePageComponents/VisitedByType/Context.esm.js +77 -0
- package/dist/homePageComponents/VisitedByType/Context.esm.js.map +1 -0
- package/dist/homePageComponents/VisitedByType/RecentlyVisited.esm.js +9 -0
- package/dist/homePageComponents/VisitedByType/RecentlyVisited.esm.js.map +1 -0
- package/dist/homePageComponents/VisitedByType/TopVisited.esm.js +9 -0
- package/dist/homePageComponents/VisitedByType/TopVisited.esm.js.map +1 -0
- package/dist/homePageComponents/VisitedByType/VisitedByType.esm.js +21 -0
- package/dist/homePageComponents/VisitedByType/VisitedByType.esm.js.map +1 -0
- package/dist/homePageComponents/WelcomeTitle/WelcomeTitle.esm.js +27 -0
- package/dist/homePageComponents/WelcomeTitle/WelcomeTitle.esm.js.map +1 -0
- package/dist/homePageComponents/WelcomeTitle/index.esm.js +2 -0
- package/dist/homePageComponents/WelcomeTitle/index.esm.js.map +1 -0
- package/dist/homePageComponents/WelcomeTitle/locales/goodAfternoon.locales.json.esm.js +256 -0
- package/dist/homePageComponents/WelcomeTitle/locales/goodAfternoon.locales.json.esm.js.map +1 -0
- package/dist/homePageComponents/WelcomeTitle/locales/goodEvening.locales.json.esm.js +196 -0
- package/dist/homePageComponents/WelcomeTitle/locales/goodEvening.locales.json.esm.js.map +1 -0
- package/dist/homePageComponents/WelcomeTitle/locales/goodMorning.locales.json.esm.js +131 -0
- package/dist/homePageComponents/WelcomeTitle/locales/goodMorning.locales.json.esm.js.map +1 -0
- package/dist/homePageComponents/WelcomeTitle/timeUtil.esm.js +41 -0
- package/dist/homePageComponents/WelcomeTitle/timeUtil.esm.js.map +1 -0
- package/dist/index.esm.js +10 -352
- package/dist/index.esm.js.map +1 -1
- package/dist/plugin.esm.js +144 -0
- package/dist/plugin.esm.js.map +1 -0
- package/dist/routes.esm.js +8 -0
- package/dist/routes.esm.js.map +1 -0
- package/package.json +20 -20
- package/dist/esm/Content-Quo42yad.esm.js +0 -396
- package/dist/esm/Content-Quo42yad.esm.js.map +0 -1
- package/dist/esm/RecentlyVisited-qOUgoCVu.esm.js +0 -48
- package/dist/esm/RecentlyVisited-qOUgoCVu.esm.js.map +0 -1
- package/dist/esm/TopVisited-B_KhSJit.esm.js +0 -48
- package/dist/esm/TopVisited-B_KhSJit.esm.js.map +0 -1
- package/dist/esm/VisitListener-dDLtFiIW.esm.js +0 -627
- package/dist/esm/VisitListener-dDLtFiIW.esm.js.map +0 -1
- package/dist/esm/index-BMySa_Iw.esm.js +0 -638
- package/dist/esm/index-BMySa_Iw.esm.js.map +0 -1
- package/dist/esm/index-BNfZuEhy.esm.js.map +0 -1
- package/dist/esm/index-BvvJGS3L.esm.js.map +0 -1
- package/dist/esm/index-Bzg5mDMo.esm.js +0 -45
- package/dist/esm/index-Bzg5mDMo.esm.js.map +0 -1
- package/dist/esm/index-CeXFfTX2.esm.js.map +0 -1
- package/dist/esm/index-D7JTE1IL.esm.js.map +0 -1
- package/dist/esm/index-Dg9lslkf.esm.js +0 -90
- package/dist/esm/index-Dg9lslkf.esm.js.map +0 -1
- package/dist/esm/index-SfHoDIi1.esm.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import Button from '@material-ui/core/Button';
|
|
3
|
+
import { useRandomJoke } from './Context.esm.js';
|
|
4
|
+
|
|
5
|
+
const Actions = () => {
|
|
6
|
+
const { rerollJoke } = useRandomJoke();
|
|
7
|
+
return /* @__PURE__ */ React.createElement(Button, { variant: "contained", color: "primary", onClick: () => rerollJoke() }, "Reroll");
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export { Actions };
|
|
11
|
+
//# sourceMappingURL=Actions.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Actions.esm.js","sources":["../../../src/homePageComponents/RandomJoke/Actions.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';\n\nimport Button from '@material-ui/core/Button';\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"],"names":[],"mappings":";;;;AAqBO,MAAM,UAAU,MAAM;AAC3B,EAAM,MAAA,EAAE,UAAW,EAAA,GAAI,aAAc,EAAA,CAAA;AACrC,EACE,uBAAA,KAAA,CAAA,aAAA,CAAC,MAAO,EAAA,EAAA,OAAA,EAAQ,WAAY,EAAA,KAAA,EAAM,WAAU,OAAS,EAAA,MAAM,UAAW,EAAA,EAAA,EAAG,QAEzE,CAAA,CAAA;AAEJ;;;;"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import Typography from '@material-ui/core/Typography';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { useRandomJoke } from './Context.esm.js';
|
|
4
|
+
|
|
5
|
+
const Content = () => {
|
|
6
|
+
const { joke, loading } = useRandomJoke();
|
|
7
|
+
if (loading)
|
|
8
|
+
return /* @__PURE__ */ React.createElement(Typography, { paragraph: true }, "Loading...");
|
|
9
|
+
return /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement(Typography, { paragraph: true }, joke.setup), /* @__PURE__ */ React.createElement(Typography, { paragraph: true }, joke.punchline));
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export { Content };
|
|
13
|
+
//# sourceMappingURL=Content.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Content.esm.js","sources":["../../../src/homePageComponents/RandomJoke/Content.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 Typography from '@material-ui/core/Typography';\nimport React from 'react';\nimport { useRandomJoke } from './Context';\n\nexport const Content = () => {\n const { joke, loading } = useRandomJoke();\n\n if (loading) return <Typography paragraph>Loading...</Typography>;\n\n return (\n <div>\n <Typography paragraph>{joke.setup}</Typography>\n <Typography paragraph>{joke.punchline}</Typography>\n </div>\n );\n};\n"],"names":[],"mappings":";;;;AAoBO,MAAM,UAAU,MAAM;AAC3B,EAAA,MAAM,EAAE,IAAA,EAAM,OAAQ,EAAA,GAAI,aAAc,EAAA,CAAA;AAExC,EAAI,IAAA,OAAA;AAAS,IAAA,uBAAQ,KAAA,CAAA,aAAA,CAAA,UAAA,EAAA,EAAW,SAAS,EAAA,IAAA,EAAA,EAAC,YAAU,CAAA,CAAA;AAEpD,EAAA,uBACG,KAAA,CAAA,aAAA,CAAA,KAAA,EAAA,IAAA,kBACE,KAAA,CAAA,aAAA,CAAA,UAAA,EAAA,EAAW,WAAS,IAAE,EAAA,EAAA,IAAA,CAAK,KAAM,CAAA,sCACjC,UAAW,EAAA,EAAA,SAAA,EAAS,IAAE,EAAA,EAAA,IAAA,CAAK,SAAU,CACxC,CAAA,CAAA;AAEJ;;;;"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import React, { createContext } from 'react';
|
|
2
|
+
|
|
3
|
+
const Context = createContext(void 0);
|
|
4
|
+
const getNewJoke = (type) => fetch(
|
|
5
|
+
`https://official-joke-api.appspot.com/jokes${type !== "any" ? `/${type}` : ""}/random`
|
|
6
|
+
).then((res) => res.json()).then((data) => Array.isArray(data) ? data[0] : data);
|
|
7
|
+
const ContextProvider = (props) => {
|
|
8
|
+
const { children, defaultCategory } = props;
|
|
9
|
+
const [loading, setLoading] = React.useState(true);
|
|
10
|
+
const [joke, setJoke] = React.useState({
|
|
11
|
+
setup: "",
|
|
12
|
+
punchline: ""
|
|
13
|
+
});
|
|
14
|
+
const [type, setType] = React.useState(
|
|
15
|
+
defaultCategory || "programming"
|
|
16
|
+
);
|
|
17
|
+
const rerollJoke = React.useCallback(() => {
|
|
18
|
+
setLoading(true);
|
|
19
|
+
getNewJoke(type).then((newJoke) => setJoke(newJoke));
|
|
20
|
+
}, [type]);
|
|
21
|
+
const handleChangeType = (newType) => {
|
|
22
|
+
setType(newType);
|
|
23
|
+
};
|
|
24
|
+
React.useEffect(() => {
|
|
25
|
+
setLoading(false);
|
|
26
|
+
}, [joke]);
|
|
27
|
+
React.useEffect(() => {
|
|
28
|
+
rerollJoke();
|
|
29
|
+
}, [rerollJoke]);
|
|
30
|
+
const value = {
|
|
31
|
+
loading,
|
|
32
|
+
joke,
|
|
33
|
+
type,
|
|
34
|
+
rerollJoke,
|
|
35
|
+
handleChangeType
|
|
36
|
+
};
|
|
37
|
+
return /* @__PURE__ */ React.createElement(Context.Provider, { value }, children);
|
|
38
|
+
};
|
|
39
|
+
const useRandomJoke = () => {
|
|
40
|
+
const value = React.useContext(Context);
|
|
41
|
+
if (value === void 0) {
|
|
42
|
+
throw new Error("useRandomJoke must be used within a RandomJokeProvider");
|
|
43
|
+
}
|
|
44
|
+
return value;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export { ContextProvider, Context as default, useRandomJoke };
|
|
48
|
+
//# sourceMappingURL=Context.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Context.esm.js","sources":["../../../src/homePageComponents/RandomJoke/Context.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"],"names":[],"mappings":";;AAiCM,MAAA,OAAA,GAAU,cAAkD,KAAS,CAAA,EAAA;AAE3E,MAAM,UAAA,GAAa,CAAC,IAClB,KAAA,KAAA;AAAA,EACE,8CACE,IAAS,KAAA,KAAA,GAAQ,CAAI,CAAA,EAAA,IAAI,KAAK,EAChC,CAAA,OAAA,CAAA;AACF,CAAA,CACG,IAAK,CAAA,CAAA,GAAA,KAAO,GAAI,CAAA,IAAA,EAAM,CACtB,CAAA,IAAA,CAAK,CAAS,IAAA,KAAA,KAAA,CAAM,QAAQ,IAAI,CAAA,GAAI,IAAK,CAAA,CAAC,IAAI,IAAK,CAAA,CAAA;AAE3C,MAAA,eAAA,GAAkB,CAAC,KAG1B,KAAA;AACJ,EAAM,MAAA,EAAE,QAAU,EAAA,eAAA,EAAoB,GAAA,KAAA,CAAA;AAEtC,EAAA,MAAM,CAAC,OAAS,EAAA,UAAU,CAAI,GAAA,KAAA,CAAM,SAAS,IAAI,CAAA,CAAA;AACjD,EAAA,MAAM,CAAC,IAAA,EAAM,OAAO,CAAA,GAAI,MAAM,QAAe,CAAA;AAAA,IAC3C,KAAO,EAAA,EAAA;AAAA,IACP,SAAW,EAAA,EAAA;AAAA,GACZ,CAAA,CAAA;AACD,EAAA,MAAM,CAAC,IAAA,EAAM,OAAO,CAAA,GAAI,KAAM,CAAA,QAAA;AA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FormLabel from '@material-ui/core/FormLabel';
|
|
3
|
+
import RadioGroup from '@material-ui/core/RadioGroup';
|
|
4
|
+
import FormControlLabel from '@material-ui/core/FormControlLabel';
|
|
5
|
+
import Radio from '@material-ui/core/Radio';
|
|
6
|
+
import React from 'react';
|
|
7
|
+
import { useRandomJoke } from './Context.esm.js';
|
|
8
|
+
import upperFirst from 'lodash/upperFirst';
|
|
9
|
+
|
|
10
|
+
const Settings = () => {
|
|
11
|
+
const { type, handleChangeType } = useRandomJoke();
|
|
12
|
+
const JOKE_TYPES = ["any", "programming"];
|
|
13
|
+
return /* @__PURE__ */ React.createElement(FormControl, { component: "fieldset" }, /* @__PURE__ */ React.createElement(FormLabel, { component: "legend" }, "Joke Type"), /* @__PURE__ */ React.createElement(
|
|
14
|
+
RadioGroup,
|
|
15
|
+
{
|
|
16
|
+
"aria-label": "joke type",
|
|
17
|
+
value: type,
|
|
18
|
+
onChange: (e) => handleChangeType(e.target.value)
|
|
19
|
+
},
|
|
20
|
+
JOKE_TYPES.map((t) => /* @__PURE__ */ React.createElement(
|
|
21
|
+
FormControlLabel,
|
|
22
|
+
{
|
|
23
|
+
key: t,
|
|
24
|
+
value: t,
|
|
25
|
+
control: /* @__PURE__ */ React.createElement(Radio, null),
|
|
26
|
+
label: upperFirst(t)
|
|
27
|
+
}
|
|
28
|
+
))
|
|
29
|
+
));
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export { Settings };
|
|
33
|
+
//# sourceMappingURL=Settings.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Settings.esm.js","sources":["../../../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 */\nimport FormControl from '@material-ui/core/FormControl';\nimport FormLabel from '@material-ui/core/FormLabel';\nimport RadioGroup from '@material-ui/core/RadioGroup';\nimport FormControlLabel from '@material-ui/core/FormControlLabel';\nimport Radio from '@material-ui/core/Radio';\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":";;;;;;;;;AAwBO,MAAM,WAAW,MAAM;AAC5B,EAAA,MAAM,EAAE,IAAA,EAAM,gBAAiB,EAAA,GAAI,aAAc,EAAA,CAAA;AACjD,EAAM,MAAA,UAAA,GAAyB,CAAC,KAAA,EAAmB,aAAyB,CAAA,CAAA;AAC5E,EACE,uBAAA,KAAA,CAAA,aAAA,CAAC,eAAY,SAAU,EAAA,UAAA,EAAA,sCACpB,SAAU,EAAA,EAAA,SAAA,EAAU,QAAS,EAAA,EAAA,WAAS,CACvC,kBAAA,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;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;"}
|
package/dist/{esm/index-SfHoDIi1.esm.js → homePageComponents/StarredEntities/Content.esm.js}
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { catalogApiRef, useStarredEntities } from '@backstage/plugin-catalog-react';
|
|
2
2
|
import { stringifyEntityRef } from '@backstage/catalog-model';
|
|
3
|
-
import {
|
|
3
|
+
import { useApi } from '@backstage/core-plugin-api';
|
|
4
4
|
import { Progress, ResponseErrorPanel } from '@backstage/core-components';
|
|
5
5
|
import List from '@material-ui/core/List';
|
|
6
6
|
import Typography from '@material-ui/core/Typography';
|
|
@@ -8,30 +8,7 @@ import Tabs from '@material-ui/core/Tabs';
|
|
|
8
8
|
import Tab from '@material-ui/core/Tab';
|
|
9
9
|
import React from 'react';
|
|
10
10
|
import useAsync from 'react-use/esm/useAsync';
|
|
11
|
-
import
|
|
12
|
-
import ListItemIcon from '@material-ui/core/ListItemIcon';
|
|
13
|
-
import Tooltip from '@material-ui/core/Tooltip';
|
|
14
|
-
import IconButton from '@material-ui/core/IconButton';
|
|
15
|
-
import ListItemText from '@material-ui/core/ListItemText';
|
|
16
|
-
import { Link } from 'react-router-dom';
|
|
17
|
-
import StarIcon from '@material-ui/icons/Star';
|
|
18
|
-
|
|
19
|
-
const StarredEntityListItem = ({
|
|
20
|
-
entity,
|
|
21
|
-
onToggleStarredEntity
|
|
22
|
-
}) => {
|
|
23
|
-
var _a;
|
|
24
|
-
const catalogEntityRoute = useRouteRef(entityRouteRef);
|
|
25
|
-
return /* @__PURE__ */ React.createElement(ListItem, { key: stringifyEntityRef(entity) }, /* @__PURE__ */ React.createElement(ListItemIcon, null, /* @__PURE__ */ React.createElement(Tooltip, { title: "Remove from starred" }, /* @__PURE__ */ React.createElement(
|
|
26
|
-
IconButton,
|
|
27
|
-
{
|
|
28
|
-
edge: "end",
|
|
29
|
-
"aria-label": "unstar",
|
|
30
|
-
onClick: () => onToggleStarredEntity(entity)
|
|
31
|
-
},
|
|
32
|
-
/* @__PURE__ */ React.createElement(StarIcon, { style: { color: "#f3ba37" } })
|
|
33
|
-
))), /* @__PURE__ */ React.createElement(Link, { to: catalogEntityRoute(entityRouteParams(entity)) }, /* @__PURE__ */ React.createElement(ListItemText, { primary: (_a = entity.metadata.title) != null ? _a : entity.metadata.name })));
|
|
34
|
-
};
|
|
11
|
+
import { StarredEntityListItem } from '../../components/StarredEntityListItem/StarredEntityListItem.esm.js';
|
|
35
12
|
|
|
36
13
|
const Content = ({
|
|
37
14
|
noStarredEntitiesMessage,
|
|
@@ -111,4 +88,4 @@ const Content = ({
|
|
|
111
88
|
};
|
|
112
89
|
|
|
113
90
|
export { Content };
|
|
114
|
-
//# sourceMappingURL=
|
|
91
|
+
//# sourceMappingURL=Content.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Content.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} from '@backstage/plugin-catalog-react';\nimport { Entity, stringifyEntityRef } from '@backstage/catalog-model';\nimport { useApi } from '@backstage/core-plugin-api';\nimport { Progress, ResponseErrorPanel } from '@backstage/core-components';\nimport List from '@material-ui/core/List';\nimport Typography from '@material-ui/core/Typography';\nimport Tabs from '@material-ui/core/Tabs';\nimport Tab from '@material-ui/core/Tab';\nimport React from 'react';\nimport useAsync from 'react-use/esm/useAsync';\nimport { StarredEntityListItem } from '../../components/StarredEntityListItem/StarredEntityListItem';\n\n/**\n * A component to display a list of starred entities for the user.\n *\n * @public\n */\n\nexport type StarredEntitiesProps = {\n noStarredEntitiesMessage?: React.ReactNode | undefined;\n groupByKind?: boolean;\n};\n\nexport const Content = ({\n noStarredEntitiesMessage,\n groupByKind,\n}: StarredEntitiesProps) => {\n const catalogApi = useApi(catalogApiRef);\n const { starredEntities, toggleStarredEntity } = useStarredEntities();\n const [activeTab, setActiveTab] = React.useState(0);\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 return (\n await catalogApi.getEntitiesByRefs({\n entityRefs: [...starredEntities],\n fields: [\n 'kind',\n 'metadata.namespace',\n 'metadata.name',\n 'metadata.title',\n ],\n })\n ).items.filter((e): e is Entity => !!e);\n }, [catalogApi, starredEntities]);\n\n if (starredEntities.size === 0)\n return (\n <Typography variant=\"body1\">\n {noStarredEntitiesMessage ||\n 'Click the star beside an entity name to add it to this list!'}\n </Typography>\n );\n\n if (entities.loading) {\n return <Progress />;\n }\n\n const groupedEntities: { [kind: string]: Entity[] } = {};\n entities.value?.forEach(entity => {\n const kind = entity.kind;\n if (!groupedEntities[kind]) {\n groupedEntities[kind] = [];\n }\n groupedEntities[kind].push(entity);\n });\n\n const groupByKindEntries = Object.entries(groupedEntities);\n\n return entities.error ? (\n <ResponseErrorPanel error={entities.error} />\n ) : (\n <div>\n {!groupByKind && (\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 <StarredEntityListItem\n key={stringifyEntityRef(entity)}\n entity={entity}\n onToggleStarredEntity={toggleStarredEntity}\n />\n ))}\n </List>\n )}\n\n {groupByKind && (\n <Tabs\n value={activeTab}\n onChange={(_, newValue) => setActiveTab(newValue)}\n variant=\"scrollable\"\n scrollButtons=\"auto\"\n aria-label=\"entity-tabs\"\n >\n {groupByKindEntries.map(([kind]) => (\n <Tab key={kind} label={kind} />\n ))}\n </Tabs>\n )}\n\n {groupByKind &&\n groupByKindEntries.map(([kind, entitiesByKind], index) => (\n <div key={kind} hidden={groupByKind && activeTab !== index}>\n <List>\n {entitiesByKind\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 <StarredEntityListItem\n key={stringifyEntityRef(entity)}\n entity={entity}\n onToggleStarredEntity={toggleStarredEntity}\n />\n ))}\n </List>\n </div>\n ))}\n </div>\n );\n};\n"],"names":["_a","_b"],"mappings":";;;;;;;;;;;;AA0CO,MAAM,UAAU,CAAC;AAAA,EACtB,wBAAA;AAAA,EACA,WAAA;AACF,CAA4B,KAAA;AA7C5B,EAAA,IAAA,EAAA,EAAA,EAAA,CAAA;AA8CE,EAAM,MAAA,UAAA,GAAa,OAAO,aAAa,CAAA,CAAA;AACvC,EAAA,MAAM,EAAE,eAAA,EAAiB,mBAAoB,EAAA,GAAI,kBAAmB,EAAA,CAAA;AACpE,EAAA,MAAM,CAAC,SAAW,EAAA,YAAY,CAAI,GAAA,KAAA,CAAM,SAAS,CAAC,CAAA,CAAA;AAGlD,EAAM,MAAA,QAAA,GAAW,SAAS,YAAY;AACpC,IAAI,IAAA,CAAC,gBAAgB,IAAM,EAAA;AACzB,MAAA,OAAO,EAAC,CAAA;AAAA,KACV;AAEA,IACE,OAAA,CAAA,MAA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mB,CAAA,GAAA,CAAI,CAAC,CAAC,IAAA,EAAM,cAAc,CAAG,EAAA,KAAA,yCAC7C,KAAI,EAAA,EAAA,GAAA,EAAK,MAAM,MAAQ,EAAA,WAAA,IAAe,cAAc,KACnD,EAAA,kBAAA,KAAA,CAAA,aAAA,CAAC,YACE,cACG,IAAA,IAAA,GAAA,KAAA,CAAA,GAAA,cAAA,CAAA,IAAA;AAAA,IAAK,CAAC,GAAG,CAAG,KAAA;AArI9B,MAAA,IAAAD,GAAAC,EAAAA,GAAAA,CAAAA;AAsImB,MAAAD,OAAAA,CAAAA,CAAAA,GAAAA,GAAA,EAAE,QAAS,CAAA,KAAA,KAAX,OAAAA,GAAoB,GAAA,CAAA,CAAE,SAAS,IAAM,EAAA,aAAA;AAAA,QAAA,CACpCC,MAAA,CAAE,CAAA,QAAA,CAAS,UAAX,IAAAA,GAAAA,GAAAA,GAAoB,EAAE,QAAS,CAAA,IAAA;AAAA,OACjC,CAAA;AAAA,KAAA;AAAA,GAAA,CAED,IAAI,CACH,MAAA,qBAAA,KAAA,CAAA,aAAA;AAAA,IAAC,qBAAA;AAAA,IAAA;AAAA,MACC,GAAA,EAAK,mBAAmB,MAAM,CAAA;AAAA,MAC9B,MAAA;AAAA,MACA,qBAAuB,EAAA,mBAAA;AAAA,KAAA;AAAA,GACzB,CAEN,CACF,CACD,CACL,CAAA,CAAA;AAEJ;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -3,21 +3,8 @@ import List from '@material-ui/core/List';
|
|
|
3
3
|
import ListItemIcon from '@material-ui/core/ListItemIcon';
|
|
4
4
|
import ListItemText from '@material-ui/core/ListItemText';
|
|
5
5
|
import { makeStyles } from '@material-ui/core/styles';
|
|
6
|
-
import React
|
|
7
|
-
|
|
8
|
-
const Context = createContext(void 0);
|
|
9
|
-
const ContextProvider = (props) => {
|
|
10
|
-
const { children, tools } = props;
|
|
11
|
-
const [toolsValue, _setTools] = React.useState(tools);
|
|
12
|
-
const value = {
|
|
13
|
-
tools: toolsValue
|
|
14
|
-
};
|
|
15
|
-
return /* @__PURE__ */ React.createElement(Context.Provider, { value }, children);
|
|
16
|
-
};
|
|
17
|
-
const useToolkit = () => {
|
|
18
|
-
const value = React.useContext(Context);
|
|
19
|
-
return value;
|
|
20
|
-
};
|
|
6
|
+
import React from 'react';
|
|
7
|
+
import { useToolkit } from './Context.esm.js';
|
|
21
8
|
|
|
22
9
|
const useStyles = makeStyles((theme) => ({
|
|
23
10
|
toolkit: {
|
|
@@ -60,5 +47,5 @@ const Content = (props) => {
|
|
|
60
47
|
))));
|
|
61
48
|
};
|
|
62
49
|
|
|
63
|
-
export { Content
|
|
64
|
-
//# sourceMappingURL=
|
|
50
|
+
export { Content };
|
|
51
|
+
//# sourceMappingURL=Content.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Content.esm.js","sources":["../../../src/homePageComponents/Toolkit/Content.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 { Link } from '@backstage/core-components';\nimport List from '@material-ui/core/List';\nimport ListItemIcon from '@material-ui/core/ListItemIcon';\nimport ListItemText from '@material-ui/core/ListItemText';\nimport { makeStyles } from '@material-ui/core/styles';\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":";;;;;;;;AAwBA,MAAM,SAAA,GAAY,WAAW,CAAU,KAAA,MAAA;AAAA,EACrC,OAAS,EAAA;AAAA,IACP,OAAS,EAAA,MAAA;AAAA,IACT,QAAU,EAAA,MAAA;AAAA,IACV,SAAW,EAAA,QAAA;AAAA,GACb;AAAA,EACA,IAAM,EAAA;AAAA,IACJ,MAAQ,EAAA,KAAA,CAAM,OAAQ,CAAA,GAAA,EAAK,CAAC,CAAA;AAAA,GAC9B;AAAA,EACA,KAAO,EAAA;AAAA,IACL,SAAA,EAAW,KAAM,CAAA,OAAA,CAAQ,CAAC,CAAA;AAAA,IAC1B,KAAO,EAAA,MAAA;AAAA,IACP,QAAU,EAAA,OAAA;AAAA,IACV,UAAY,EAAA,MAAA;AAAA,IACZ,YAAc,EAAA,YAAA;AAAA,IACd,KAAA,EAAO,KAAM,CAAA,OAAA,CAAQ,IAAK,CAAA,SAAA;AAAA,GAC5B;AAAA,EACA,IAAM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;AAAA,KAAA;AAAA,GAEpB,CACD,CACH,CAAA,CAAA;AAEJ;;;;"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import React, { createContext } from 'react';
|
|
2
|
+
|
|
3
|
+
const Context = createContext(void 0);
|
|
4
|
+
const ContextProvider = (props) => {
|
|
5
|
+
const { children, tools } = props;
|
|
6
|
+
const [toolsValue, _setTools] = React.useState(tools);
|
|
7
|
+
const value = {
|
|
8
|
+
tools: toolsValue
|
|
9
|
+
};
|
|
10
|
+
return /* @__PURE__ */ React.createElement(Context.Provider, { value }, children);
|
|
11
|
+
};
|
|
12
|
+
const useToolkit = () => {
|
|
13
|
+
const value = React.useContext(Context);
|
|
14
|
+
return value;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export { ContextProvider, Context as default, useToolkit };
|
|
18
|
+
//# sourceMappingURL=Context.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Context.esm.js","sources":["../../../src/homePageComponents/Toolkit/Context.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"],"names":[],"mappings":";;AA6BM,MAAA,OAAA,GAAU,cAA+C,KAAS,CAAA,EAAA;AAE3D,MAAA,eAAA,GAAkB,CAAC,KAG1B,KAAA;AACJ,EAAM,MAAA,EAAE,QAAU,EAAA,KAAA,EAAU,GAAA,KAAA,CAAA;AAE5B,EAAA,MAAM,CAAC,UAAY,EAAA,SAAS,CAAI,GAAA,KAAA,CAAM,SAAS,KAAK,CAAA,CAAA;AAEpD,EAAA,MAAM,KAA6B,GAAA;AAAA,IACjC,KAAO,EAAA,UAAA;AAAA,GACT,CAAA;AAEA,EAAA,uBAAQ,KAAA,CAAA,aAAA,CAAA,OAAA,CAAQ,QAAR,EAAA,EAAiB,SAAe,QAAS,CAAA,CAAA;AACnD,EAAA;AAEO,MAAM,aAAa,MAAM;AAC9B,EAAM,MAAA,KAAA,GAAQ,KAAM,CAAA,UAAA,CAAW,OAAO,CAAA,CAAA;AACtC,EAAO,OAAA,KAAA,CAAA;AACT;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import React, { useCallback } from 'react';
|
|
2
|
+
import Button from '@material-ui/core/Button';
|
|
3
|
+
import { useContext } from './Context.esm.js';
|
|
4
|
+
|
|
5
|
+
const Actions = () => {
|
|
6
|
+
const { collapsed, setCollapsed, visits, numVisitsOpen, loading } = useContext();
|
|
7
|
+
const onClick = useCallback(
|
|
8
|
+
() => setCollapsed((prevCollapsed) => !prevCollapsed),
|
|
9
|
+
[setCollapsed]
|
|
10
|
+
);
|
|
11
|
+
const label = collapsed ? "View More" : "View Less";
|
|
12
|
+
if (!loading && visits.length <= numVisitsOpen)
|
|
13
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null);
|
|
14
|
+
return /* @__PURE__ */ React.createElement(Button, { variant: "text", onClick }, label);
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export { Actions };
|
|
18
|
+
//# sourceMappingURL=Actions.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Actions.esm.js","sources":["../../../src/homePageComponents/VisitedByType/Actions.tsx"],"sourcesContent":["/*\n * Copyright 2023 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, { useCallback } from 'react';\nimport Button from '@material-ui/core/Button';\nimport { useContext } from './Context';\n\nexport const Actions = () => {\n const { collapsed, setCollapsed, visits, numVisitsOpen, loading } =\n useContext();\n const onClick = useCallback(\n () => setCollapsed(prevCollapsed => !prevCollapsed),\n [setCollapsed],\n );\n const label = collapsed ? 'View More' : 'View Less';\n\n if (!loading && visits.length <= numVisitsOpen) return <></>;\n\n return (\n <Button variant=\"text\" onClick={onClick}>\n {label}\n </Button>\n );\n};\n"],"names":[],"mappings":";;;;AAoBO,MAAM,UAAU,MAAM;AAC3B,EAAA,MAAM,EAAE,SAAW,EAAA,YAAA,EAAc,QAAQ,aAAe,EAAA,OAAA,KACtD,UAAW,EAAA,CAAA;AACb,EAAA,MAAM,OAAU,GAAA,WAAA;AAAA,IACd,MAAM,YAAA,CAAa,CAAiB,aAAA,KAAA,CAAC,aAAa,CAAA;AAAA,IAClD,CAAC,YAAY,CAAA;AAAA,GACf,CAAA;AACA,EAAM,MAAA,KAAA,GAAQ,YAAY,WAAc,GAAA,WAAA,CAAA;AAExC,EAAI,IAAA,CAAC,OAAW,IAAA,MAAA,CAAO,MAAU,IAAA,aAAA;AAAe,IAAA,uBAAS,KAAA,CAAA,aAAA,CAAA,KAAA,CAAA,QAAA,EAAA,IAAA,CAAA,CAAA;AAEzD,EAAA,uBACG,KAAA,CAAA,aAAA,CAAA,MAAA,EAAA,EAAO,OAAQ,EAAA,MAAA,EAAO,WACpB,KACH,CAAA,CAAA;AAEJ;;;;"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import React, { useEffect } from 'react';
|
|
2
|
+
import { createFilterByQueryParamFromConfig } from '../../api/config.esm.js';
|
|
3
|
+
import { VisitedByType } from './VisitedByType.esm.js';
|
|
4
|
+
import '@backstage/core-app-api';
|
|
5
|
+
import { visitsApiRef } from '../../api/VisitsApi.esm.js';
|
|
6
|
+
import { useContext } from './Context.esm.js';
|
|
7
|
+
import { useApi, configApiRef } from '@backstage/core-plugin-api';
|
|
8
|
+
import useAsync from 'react-use/esm/useAsync';
|
|
9
|
+
|
|
10
|
+
const Content = ({
|
|
11
|
+
visits,
|
|
12
|
+
numVisitsOpen,
|
|
13
|
+
numVisitsTotal,
|
|
14
|
+
loading,
|
|
15
|
+
kind
|
|
16
|
+
}) => {
|
|
17
|
+
const { setContext, setVisits, setLoading } = useContext();
|
|
18
|
+
useEffect(() => {
|
|
19
|
+
const context = {};
|
|
20
|
+
context.kind = kind;
|
|
21
|
+
if (visits) {
|
|
22
|
+
context.visits = visits;
|
|
23
|
+
context.loading = false;
|
|
24
|
+
} else if (loading) {
|
|
25
|
+
context.loading = loading;
|
|
26
|
+
}
|
|
27
|
+
if (numVisitsOpen)
|
|
28
|
+
context.numVisitsOpen = numVisitsOpen;
|
|
29
|
+
if (numVisitsTotal)
|
|
30
|
+
context.numVisitsTotal = numVisitsTotal;
|
|
31
|
+
setContext((state) => ({ ...state, ...context }));
|
|
32
|
+
}, [setContext, kind, visits, loading, numVisitsOpen, numVisitsTotal]);
|
|
33
|
+
const config = useApi(configApiRef);
|
|
34
|
+
const visitsApi = useApi(visitsApiRef);
|
|
35
|
+
const { loading: reqLoading } = useAsync(async () => {
|
|
36
|
+
var _a, _b;
|
|
37
|
+
if (!visits && !loading && kind === "recent") {
|
|
38
|
+
const filterBy = createFilterByQueryParamFromConfig(
|
|
39
|
+
(_a = config.getOptionalConfigArray("home.recentVisits.filterBy")) != null ? _a : []
|
|
40
|
+
);
|
|
41
|
+
return await visitsApi.list({
|
|
42
|
+
limit: numVisitsTotal != null ? numVisitsTotal : 8,
|
|
43
|
+
orderBy: [{ field: "timestamp", direction: "desc" }],
|
|
44
|
+
...filterBy && { filterBy }
|
|
45
|
+
}).then(setVisits);
|
|
46
|
+
}
|
|
47
|
+
if (!visits && !loading && kind === "top") {
|
|
48
|
+
const filterBy = createFilterByQueryParamFromConfig(
|
|
49
|
+
(_b = config.getOptionalConfigArray("home.topVisits.filterBy")) != null ? _b : []
|
|
50
|
+
);
|
|
51
|
+
return await visitsApi.list({
|
|
52
|
+
limit: numVisitsTotal != null ? numVisitsTotal : 8,
|
|
53
|
+
orderBy: [{ field: "hits", direction: "desc" }],
|
|
54
|
+
...filterBy && { filterBy }
|
|
55
|
+
}).then(setVisits);
|
|
56
|
+
}
|
|
57
|
+
return void 0;
|
|
58
|
+
}, [visitsApi, visits, loading, setVisits]);
|
|
59
|
+
useEffect(() => {
|
|
60
|
+
if (!loading) {
|
|
61
|
+
setLoading(reqLoading);
|
|
62
|
+
}
|
|
63
|
+
}, [loading, setLoading, reqLoading]);
|
|
64
|
+
return /* @__PURE__ */ React.createElement(VisitedByType, null);
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
export { Content };
|
|
68
|
+
//# sourceMappingURL=Content.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Content.esm.js","sources":["../../../src/homePageComponents/VisitedByType/Content.tsx"],"sourcesContent":["/*\n * Copyright 2023 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, { useEffect } from 'react';\nimport { createFilterByQueryParamFromConfig } from '../../api/config';\nimport { VisitedByType } from './VisitedByType';\nimport { Visit, visitsApiRef } from '../../api';\nimport { ContextValueOnly, useContext } from './Context';\nimport { configApiRef, useApi } from '@backstage/core-plugin-api';\nimport useAsync from 'react-use/esm/useAsync';\n\n/** @public */\nexport type VisitedByTypeKind = 'recent' | 'top';\n\n/** @public */\nexport type VisitedByTypeProps = {\n visits?: Array<Visit>;\n numVisitsOpen?: number;\n numVisitsTotal?: number;\n loading?: boolean;\n kind: VisitedByTypeKind;\n};\n\n/**\n * Display recently visited pages for the homepage\n * @public\n */\nexport const Content = ({\n visits,\n numVisitsOpen,\n numVisitsTotal,\n loading,\n kind,\n}: VisitedByTypeProps) => {\n const { setContext, setVisits, setLoading } = useContext();\n // Allows behavior override from properties\n useEffect(() => {\n const context: Partial<ContextValueOnly> = {};\n context.kind = kind;\n if (visits) {\n context.visits = visits;\n context.loading = false;\n } else if (loading) {\n context.loading = loading;\n }\n if (numVisitsOpen) context.numVisitsOpen = numVisitsOpen;\n if (numVisitsTotal) context.numVisitsTotal = numVisitsTotal;\n setContext(state => ({ ...state, ...context }));\n }, [setContext, kind, visits, loading, numVisitsOpen, numVisitsTotal]);\n\n const config = useApi(configApiRef);\n // Fetches data from visitsApi in case visits and loading are not provided\n const visitsApi = useApi(visitsApiRef);\n const { loading: reqLoading } = useAsync(async () => {\n if (!visits && !loading && kind === 'recent') {\n const filterBy = createFilterByQueryParamFromConfig(\n config.getOptionalConfigArray('home.recentVisits.filterBy') ?? [],\n );\n return await visitsApi\n .list({\n limit: numVisitsTotal ?? 8,\n orderBy: [{ field: 'timestamp', direction: 'desc' }],\n ...(filterBy && { filterBy }),\n })\n .then(setVisits);\n }\n if (!visits && !loading && kind === 'top') {\n const filterBy = createFilterByQueryParamFromConfig(\n config.getOptionalConfigArray('home.topVisits.filterBy') ?? [],\n );\n return await visitsApi\n .list({\n limit: numVisitsTotal ?? 8,\n orderBy: [{ field: 'hits', direction: 'desc' }],\n ...(filterBy && { filterBy }),\n })\n .then(setVisits);\n }\n return undefined;\n }, [visitsApi, visits, loading, setVisits]);\n useEffect(() => {\n if (!loading) {\n setLoading(reqLoading);\n }\n }, [loading, setLoading, reqLoading]);\n\n return <VisitedByType />;\n};\n"],"names":[],"mappings":";;;;;;;;;AAwCO,MAAM,UAAU,CAAC;AAAA,EACtB,MAAA;AAAA,EACA,aAAA;AAAA,EACA,cAAA;AAAA,EACA,OAAA;AAAA,EACA,IAAA;AACF,CAA0B,KAAA;AACxB,EAAA,MAAM,EAAE,UAAA,EAAY,SAAW,EAAA,UAAA,KAAe,UAAW,EAAA,CAAA;AAEzD,EAAA,SAAA,CAAU,MAAM;AACd,IAAA,MAAM,UAAqC,EAAC,CAAA;AAC5C,IAAA,OAAA,CAAQ,IAAO,GAAA,IAAA,CAAA;AACf,IAAA,IAAI,MAAQ,EAAA;AACV,MAAA,OAAA,CAAQ,MAAS,GAAA,MAAA,CAAA;AACjB,MAAA,OAAA,CAAQ,OAAU,GAAA,KAAA,CAAA;AAAA,eACT,OAAS,EAAA;AAClB,MAAA,OAAA,CAAQ,OAAU,GAAA,OAAA,CAAA;AAAA,KACpB;AACA,IAAI,IAAA,aAAA;AAAe,MAAA,OAAA,CAAQ,aAAgB,GAAA,aAAA,CAAA;AAC3C,IAAI,IAAA,cAAA;AAAgB,MAAA,OAAA,CAAQ,cAAiB,GAAA,cAAA,CAAA;AAC7C,IAAA,UAAA,CAAW,YAAU,EAAE,GAAG,KAAO,EAAA,GAAG,SAAU,CAAA,CAAA,CAAA;AAAA,GAChD,EAAG,CAAC,UAAY,EAAA,IAAA,EAAM,QAAQ,OAAS,EAAA,a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AA,CAAK,SAAS,CAAA,CAAA;AAAA,KACnB;AACA,IAAO,OAAA,KAAA,CAAA,CAAA;AAAA,KACN,CAAC,SAAA,EAAW,MAAQ,EAAA,OAAA,EAAS,SAAS,CAAC,CAAA,CAAA;AAC1C,EAAA,SAAA,CAAU,MAAM;AACd,IAAA,IAAI,CAAC,OAAS,EAAA;AACZ,MAAA,UAAA,CAAW,UAAU,CAAA,CAAA;AAAA,KACvB;AAAA,GACC,EAAA,CAAC,OAAS,EAAA,UAAA,EAAY,UAAU,CAAC,CAAA,CAAA;AAEpC,EAAA,2CAAQ,aAAc,EAAA,IAAA,CAAA,CAAA;AACxB;;;;"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import React, { createContext, useMemo } from 'react';
|
|
2
|
+
|
|
3
|
+
const defaultContextValueOnly = {
|
|
4
|
+
collapsed: true,
|
|
5
|
+
numVisitsOpen: 3,
|
|
6
|
+
numVisitsTotal: 8,
|
|
7
|
+
visits: [],
|
|
8
|
+
loading: true,
|
|
9
|
+
kind: "recent"
|
|
10
|
+
};
|
|
11
|
+
const defaultContextValue = {
|
|
12
|
+
...defaultContextValueOnly,
|
|
13
|
+
setCollapsed: () => {
|
|
14
|
+
},
|
|
15
|
+
setNumVisitsOpen: () => {
|
|
16
|
+
},
|
|
17
|
+
setNumVisitsTotal: () => {
|
|
18
|
+
},
|
|
19
|
+
setVisits: () => {
|
|
20
|
+
},
|
|
21
|
+
setLoading: () => {
|
|
22
|
+
},
|
|
23
|
+
setKind: () => {
|
|
24
|
+
},
|
|
25
|
+
setContext: () => {
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
const Context = createContext(defaultContextValue);
|
|
29
|
+
const getFilteredSet = (setContext, contextKey) => (e) => setContext((state) => ({
|
|
30
|
+
...state,
|
|
31
|
+
[contextKey]: typeof e === "function" ? e(state[contextKey]) : e
|
|
32
|
+
}));
|
|
33
|
+
const ContextProvider = ({ children }) => {
|
|
34
|
+
const [context, setContext] = React.useState(
|
|
35
|
+
defaultContextValueOnly
|
|
36
|
+
);
|
|
37
|
+
const {
|
|
38
|
+
setCollapsed,
|
|
39
|
+
setNumVisitsOpen,
|
|
40
|
+
setNumVisitsTotal,
|
|
41
|
+
setVisits,
|
|
42
|
+
setLoading,
|
|
43
|
+
setKind
|
|
44
|
+
} = useMemo(
|
|
45
|
+
() => ({
|
|
46
|
+
setCollapsed: getFilteredSet(setContext, "collapsed"),
|
|
47
|
+
setNumVisitsOpen: getFilteredSet(setContext, "numVisitsOpen"),
|
|
48
|
+
setNumVisitsTotal: getFilteredSet(setContext, "numVisitsTotal"),
|
|
49
|
+
setVisits: getFilteredSet(setContext, "visits"),
|
|
50
|
+
setLoading: getFilteredSet(setContext, "loading"),
|
|
51
|
+
setKind: getFilteredSet(setContext, "kind")
|
|
52
|
+
}),
|
|
53
|
+
[setContext]
|
|
54
|
+
);
|
|
55
|
+
const value = {
|
|
56
|
+
...context,
|
|
57
|
+
setContext,
|
|
58
|
+
setCollapsed,
|
|
59
|
+
setNumVisitsOpen,
|
|
60
|
+
setNumVisitsTotal,
|
|
61
|
+
setVisits,
|
|
62
|
+
setLoading,
|
|
63
|
+
setKind
|
|
64
|
+
};
|
|
65
|
+
return /* @__PURE__ */ React.createElement(Context.Provider, { value }, children);
|
|
66
|
+
};
|
|
67
|
+
const useContext = () => {
|
|
68
|
+
const value = React.useContext(Context);
|
|
69
|
+
if (value === void 0)
|
|
70
|
+
throw new Error(
|
|
71
|
+
"VisitedByType useContext found undefined ContextValue, <ContextProvider/> could be missing"
|
|
72
|
+
);
|
|
73
|
+
return value;
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
export { Context, ContextProvider, Context as default, defaultContextValue, useContext };
|
|
77
|
+
//# sourceMappingURL=Context.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Context.esm.js","sources":["../../../src/homePageComponents/VisitedByType/Context.tsx"],"sourcesContent":["/*\n * Copyright 2023 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, { Dispatch, SetStateAction, createContext, useMemo } from 'react';\nimport { Visit } from '../../api/VisitsApi';\nimport { VisitedByTypeKind } from './Content';\n\nexport type ContextValueOnly = {\n collapsed: boolean;\n numVisitsOpen: number;\n numVisitsTotal: number;\n visits: Array<Visit>;\n loading: boolean;\n kind: VisitedByTypeKind;\n};\n\nexport type ContextValue = ContextValueOnly & {\n setCollapsed: Dispatch<SetStateAction<boolean>>;\n setNumVisitsOpen: Dispatch<SetStateAction<number>>;\n setNumVisitsTotal: Dispatch<SetStateAction<number>>;\n setVisits: Dispatch<SetStateAction<Array<Visit>>>;\n setLoading: Dispatch<SetStateAction<boolean>>;\n setKind: Dispatch<SetStateAction<VisitedByTypeKind>>;\n setContext: Dispatch<SetStateAction<ContextValueOnly>>;\n};\n\nconst defaultContextValueOnly: ContextValueOnly = {\n collapsed: true,\n numVisitsOpen: 3,\n numVisitsTotal: 8,\n visits: [],\n loading: true,\n kind: 'recent',\n};\n\nexport const defaultContextValue: ContextValue = {\n ...defaultContextValueOnly,\n setCollapsed: () => {},\n setNumVisitsOpen: () => {},\n setNumVisitsTotal: () => {},\n setVisits: () => {},\n setLoading: () => {},\n setKind: () => {},\n setContext: () => {},\n};\n\nexport const Context = createContext<ContextValue>(defaultContextValue);\n\nconst getFilteredSet =\n <T,>(\n setContext: Dispatch<SetStateAction<ContextValueOnly>>,\n contextKey: keyof ContextValueOnly,\n ) =>\n (e: SetStateAction<T>) =>\n setContext(state => ({\n ...state,\n [contextKey]:\n typeof e === 'function' ? (e as Function)(state[contextKey]) : e,\n }));\n\nexport const ContextProvider = ({ children }: { children: JSX.Element }) => {\n const [context, setContext] = React.useState<ContextValueOnly>(\n defaultContextValueOnly,\n );\n const {\n setCollapsed,\n setNumVisitsOpen,\n setNumVisitsTotal,\n setVisits,\n setLoading,\n setKind,\n } = useMemo(\n () => ({\n setCollapsed: getFilteredSet(setContext, 'collapsed'),\n setNumVisitsOpen: getFilteredSet(setContext, 'numVisitsOpen'),\n setNumVisitsTotal: getFilteredSet(setContext, 'numVisitsTotal'),\n setVisits: getFilteredSet(setContext, 'visits'),\n setLoading: getFilteredSet(setContext, 'loading'),\n setKind: getFilteredSet(setContext, 'kind'),\n }),\n [setContext],\n );\n\n const value: ContextValue = {\n ...context,\n setContext,\n setCollapsed,\n setNumVisitsOpen,\n setNumVisitsTotal,\n setVisits,\n setLoading,\n setKind,\n };\n\n return <Context.Provider value={value}>{children}</Context.Provider>;\n};\n\nexport const useContext = () => {\n const value = React.useContext(Context);\n\n if (value === undefined)\n throw new Error(\n 'VisitedByType useContext found undefined ContextValue, <ContextProvider/> could be missing',\n );\n\n return value;\n};\n\nexport default Context;\n"],"names":[],"mappings":";;AAuCA,MAAM,uBAA4C,GAAA;AAAA,EAChD,SAAW,EAAA,IAAA;AAAA,EACX,aAAe,EAAA,CAAA;AAAA,EACf,cAAgB,EAAA,CAAA;AAAA,EAChB,QAAQ,EAAC;AAAA,EACT,OAAS,EAAA,IAAA;AAAA,EACT,IAAM,EAAA,QAAA;AACR,CAAA,CAAA;AAEO,MAAM,mBAAoC,GAAA;AAAA,EAC/C,GAAG,uBAAA;AAAA,EACH,cAAc,MAAM;AAAA,GAAC;AAAA,EACrB,kBAAkB,MAAM;AAAA,GAAC;AAAA,EACzB,mBAAmB,MAAM;AAAA,GAAC;AAAA,EAC1B,WAAW,MAAM;AAAA,GAAC;AAAA,EAClB,YAAY,MAAM;AAAA,GAAC;AAAA,EACnB,SAAS,MAAM;AAAA,GAAC;AAAA,EAChB,YAAY,MAAM;AAAA,GAAC;AACrB,EAA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AAAA,GACF,CAAA;AAEA,EAAA,uBAAQ,KAAA,CAAA,aAAA,CAAA,OAAA,CAAQ,QAAR,EAAA,EAAiB,SAAe,QAAS,CAAA,CAAA;AACnD,EAAA;AAEO,MAAM,aAAa,MAAM;AAC9B,EAAM,MAAA,KAAA,GAAQ,KAAM,CAAA,UAAA,CAAW,OAAO,CAAA,CAAA;AAEtC,EAAA,IAAI,KAAU,KAAA,KAAA,CAAA;AACZ,IAAA,MAAM,IAAI,KAAA;AAAA,MACR,4FAAA;AAAA,KACF,CAAA;AAEF,EAAO,OAAA,KAAA,CAAA;AACT;;;;"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { Actions } from './Actions.esm.js';
|
|
2
|
+
export { ContextProvider } from './Context.esm.js';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { Content } from './Content.esm.js';
|
|
5
|
+
|
|
6
|
+
const RecentlyVisitedContent = (props) => /* @__PURE__ */ React.createElement(Content, { ...props, kind: "recent" });
|
|
7
|
+
|
|
8
|
+
export { RecentlyVisitedContent as Content };
|
|
9
|
+
//# sourceMappingURL=RecentlyVisited.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RecentlyVisited.esm.js","sources":["../../../src/homePageComponents/VisitedByType/RecentlyVisited.tsx"],"sourcesContent":["/*\n * Copyright 2023 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\nexport { Actions } from './Actions';\nexport { ContextProvider } from './Context';\nexport type { VisitedByTypeProps, VisitedByTypeKind } from './Content';\nimport React from 'react';\nimport { Content, VisitedByTypeProps } from './Content';\n\nconst RecentlyVisitedContent = (props: Partial<VisitedByTypeProps>) => (\n <Content {...props} kind=\"recent\" />\n);\n\nexport { RecentlyVisitedContent as Content };\n"],"names":[],"mappings":";;;;;AAsBM,MAAA,sBAAA,GAAyB,CAAC,KAC9B,qBAAA,KAAA,CAAA,aAAA,CAAC,WAAS,GAAG,KAAA,EAAO,MAAK,QAAS,EAAA;;;;"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { Actions } from './Actions.esm.js';
|
|
2
|
+
export { ContextProvider } from './Context.esm.js';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { Content } from './Content.esm.js';
|
|
5
|
+
|
|
6
|
+
const TopVisitedContent = (props) => /* @__PURE__ */ React.createElement(Content, { ...props, kind: "top" });
|
|
7
|
+
|
|
8
|
+
export { TopVisitedContent as Content };
|
|
9
|
+
//# sourceMappingURL=TopVisited.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TopVisited.esm.js","sources":["../../../src/homePageComponents/VisitedByType/TopVisited.tsx"],"sourcesContent":["/*\n * Copyright 2023 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\nexport { Actions } from './Actions';\nexport { ContextProvider } from './Context';\nexport type { VisitedByTypeProps, VisitedByTypeKind } from './Content';\nimport React from 'react';\nimport { Content, VisitedByTypeProps } from './Content';\n\nconst TopVisitedContent = (props: Partial<VisitedByTypeProps>) => (\n <Content {...props} kind=\"top\" />\n);\n\nexport { TopVisitedContent as Content };\n"],"names":[],"mappings":";;;;;AAsBM,MAAA,iBAAA,GAAoB,CAAC,KACzB,qBAAA,KAAA,CAAA,aAAA,CAAC,WAAS,GAAG,KAAA,EAAO,MAAK,KAAM,EAAA;;;;"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { VisitList } from '../../components/VisitList/VisitList.esm.js';
|
|
3
|
+
import { useContext } from './Context.esm.js';
|
|
4
|
+
|
|
5
|
+
const VisitedByType = () => {
|
|
6
|
+
const { collapsed, numVisitsOpen, numVisitsTotal, visits, loading, kind } = useContext();
|
|
7
|
+
return /* @__PURE__ */ React.createElement(
|
|
8
|
+
VisitList,
|
|
9
|
+
{
|
|
10
|
+
visits,
|
|
11
|
+
detailType: kind === "top" ? "hits" : "time-ago",
|
|
12
|
+
collapsed,
|
|
13
|
+
numVisitsOpen,
|
|
14
|
+
numVisitsTotal,
|
|
15
|
+
loading
|
|
16
|
+
}
|
|
17
|
+
);
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export { VisitedByType };
|
|
21
|
+
//# sourceMappingURL=VisitedByType.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"VisitedByType.esm.js","sources":["../../../src/homePageComponents/VisitedByType/VisitedByType.tsx"],"sourcesContent":["/*\n * Copyright 2023 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 { VisitList } from '../../components/VisitList';\nimport { useContext } from './Context';\n\nexport const VisitedByType = () => {\n const { collapsed, numVisitsOpen, numVisitsTotal, visits, loading, kind } =\n useContext();\n\n return (\n <VisitList\n visits={visits}\n detailType={kind === 'top' ? 'hits' : 'time-ago'}\n collapsed={collapsed}\n numVisitsOpen={numVisitsOpen}\n numVisitsTotal={numVisitsTotal}\n loading={loading}\n />\n );\n};\n"],"names":[],"mappings":";;;;AAoBO,MAAM,gBAAgB,MAAM;AACjC,EAAM,MAAA,EAAE,WAAW,aAAe,EAAA,cAAA,EAAgB,QAAQ,OAAS,EAAA,IAAA,KACjE,UAAW,EAAA,CAAA;AAEb,EACE,uBAAA,KAAA,CAAA,aAAA;AAAA,IAAC,SAAA;AAAA,IAAA;AAAA,MACC,MAAA;AAAA,MACA,UAAA,EAAY,IAAS,KAAA,KAAA,GAAQ,MAAS,GAAA,UAAA;AAAA,MACtC,SAAA;AAAA,MACA,aAAA;AAAA,MACA,cAAA;AAAA,MACA,OAAA;AAAA,KAAA;AAAA,GACF,CAAA;AAEJ;;;;"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { useApi, identityApiRef, alertApiRef } from '@backstage/core-plugin-api';
|
|
2
|
+
import Tooltip from '@material-ui/core/Tooltip';
|
|
3
|
+
import Typography from '@material-ui/core/Typography';
|
|
4
|
+
import React, { useMemo, useEffect } from 'react';
|
|
5
|
+
import useAsync from 'react-use/esm/useAsync';
|
|
6
|
+
import { getTimeBasedGreeting } from './timeUtil.esm.js';
|
|
7
|
+
|
|
8
|
+
const WelcomeTitle = ({ language }) => {
|
|
9
|
+
const identityApi = useApi(identityApiRef);
|
|
10
|
+
const alertApi = useApi(alertApiRef);
|
|
11
|
+
const greeting = useMemo(() => getTimeBasedGreeting(language), [language]);
|
|
12
|
+
const { value: profile, error } = useAsync(
|
|
13
|
+
() => identityApi.getProfileInfo()
|
|
14
|
+
);
|
|
15
|
+
useEffect(() => {
|
|
16
|
+
if (error) {
|
|
17
|
+
alertApi.post({
|
|
18
|
+
message: `Failed to load user identity: ${error}`,
|
|
19
|
+
severity: "error"
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
}, [error, alertApi]);
|
|
23
|
+
return /* @__PURE__ */ React.createElement(Tooltip, { title: greeting.language }, /* @__PURE__ */ React.createElement(Typography, { component: "span", variant: "inherit" }, `${greeting.greeting}${(profile == null ? void 0 : profile.displayName) ? `, ${profile == null ? void 0 : profile.displayName}` : ""}!`));
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export { WelcomeTitle };
|
|
27
|
+
//# sourceMappingURL=WelcomeTitle.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WelcomeTitle.esm.js","sources":["../../../src/homePageComponents/WelcomeTitle/WelcomeTitle.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 {\n alertApiRef,\n identityApiRef,\n useApi,\n} from '@backstage/core-plugin-api';\nimport Tooltip from '@material-ui/core/Tooltip';\nimport Typography from '@material-ui/core/Typography';\nimport React, { useEffect, useMemo } from 'react';\nimport useAsync from 'react-use/esm/useAsync';\nimport { getTimeBasedGreeting } from './timeUtil';\n\n/** @public */\nexport type WelcomeTitleLanguageProps = {\n language?: string[];\n};\n\nexport const WelcomeTitle = ({ language }: WelcomeTitleLanguageProps) => {\n const identityApi = useApi(identityApiRef);\n const alertApi = useApi(alertApiRef);\n const greeting = useMemo(() => getTimeBasedGreeting(language), [language]);\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 <Typography component=\"span\" variant=\"inherit\">{`${greeting.greeting}${\n profile?.displayName ? `, ${profile?.displayName}` : ''\n }!`}</Typography>\n </Tooltip>\n );\n};\n"],"names":[],"mappings":";;;;;;;AA+BO,MAAM,YAAe,GAAA,CAAC,EAAE,QAAA,EAA0C,KAAA;AACvE,EAAM,MAAA,WAAA,GAAc,OAAO,cAAc,CAAA,CAAA;AACzC,EAAM,MAAA,QAAA,GAAW,OAAO,WAAW,CAAA,CAAA;AACnC,EAAM,MAAA,QAAA,GAAW,QAAQ,MAAM,oBAAA,CAAqB,QAAQ,CAAG,EAAA,CAAC,QAAQ,CAAC,CAAA,CAAA;AAEzE,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,OAAA,EAAS,iCAAiC,KAAK,CAAA,CAAA;AAAA,QAC/C,QAAU,EAAA,OAAA;AAAA,OACX,CAAA,CAAA;AAAA,KACH;AAAA,GACC,EAAA,CAAC,KAAO,EAAA,QAAQ,CAAC,CAAA,CAAA;AAEpB,EACE,uBAAA,KAAA,CAAA,aAAA,CAAC,WAAQ,KAAO,EAAA,QAAA,CAAS,4BACtB,KAAA,CAAA,aAAA,CAAA,UAAA,EAAA,EAAW,SAAU,EAAA,MAAA,EAAO,OAAQ,EAAA,SAAA,EAAA,EAAW,GAAG,QAAS,CAAA,QAAQ,CAClE,EAAA,CAAA,OAAA,IAAA,IAAA,GAAA,KAAA,CAAA,GAAA,OAAA,CAAS,WAAc,IAAA,CAAA,EAAA,EAAK,mCAAS,WAAW,CAAA,CAAA,GAAK,EACvD,CAAA,CAAA,CAAI,CACN,CAAA,CAAA;AAEJ;;;;"}
|