@drodil/backstage-plugin-qeta-react 3.48.1 → 3.49.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/dist/components/AIAnswerCard/AIAnswerCard.esm.js +4 -7
- package/dist/components/AIAnswerCard/AIAnswerCard.esm.js.map +1 -1
- package/dist/components/AnswerForm/AnswerForm.esm.js +12 -6
- package/dist/components/AnswerForm/AnswerForm.esm.js.map +1 -1
- package/dist/components/AnswersContainer/AnswerList.esm.js +2 -2
- package/dist/components/AnswersContainer/AnswerList.esm.js.map +1 -1
- package/dist/components/AnswersContainer/AnswerListItem.esm.js +162 -98
- package/dist/components/AnswersContainer/AnswerListItem.esm.js.map +1 -1
- package/dist/components/ArticleContent/ArticleContent.esm.js +1 -2
- package/dist/components/ArticleContent/ArticleContent.esm.js.map +1 -1
- package/dist/components/AuthorBox/AuthorBox.esm.js +3 -3
- package/dist/components/AuthorBox/AuthorBox.esm.js.map +1 -1
- package/dist/components/Buttons/AddToCollectionButton.esm.js +3 -11
- package/dist/components/Buttons/AddToCollectionButton.esm.js.map +1 -1
- package/dist/components/Buttons/AskQuestionButton.esm.js +5 -8
- package/dist/components/Buttons/AskQuestionButton.esm.js.map +1 -1
- package/dist/components/Buttons/ButtonContainer.esm.js +2 -4
- package/dist/components/Buttons/ButtonContainer.esm.js.map +1 -1
- package/dist/components/Buttons/ContentHeaderButton.esm.js +27 -0
- package/dist/components/Buttons/ContentHeaderButton.esm.js.map +1 -0
- package/dist/components/Buttons/CreateCollectionButton.esm.js +3 -5
- package/dist/components/Buttons/CreateCollectionButton.esm.js.map +1 -1
- package/dist/components/Buttons/CreateLinkButton.esm.js +5 -8
- package/dist/components/Buttons/CreateLinkButton.esm.js.map +1 -1
- package/dist/components/Buttons/OpenLinkButton.esm.js +3 -1
- package/dist/components/Buttons/OpenLinkButton.esm.js.map +1 -1
- package/dist/components/Buttons/WriteArticleButton.esm.js +5 -8
- package/dist/components/Buttons/WriteArticleButton.esm.js.map +1 -1
- package/dist/components/CollectionsGrid/CollectionsGrid.esm.js +1 -0
- package/dist/components/CollectionsGrid/CollectionsGrid.esm.js.map +1 -1
- package/dist/components/CollectionsGrid/CollectionsGridContent.esm.js +3 -13
- package/dist/components/CollectionsGrid/CollectionsGridContent.esm.js.map +1 -1
- package/dist/components/CollectionsGrid/CollectionsGridItem.esm.js +155 -51
- package/dist/components/CollectionsGrid/CollectionsGridItem.esm.js.map +1 -1
- package/dist/components/CommentSection/CommentForm.esm.js +49 -20
- package/dist/components/CommentSection/CommentForm.esm.js.map +1 -1
- package/dist/components/CommentSection/CommentListItem.esm.js +38 -32
- package/dist/components/CommentSection/CommentListItem.esm.js.map +1 -1
- package/dist/components/CommentSection/CommentSection.esm.js +3 -2
- package/dist/components/CommentSection/CommentSection.esm.js.map +1 -1
- package/dist/components/ContentHeader/ContentHeader.esm.js +83 -0
- package/dist/components/ContentHeader/ContentHeader.esm.js.map +1 -0
- package/dist/components/ContentHeaderCard/ContentHeaderCard.esm.js +151 -0
- package/dist/components/ContentHeaderCard/ContentHeaderCard.esm.js.map +1 -0
- package/dist/components/EntitiesGrid/EntitiesGrid.esm.js +63 -23
- package/dist/components/EntitiesGrid/EntitiesGrid.esm.js.map +1 -1
- package/dist/components/EntitiesGrid/EntitiesGridContent.esm.js +1 -1
- package/dist/components/EntitiesGrid/EntitiesGridContent.esm.js.map +1 -1
- package/dist/components/EntitiesGrid/EntitiesGridItem.esm.js +109 -55
- package/dist/components/EntitiesGrid/EntitiesGridItem.esm.js.map +1 -1
- package/dist/components/FilterPanel/DateRangeFilter.esm.js +5 -5
- package/dist/components/FilterPanel/DateRangeFilter.esm.js.map +1 -1
- package/dist/components/FilterPanel/FilterPanel.esm.js +171 -96
- package/dist/components/FilterPanel/FilterPanel.esm.js.map +1 -1
- package/dist/components/FollowedLists/FollowedCollectionsList.esm.js +61 -4
- package/dist/components/FollowedLists/FollowedCollectionsList.esm.js.map +1 -1
- package/dist/components/FollowedLists/FollowedEntitiesList.esm.js +64 -6
- package/dist/components/FollowedLists/FollowedEntitiesList.esm.js.map +1 -1
- package/dist/components/FollowedLists/FollowedTagsList.esm.js +61 -5
- package/dist/components/FollowedLists/FollowedTagsList.esm.js.map +1 -1
- package/dist/components/FollowedLists/FollowedUsersList.esm.js +69 -10
- package/dist/components/FollowedLists/FollowedUsersList.esm.js.map +1 -1
- package/dist/components/GridItemStyles/useGridItemStyles.esm.js +16 -6
- package/dist/components/GridItemStyles/useGridItemStyles.esm.js.map +1 -1
- package/dist/components/HeaderImageInput/HeaderImageInput.esm.js +1 -1
- package/dist/components/HeaderImageInput/HeaderImageInput.esm.js.map +1 -1
- package/dist/components/HomePageCards/ImpactCard.esm.js +96 -31
- package/dist/components/HomePageCards/ImpactCard.esm.js.map +1 -1
- package/dist/components/LeftMenu/LeftMenu.esm.js +237 -121
- package/dist/components/LeftMenu/LeftMenu.esm.js.map +1 -1
- package/dist/components/MarkdownEditor/MarkdownEditor.esm.js +7 -1
- package/dist/components/MarkdownEditor/MarkdownEditor.esm.js.map +1 -1
- package/dist/components/MarkdownRenderer/MarkdownRenderer.esm.js +2 -2
- package/dist/components/MarkdownRenderer/MarkdownRenderer.esm.js.map +1 -1
- package/dist/components/PostForm/EntitiesInput.esm.js +6 -1
- package/dist/components/PostForm/EntitiesInput.esm.js.map +1 -1
- package/dist/components/PostForm/PostForm.esm.js +24 -10
- package/dist/components/PostForm/PostForm.esm.js.map +1 -1
- package/dist/components/PostForm/TagInput.esm.js +4 -3
- package/dist/components/PostForm/TagInput.esm.js.map +1 -1
- package/dist/components/PostHighlightList/PostHighlightList.esm.js +45 -28
- package/dist/components/PostHighlightList/PostHighlightList.esm.js.map +1 -1
- package/dist/components/PostsContainer/PostList.esm.js +1 -1
- package/dist/components/PostsContainer/PostList.esm.js.map +1 -1
- package/dist/components/PostsContainer/PostListItem.esm.js +130 -133
- package/dist/components/PostsContainer/PostListItem.esm.js.map +1 -1
- package/dist/components/PostsContainer/PostsContainer.esm.js +1 -1
- package/dist/components/PostsGrid/PostsGrid.esm.js +2 -2
- package/dist/components/PostsGrid/PostsGrid.esm.js.map +1 -1
- package/dist/components/PostsGrid/PostsGridContent.esm.js +1 -2
- package/dist/components/PostsGrid/PostsGridContent.esm.js.map +1 -1
- package/dist/components/PostsGrid/PostsGridItem.esm.js +117 -51
- package/dist/components/PostsGrid/PostsGridItem.esm.js.map +1 -1
- package/dist/components/QetaContext/QetaContext.esm.js +26 -0
- package/dist/components/QetaContext/QetaContext.esm.js.map +1 -0
- package/dist/components/StatsChart/StatsChart.esm.js +143 -103
- package/dist/components/StatsChart/StatsChart.esm.js.map +1 -1
- package/dist/components/SuggestionsCard/SuggestionsCard.esm.js +51 -10
- package/dist/components/SuggestionsCard/SuggestionsCard.esm.js.map +1 -1
- package/dist/components/TagsAndEntities/TagChip.esm.js +3 -0
- package/dist/components/TagsAndEntities/TagChip.esm.js.map +1 -1
- package/dist/components/TagsAndEntities/UserChip.esm.js +7 -41
- package/dist/components/TagsAndEntities/UserChip.esm.js.map +1 -1
- package/dist/components/TagsGrid/TagGridItem.esm.js +213 -108
- package/dist/components/TagsGrid/TagGridItem.esm.js.map +1 -1
- package/dist/components/TagsGrid/TagsGrid.esm.js +93 -53
- package/dist/components/TagsGrid/TagsGrid.esm.js.map +1 -1
- package/dist/components/TagsGrid/TagsGridContent.esm.js +1 -1
- package/dist/components/TagsGrid/TagsGridContent.esm.js.map +1 -1
- package/dist/components/TemplateList/TemplateList.esm.js +1 -1
- package/dist/components/TemplateList/TemplateList.esm.js.map +1 -1
- package/dist/components/TopRankingUsersCard/TopRankingUsersCard.esm.js +21 -6
- package/dist/components/TopRankingUsersCard/TopRankingUsersCard.esm.js.map +1 -1
- package/dist/components/UsersGrid/UsersGrid.esm.js +53 -15
- package/dist/components/UsersGrid/UsersGrid.esm.js.map +1 -1
- package/dist/components/UsersGrid/UsersGridContent.esm.js +1 -1
- package/dist/components/UsersGrid/UsersGridContent.esm.js.map +1 -1
- package/dist/components/UsersGrid/UsersGridItem.esm.js +148 -82
- package/dist/components/UsersGrid/UsersGridItem.esm.js.map +1 -1
- package/dist/components/Utility/QetaGridHeader.esm.js +1 -0
- package/dist/components/Utility/QetaGridHeader.esm.js.map +1 -1
- package/dist/components/Utility/VoteButtonContainer.esm.js +10 -5
- package/dist/components/Utility/VoteButtonContainer.esm.js.map +1 -1
- package/dist/index.d.ts +150 -32
- package/dist/index.esm.js +5 -4
- package/dist/index.esm.js.map +1 -1
- package/dist/translation.esm.js +65 -11
- package/dist/translation.esm.js.map +1 -1
- package/package.json +2 -2
- package/dist/components/CollectionCard/CollectionCard.esm.js +0 -81
- package/dist/components/CollectionCard/CollectionCard.esm.js.map +0 -1
- package/dist/components/ExtensionContext/ExtensionContext.esm.js +0 -23
- package/dist/components/ExtensionContext/ExtensionContext.esm.js.map +0 -1
- package/dist/components/SummaryStatsGrid/SummaryStatsGrid.esm.js +0 -154
- package/dist/components/SummaryStatsGrid/SummaryStatsGrid.esm.js.map +0 -1
- package/dist/components/TagsAndEntities/CollectionChip.esm.js +0 -92
- package/dist/components/TagsAndEntities/CollectionChip.esm.js.map +0 -1
- package/dist/components/Utility/SmallAvatar.esm.js +0 -18
- package/dist/components/Utility/SmallAvatar.esm.js.map +0 -1
|
@@ -9,23 +9,52 @@ import 'dataloader';
|
|
|
9
9
|
import '@backstage/plugin-catalog-react';
|
|
10
10
|
import { useTranslationRef } from '@backstage/core-plugin-api/alpha';
|
|
11
11
|
import { qetaTranslationRef } from '../../translation.esm.js';
|
|
12
|
-
import '
|
|
12
|
+
import { useIdentityApi } from '../../hooks/useIdentityApi.esm.js';
|
|
13
13
|
import '@backstage/plugin-permission-react';
|
|
14
14
|
import '@drodil/backstage-plugin-qeta-common';
|
|
15
15
|
import '@backstage/plugin-permission-common';
|
|
16
|
-
import { Box, Card, CardContent,
|
|
17
|
-
import { Alert } from '@material-ui/lab';
|
|
16
|
+
import { Box, Card, CardContent, Divider, Grid, Typography, Tooltip } from '@material-ui/core';
|
|
17
|
+
import { Skeleton, Alert } from '@material-ui/lab';
|
|
18
|
+
import ThumbUp from '@material-ui/icons/ThumbUp';
|
|
19
|
+
import HelpOutline from '@material-ui/icons/HelpOutline';
|
|
20
|
+
import QuestionAnswerIcon from '@material-ui/icons/QuestionAnswer';
|
|
21
|
+
import PeopleIcon from '@material-ui/icons/People';
|
|
18
22
|
|
|
19
23
|
const ImpactCard = () => {
|
|
20
24
|
const { t } = useTranslationRef(qetaTranslationRef);
|
|
25
|
+
const { value: user, loading: userLoading } = useIdentityApi(
|
|
26
|
+
(api) => api.getBackstageIdentity(),
|
|
27
|
+
[]
|
|
28
|
+
);
|
|
21
29
|
const {
|
|
22
30
|
value: response,
|
|
23
|
-
loading,
|
|
31
|
+
loading: statsLoading,
|
|
24
32
|
error
|
|
25
|
-
} = useQetaApi(
|
|
33
|
+
} = useQetaApi(
|
|
34
|
+
async (api) => {
|
|
35
|
+
if (!user) {
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
const [impact, stats] = await Promise.all([
|
|
39
|
+
api.getUserImpact(),
|
|
40
|
+
api.getUserStats(user.userEntityRef)
|
|
41
|
+
]);
|
|
42
|
+
return { impact, stats };
|
|
43
|
+
},
|
|
44
|
+
[user]
|
|
45
|
+
);
|
|
46
|
+
const loading = userLoading || statsLoading;
|
|
26
47
|
const renderContent = () => {
|
|
27
48
|
if (loading) {
|
|
28
|
-
return /* @__PURE__ */
|
|
49
|
+
return /* @__PURE__ */ jsxs(Box, { p: 2, children: [
|
|
50
|
+
/* @__PURE__ */ jsx(Skeleton, { variant: "text", width: "60%", height: 32 }),
|
|
51
|
+
/* @__PURE__ */ jsx(Skeleton, { variant: "text", width: "40%", height: 48 }),
|
|
52
|
+
/* @__PURE__ */ jsx(Box, { mt: 2, children: /* @__PURE__ */ jsx(Divider, {}) }),
|
|
53
|
+
/* @__PURE__ */ jsx(Box, { mt: 2, children: /* @__PURE__ */ jsx(Grid, { container: true, spacing: 2, children: Array.from(new Array(4)).map((_, i) => /* @__PURE__ */ jsxs(Grid, { item: true, xs: 6, children: [
|
|
54
|
+
/* @__PURE__ */ jsx(Skeleton, { variant: "circle", width: 24, height: 24 }),
|
|
55
|
+
/* @__PURE__ */ jsx(Skeleton, { variant: "text", width: "80%" })
|
|
56
|
+
] }, i)) }) })
|
|
57
|
+
] });
|
|
29
58
|
}
|
|
30
59
|
if (error) {
|
|
31
60
|
return /* @__PURE__ */ jsx(Alert, { severity: "error", children: t("impactCard.error") });
|
|
@@ -33,33 +62,69 @@ const ImpactCard = () => {
|
|
|
33
62
|
if (!response) {
|
|
34
63
|
return null;
|
|
35
64
|
}
|
|
36
|
-
const
|
|
65
|
+
const { impact, stats } = response;
|
|
66
|
+
const formatNumber = (num) => {
|
|
67
|
+
return num >= 1e3 ? numeral(num).format("0.0 a") : num;
|
|
68
|
+
};
|
|
69
|
+
const formattedImpact = formatNumber(impact.impact);
|
|
70
|
+
const statItems = [
|
|
71
|
+
{
|
|
72
|
+
icon: /* @__PURE__ */ jsx(ThumbUp, { fontSize: "small" }),
|
|
73
|
+
value: formatNumber(stats.summary.totalVotes),
|
|
74
|
+
label: t("impactCard.votes")
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
icon: /* @__PURE__ */ jsx(HelpOutline, { fontSize: "small" }),
|
|
78
|
+
value: formatNumber(stats.summary.totalQuestions),
|
|
79
|
+
label: t("impactCard.questions")
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
icon: /* @__PURE__ */ jsx(QuestionAnswerIcon, { fontSize: "small" }),
|
|
83
|
+
value: formatNumber(stats.summary.totalAnswers),
|
|
84
|
+
label: t("impactCard.answers")
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
icon: /* @__PURE__ */ jsx(PeopleIcon, { fontSize: "small" }),
|
|
88
|
+
value: formatNumber(stats.summary.totalFollowers),
|
|
89
|
+
label: t("impactCard.followers")
|
|
90
|
+
}
|
|
91
|
+
];
|
|
37
92
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
38
93
|
/* @__PURE__ */ jsx(Typography, { variant: "h5", component: "h2", gutterBottom: true, children: t("impactCard.title") }),
|
|
39
|
-
/* @__PURE__ */
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
94
|
+
/* @__PURE__ */ jsxs(Box, { display: "flex", alignItems: "center", mb: 1, children: [
|
|
95
|
+
/* @__PURE__ */ jsx(
|
|
96
|
+
Typography,
|
|
97
|
+
{
|
|
98
|
+
variant: "h3",
|
|
99
|
+
component: "p",
|
|
100
|
+
"aria-label": `${formattedImpact} views`,
|
|
101
|
+
style: { fontWeight: "bold", marginBottom: 0 },
|
|
102
|
+
children: formattedImpact
|
|
103
|
+
}
|
|
104
|
+
),
|
|
105
|
+
/* @__PURE__ */ jsx(
|
|
106
|
+
Typography,
|
|
107
|
+
{
|
|
108
|
+
variant: "body2",
|
|
109
|
+
component: "span",
|
|
110
|
+
style: { marginLeft: "0.5em", verticalAlign: "middle" },
|
|
111
|
+
color: "textSecondary",
|
|
112
|
+
children: t("impactCard.views")
|
|
113
|
+
}
|
|
114
|
+
)
|
|
115
|
+
] }),
|
|
116
|
+
/* @__PURE__ */ jsx(Typography, { variant: "body2", color: "textSecondary", paragraph: true, children: t("impactCard.contributions", {
|
|
117
|
+
lastWeek: impact.lastWeekImpact.toString(10)
|
|
118
|
+
}) }),
|
|
119
|
+
/* @__PURE__ */ jsx(Divider, {}),
|
|
120
|
+
/* @__PURE__ */ jsx(Box, { mt: 2, children: /* @__PURE__ */ jsx(Grid, { container: true, spacing: 1, children: statItems.map((item, index) => /* @__PURE__ */ jsx(Grid, { item: true, xs: 6, children: /* @__PURE__ */ jsxs(Box, { display: "flex", alignItems: "center", color: "textSecondary", children: [
|
|
121
|
+
/* @__PURE__ */ jsx(Tooltip, { title: item.label, children: /* @__PURE__ */ jsx(Box, { display: "flex", alignItems: "center", children: item.icon }) }),
|
|
122
|
+
/* @__PURE__ */ jsx(Box, { ml: 1, children: /* @__PURE__ */ jsxs(Typography, { variant: "subtitle2", component: "span", children: [
|
|
123
|
+
item.value,
|
|
124
|
+
" ",
|
|
125
|
+
item.label.toLowerCase()
|
|
126
|
+
] }) })
|
|
127
|
+
] }) }, index)) }) })
|
|
63
128
|
] });
|
|
64
129
|
};
|
|
65
130
|
return /* @__PURE__ */ jsx(
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ImpactCard.esm.js","sources":["../../../src/components/HomePageCards/ImpactCard.tsx"],"sourcesContent":["import numeral from 'numeral';\nimport { useQetaApi } from '../../hooks';\nimport {\n Box,\n Card,\n CardContent,\n Typography,\n CircularProgress,\n} from '@material-ui/core';\nimport { useTranslationRef } from '@backstage/core-plugin-api/alpha';\nimport { qetaTranslationRef } from '../../translation.ts';\nimport { Alert } from '@material-ui/lab';\n\ninterface ImpactResponse {\n impact: number;\n lastWeekImpact: number;\n}\n\nexport const ImpactCard = () => {\n const { t } = useTranslationRef(qetaTranslationRef);\n const {\n value: response,\n loading,\n error,\n } = useQetaApi<ImpactResponse>(api => api.getUserImpact(), []);\n\n const renderContent = () => {\n if (loading) {\n return (\n <Box display=\"flex\" justifyContent=\"center\" p={2}>\n <CircularProgress size={24} />\n </Box>\n );\n }\n\n if (error) {\n return <Alert severity=\"error\">{t('impactCard.error')}</Alert>;\n }\n\n if (!response) {\n return null;\n }\n\n const formattedImpact =\n response.impact >= 1000\n ? numeral(response.impact).format('0.0 a')\n : response.impact;\n\n return (\n <>\n <Typography variant=\"h5\" component=\"h2\" gutterBottom>\n {t('impactCard.title')}\n </Typography>\n <Box display=\"flex\" alignItems=\"center\" mb={1}>\n <Typography\n variant=\"h5\"\n component=\"p\"\n aria-label={`${formattedImpact} views`}\n >\n {formattedImpact}\n <Typography\n variant=\"caption\"\n component=\"span\"\n style={{ marginLeft: '1em' }}\n color=\"textSecondary\"\n >\n {t('impactCard.views')}\n </Typography>\n </Typography>\n </Box>\n <Typography variant=\"body2\" color=\"textSecondary\">\n {t('impactCard.contributions', {\n lastWeek: response.lastWeekImpact.toString(10),\n })}\n </Typography>\n </>\n );\n };\n\n return (\n <Box\n display={{ md: 'none', lg: 'block' }}\n style={{ marginBottom: '1em' }}\n role=\"region\"\n aria-label={t('impactCard.title')}\n >\n <Card elevation={2}>\n <CardContent>{renderContent()}</CardContent>\n </Card>\n </Box>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAkBO,MAAM,aAAa,MAAM;AAC9B,EAAA,MAAM,EAAE,CAAA,EAAM,GAAA,iBAAA,CAAkB,kBAAkB,CAAA;AAClD,EAAM,MAAA;AAAA,IACJ,KAAO,EAAA,QAAA;AAAA,IACP,OAAA;AAAA,IACA;AAAA,MACE,UAA2B,CAAA,CAAA,GAAA,KAAO,IAAI,aAAc,EAAA,EAAG,EAAE,CAAA;AAE7D,EAAA,MAAM,gBAAgB,MAAM;AAC1B,IAAA,IAAI,OAAS,EAAA;AACX,MAAA,uBACG,GAAA,CAAA,GAAA,EAAA,EAAI,OAAQ,EAAA,MAAA,EAAO,cAAe,EAAA,QAAA,EAAS,CAAG,EAAA,CAAA,EAC7C,QAAC,kBAAA,GAAA,CAAA,gBAAA,EAAA,EAAiB,IAAM,EAAA,EAAA,EAAI,CAC9B,EAAA,CAAA;AAAA;AAIJ,IAAA,IAAI,KAAO,EAAA;AACT,MAAA,2BAAQ,KAAM,EAAA,EAAA,QAAA,EAAS,OAAS,EAAA,QAAA,EAAA,CAAA,CAAE,kBAAkB,CAAE,EAAA,CAAA;AAAA;AAGxD,IAAA,IAAI,CAAC,QAAU,EAAA;AAC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AA;AAAA,IAAA;AAAA,MACC,OAAS,EAAA,EAAE,EAAI,EAAA,MAAA,EAAQ,IAAI,OAAQ,EAAA;AAAA,MACnC,KAAA,EAAO,EAAE,YAAA,EAAc,KAAM,EAAA;AAAA,MAC7B,IAAK,EAAA,QAAA;AAAA,MACL,YAAA,EAAY,EAAE,kBAAkB,CAAA;AAAA,MAEhC,QAAA,kBAAA,GAAA,CAAC,QAAK,SAAW,EAAA,CAAA,EACf,8BAAC,WAAa,EAAA,EAAA,QAAA,EAAA,aAAA,IAAgB,CAChC,EAAA;AAAA;AAAA,GACF;AAEJ;;;;"}
|
|
1
|
+
{"version":3,"file":"ImpactCard.esm.js","sources":["../../../src/components/HomePageCards/ImpactCard.tsx"],"sourcesContent":["import numeral from 'numeral';\nimport { useIdentityApi, useQetaApi } from '../../hooks';\nimport {\n Box,\n Card,\n CardContent,\n Typography,\n Grid,\n Divider,\n Tooltip,\n} from '@material-ui/core';\nimport { Skeleton } from '@material-ui/lab';\nimport { useTranslationRef } from '@backstage/core-plugin-api/alpha';\nimport { qetaTranslationRef } from '../../translation.ts';\nimport { Alert } from '@material-ui/lab';\nimport {\n ImpactResponse,\n StatisticsResponse,\n UserStat,\n} from '@drodil/backstage-plugin-qeta-common';\nimport ThumbUp from '@material-ui/icons/ThumbUp';\nimport HelpOutline from '@material-ui/icons/HelpOutline';\nimport QuestionAnswer from '@material-ui/icons/QuestionAnswer';\nimport People from '@material-ui/icons/People';\n\nexport const ImpactCard = () => {\n const { t } = useTranslationRef(qetaTranslationRef);\n const { value: user, loading: userLoading } = useIdentityApi(\n api => api.getBackstageIdentity(),\n [],\n );\n\n const {\n value: response,\n loading: statsLoading,\n error,\n } = useQetaApi<{\n impact: ImpactResponse;\n stats: StatisticsResponse<UserStat>;\n } | null>(\n async api => {\n if (!user) {\n return null;\n }\n const [impact, stats] = await Promise.all([\n api.getUserImpact(),\n api.getUserStats(user.userEntityRef),\n ]);\n return { impact, stats };\n },\n [user],\n );\n\n const loading = userLoading || statsLoading;\n\n const renderContent = () => {\n if (loading) {\n return (\n <Box p={2}>\n <Skeleton variant=\"text\" width=\"60%\" height={32} />\n <Skeleton variant=\"text\" width=\"40%\" height={48} />\n <Box mt={2}>\n <Divider />\n </Box>\n <Box mt={2}>\n <Grid container spacing={2}>\n {Array.from(new Array(4)).map((_, i) => (\n <Grid item xs={6} key={i}>\n <Skeleton variant=\"circle\" width={24} height={24} />\n <Skeleton variant=\"text\" width=\"80%\" />\n </Grid>\n ))}\n </Grid>\n </Box>\n </Box>\n );\n }\n\n if (error) {\n return <Alert severity=\"error\">{t('impactCard.error')}</Alert>;\n }\n\n if (!response) {\n return null;\n }\n\n const { impact, stats } = response;\n\n const formatNumber = (num: number) => {\n return num >= 1000 ? numeral(num).format('0.0 a') : num;\n };\n\n const formattedImpact = formatNumber(impact.impact);\n\n const statItems = [\n {\n icon: <ThumbUp fontSize=\"small\" />,\n value: formatNumber(stats.summary.totalVotes),\n label: t('impactCard.votes'),\n },\n {\n icon: <HelpOutline fontSize=\"small\" />,\n value: formatNumber(stats.summary.totalQuestions),\n label: t('impactCard.questions'),\n },\n {\n icon: <QuestionAnswer fontSize=\"small\" />,\n value: formatNumber(stats.summary.totalAnswers),\n label: t('impactCard.answers'),\n },\n {\n icon: <People fontSize=\"small\" />,\n value: formatNumber(stats.summary.totalFollowers),\n label: t('impactCard.followers'),\n },\n ];\n\n return (\n <>\n <Typography variant=\"h5\" component=\"h2\" gutterBottom>\n {t('impactCard.title')}\n </Typography>\n <Box display=\"flex\" alignItems=\"center\" mb={1}>\n <Typography\n variant=\"h3\"\n component=\"p\"\n aria-label={`${formattedImpact} views`}\n style={{ fontWeight: 'bold', marginBottom: 0 }}\n >\n {formattedImpact}\n </Typography>\n <Typography\n variant=\"body2\"\n component=\"span\"\n style={{ marginLeft: '0.5em', verticalAlign: 'middle' }}\n color=\"textSecondary\"\n >\n {t('impactCard.views')}\n </Typography>\n </Box>\n <Typography variant=\"body2\" color=\"textSecondary\" paragraph>\n {t('impactCard.contributions', {\n lastWeek: impact.lastWeekImpact.toString(10),\n })}\n </Typography>\n\n <Divider />\n\n <Box mt={2}>\n <Grid container spacing={1}>\n {statItems.map((item, index) => (\n <Grid item xs={6} key={index}>\n <Box display=\"flex\" alignItems=\"center\" color=\"textSecondary\">\n <Tooltip title={item.label}>\n <Box display=\"flex\" alignItems=\"center\">\n {item.icon}\n </Box>\n </Tooltip>\n <Box ml={1}>\n <Typography variant=\"subtitle2\" component=\"span\">\n {item.value} {item.label.toLowerCase()}\n </Typography>\n </Box>\n </Box>\n </Grid>\n ))}\n </Grid>\n </Box>\n </>\n );\n };\n\n return (\n <Box\n display={{ md: 'none', lg: 'block' }}\n style={{ marginBottom: '1em' }}\n role=\"region\"\n aria-label={t('impactCard.title')}\n >\n <Card elevation={2}>\n <CardContent>{renderContent()}</CardContent>\n </Card>\n </Box>\n );\n};\n"],"names":["QuestionAnswer","People"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAyBO,MAAM,aAAa,MAAM;AAC9B,EAAA,MAAM,EAAE,CAAA,EAAM,GAAA,iBAAA,CAAkB,kBAAkB,CAAA;AAClD,EAAA,MAAM,EAAE,KAAA,EAAO,IAAM,EAAA,OAAA,EAAS,aAAgB,GAAA,cAAA;AAAA,IAC5C,CAAA,GAAA,KAAO,IAAI,oBAAqB,EAAA;AAAA,IAChC;AAAC,GACH;AAEA,EAAM,MAAA;AAAA,IACJ,KAAO,EAAA,QAAA;AAAA,IACP,OAAS,EAAA,YAAA;AAAA,IACT;AAAA,GACE,GAAA,UAAA;AAAA,IAIF,OAAM,GAAO,KAAA;AACX,MAAA,IAAI,CAAC,IAAM,EAAA;AACT,QAAO,OAAA,IAAA;AAAA;AAET,MAAA,MAAM,CAAC,MAAQ,EAAA,KAAK,CAAI,GAAA,MAAM,QAAQ,GAAI,CAAA;AAAA,QACxC,IAAI,aAAc,EAAA;AAAA,QAClB,GAAA,CAAI,YAAa,CAAA,IAAA,CAAK,aAAa;AAAA,O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AA,EAAQ,IAAI,OAAQ,EAAA;AAAA,MACnC,KAAA,EAAO,EAAE,YAAA,EAAc,KAAM,EAAA;AAAA,MAC7B,IAAK,EAAA,QAAA;AAAA,MACL,YAAA,EAAY,EAAE,kBAAkB,CAAA;AAAA,MAEhC,QAAA,kBAAA,GAAA,CAAC,QAAK,SAAW,EAAA,CAAA,EACf,8BAAC,WAAa,EAAA,EAAA,QAAA,EAAA,aAAA,IAAgB,CAChC,EAAA;AAAA;AAAA,GACF;AAEJ;;;;"}
|
|
@@ -1,20 +1,23 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { makeStyles,
|
|
3
|
-
import AccountBox from '@material-ui/icons/AccountBox';
|
|
4
|
-
import LoyaltyOutlined from '@material-ui/icons/LoyaltyOutlined';
|
|
5
|
-
import StarIcon from '@material-ui/icons/Star';
|
|
1
|
+
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
2
|
+
import { makeStyles, List, Box, Tooltip, IconButton, ListItemIcon, Typography, Divider, MenuItem } from '@material-ui/core';
|
|
6
3
|
import { useRouteRef, useApp } from '@backstage/core-plugin-api';
|
|
7
|
-
import HelpOutlinedIcon from '@material-ui/icons/HelpOutlined';
|
|
8
4
|
import { useNavigate } from 'react-router-dom';
|
|
9
|
-
import Home from '@material-ui/icons/Home';
|
|
10
5
|
import { useLocation } from 'react-use';
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
import
|
|
6
|
+
import HomeOutlined from '@material-ui/icons/HomeOutlined';
|
|
7
|
+
import HelpOutline from '@material-ui/icons/HelpOutline';
|
|
8
|
+
import LibraryBooksOutlined from '@material-ui/icons/LibraryBooksOutlined';
|
|
9
|
+
import LinkIcon from '@material-ui/icons/Link';
|
|
10
|
+
import StarBorder from '@material-ui/icons/StarBorder';
|
|
11
|
+
import CategoryOutlined from '@material-ui/icons/CategoryOutlined';
|
|
12
|
+
import LocalOfferOutlined from '@material-ui/icons/LocalOfferOutlined';
|
|
13
|
+
import PlaylistPlayOutlined from '@material-ui/icons/PlaylistPlayOutlined';
|
|
14
|
+
import PeopleOutline from '@material-ui/icons/PeopleOutline';
|
|
15
|
+
import PersonOutline from '@material-ui/icons/PersonOutline';
|
|
16
|
+
import EmojiEventsOutlined from '@material-ui/icons/EmojiEventsOutlined';
|
|
17
|
+
import SettingsOutlined from '@material-ui/icons/SettingsOutlined';
|
|
18
|
+
import MenuOpenIcon from '@material-ui/icons/MenuOpen';
|
|
19
|
+
import ChevronRightIcon from '@material-ui/icons/ChevronRight';
|
|
15
20
|
import { qetaRouteRef, tagsRouteRef, favoriteQuestionsRouteRef, statisticsRouteRef, userRouteRef, questionsRouteRef, articlesRouteRef, linksRouteRef, collectionsRouteRef, entitiesRouteRef, usersRouteRef, moderatorRouteRef } from '../../routes.esm.js';
|
|
16
|
-
import '../TopRankingUsersCard/TopRankingUsersCard.esm.js';
|
|
17
|
-
import { TrophyIcon } from '../TopRankingUsersCard/TrophyIcon.esm.js';
|
|
18
21
|
import '../../api.esm.js';
|
|
19
22
|
import 'react';
|
|
20
23
|
import '@backstage/catalog-model';
|
|
@@ -24,70 +27,115 @@ import { useTranslationRef } from '@backstage/core-plugin-api/alpha';
|
|
|
24
27
|
import { qetaTranslationRef } from '../../translation.esm.js';
|
|
25
28
|
import { useIdentityApi } from '../../hooks/useIdentityApi.esm.js';
|
|
26
29
|
import { useIsModerator } from '../../hooks/useIsModerator.esm.js';
|
|
27
|
-
import LinkIcon from '@material-ui/icons/Link';
|
|
28
30
|
|
|
29
31
|
const useStyles = makeStyles(
|
|
30
32
|
(theme) => {
|
|
31
33
|
return {
|
|
32
34
|
leftMenu: {
|
|
33
35
|
top: "0",
|
|
34
|
-
width: "
|
|
35
|
-
|
|
36
|
+
width: "220px",
|
|
37
|
+
// Standard width
|
|
38
|
+
paddingTop: 0,
|
|
36
39
|
paddingBottom: theme.spacing(2),
|
|
37
|
-
transition: "
|
|
40
|
+
transition: "width 0.2s ease-in-out",
|
|
41
|
+
display: "flex",
|
|
42
|
+
flexDirection: "column",
|
|
43
|
+
height: "100%"
|
|
44
|
+
},
|
|
45
|
+
leftMenuCompact: {
|
|
46
|
+
width: "72px",
|
|
47
|
+
overflowX: "hidden",
|
|
48
|
+
"& $sectionHeader": {
|
|
49
|
+
display: "none"
|
|
50
|
+
},
|
|
51
|
+
"& $divider": {
|
|
52
|
+
display: "none"
|
|
53
|
+
}
|
|
38
54
|
},
|
|
39
55
|
inPopup: {
|
|
40
56
|
marginRight: 0,
|
|
41
|
-
padding: theme.spacing(1)
|
|
57
|
+
padding: theme.spacing(1),
|
|
58
|
+
width: "auto"
|
|
42
59
|
},
|
|
43
60
|
outsidePopup: {
|
|
44
|
-
marginRight: theme.spacing(3),
|
|
45
|
-
float: "right",
|
|
46
61
|
position: "sticky",
|
|
47
|
-
top: theme.spacing(2)
|
|
62
|
+
top: theme.spacing(2),
|
|
63
|
+
float: "right",
|
|
64
|
+
maxHeight: "calc(100vh - 100px)",
|
|
65
|
+
overflowY: "auto"
|
|
48
66
|
},
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
padding: theme.spacing(0.75, 1.5),
|
|
67
|
+
menuItem: {
|
|
68
|
+
margin: (props) => props.compact ? 0 : theme.spacing(0, 2),
|
|
69
|
+
justifyContent: (props) => props.compact ? "center" : "flex-start",
|
|
70
|
+
padding: (props) => props.compact ? theme.spacing(1, 0) : theme.spacing(1, 1),
|
|
71
|
+
borderRadius: (props) => props.compact ? 0 : theme.shape.borderRadius,
|
|
55
72
|
transition: "all 0.2s ease-in-out",
|
|
73
|
+
color: theme.palette.text.primary,
|
|
74
|
+
display: "flex",
|
|
75
|
+
alignItems: "center",
|
|
76
|
+
minHeight: 48,
|
|
56
77
|
"&:hover": {
|
|
57
|
-
backgroundColor: theme.palette.
|
|
58
|
-
color: theme.palette.primary.contrastText,
|
|
59
|
-
transform: "translateX(4px)"
|
|
60
|
-
},
|
|
61
|
-
"& svg": {
|
|
62
|
-
color: theme.palette.primary.contrastText
|
|
78
|
+
backgroundColor: theme.palette.action.hover
|
|
63
79
|
}
|
|
64
80
|
},
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
81
|
+
selectedMenuItem: {
|
|
82
|
+
color: theme.palette.primary.main,
|
|
83
|
+
backgroundColor: "transparent",
|
|
84
|
+
fontWeight: 600,
|
|
85
|
+
position: "relative",
|
|
86
|
+
"&::before": {
|
|
87
|
+
content: '""',
|
|
88
|
+
position: "absolute",
|
|
89
|
+
left: 0,
|
|
90
|
+
top: "50%",
|
|
91
|
+
transform: "translateY(-50%)",
|
|
92
|
+
height: "60%",
|
|
93
|
+
width: "4px",
|
|
94
|
+
backgroundColor: theme.palette.primary.main,
|
|
95
|
+
borderRadius: "0 4px 4px 0"
|
|
96
|
+
},
|
|
71
97
|
"&:hover": {
|
|
72
|
-
backgroundColor: theme.palette.action.hover
|
|
73
|
-
|
|
98
|
+
backgroundColor: theme.palette.action.hover
|
|
99
|
+
},
|
|
100
|
+
"& svg": {
|
|
101
|
+
color: theme.palette.primary.main
|
|
74
102
|
}
|
|
75
103
|
},
|
|
76
104
|
menuIcon: {
|
|
77
105
|
minWidth: "32px",
|
|
78
|
-
color: "inherit"
|
|
106
|
+
color: "inherit",
|
|
107
|
+
display: "flex",
|
|
108
|
+
justifyContent: "center"
|
|
79
109
|
},
|
|
80
110
|
sectionHeader: {
|
|
81
|
-
padding: theme.spacing(
|
|
111
|
+
padding: theme.spacing(0.5, 3, 0.5, 3),
|
|
82
112
|
marginTop: theme.spacing(2),
|
|
83
113
|
color: theme.palette.text.secondary,
|
|
84
114
|
fontWeight: 600,
|
|
85
115
|
textTransform: "uppercase",
|
|
86
|
-
|
|
116
|
+
fontSize: "0.75rem",
|
|
117
|
+
letterSpacing: "0.5px",
|
|
118
|
+
whiteSpace: "nowrap"
|
|
87
119
|
},
|
|
88
120
|
divider: {
|
|
89
|
-
margin: theme.spacing(1, 2),
|
|
121
|
+
margin: theme.spacing(1, 2.5),
|
|
90
122
|
backgroundColor: theme.palette.divider
|
|
123
|
+
},
|
|
124
|
+
toggleButton: {
|
|
125
|
+
marginLeft: "auto",
|
|
126
|
+
marginRight: theme.spacing(1),
|
|
127
|
+
marginBottom: theme.spacing(1)
|
|
128
|
+
},
|
|
129
|
+
label: {
|
|
130
|
+
marginLeft: theme.spacing(1.5),
|
|
131
|
+
whiteSpace: "nowrap",
|
|
132
|
+
opacity: 1,
|
|
133
|
+
transition: "opacity 0.2s"
|
|
134
|
+
},
|
|
135
|
+
labelHidden: {
|
|
136
|
+
opacity: 0,
|
|
137
|
+
width: 0,
|
|
138
|
+
display: "none"
|
|
91
139
|
}
|
|
92
140
|
};
|
|
93
141
|
},
|
|
@@ -106,23 +154,27 @@ const LeftMenu = (props) => {
|
|
|
106
154
|
const entitiesRoute = useRouteRef(entitiesRouteRef);
|
|
107
155
|
const usersRoute = useRouteRef(usersRouteRef);
|
|
108
156
|
const moderatorRoute = useRouteRef(moderatorRouteRef);
|
|
109
|
-
const styles = useStyles();
|
|
157
|
+
const styles = useStyles(props);
|
|
110
158
|
const { t } = useTranslationRef(qetaTranslationRef);
|
|
111
159
|
const location = useLocation();
|
|
112
160
|
const navigate = useNavigate();
|
|
113
161
|
const { isModerator } = useIsModerator();
|
|
114
162
|
const app = useApp();
|
|
163
|
+
const { compact = false, onToggle } = props;
|
|
115
164
|
const {
|
|
116
165
|
value: user,
|
|
117
166
|
loading: loadingUser,
|
|
118
167
|
error: userError
|
|
119
168
|
} = useIdentityApi((api) => api.getBackstageIdentity(), []);
|
|
169
|
+
const EntityIcon = app.getSystemIcon("kind:system") ?? CategoryOutlined;
|
|
120
170
|
const CustomMenuItem = ({
|
|
121
171
|
route,
|
|
122
172
|
hasSubRoutes,
|
|
123
|
-
children
|
|
173
|
+
children,
|
|
174
|
+
label
|
|
124
175
|
}) => {
|
|
125
|
-
|
|
176
|
+
const isSelected = route === location.pathname || hasSubRoutes && location.pathname?.startsWith(route);
|
|
177
|
+
return /* @__PURE__ */ jsx(Tooltip, { title: compact ? label : "", placement: "right", children: /* @__PURE__ */ jsxs(
|
|
126
178
|
MenuItem,
|
|
127
179
|
{
|
|
128
180
|
onClick: (e) => {
|
|
@@ -135,85 +187,149 @@ const LeftMenu = (props) => {
|
|
|
135
187
|
props.onClick(e);
|
|
136
188
|
}
|
|
137
189
|
},
|
|
138
|
-
className:
|
|
190
|
+
className: `${styles.menuItem} ${isSelected ? styles.selectedMenuItem : ""}`,
|
|
139
191
|
href: route,
|
|
140
192
|
component: "a",
|
|
141
|
-
children
|
|
193
|
+
children: [
|
|
194
|
+
children,
|
|
195
|
+
/* @__PURE__ */ jsx(
|
|
196
|
+
Typography,
|
|
197
|
+
{
|
|
198
|
+
variant: "body2",
|
|
199
|
+
className: compact ? styles.labelHidden : styles.label,
|
|
200
|
+
style: { fontWeight: isSelected ? 600 : 400 },
|
|
201
|
+
children: label
|
|
202
|
+
}
|
|
203
|
+
)
|
|
204
|
+
]
|
|
142
205
|
}
|
|
143
|
-
);
|
|
206
|
+
) });
|
|
144
207
|
};
|
|
145
|
-
const
|
|
146
|
-
|
|
147
|
-
|
|
208
|
+
const isPopup = props.inPopup;
|
|
209
|
+
const isCompact = compact && !isPopup;
|
|
210
|
+
return /* @__PURE__ */ jsxs(
|
|
211
|
+
List,
|
|
148
212
|
{
|
|
149
213
|
id: "left-menu",
|
|
150
|
-
className: `${styles.leftMenu} ${
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
{
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
/* @__PURE__ */
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
214
|
+
className: `${styles.leftMenu} ${isPopup ? styles.inPopup : `${styles.outsidePopup} ${isCompact ? styles.leftMenuCompact : ""}`}`,
|
|
215
|
+
component: "nav",
|
|
216
|
+
"aria-labelledby": "nested-list-subheader",
|
|
217
|
+
disablePadding: true,
|
|
218
|
+
children: [
|
|
219
|
+
!isPopup && /* @__PURE__ */ jsx(Box, { display: "flex", justifyContent: isCompact ? "center" : "flex-end", children: /* @__PURE__ */ jsx(
|
|
220
|
+
Tooltip,
|
|
221
|
+
{
|
|
222
|
+
title: isCompact ? t("leftMenu.expand") : t("leftMenu.collapse"),
|
|
223
|
+
placement: "right",
|
|
224
|
+
children: /* @__PURE__ */ jsx(
|
|
225
|
+
IconButton,
|
|
226
|
+
{
|
|
227
|
+
onClick: onToggle,
|
|
228
|
+
size: "small",
|
|
229
|
+
className: isCompact ? "" : styles.toggleButton,
|
|
230
|
+
style: { marginBottom: 0 },
|
|
231
|
+
children: isCompact ? /* @__PURE__ */ jsx(ChevronRightIcon, {}) : /* @__PURE__ */ jsx(MenuOpenIcon, {})
|
|
232
|
+
}
|
|
233
|
+
)
|
|
234
|
+
}
|
|
235
|
+
) }),
|
|
236
|
+
/* @__PURE__ */ jsx(CustomMenuItem, { route: rootRoute(), label: t("leftMenu.home"), children: /* @__PURE__ */ jsx(ListItemIcon, { className: styles.menuIcon, children: /* @__PURE__ */ jsx(HomeOutlined, { fontSize: "small" }) }) }),
|
|
237
|
+
/* @__PURE__ */ jsx("li", { style: { listStyle: "none" }, children: /* @__PURE__ */ jsx(Typography, { className: styles.sectionHeader, children: t("leftMenu.content") }) }),
|
|
238
|
+
/* @__PURE__ */ jsx(Divider, { className: styles.divider, component: "li" }),
|
|
239
|
+
/* @__PURE__ */ jsx(
|
|
240
|
+
CustomMenuItem,
|
|
241
|
+
{
|
|
242
|
+
route: questionsRoute(),
|
|
243
|
+
hasSubRoutes: true,
|
|
244
|
+
label: t("leftMenu.questions"),
|
|
245
|
+
children: /* @__PURE__ */ jsx(ListItemIcon, { className: styles.menuIcon, children: /* @__PURE__ */ jsx(HelpOutline, { fontSize: "small" }) })
|
|
246
|
+
}
|
|
247
|
+
),
|
|
248
|
+
/* @__PURE__ */ jsx(
|
|
249
|
+
CustomMenuItem,
|
|
250
|
+
{
|
|
251
|
+
route: articlesRoute(),
|
|
252
|
+
hasSubRoutes: true,
|
|
253
|
+
label: t("leftMenu.articles"),
|
|
254
|
+
children: /* @__PURE__ */ jsx(ListItemIcon, { className: styles.menuIcon, children: /* @__PURE__ */ jsx(LibraryBooksOutlined, { fontSize: "small" }) })
|
|
255
|
+
}
|
|
256
|
+
),
|
|
257
|
+
/* @__PURE__ */ jsx(
|
|
258
|
+
CustomMenuItem,
|
|
259
|
+
{
|
|
260
|
+
route: linksRoute(),
|
|
261
|
+
hasSubRoutes: true,
|
|
262
|
+
label: t("leftMenu.links"),
|
|
263
|
+
children: /* @__PURE__ */ jsx(ListItemIcon, { className: styles.menuIcon, children: /* @__PURE__ */ jsx(LinkIcon, { fontSize: "small" }) })
|
|
264
|
+
}
|
|
265
|
+
),
|
|
266
|
+
/* @__PURE__ */ jsx(
|
|
267
|
+
CustomMenuItem,
|
|
268
|
+
{
|
|
269
|
+
route: favoritesRoute(),
|
|
270
|
+
label: t("leftMenu.favoriteQuestions"),
|
|
271
|
+
children: /* @__PURE__ */ jsx(ListItemIcon, { className: styles.menuIcon, children: /* @__PURE__ */ jsx(StarBorder, { fontSize: "small" }) })
|
|
272
|
+
}
|
|
273
|
+
),
|
|
274
|
+
/* @__PURE__ */ jsx(
|
|
275
|
+
CustomMenuItem,
|
|
276
|
+
{
|
|
277
|
+
route: entitiesRoute(),
|
|
278
|
+
hasSubRoutes: true,
|
|
279
|
+
label: t("leftMenu.entities"),
|
|
280
|
+
children: /* @__PURE__ */ jsx(ListItemIcon, { className: styles.menuIcon, children: /* @__PURE__ */ jsx(EntityIcon, { fontSize: "small" }) })
|
|
281
|
+
}
|
|
282
|
+
),
|
|
283
|
+
/* @__PURE__ */ jsx(
|
|
284
|
+
CustomMenuItem,
|
|
285
|
+
{
|
|
286
|
+
route: tagsRoute(),
|
|
287
|
+
hasSubRoutes: true,
|
|
288
|
+
label: t("leftMenu.tags"),
|
|
289
|
+
children: /* @__PURE__ */ jsx(ListItemIcon, { className: styles.menuIcon, children: /* @__PURE__ */ jsx(LocalOfferOutlined, { fontSize: "small" }) })
|
|
290
|
+
}
|
|
291
|
+
),
|
|
292
|
+
/* @__PURE__ */ jsx("li", { style: { listStyle: "none" }, children: /* @__PURE__ */ jsx(Typography, { className: styles.sectionHeader, children: t("leftMenu.community") }) }),
|
|
293
|
+
/* @__PURE__ */ jsx(Divider, { className: styles.divider, component: "li" }),
|
|
294
|
+
/* @__PURE__ */ jsx(
|
|
295
|
+
CustomMenuItem,
|
|
296
|
+
{
|
|
297
|
+
route: collectionsRoute(),
|
|
298
|
+
hasSubRoutes: true,
|
|
299
|
+
label: t("leftMenu.collections"),
|
|
300
|
+
children: /* @__PURE__ */ jsx(ListItemIcon, { className: styles.menuIcon, children: /* @__PURE__ */ jsx(PlaylistPlayOutlined, { fontSize: "small" }) })
|
|
301
|
+
}
|
|
302
|
+
),
|
|
303
|
+
/* @__PURE__ */ jsx(CustomMenuItem, { route: usersRoute(), label: t("leftMenu.users"), children: /* @__PURE__ */ jsx(ListItemIcon, { className: styles.menuIcon, children: /* @__PURE__ */ jsx(PeopleOutline, { fontSize: "small" }) }) }),
|
|
304
|
+
user && !loadingUser && !userError && /* @__PURE__ */ jsx(
|
|
305
|
+
CustomMenuItem,
|
|
306
|
+
{
|
|
307
|
+
route: `${userRoute()}/${user.userEntityRef}`,
|
|
308
|
+
label: t("leftMenu.profile"),
|
|
309
|
+
children: /* @__PURE__ */ jsx(ListItemIcon, { className: styles.menuIcon, children: /* @__PURE__ */ jsx(PersonOutline, { fontSize: "small" }) })
|
|
310
|
+
}
|
|
311
|
+
),
|
|
312
|
+
/* @__PURE__ */ jsx(
|
|
313
|
+
CustomMenuItem,
|
|
314
|
+
{
|
|
315
|
+
route: statisticsRoute(),
|
|
316
|
+
label: t("leftMenu.statistics"),
|
|
317
|
+
children: /* @__PURE__ */ jsx(ListItemIcon, { className: styles.menuIcon, children: /* @__PURE__ */ jsx(EmojiEventsOutlined, { fontSize: "small" }) })
|
|
318
|
+
}
|
|
319
|
+
),
|
|
320
|
+
isModerator && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
321
|
+
/* @__PURE__ */ jsx("li", { style: { listStyle: "none" }, children: /* @__PURE__ */ jsx(Typography, { className: styles.sectionHeader, children: t("leftMenu.manage") }) }),
|
|
322
|
+
/* @__PURE__ */ jsx(Divider, { className: styles.divider, component: "li" }),
|
|
323
|
+
/* @__PURE__ */ jsx(
|
|
324
|
+
CustomMenuItem,
|
|
325
|
+
{
|
|
326
|
+
route: moderatorRoute(),
|
|
327
|
+
label: t("leftMenu.moderate"),
|
|
328
|
+
children: /* @__PURE__ */ jsx(ListItemIcon, { className: styles.menuIcon, children: /* @__PURE__ */ jsx(SettingsOutlined, { fontSize: "small" }) })
|
|
329
|
+
}
|
|
330
|
+
)
|
|
331
|
+
] })
|
|
332
|
+
]
|
|
217
333
|
}
|
|
218
334
|
);
|
|
219
335
|
};
|