@drodil/backstage-plugin-qeta 2.5.2 → 2.6.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/AnswersContainer/AnswerList.esm.js +5 -4
- package/dist/components/AnswersContainer/AnswerList.esm.js.map +1 -1
- package/dist/components/AnswersContainer/AnswerListItem.esm.js +8 -7
- package/dist/components/AnswersContainer/AnswerListItem.esm.js.map +1 -1
- package/dist/components/AnswersContainer/AnswersContainer.esm.js +12 -15
- package/dist/components/AnswersContainer/AnswersContainer.esm.js.map +1 -1
- package/dist/components/AskAnonymouslyCheckbox/AskAnonymouslyCheckbox.esm.js +3 -1
- package/dist/components/AskAnonymouslyCheckbox/AskAnonymouslyCheckbox.esm.js.map +1 -1
- package/dist/components/AskForm/AskForm.esm.js +13 -6
- package/dist/components/AskForm/AskForm.esm.js.map +1 -1
- package/dist/components/AskForm/EntitiesInput.esm.js +7 -3
- package/dist/components/AskForm/EntitiesInput.esm.js.map +1 -1
- package/dist/components/AskForm/TagInput.esm.js +7 -3
- package/dist/components/AskForm/TagInput.esm.js.map +1 -1
- package/dist/components/AskPage/AskPage.esm.js +7 -3
- package/dist/components/AskPage/AskPage.esm.js.map +1 -1
- package/dist/components/Buttons/AskQuestionButton.esm.js +3 -1
- package/dist/components/Buttons/AskQuestionButton.esm.js.map +1 -1
- package/dist/components/Buttons/BackToQuestionsButton.esm.js +3 -2
- package/dist/components/Buttons/BackToQuestionsButton.esm.js.map +1 -1
- package/dist/components/CommentSection/CommentList.esm.js +3 -2
- package/dist/components/CommentSection/CommentList.esm.js.map +1 -1
- package/dist/components/CommentSection/CommentSection.esm.js +5 -3
- package/dist/components/CommentSection/CommentSection.esm.js.map +1 -1
- package/dist/components/DeleteModal/DeleteModal.esm.js +6 -5
- package/dist/components/DeleteModal/DeleteModal.esm.js.map +1 -1
- package/dist/components/FavoritePage/FavoritePage.esm.js +3 -1
- package/dist/components/FavoritePage/FavoritePage.esm.js.map +1 -1
- package/dist/components/HomePage/HomePage.esm.js +19 -13
- package/dist/components/HomePage/HomePage.esm.js.map +1 -1
- package/dist/components/Links/Links.esm.js +3 -1
- package/dist/components/Links/Links.esm.js.map +1 -1
- package/dist/components/QuestionHighlightList/QuestionHighlightList.esm.js +3 -2
- package/dist/components/QuestionHighlightList/QuestionHighlightList.esm.js.map +1 -1
- package/dist/components/QuestionPage/AnswerCard.esm.js +4 -3
- package/dist/components/QuestionPage/AnswerCard.esm.js.map +1 -1
- package/dist/components/QuestionPage/AnswerForm.esm.js +6 -4
- package/dist/components/QuestionPage/AnswerForm.esm.js.map +1 -1
- package/dist/components/QuestionPage/AuthorBox.esm.js +3 -2
- package/dist/components/QuestionPage/AuthorBox.esm.js.map +1 -1
- package/dist/components/QuestionPage/FavoriteButton.esm.js +4 -2
- package/dist/components/QuestionPage/FavoriteButton.esm.js.map +1 -1
- package/dist/components/QuestionPage/LinkButton.esm.js +9 -13
- package/dist/components/QuestionPage/LinkButton.esm.js.map +1 -1
- package/dist/components/QuestionPage/QuestionCard.esm.js +4 -3
- package/dist/components/QuestionPage/QuestionCard.esm.js.map +1 -1
- package/dist/components/QuestionPage/QuestionPage.esm.js +19 -16
- package/dist/components/QuestionPage/QuestionPage.esm.js.map +1 -1
- package/dist/components/QuestionPage/VoteButtons.esm.js +7 -5
- package/dist/components/QuestionPage/VoteButtons.esm.js.map +1 -1
- package/dist/components/QuestionTableCard/QuestionsTable.esm.js +8 -7
- package/dist/components/QuestionTableCard/QuestionsTable.esm.js.map +1 -1
- package/dist/components/QuestionsContainer/DateRangeFilter.esm.js +12 -11
- package/dist/components/QuestionsContainer/DateRangeFilter.esm.js.map +1 -1
- package/dist/components/QuestionsContainer/FilterPanel.esm.js +22 -19
- package/dist/components/QuestionsContainer/FilterPanel.esm.js.map +1 -1
- package/dist/components/QuestionsContainer/NoQuestionsCard.esm.js +4 -3
- package/dist/components/QuestionsContainer/NoQuestionsCard.esm.js.map +1 -1
- package/dist/components/QuestionsContainer/QuestionList.esm.js +4 -3
- package/dist/components/QuestionsContainer/QuestionList.esm.js.map +1 -1
- package/dist/components/QuestionsContainer/QuestionListItem.esm.js +12 -9
- package/dist/components/QuestionsContainer/QuestionListItem.esm.js.map +1 -1
- package/dist/components/QuestionsContainer/QuestionsContainer.esm.js +13 -9
- package/dist/components/QuestionsContainer/QuestionsContainer.esm.js.map +1 -1
- package/dist/components/Statistics/TopRankingUsersCard.esm.js +15 -14
- package/dist/components/Statistics/TopRankingUsersCard.esm.js.map +1 -1
- package/dist/components/TagPage/TagPage.esm.js +10 -1
- package/dist/components/TagPage/TagPage.esm.js.map +1 -1
- package/dist/components/TagPage/TagsContainer.esm.js +7 -13
- package/dist/components/TagPage/TagsContainer.esm.js.map +1 -1
- package/dist/components/UserPage/UserPage.esm.js +18 -3
- package/dist/components/UserPage/UserPage.esm.js.map +1 -1
- package/dist/index.d.ts +180 -1
- package/dist/index.esm.js +1 -0
- package/dist/index.esm.js.map +1 -1
- package/dist/locale/fi.esm.js +185 -0
- package/dist/locale/fi.esm.js.map +1 -0
- package/dist/translation.esm.js +323 -0
- package/dist/translation.esm.js.map +1 -0
- package/dist/utils/hooks.esm.js +6 -1
- package/dist/utils/hooks.esm.js.map +1 -1
- package/package.json +16 -16
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Box, List, ListSubheader, ListItem, ListItemText, Divider } from '@material-ui/core';
|
|
2
2
|
import React from 'react';
|
|
3
|
-
import { useQetaApi, useStyles } from '../../utils/hooks.esm.js';
|
|
3
|
+
import { useQetaApi, useStyles, useTranslation } from '../../utils/hooks.esm.js';
|
|
4
4
|
import { Skeleton } from '@material-ui/lab';
|
|
5
5
|
import { useRouteRef } from '@backstage/core-plugin-api';
|
|
6
6
|
import { questionRouteRef } from '@drodil/backstage-plugin-qeta-react';
|
|
@@ -12,6 +12,7 @@ const QuestionHighlightList = (props) => {
|
|
|
12
12
|
error
|
|
13
13
|
} = useQetaApi((api) => api.getQuestionsList(props.type), []);
|
|
14
14
|
const classes = useStyles();
|
|
15
|
+
const { t } = useTranslation();
|
|
15
16
|
const questionRoute = useRouteRef(questionRouteRef);
|
|
16
17
|
const questions = response?.questions ?? [];
|
|
17
18
|
return /* @__PURE__ */ React.createElement(
|
|
@@ -39,7 +40,7 @@ const QuestionHighlightList = (props) => {
|
|
|
39
40
|
)
|
|
40
41
|
},
|
|
41
42
|
loading && /* @__PURE__ */ React.createElement(ListItem, null, /* @__PURE__ */ React.createElement(Skeleton, { variant: "rect" })),
|
|
42
|
-
error && /* @__PURE__ */ React.createElement(ListItem, null, /* @__PURE__ */ React.createElement(ListItemText, null, "
|
|
43
|
+
error && /* @__PURE__ */ React.createElement(ListItem, null, /* @__PURE__ */ React.createElement(ListItemText, null, t("homePage.highlights.loadError"))),
|
|
43
44
|
!error && questions.length === 0 && /* @__PURE__ */ React.createElement(ListItem, null, /* @__PURE__ */ React.createElement(ListItemText, null, props.noQuestionsLabel)),
|
|
44
45
|
!error && questions.map((q) => /* @__PURE__ */ React.createElement(React.Fragment, { key: q.id }, /* @__PURE__ */ React.createElement(Divider, null), /* @__PURE__ */ React.createElement(
|
|
45
46
|
ListItem,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QuestionHighlightList.esm.js","sources":["../../../src/components/QuestionHighlightList/QuestionHighlightList.tsx"],"sourcesContent":["import {\n Box,\n Divider,\n List,\n ListItem,\n ListItemText,\n ListSubheader,\n} from '@material-ui/core';\nimport React from 'react';\nimport { useQetaApi, useStyles } from '../../utils/hooks';\nimport { Skeleton } from '@material-ui/lab';\nimport { useRouteRef } from '@backstage/core-plugin-api';\nimport { questionRouteRef } from '@drodil/backstage-plugin-qeta-react';\n\nexport const QuestionHighlightList = (props: {\n type: string;\n title: string;\n noQuestionsLabel: string;\n icon?:
|
|
1
|
+
{"version":3,"file":"QuestionHighlightList.esm.js","sources":["../../../src/components/QuestionHighlightList/QuestionHighlightList.tsx"],"sourcesContent":["import {\n Box,\n Divider,\n List,\n ListItem,\n ListItemText,\n ListSubheader,\n} from '@material-ui/core';\nimport React from 'react';\nimport { useQetaApi, useStyles, useTranslation } from '../../utils/hooks';\nimport { Skeleton } from '@material-ui/lab';\nimport { useRouteRef } from '@backstage/core-plugin-api';\nimport { questionRouteRef } from '@drodil/backstage-plugin-qeta-react';\n\nexport const QuestionHighlightList = (props: {\n type: string;\n title: string;\n noQuestionsLabel: string;\n icon?: React.ReactNode;\n}) => {\n const {\n value: response,\n loading,\n error,\n } = useQetaApi(api => api.getQuestionsList(props.type), []);\n const classes = useStyles();\n const { t } = useTranslation();\n const questionRoute = useRouteRef(questionRouteRef);\n\n const questions = response?.questions ?? [];\n\n return (\n <Box\n className={`qetaQuestionHighlightList ${classes.questionHighlightList}`}\n display={{ md: 'none', lg: 'block' }}\n >\n <List\n component=\"nav\"\n aria-labelledby=\"nested-list-subheader\"\n className=\"qetaQuestionHighlightListList\"\n subheader={\n <ListSubheader\n disableSticky\n component=\"div\"\n id=\"nested-list-subheader\"\n color=\"primary\"\n >\n {props.title}\n {props.icon}\n </ListSubheader>\n }\n >\n {loading && (\n <ListItem>\n <Skeleton variant=\"rect\" />\n </ListItem>\n )}\n {error && (\n <ListItem>\n <ListItemText>{t('homePage.highlights.loadError')}</ListItemText>\n </ListItem>\n )}\n {!error && questions.length === 0 && (\n <ListItem>\n <ListItemText>{props.noQuestionsLabel}</ListItemText>\n </ListItem>\n )}\n {!error &&\n questions.map(q => (\n <React.Fragment key={q.id}>\n <Divider />\n <ListItem\n className=\"qetaQuestionHighlightListListItem\"\n button\n dense\n component=\"a\"\n href={questionRoute({ id: q.id.toString(10) })}\n >\n <ListItemText>{q.title}</ListItemText>\n </ListItem>\n </React.Fragment>\n ))}\n </List>\n </Box>\n );\n};\n"],"names":[],"mappings":";;;;;;;AAca,MAAA,qBAAA,GAAwB,CAAC,KAKhC,KAAA;AACJ,EAAM,MAAA;AAAA,IACJ,KAAO,EAAA,QAAA;AAAA,IACP,OAAA;AAAA,IACA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AE,CACpD,CAAA;AAAA,MAED,CAAC,KAAS,IAAA,SAAA,CAAU,MAAW,KAAA,CAAA,oBAC7B,KAAA,CAAA,aAAA,CAAA,QAAA,EAAA,IAAA,kBACE,KAAA,CAAA,aAAA,CAAA,YAAA,EAAA,IAAA,EAAc,KAAM,CAAA,gBAAiB,CACxC,CAAA;AAAA,MAED,CAAC,KAAA,IACA,SAAU,CAAA,GAAA,CAAI,uBACX,KAAA,CAAA,aAAA,CAAA,KAAA,CAAM,QAAN,EAAA,EAAe,GAAK,EAAA,CAAA,CAAE,EACrB,EAAA,kBAAA,KAAA,CAAA,aAAA,CAAC,aAAQ,CACT,kBAAA,KAAA,CAAA,aAAA;AAAA,QAAC,QAAA;AAAA,QAAA;AAAA,UACC,SAAU,EAAA,mCAAA;AAAA,UACV,MAAM,EAAA,IAAA;AAAA,UACN,KAAK,EAAA,IAAA;AAAA,UACL,SAAU,EAAA,GAAA;AAAA,UACV,IAAA,EAAM,cAAc,EAAE,EAAA,EAAI,EAAE,EAAG,CAAA,QAAA,CAAS,EAAE,CAAA,EAAG,CAAA;AAAA,SAAA;AAAA,wBAE7C,KAAA,CAAA,aAAA,CAAC,YAAc,EAAA,IAAA,EAAA,CAAA,CAAE,KAAM,CAAA;AAAA,OAE3B,CACD,CAAA;AAAA,KACL;AAAA,GACF,CAAA;AAEJ;;;;"}
|
|
@@ -2,7 +2,7 @@ import { Card, CardContent, Grid, Typography, Box, Button } from '@material-ui/c
|
|
|
2
2
|
import { MarkdownContent } from '@backstage/core-components';
|
|
3
3
|
import React from 'react';
|
|
4
4
|
import { VoteButtons } from './VoteButtons.esm.js';
|
|
5
|
-
import { useStyles } from '../../utils/hooks.esm.js';
|
|
5
|
+
import { useStyles, useTranslation } from '../../utils/hooks.esm.js';
|
|
6
6
|
import { DeleteModal } from '../DeleteModal/DeleteModal.esm.js';
|
|
7
7
|
import { AnswerForm } from './AnswerForm.esm.js';
|
|
8
8
|
import { AuthorBox } from './AuthorBox.esm.js';
|
|
@@ -16,6 +16,7 @@ const AnswerCard = (props) => {
|
|
|
16
16
|
const styles = useStyles();
|
|
17
17
|
const [editMode, setEditMode] = React.useState(false);
|
|
18
18
|
const [answerEntity, setAnswerEntity] = React.useState(answer);
|
|
19
|
+
const { t } = useTranslation();
|
|
19
20
|
const [deleteModalOpen, setDeleteModalOpen] = React.useState(false);
|
|
20
21
|
const handleDeleteModalOpen = () => setDeleteModalOpen(true);
|
|
21
22
|
const handleDeleteModalClose = () => setDeleteModalOpen(false);
|
|
@@ -64,7 +65,7 @@ const AnswerCard = (props) => {
|
|
|
64
65
|
className: `${styles.marginRight} qetaAnswerCardDeleteBtn`,
|
|
65
66
|
startIcon: /* @__PURE__ */ React.createElement(DeleteIcon, null)
|
|
66
67
|
},
|
|
67
|
-
"
|
|
68
|
+
t("deleteModal.deleteButton")
|
|
68
69
|
), /* @__PURE__ */ React.createElement(
|
|
69
70
|
DeleteModal,
|
|
70
71
|
{
|
|
@@ -83,7 +84,7 @@ const AnswerCard = (props) => {
|
|
|
83
84
|
onClick: () => setEditMode(true),
|
|
84
85
|
className: "qetaAnswerCardEditBtn"
|
|
85
86
|
},
|
|
86
|
-
"
|
|
87
|
+
t("questionPage.editButton")
|
|
87
88
|
)
|
|
88
89
|
)), /* @__PURE__ */ React.createElement(Grid, { item: true, xs: 3, className: styles.noPadding }, /* @__PURE__ */ React.createElement(AuthorBox, { entity: answerEntity }))))))
|
|
89
90
|
), /* @__PURE__ */ React.createElement(
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AnswerCard.esm.js","sources":["../../../src/components/QuestionPage/AnswerCard.tsx"],"sourcesContent":["import {\n AnswerResponse,\n QuestionResponse,\n} from '@drodil/backstage-plugin-qeta-common';\nimport {\n Box,\n Button,\n Card,\n CardContent,\n Grid,\n Typography,\n} from '@material-ui/core';\nimport { MarkdownContent } from '@backstage/core-components';\nimport React from 'react';\nimport { VoteButtons } from './VoteButtons';\nimport { useStyles } from '../../utils/hooks';\nimport { DeleteModal } from '../DeleteModal/DeleteModal';\nimport { AnswerForm } from './AnswerForm';\nimport { AuthorBox } from './AuthorBox';\nimport { CommentSection } from '../CommentSection/CommentSection';\nimport { LinkButton } from './LinkButton';\nimport DeleteIcon from '@material-ui/icons/Delete';\nimport EditIcon from '@material-ui/icons/Edit';\n\nexport const AnswerCard = (props: {\n answer: AnswerResponse;\n question: QuestionResponse;\n}) => {\n const { answer, question } = props;\n const styles = useStyles();\n\n const [editMode, setEditMode] = React.useState(false);\n const [answerEntity, setAnswerEntity] = React.useState(answer);\n\n const [deleteModalOpen, setDeleteModalOpen] = React.useState(false);\n const handleDeleteModalOpen = () => setDeleteModalOpen(true);\n const handleDeleteModalClose = () => setDeleteModalOpen(false);\n const highlightedAnswer =\n window.location.hash.slice(1) === `answer_${answer.id}`;\n\n const onAnswerEdit = (a: AnswerResponse) => {\n setEditMode(false);\n setAnswerEntity(a);\n };\n\n const onCommentAction = (_: QuestionResponse, a?: AnswerResponse) => {\n if (a) {\n setAnswerEntity(a);\n }\n };\n\n return (\n <>\n <Card\n id={`answer_${answer.id}`}\n className={`qetaAnswerCard ${styles.questionCard} ${\n highlightedAnswer ? styles.highlight : ''\n }`}\n >\n <CardContent>\n <div className={styles.questionCardVote}>\n <VoteButtons entity={answerEntity} question={question} />\n <LinkButton entity={answerEntity} />\n </div>\n <div className={styles.answerCardContent}>\n {editMode ? (\n <AnswerForm\n question={question}\n onPost={onAnswerEdit}\n id={answerEntity.id}\n />\n ) : (\n <Grid container>\n <Grid item xs={12}>\n <Typography variant=\"body1\" gutterBottom>\n <MarkdownContent\n className={`qetaAndwerCardAnswerContent ${styles.markdownContent}`}\n content={answerEntity.content}\n dialect=\"gfm\"\n />\n </Typography>\n </Grid>\n <Grid item container justifyContent=\"space-around\">\n <Grid item xs={9} style={{ alignSelf: 'flex-end' }}>\n {(answerEntity.own ||\n answerEntity.canDelete ||\n answerEntity.canEdit) && (\n <Box\n className={`qetaAnswerCardActions ${styles.questionCardActions}`}\n >\n {!answerEntity.correct &&\n (answerEntity.own || answerEntity.canDelete) && (\n <>\n <Button\n variant=\"outlined\"\n size=\"small\"\n color=\"secondary\"\n onClick={handleDeleteModalOpen}\n className={`${styles.marginRight} qetaAnswerCardDeleteBtn`}\n startIcon={<DeleteIcon />}\n >\n
|
|
1
|
+
{"version":3,"file":"AnswerCard.esm.js","sources":["../../../src/components/QuestionPage/AnswerCard.tsx"],"sourcesContent":["import {\n AnswerResponse,\n QuestionResponse,\n} from '@drodil/backstage-plugin-qeta-common';\nimport {\n Box,\n Button,\n Card,\n CardContent,\n Grid,\n Typography,\n} from '@material-ui/core';\nimport { MarkdownContent } from '@backstage/core-components';\nimport React from 'react';\nimport { VoteButtons } from './VoteButtons';\nimport { useStyles, useTranslation } from '../../utils/hooks';\nimport { DeleteModal } from '../DeleteModal/DeleteModal';\nimport { AnswerForm } from './AnswerForm';\nimport { AuthorBox } from './AuthorBox';\nimport { CommentSection } from '../CommentSection/CommentSection';\nimport { LinkButton } from './LinkButton';\nimport DeleteIcon from '@material-ui/icons/Delete';\nimport EditIcon from '@material-ui/icons/Edit';\n\nexport const AnswerCard = (props: {\n answer: AnswerResponse;\n question: QuestionResponse;\n}) => {\n const { answer, question } = props;\n const styles = useStyles();\n\n const [editMode, setEditMode] = React.useState(false);\n const [answerEntity, setAnswerEntity] = React.useState(answer);\n const { t } = useTranslation();\n\n const [deleteModalOpen, setDeleteModalOpen] = React.useState(false);\n const handleDeleteModalOpen = () => setDeleteModalOpen(true);\n const handleDeleteModalClose = () => setDeleteModalOpen(false);\n const highlightedAnswer =\n window.location.hash.slice(1) === `answer_${answer.id}`;\n\n const onAnswerEdit = (a: AnswerResponse) => {\n setEditMode(false);\n setAnswerEntity(a);\n };\n\n const onCommentAction = (_: QuestionResponse, a?: AnswerResponse) => {\n if (a) {\n setAnswerEntity(a);\n }\n };\n\n return (\n <>\n <Card\n id={`answer_${answer.id}`}\n className={`qetaAnswerCard ${styles.questionCard} ${\n highlightedAnswer ? styles.highlight : ''\n }`}\n >\n <CardContent>\n <div className={styles.questionCardVote}>\n <VoteButtons entity={answerEntity} question={question} />\n <LinkButton entity={answerEntity} />\n </div>\n <div className={styles.answerCardContent}>\n {editMode ? (\n <AnswerForm\n question={question}\n onPost={onAnswerEdit}\n id={answerEntity.id}\n />\n ) : (\n <Grid container>\n <Grid item xs={12}>\n <Typography variant=\"body1\" gutterBottom>\n <MarkdownContent\n className={`qetaAndwerCardAnswerContent ${styles.markdownContent}`}\n content={answerEntity.content}\n dialect=\"gfm\"\n />\n </Typography>\n </Grid>\n <Grid item container justifyContent=\"space-around\">\n <Grid item xs={9} style={{ alignSelf: 'flex-end' }}>\n {(answerEntity.own ||\n answerEntity.canDelete ||\n answerEntity.canEdit) && (\n <Box\n className={`qetaAnswerCardActions ${styles.questionCardActions}`}\n >\n {!answerEntity.correct &&\n (answerEntity.own || answerEntity.canDelete) && (\n <>\n <Button\n variant=\"outlined\"\n size=\"small\"\n color=\"secondary\"\n onClick={handleDeleteModalOpen}\n className={`${styles.marginRight} qetaAnswerCardDeleteBtn`}\n startIcon={<DeleteIcon />}\n >\n {t('deleteModal.deleteButton')}\n </Button>\n <DeleteModal\n open={deleteModalOpen}\n onClose={handleDeleteModalClose}\n entity={answerEntity}\n question={question}\n />\n </>\n )}\n {(answerEntity.own || answerEntity.canEdit) && (\n <Button\n variant=\"outlined\"\n size=\"small\"\n startIcon={<EditIcon />}\n onClick={() => setEditMode(true)}\n className=\"qetaAnswerCardEditBtn\"\n >\n {t('questionPage.editButton')}\n </Button>\n )}\n </Box>\n )}\n </Grid>\n <Grid item xs={3} className={styles.noPadding}>\n <AuthorBox entity={answerEntity} />\n </Grid>\n </Grid>\n </Grid>\n )}\n </div>\n </CardContent>\n </Card>\n <CommentSection\n question={question}\n answer={answerEntity}\n onCommentPost={onCommentAction}\n onCommentDelete={onCommentAction}\n />\n </>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;AAwBa,MAAA,UAAA,GA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AA,UAAA;AAAA,UACR,IAAK,EAAA,OAAA;AAAA,UACL,SAAA,sCAAY,QAAS,EAAA,IAAA,CAAA;AAAA,UACrB,OAAA,EAAS,MAAM,WAAA,CAAY,IAAI,CAAA;AAAA,UAC/B,SAAU,EAAA,uBAAA;AAAA,SAAA;AAAA,QAET,EAAE,yBAAyB,CAAA;AAAA,OAC9B;AAAA,KAIR,CACA,kBAAA,KAAA,CAAA,aAAA,CAAC,QAAK,IAAI,EAAA,IAAA,EAAC,IAAI,CAAG,EAAA,SAAA,EAAW,OAAO,SAClC,EAAA,kBAAA,KAAA,CAAA,aAAA,CAAC,aAAU,MAAQ,EAAA,YAAA,EAAc,CACnC,CACF,CACF,CAEJ,CACF,CAAA;AAAA,GAEF,kBAAA,KAAA,CAAA,aAAA;AAAA,IAAC,cAAA;AAAA,IAAA;AAAA,MACC,QAAA;AAAA,MACA,MAAQ,EAAA,YAAA;AAAA,MACR,aAAe,EAAA,eAAA;AAAA,MACf,eAAiB,EAAA,eAAA;AAAA,KAAA;AAAA,GAErB,CAAA,CAAA;AAEJ;;;;"}
|
|
@@ -3,7 +3,7 @@ import { Typography, Button } from '@material-ui/core';
|
|
|
3
3
|
import React, { useEffect } from 'react';
|
|
4
4
|
import { useAnalytics, useApi, configApiRef } from '@backstage/core-plugin-api';
|
|
5
5
|
import { qetaCreateAnswerPermission } from '@drodil/backstage-plugin-qeta-common';
|
|
6
|
-
import { useStyles } from '../../utils/hooks.esm.js';
|
|
6
|
+
import { useStyles, useTranslation } from '../../utils/hooks.esm.js';
|
|
7
7
|
import { useForm, Controller } from 'react-hook-form';
|
|
8
8
|
import { MarkdownEditor } from '../MarkdownEditor/MarkdownEditor.esm.js';
|
|
9
9
|
import { RequirePermission } from '@backstage/plugin-permission-react';
|
|
@@ -23,6 +23,7 @@ const AnswerForm = (props) => {
|
|
|
23
23
|
const styles = useStyles();
|
|
24
24
|
const configApi = useApi(configApiRef);
|
|
25
25
|
const allowAnonymouns = configApi.getOptionalBoolean("qeta.allowAnonymous");
|
|
26
|
+
const { t } = useTranslation();
|
|
26
27
|
const {
|
|
27
28
|
handleSubmit,
|
|
28
29
|
control,
|
|
@@ -84,7 +85,7 @@ const AnswerForm = (props) => {
|
|
|
84
85
|
permission: qetaCreateAnswerPermission,
|
|
85
86
|
errorPage: /* @__PURE__ */ React.createElement(React.Fragment, null)
|
|
86
87
|
},
|
|
87
|
-
/* @__PURE__ */ React.createElement("form", { onSubmit: handleSubmit(postAnswer), className: "qetaAnswerForm" }, /* @__PURE__ */ React.createElement(Typography, { variant: "h6" }, "Your answer"), error && /* @__PURE__ */ React.createElement(WarningPanel, { severity: "error", title: "
|
|
88
|
+
/* @__PURE__ */ React.createElement("form", { onSubmit: handleSubmit(postAnswer), className: "qetaAnswerForm" }, /* @__PURE__ */ React.createElement(Typography, { variant: "h6" }, "Your answer"), error && /* @__PURE__ */ React.createElement(WarningPanel, { severity: "error", title: t("answerForm.errorPosting") }), /* @__PURE__ */ React.createElement(
|
|
88
89
|
Controller,
|
|
89
90
|
{
|
|
90
91
|
control,
|
|
@@ -100,6 +101,7 @@ const AnswerForm = (props) => {
|
|
|
100
101
|
height: 200,
|
|
101
102
|
error: "answer" in errors,
|
|
102
103
|
config: configApi,
|
|
104
|
+
placeholder: t("answerForm.contentInput.placeholder"),
|
|
103
105
|
onImageUpload: (imageId) => {
|
|
104
106
|
setImages((prevImages) => [...prevImages, imageId]);
|
|
105
107
|
}
|
|
@@ -111,7 +113,7 @@ const AnswerForm = (props) => {
|
|
|
111
113
|
AskAnonymouslyCheckbox,
|
|
112
114
|
{
|
|
113
115
|
control,
|
|
114
|
-
label: "
|
|
116
|
+
label: t("anonymousCheckbox.answerAnonymously")
|
|
115
117
|
}
|
|
116
118
|
), /* @__PURE__ */ React.createElement(
|
|
117
119
|
Button,
|
|
@@ -121,7 +123,7 @@ const AnswerForm = (props) => {
|
|
|
121
123
|
color: "primary",
|
|
122
124
|
className: `qetaAnswerFormPostBtn ${styles.postButton}`
|
|
123
125
|
},
|
|
124
|
-
id ? "
|
|
126
|
+
id ? t("answerForm.submit.existingAnswer") : t("answerForm.submit.newAnswer")
|
|
125
127
|
))
|
|
126
128
|
);
|
|
127
129
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AnswerForm.esm.js","sources":["../../../src/components/QuestionPage/AnswerForm.tsx"],"sourcesContent":["import { WarningPanel } from '@backstage/core-components';\nimport { Button, Typography } from '@material-ui/core';\nimport React, { useEffect } from 'react';\nimport { configApiRef, useAnalytics, useApi } from '@backstage/core-plugin-api';\nimport {\n AnswerRequest,\n AnswerResponse,\n qetaCreateAnswerPermission,\n QuestionResponse,\n} from '@drodil/backstage-plugin-qeta-common';\nimport { useStyles } from '../../utils/hooks';\nimport { Controller, useForm } from 'react-hook-form';\nimport { MarkdownEditor } from '../MarkdownEditor/MarkdownEditor';\nimport { RequirePermission } from '@backstage/plugin-permission-react';\nimport { AskAnonymouslyCheckbox } from '../AskAnonymouslyCheckbox/AskAnonymouslyCheckbox';\nimport { qetaApiRef } from '../../api';\n\nconst getDefaultValues = (questionId: number) => {\n return { questionId, answer: '' };\n};\n\nexport const AnswerForm = (props: {\n question: QuestionResponse;\n onPost: (answer: AnswerResponse) => void;\n id?: number;\n}) => {\n const { question, onPost, id } = props;\n const [values, setValues] = React.useState(getDefaultValues(question.id));\n const analytics = useAnalytics();\n const [error, setError] = React.useState(false);\n const [images, setImages] = React.useState<number[]>([]);\n const qetaApi = useApi(qetaApiRef);\n const styles = useStyles();\n const configApi = useApi(configApiRef);\n const allowAnonymouns = configApi.getOptionalBoolean('qeta.allowAnonymous');\n\n const {\n handleSubmit,\n control,\n formState: { errors },\n reset,\n } = useForm<AnswerRequest>({\n values,\n defaultValues: getDefaultValues(question.id),\n });\n\n const postAnswer = (data: AnswerRequest) => {\n if (id) {\n qetaApi\n .updateAnswer(id, {\n questionId: question.id,\n answer: data.answer,\n images,\n })\n .then(a => {\n if (!a || !('id' in a)) {\n setError(true);\n return;\n }\n analytics.captureEvent('edit', 'answer');\n reset();\n onPost(a);\n })\n .catch(_e => setError(true));\n return;\n }\n // http://localhost:7007/api/qeta/attachments/36e551b1-3be7-479a-8942-b7018434e710\n qetaApi\n .postAnswer({\n questionId: question.id,\n answer: data.answer,\n images,\n anonymous: data.anonymous,\n })\n .then(a => {\n if (!a || !('id' in a)) {\n setError(true);\n return;\n }\n analytics.captureEvent('post', 'answer');\n reset();\n onPost(a);\n })\n .catch(_e => setError(true));\n };\n\n useEffect(() => {\n if (id) {\n qetaApi.getAnswer(question.id, id).then(a => {\n if ('content' in a) {\n setValues({ questionId: question.id, answer: a.content });\n } else {\n setError(true);\n }\n });\n }\n }, [id, question, qetaApi]);\n\n useEffect(() => {\n reset(values);\n }, [values, reset]);\n\n return (\n <RequirePermission\n permission={qetaCreateAnswerPermission}\n errorPage={<></>}\n >\n <form onSubmit={handleSubmit(postAnswer)} className=\"qetaAnswerForm\">\n <Typography variant=\"h6\">Your answer</Typography>\n {error && (\n <WarningPanel severity=\"error\" title
|
|
1
|
+
{"version":3,"file":"AnswerForm.esm.js","sources":["../../../src/components/QuestionPage/AnswerForm.tsx"],"sourcesContent":["import { WarningPanel } from '@backstage/core-components';\nimport { Button, Typography } from '@material-ui/core';\nimport React, { useEffect } from 'react';\nimport { configApiRef, useAnalytics, useApi } from '@backstage/core-plugin-api';\nimport {\n AnswerRequest,\n AnswerResponse,\n qetaCreateAnswerPermission,\n QuestionResponse,\n} from '@drodil/backstage-plugin-qeta-common';\nimport { useStyles, useTranslation } from '../../utils/hooks';\nimport { Controller, useForm } from 'react-hook-form';\nimport { MarkdownEditor } from '../MarkdownEditor/MarkdownEditor';\nimport { RequirePermission } from '@backstage/plugin-permission-react';\nimport { AskAnonymouslyCheckbox } from '../AskAnonymouslyCheckbox/AskAnonymouslyCheckbox';\nimport { qetaApiRef } from '../../api';\n\nconst getDefaultValues = (questionId: number) => {\n return { questionId, answer: '' };\n};\n\nexport const AnswerForm = (props: {\n question: QuestionResponse;\n onPost: (answer: AnswerResponse) => void;\n id?: number;\n}) => {\n const { question, onPost, id } = props;\n const [values, setValues] = React.useState(getDefaultValues(question.id));\n const analytics = useAnalytics();\n const [error, setError] = React.useState(false);\n const [images, setImages] = React.useState<number[]>([]);\n const qetaApi = useApi(qetaApiRef);\n const styles = useStyles();\n const configApi = useApi(configApiRef);\n const allowAnonymouns = configApi.getOptionalBoolean('qeta.allowAnonymous');\n const { t } = useTranslation();\n\n const {\n handleSubmit,\n control,\n formState: { errors },\n reset,\n } = useForm<AnswerRequest>({\n values,\n defaultValues: getDefaultValues(question.id),\n });\n\n const postAnswer = (data: AnswerRequest) => {\n if (id) {\n qetaApi\n .updateAnswer(id, {\n questionId: question.id,\n answer: data.answer,\n images,\n })\n .then(a => {\n if (!a || !('id' in a)) {\n setError(true);\n return;\n }\n analytics.captureEvent('edit', 'answer');\n reset();\n onPost(a);\n })\n .catch(_e => setError(true));\n return;\n }\n // http://localhost:7007/api/qeta/attachments/36e551b1-3be7-479a-8942-b7018434e710\n qetaApi\n .postAnswer({\n questionId: question.id,\n answer: data.answer,\n images,\n anonymous: data.anonymous,\n })\n .then(a => {\n if (!a || !('id' in a)) {\n setError(true);\n return;\n }\n analytics.captureEvent('post', 'answer');\n reset();\n onPost(a);\n })\n .catch(_e => setError(true));\n };\n\n useEffect(() => {\n if (id) {\n qetaApi.getAnswer(question.id, id).then(a => {\n if ('content' in a) {\n setValues({ questionId: question.id, answer: a.content });\n } else {\n setError(true);\n }\n });\n }\n }, [id, question, qetaApi]);\n\n useEffect(() => {\n reset(values);\n }, [values, reset]);\n\n return (\n <RequirePermission\n permission={qetaCreateAnswerPermission}\n errorPage={<></>}\n >\n <form onSubmit={handleSubmit(postAnswer)} className=\"qetaAnswerForm\">\n <Typography variant=\"h6\">Your answer</Typography>\n {error && (\n <WarningPanel severity=\"error\" title={t('answerForm.errorPosting')} />\n )}\n <Controller\n control={control}\n defaultValue=\"\"\n rules={{\n required: true,\n }}\n render={({ field: { onChange, value } }) => (\n <MarkdownEditor\n value={value}\n onChange={onChange}\n height={200}\n error={'answer' in errors}\n config={configApi}\n placeholder={t('answerForm.contentInput.placeholder')}\n onImageUpload={(imageId: number) => {\n setImages(prevImages => [...prevImages, imageId]);\n }}\n />\n )}\n name=\"answer\"\n />\n {allowAnonymouns && !id && (\n <AskAnonymouslyCheckbox\n control={control}\n label={t('anonymousCheckbox.answerAnonymously')}\n />\n )}\n <Button\n variant=\"outlined\"\n type=\"submit\"\n color=\"primary\"\n className={`qetaAnswerFormPostBtn ${styles.postButton}`}\n >\n {id\n ? t('answerForm.submit.existingAnswer')\n : t('answerForm.submit.newAnswer')}\n </Button>\n </form>\n </RequirePermission>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;AAiBA,MAAM,gBAAA,GAAmB,CAAC,UAAuB,KAAA;AAC/C,EAAO,OAAA,EAAE,UAAY,EAAA,MAAA,EAAQ,EAAG,EAAA,CAAA;AAClC,CAAA,CAAA;AAEa,MAAA,UAAA,GAAa,CAAC,KAIrB,KAAA;AACJ,EAAA,MAAM,EAAE,QAAA,EAAU,MAAQ,EAAA,EAAA,EAAO,GAAA,KAAA,CAAA;AACjC,EAAM,MAAA,CAAC,QAAQ,SAAS,CAAA,GAAI,MAAM,QAAS,CAAA,gBAAA,CAAiB,QAAS,CAAA,EAAE,CAAC,CAAA,CAAA;AACxE,EAAA,MAAM,YAAY,YAAa,EAAA,CAAA;AAC/B,EAAA,MAAM,CAAC,KAAO,EAAA,QAAQ,CAAI,GAAA,KAAA,CAAM,SAAS,KAAK,CAAA,CAAA;AAC9C,EAAA,MAAM,CAAC,MAAQ,EAAA,SAAS,IAAI,KAAM,CAAA,QAAA,CAAmB,EAAE,CAAA,CAAA;AACvD,EAAM,MAAA,OAAA,GAAU,OAAO,UAAU,CAAA,CAAA;AACjC,EAAA,MAAM,SAAS,SAAU,EAAA,CAAA;AACzB,EAAM,MAAA,SAAA,GAAY,OAAO,YAAY,CAAA,CAAA;AACr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QACR,IAAK,EAAA,QAAA;AAAA,QACL,KAAM,EAAA,SAAA;AAAA,QACN,SAAA,EAAW,CAAyB,sBAAA,EAAA,MAAA,CAAO,UAAU,CAAA,CAAA;AAAA,OAAA;AAAA,MAEpD,EACG,GAAA,CAAA,CAAE,kCAAkC,CAAA,GACpC,EAAE,6BAA6B,CAAA;AAAA,KAEvC,CAAA;AAAA,GACF,CAAA;AAEJ;;;;"}
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import { Box, Grid, Typography, Avatar } from '@material-ui/core';
|
|
2
2
|
import React from 'react';
|
|
3
|
-
import { useStyles, useEntityAuthor } from '../../utils/hooks.esm.js';
|
|
3
|
+
import { useStyles, useTranslation, useEntityAuthor } from '../../utils/hooks.esm.js';
|
|
4
4
|
import { RelativeTimeWithTooltip } from '../RelativeTimeWithTooltip/RelativeTimeWithTooltip.esm.js';
|
|
5
5
|
import { UpdatedByLink, AuthorLink } from '../Links/Links.esm.js';
|
|
6
6
|
|
|
7
7
|
const AuthorBox = (props) => {
|
|
8
8
|
const { entity } = props;
|
|
9
9
|
const styles = useStyles();
|
|
10
|
+
const { t } = useTranslation();
|
|
10
11
|
const { name, initials, user } = useEntityAuthor(entity);
|
|
11
|
-
return /* @__PURE__ */ React.createElement(Box, { className: `qetaAuthorBox ${styles.questionCardAuthor}` }, /* @__PURE__ */ React.createElement(Grid, { container: true, alignItems: "center" }, /* @__PURE__ */ React.createElement(Grid, { item: true, xs: 12, style: { paddingBottom: 0 } }, /* @__PURE__ */ React.createElement(Typography, { className: "qetaAuthorBoxCreated", variant: "caption" }, "
|
|
12
|
+
return /* @__PURE__ */ React.createElement(Box, { className: `qetaAuthorBox ${styles.questionCardAuthor}` }, /* @__PURE__ */ React.createElement(Grid, { container: true, alignItems: "center" }, /* @__PURE__ */ React.createElement(Grid, { item: true, xs: 12, style: { paddingBottom: 0 } }, /* @__PURE__ */ React.createElement(Typography, { className: "qetaAuthorBoxCreated", variant: "caption" }, t("authorBox.postedAtTime"), " ", /* @__PURE__ */ React.createElement(RelativeTimeWithTooltip, { value: entity.created }))), entity.updated && entity.updatedBy && /* @__PURE__ */ React.createElement(Grid, { item: true, xs: 12, style: { paddingBottom: 0, paddingTop: 0 } }, /* @__PURE__ */ React.createElement(Typography, { className: "qetaAuthorBoxUpdated", variant: "caption" }, t("authorBox.updatedAtTime"), " ", /* @__PURE__ */ React.createElement(RelativeTimeWithTooltip, { value: entity.updated }), " ", t("authorBox.updatedBy"), " ", /* @__PURE__ */ React.createElement(UpdatedByLink, { entity }))), /* @__PURE__ */ React.createElement(Grid, { item: true, xs: 2 }, /* @__PURE__ */ React.createElement(
|
|
12
13
|
Avatar,
|
|
13
14
|
{
|
|
14
15
|
src: user?.spec?.profile?.picture,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AuthorBox.esm.js","sources":["../../../src/components/QuestionPage/AuthorBox.tsx"],"sourcesContent":["import { Avatar, Box, Grid, Typography } from '@material-ui/core';\nimport React from 'react';\nimport { useEntityAuthor, useStyles } from '../../utils/hooks';\nimport {\n AnswerResponse,\n QuestionResponse,\n} from '@drodil/backstage-plugin-qeta-common';\nimport { RelativeTimeWithTooltip } from '../RelativeTimeWithTooltip/RelativeTimeWithTooltip';\nimport { AuthorLink, UpdatedByLink } from '../Links/Links';\n\nexport const AuthorBox = (props: {\n entity: QuestionResponse | AnswerResponse;\n}) => {\n const { entity } = props;\n const styles = useStyles();\n const { name, initials, user } = useEntityAuthor(entity);\n\n return (\n <Box className={`qetaAuthorBox ${styles.questionCardAuthor}`}>\n <Grid container alignItems=\"center\">\n <Grid item xs={12} style={{ paddingBottom: 0 }}>\n <Typography className=\"qetaAuthorBoxCreated\" variant=\"caption\">\n
|
|
1
|
+
{"version":3,"file":"AuthorBox.esm.js","sources":["../../../src/components/QuestionPage/AuthorBox.tsx"],"sourcesContent":["import { Avatar, Box, Grid, Typography } from '@material-ui/core';\nimport React from 'react';\nimport { useEntityAuthor, useStyles, useTranslation } from '../../utils/hooks';\nimport {\n AnswerResponse,\n QuestionResponse,\n} from '@drodil/backstage-plugin-qeta-common';\nimport { RelativeTimeWithTooltip } from '../RelativeTimeWithTooltip/RelativeTimeWithTooltip';\nimport { AuthorLink, UpdatedByLink } from '../Links/Links';\n\nexport const AuthorBox = (props: {\n entity: QuestionResponse | AnswerResponse;\n}) => {\n const { entity } = props;\n const styles = useStyles();\n const { t } = useTranslation();\n const { name, initials, user } = useEntityAuthor(entity);\n\n return (\n <Box className={`qetaAuthorBox ${styles.questionCardAuthor}`}>\n <Grid container alignItems=\"center\">\n <Grid item xs={12} style={{ paddingBottom: 0 }}>\n <Typography className=\"qetaAuthorBoxCreated\" variant=\"caption\">\n {t('authorBox.postedAtTime')}{' '}\n <RelativeTimeWithTooltip value={entity.created} />\n </Typography>\n </Grid>\n {entity.updated && entity.updatedBy && (\n <Grid item xs={12} style={{ paddingBottom: 0, paddingTop: 0 }}>\n <Typography className=\"qetaAuthorBoxUpdated\" variant=\"caption\">\n {t('authorBox.updatedAtTime')}{' '}\n <RelativeTimeWithTooltip value={entity.updated} />{' '}\n {t('authorBox.updatedBy')} <UpdatedByLink entity={entity} />\n </Typography>\n </Grid>\n )}\n <Grid item xs={2}>\n <Avatar\n src={user?.spec?.profile?.picture}\n className=\"qetaAuthorBoxAvatar avatar\"\n alt={name}\n variant=\"rounded\"\n >\n {initials}\n </Avatar>\n </Grid>\n <Grid item xs={10} className={styles.authorLink}>\n <Box style={{ paddingLeft: '5px' }}>\n <AuthorLink entity={entity} />\n </Box>\n </Grid>\n </Grid>\n </Box>\n );\n};\n"],"names":[],"mappings":";;;;;;AAUa,MAAA,SAAA,GAAY,CAAC,KAEpB,KAAA;AACJ,EAAM,MAAA,EAAE,QAAW,GAAA,KAAA,CAAA;AACnB,EAAA,MAAM,SAAS,SAAU,EAAA,CAAA;AACzB,EAAM,MAAA,EAAE,CAAE,EAAA,GAAI,cAAe,EAAA,CAAA;AAC7B,EAAA,MAAM,EAAE,IAAM,EA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AA;AAAA,MAC1B,SAAU,EAAA,4BAAA;AAAA,MACV,GAAK,EAAA,IAAA;AAAA,MACL,OAAQ,EAAA,SAAA;AAAA,KAAA;AAAA,IAEP,QAAA;AAAA,GAEL,CACA,kBAAA,KAAA,CAAA,aAAA,CAAC,IAAK,EAAA,EAAA,IAAA,EAAI,MAAC,EAAI,EAAA,EAAA,EAAI,SAAW,EAAA,MAAA,CAAO,UACnC,EAAA,kBAAA,KAAA,CAAA,aAAA,CAAC,OAAI,KAAO,EAAA,EAAE,WAAa,EAAA,KAAA,EACzB,EAAA,kBAAA,KAAA,CAAA,aAAA,CAAC,cAAW,MAAgB,EAAA,CAC9B,CACF,CACF,CACF,CAAA,CAAA;AAEJ;;;;"}
|
|
@@ -4,10 +4,12 @@ import { useApi } from '@backstage/core-plugin-api';
|
|
|
4
4
|
import StarIcon from '@material-ui/icons/Star';
|
|
5
5
|
import StarOutlineIcon from '@material-ui/icons/StarOutline';
|
|
6
6
|
import { qetaApiRef } from '../../api/QetaClient.esm.js';
|
|
7
|
+
import { useTranslation } from '../../utils/hooks.esm.js';
|
|
7
8
|
|
|
8
9
|
const FavoriteButton = (props) => {
|
|
9
10
|
const [entity, setEntity] = React.useState(props.entity);
|
|
10
11
|
const qetaApi = useApi(qetaApiRef);
|
|
12
|
+
const { t } = useTranslation();
|
|
11
13
|
const favoriteQuestion = () => {
|
|
12
14
|
qetaApi.favoriteQuestion(entity.id).then((response) => {
|
|
13
15
|
setEntity(response);
|
|
@@ -18,7 +20,7 @@ const FavoriteButton = (props) => {
|
|
|
18
20
|
setEntity(response);
|
|
19
21
|
});
|
|
20
22
|
};
|
|
21
|
-
return /* @__PURE__ */ React.createElement(React.Fragment, null, entity.favorite ? /* @__PURE__ */ React.createElement(Tooltip, { title: "
|
|
23
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, entity.favorite ? /* @__PURE__ */ React.createElement(Tooltip, { title: t("favorite.remove") }, /* @__PURE__ */ React.createElement(
|
|
22
24
|
IconButton,
|
|
23
25
|
{
|
|
24
26
|
"aria-label": "unfavorite",
|
|
@@ -27,7 +29,7 @@ const FavoriteButton = (props) => {
|
|
|
27
29
|
className: "qetaUnfavoriteBtn"
|
|
28
30
|
},
|
|
29
31
|
/* @__PURE__ */ React.createElement(StarIcon, null)
|
|
30
|
-
)) : /* @__PURE__ */ React.createElement(Tooltip, { title: "
|
|
32
|
+
)) : /* @__PURE__ */ React.createElement(Tooltip, { title: t("favorite.add") }, /* @__PURE__ */ React.createElement(
|
|
31
33
|
IconButton,
|
|
32
34
|
{
|
|
33
35
|
"aria-label": "favorite",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FavoriteButton.esm.js","sources":["../../../src/components/QuestionPage/FavoriteButton.tsx"],"sourcesContent":["import { QuestionResponse } from '@drodil/backstage-plugin-qeta-common';\nimport { IconButton, Tooltip } from '@material-ui/core';\nimport React from 'react';\nimport { useApi } from '@backstage/core-plugin-api';\nimport StarIcon from '@material-ui/icons/Star';\nimport StarOutlineIcon from '@material-ui/icons/StarOutline';\nimport { qetaApiRef } from '../../api';\n\nexport const FavoriteButton = (props: { entity: QuestionResponse }) => {\n const [entity, setEntity] = React.useState<QuestionResponse>(props.entity);\n const qetaApi = useApi(qetaApiRef);\n\n const favoriteQuestion = () => {\n qetaApi.favoriteQuestion(entity.id).then(response => {\n setEntity(response);\n });\n };\n\n const unfavoriteQuestion = () => {\n qetaApi.unfavoriteQuestion(entity.id).then(response => {\n setEntity(response);\n });\n };\n\n return (\n <React.Fragment>\n {entity.favorite ? (\n <Tooltip title
|
|
1
|
+
{"version":3,"file":"FavoriteButton.esm.js","sources":["../../../src/components/QuestionPage/FavoriteButton.tsx"],"sourcesContent":["import { QuestionResponse } from '@drodil/backstage-plugin-qeta-common';\nimport { IconButton, Tooltip } from '@material-ui/core';\nimport React from 'react';\nimport { useApi } from '@backstage/core-plugin-api';\nimport StarIcon from '@material-ui/icons/Star';\nimport StarOutlineIcon from '@material-ui/icons/StarOutline';\nimport { qetaApiRef } from '../../api';\nimport { useTranslation } from '../../utils/hooks';\n\nexport const FavoriteButton = (props: { entity: QuestionResponse }) => {\n const [entity, setEntity] = React.useState<QuestionResponse>(props.entity);\n const qetaApi = useApi(qetaApiRef);\n const { t } = useTranslation();\n\n const favoriteQuestion = () => {\n qetaApi.favoriteQuestion(entity.id).then(response => {\n setEntity(response);\n });\n };\n\n const unfavoriteQuestion = () => {\n qetaApi.unfavoriteQuestion(entity.id).then(response => {\n setEntity(response);\n });\n };\n\n return (\n <React.Fragment>\n {entity.favorite ? (\n <Tooltip title={t('favorite.remove')}>\n <IconButton\n aria-label=\"unfavorite\"\n size=\"small\"\n onClick={unfavoriteQuestion}\n className=\"qetaUnfavoriteBtn\"\n >\n <StarIcon />\n </IconButton>\n </Tooltip>\n ) : (\n <Tooltip title={t('favorite.add')}>\n <IconButton\n aria-label=\"favorite\"\n size=\"small\"\n onClick={favoriteQuestion}\n className=\"qetaFavoriteBtn\"\n >\n <StarOutlineIcon />\n </IconButton>\n </Tooltip>\n )}\n </React.Fragment>\n );\n};\n"],"names":[],"mappings":";;;;;;;;AASa,MAAA,cAAA,GAAiB,CAAC,KAAwC,KAAA;AACrE,EAAA,MAAM,CAAC,MAAQ,EAAA,SAAS,IAAI,KAAM,CAAA,QAAA,CAA2B,MAAM,MAAM,CAAA,CAAA;AACzE,EAAM,MAAA,OAAA,GAAU,OAAO,UAAU,CAAA,CAAA;AACjC,EAAM,MAAA,EAAE,CAAE,EAAA,GAAI,cAAe,EAAA,CAAA;AAE7B,EAAA,MAAM,mBAAmB,MAAM;AAC7B,IAAA,OAAA,CAAQ,gBAAiB,CAAA,MAAA,CAAO,EAAE,CAAA,CAAE,KAAK,CAAY,QAAA,KAAA;AACnD,MAAA,SAAA,CAAU,QAAQ,CAAA,CAAA;AAAA,KACnB,CAAA,CAAA;AAAA,GACH,CAAA;AAEA,EAAA,MAAM,qBAAqB,MAAM;AAC/B,IAAA,OAAA,CAAQ,kBAAmB,CAAA,MAAA,CAAO,EAAE,CAAA,CAAE,KAAK,CAAY,QAAA,KAAA;AACrD,MAAA,SAAA,CAAU,QAAQ,CAAA,CAAA;AAAA,KACnB,CAAA,CAAA;AAAA,GACH,CAAA;AAEA,EACE,uBAAA,KAAA,CAAA,aAAA,CAAC,KAAM,CAAA,QAAA,EAAN,IACE,EAAA,MAAA,CAAO,QACN,mBAAA,KAAA,CAAA,aAAA,CAAC,OAAQ,EAAA,EAAA,KAAA,EAAO,CAAE,CAAA,iBAAiB,CACjC,EAAA,kBAAA,KAAA,CAAA,aAAA;AAAA,IAAC,UAAA;AAAA,IAAA;AAAA,MACC,YAAW,EAAA,YAAA;AAAA,MACX,IAAK,EAAA,OAAA;AAAA,MACL,OAAS,EAAA,kBAAA;AAAA,MACT,SAAU,EAAA,mBAAA;AAAA,KAAA;AAAA,wCAET,QAAS,EAAA,IAAA,CAAA;AAAA,GAEd,CAEA,mBAAA,KAAA,CAAA,aAAA,CAAC,WAAQ,KAAO,EAAA,CAAA,CAAE,cAAc,CAC9B,EAAA,kBAAA,KAAA,CAAA,aAAA;AAAA,IAAC,UAAA;AAAA,IAAA;AAAA,MACC,YAAW,EAAA,UAAA;AAAA,MACX,IAAK,EAAA,OAAA;AAAA,MACL,OAAS,EAAA,gBAAA;AAAA,MACT,SAAU,EAAA,iBAAA;AAAA,KAAA;AAAA,wCAET,eAAgB,EAAA,IAAA,CAAA;AAAA,GAErB,CAEJ,CAAA,CAAA;AAEJ;;;;"}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { Tooltip, IconButton } from '@material-ui/core';
|
|
2
2
|
import Link from '@material-ui/icons/Link';
|
|
3
3
|
import React from 'react';
|
|
4
|
+
import { useTranslation } from '../../utils/hooks.esm.js';
|
|
4
5
|
|
|
5
6
|
const LinkButton = (props) => {
|
|
6
7
|
const isQuestion = "title" in props.entity;
|
|
8
|
+
const { t } = useTranslation();
|
|
7
9
|
const copyToClipboard = () => {
|
|
8
10
|
const url = new URL(window.location.href);
|
|
9
11
|
if (!isQuestion) {
|
|
@@ -11,21 +13,15 @@ const LinkButton = (props) => {
|
|
|
11
13
|
}
|
|
12
14
|
window.navigator.clipboard.writeText(url.toString());
|
|
13
15
|
};
|
|
14
|
-
return /* @__PURE__ */ React.createElement(
|
|
15
|
-
|
|
16
|
+
return /* @__PURE__ */ React.createElement(Tooltip, { title: isQuestion ? t("link.question") : t("link.answer") }, /* @__PURE__ */ React.createElement(
|
|
17
|
+
IconButton,
|
|
16
18
|
{
|
|
17
|
-
|
|
19
|
+
"aria-label": t("link.aria"),
|
|
20
|
+
size: "small",
|
|
21
|
+
onClick: copyToClipboard
|
|
18
22
|
},
|
|
19
|
-
/* @__PURE__ */ React.createElement(
|
|
20
|
-
|
|
21
|
-
{
|
|
22
|
-
"aria-label": "copy link to clipboard",
|
|
23
|
-
size: "small",
|
|
24
|
-
onClick: copyToClipboard
|
|
25
|
-
},
|
|
26
|
-
/* @__PURE__ */ React.createElement(Link, null)
|
|
27
|
-
)
|
|
28
|
-
);
|
|
23
|
+
/* @__PURE__ */ React.createElement(Link, null)
|
|
24
|
+
));
|
|
29
25
|
};
|
|
30
26
|
|
|
31
27
|
export { LinkButton };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LinkButton.esm.js","sources":["../../../src/components/QuestionPage/LinkButton.tsx"],"sourcesContent":["import { IconButton, Tooltip } from '@material-ui/core';\nimport Link from '@material-ui/icons/Link';\nimport React from 'react';\nimport {\n AnswerResponse,\n QuestionResponse,\n} from '@drodil/backstage-plugin-qeta-common';\n\nexport const LinkButton = (props: {\n entity: QuestionResponse | AnswerResponse;\n}) => {\n const isQuestion = 'title' in props.entity;\n const copyToClipboard = () => {\n const url = new URL(window.location.href);\n if (!isQuestion) {\n url.hash = `#answer_${props.entity.id}`;\n }\n window.navigator.clipboard.writeText(url.toString());\n };\n\n return (\n <Tooltip
|
|
1
|
+
{"version":3,"file":"LinkButton.esm.js","sources":["../../../src/components/QuestionPage/LinkButton.tsx"],"sourcesContent":["import { IconButton, Tooltip } from '@material-ui/core';\nimport Link from '@material-ui/icons/Link';\nimport React from 'react';\nimport {\n AnswerResponse,\n QuestionResponse,\n} from '@drodil/backstage-plugin-qeta-common';\nimport { useTranslation } from '../../utils/hooks';\n\nexport const LinkButton = (props: {\n entity: QuestionResponse | AnswerResponse;\n}) => {\n const isQuestion = 'title' in props.entity;\n const { t } = useTranslation();\n const copyToClipboard = () => {\n const url = new URL(window.location.href);\n if (!isQuestion) {\n url.hash = `#answer_${props.entity.id}`;\n }\n window.navigator.clipboard.writeText(url.toString());\n };\n\n return (\n <Tooltip title={isQuestion ? t('link.question') : t('link.answer')}>\n <IconButton\n aria-label={t('link.aria')}\n size=\"small\"\n onClick={copyToClipboard}\n >\n <Link />\n </IconButton>\n </Tooltip>\n );\n};\n"],"names":[],"mappings":";;;;;AASa,MAAA,UAAA,GAAa,CAAC,KAErB,KAAA;AACJ,EAAM,MAAA,UAAA,GAAa,WAAW,KAAM,CAAA,MAAA,CAAA;AACpC,EAAM,MAAA,EAAE,CAAE,EAAA,GAAI,cAAe,EAAA,CAAA;AAC7B,EAAA,MAAM,kBAAkB,MAAM;AAC5B,IAAA,MAAM,GAAM,GAAA,IAAI,GAAI,CAAA,MAAA,CAAO,SAAS,IAAI,CAAA,CAAA;AACxC,IAAA,IAAI,CAAC,UAAY,EAAA;AACf,MAAA,GAAA,CAAI,IAAO,GAAA,CAAA,QAAA,EAAW,KAAM,CAAA,MAAA,CAAO,EAAE,CAAA,CAAA,CAAA;AAAA,KACvC;AACA,IAAA,MAAA,CAAO,SAAU,CAAA,SAAA,CAAU,SAAU,CAAA,GAAA,CAAI,UAAU,CAAA,CAAA;AAAA,GACrD,CAAA;AAEA,EACE,uBAAA,KAAA,CAAA,aAAA,CAAC,WAAQ,KAAO,EAAA,UAAA,GAAa,EAAE,eAAe,CAAA,GAAI,CAAE,CAAA,aAAa,CAC/D,EAAA,kBAAA,KAAA,CAAA,aAAA;AAAA,IAAC,UAAA;AAAA,IAAA;AAAA,MACC,YAAA,EAAY,EAAE,WAAW,CAAA;AAAA,MACzB,IAAK,EAAA,OAAA;AAAA,MACL,OAAS,EAAA,eAAA;AAAA,KAAA;AAAA,wCAER,IAAK,EAAA,IAAA,CAAA;AAAA,GAEV,CAAA,CAAA;AAEJ;;;;"}
|
|
@@ -2,7 +2,7 @@ import { Card, CardContent, Typography, Grid, Box, Button } from '@material-ui/c
|
|
|
2
2
|
import { MarkdownContent } from '@backstage/core-components';
|
|
3
3
|
import React, { useEffect } from 'react';
|
|
4
4
|
import { VoteButtons } from './VoteButtons.esm.js';
|
|
5
|
-
import { useStyles } from '../../utils/hooks.esm.js';
|
|
5
|
+
import { useStyles, useTranslation } from '../../utils/hooks.esm.js';
|
|
6
6
|
import { DeleteModal } from '../DeleteModal/DeleteModal.esm.js';
|
|
7
7
|
import DeleteIcon from '@material-ui/icons/Delete';
|
|
8
8
|
import EditIcon from '@material-ui/icons/Edit';
|
|
@@ -22,6 +22,7 @@ const QuestionCard = (props) => {
|
|
|
22
22
|
const [questionEntity, setQuestionEntity] = React.useState(question);
|
|
23
23
|
const handleDeleteModalOpen = () => setDeleteModalOpen(true);
|
|
24
24
|
const handleDeleteModalClose = () => setDeleteModalOpen(false);
|
|
25
|
+
const { t } = useTranslation();
|
|
25
26
|
const onCommentAction = (q, _) => {
|
|
26
27
|
setQuestionEntity(q);
|
|
27
28
|
};
|
|
@@ -68,7 +69,7 @@ const QuestionCard = (props) => {
|
|
|
68
69
|
className: `${styles.marginRight} qetaQuestionCardDeleteBtn`,
|
|
69
70
|
startIcon: /* @__PURE__ */ React.createElement(DeleteIcon, null)
|
|
70
71
|
},
|
|
71
|
-
"
|
|
72
|
+
t("deleteModal.deleteButton")
|
|
72
73
|
), /* @__PURE__ */ React.createElement(
|
|
73
74
|
DeleteModal,
|
|
74
75
|
{
|
|
@@ -87,7 +88,7 @@ const QuestionCard = (props) => {
|
|
|
87
88
|
}),
|
|
88
89
|
className: "qetaQuestionCardEditBtn"
|
|
89
90
|
},
|
|
90
|
-
"
|
|
91
|
+
t("questionPage.editButton")
|
|
91
92
|
))),
|
|
92
93
|
/* @__PURE__ */ React.createElement(Grid, { item: true, xs: 3, className: styles.noPadding }, /* @__PURE__ */ React.createElement(AuthorBox, { entity: questionEntity }))
|
|
93
94
|
)))
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QuestionCard.esm.js","sources":["../../../src/components/QuestionPage/QuestionCard.tsx"],"sourcesContent":["import {\n AnswerResponse,\n QuestionResponse,\n} from '@drodil/backstage-plugin-qeta-common';\nimport {\n Box,\n Button,\n Card,\n CardContent,\n Grid,\n Typography,\n} from '@material-ui/core';\nimport { MarkdownContent } from '@backstage/core-components';\nimport React, { useEffect } from 'react';\nimport { VoteButtons } from './VoteButtons';\nimport { useStyles } from '../../utils/hooks';\nimport { DeleteModal } from '../DeleteModal/DeleteModal';\nimport DeleteIcon from '@material-ui/icons/Delete';\nimport EditIcon from '@material-ui/icons/Edit';\nimport { FavoriteButton } from './FavoriteButton';\nimport { AuthorBox } from './AuthorBox';\nimport { TagsAndEntities } from './TagsAndEntities';\nimport { CommentSection } from '../CommentSection/CommentSection';\nimport { useRouteRef } from '@backstage/core-plugin-api';\nimport { editQuestionRouteRef } from '@drodil/backstage-plugin-qeta-react';\nimport { LinkButton } from './LinkButton';\n\nexport const QuestionCard = (props: { question: QuestionResponse }) => {\n const { question } = props;\n const styles = useStyles();\n const editQuestionRoute = useRouteRef(editQuestionRouteRef);\n const [deleteModalOpen, setDeleteModalOpen] = React.useState(false);\n const [questionEntity, setQuestionEntity] = React.useState(question);\n const handleDeleteModalOpen = () => setDeleteModalOpen(true);\n const handleDeleteModalClose = () => setDeleteModalOpen(false);\n const onCommentAction = (q: QuestionResponse, _?: AnswerResponse) => {\n setQuestionEntity(q);\n };\n\n const highlightedAnswer = window.location.hash.slice(1) ?? undefined;\n useEffect(() => {\n if (highlightedAnswer) {\n try {\n const element = document.querySelector(`#${highlightedAnswer}`);\n if (element) {\n element.scrollIntoView();\n }\n } catch (e) {\n // NOOP\n }\n }\n }, [highlightedAnswer]);\n\n return (\n <>\n <Card\n variant=\"outlined\"\n className={`qetaQuestionCard ${styles.questionCard}`}\n >\n <CardContent>\n <div className={styles.questionCardVote}>\n <VoteButtons entity={questionEntity} />\n <FavoriteButton entity={questionEntity} />\n <LinkButton entity={questionEntity} />\n </div>\n <div className={styles.questionCardContent}>\n <Typography variant=\"body1\" gutterBottom>\n <MarkdownContent\n content={questionEntity.content}\n dialect=\"gfm\"\n className={styles.markdownContent}\n />\n </Typography>\n <Grid\n container\n item\n justifyContent=\"space-around\"\n className={styles.questionCardMetadata}\n >\n <Grid item xs={9} style={{ alignSelf: 'flex-end' }}>\n <TagsAndEntities question={questionEntity} />\n {(question.own || question.canEdit || question.canDelete) && (\n <Box className={styles.questionCardActions}>\n {(question.own || question.canDelete) && (\n <>\n <Button\n variant=\"outlined\"\n size=\"small\"\n color=\"secondary\"\n onClick={handleDeleteModalOpen}\n className={`${styles.marginRight} qetaQuestionCardDeleteBtn`}\n startIcon={<DeleteIcon />}\n >\n
|
|
1
|
+
{"version":3,"file":"QuestionCard.esm.js","sources":["../../../src/components/QuestionPage/QuestionCard.tsx"],"sourcesContent":["import {\n AnswerResponse,\n QuestionResponse,\n} from '@drodil/backstage-plugin-qeta-common';\nimport {\n Box,\n Button,\n Card,\n CardContent,\n Grid,\n Typography,\n} from '@material-ui/core';\nimport { MarkdownContent } from '@backstage/core-components';\nimport React, { useEffect } from 'react';\nimport { VoteButtons } from './VoteButtons';\nimport { useStyles, useTranslation } from '../../utils/hooks';\nimport { DeleteModal } from '../DeleteModal/DeleteModal';\nimport DeleteIcon from '@material-ui/icons/Delete';\nimport EditIcon from '@material-ui/icons/Edit';\nimport { FavoriteButton } from './FavoriteButton';\nimport { AuthorBox } from './AuthorBox';\nimport { TagsAndEntities } from './TagsAndEntities';\nimport { CommentSection } from '../CommentSection/CommentSection';\nimport { useRouteRef } from '@backstage/core-plugin-api';\nimport { editQuestionRouteRef } from '@drodil/backstage-plugin-qeta-react';\nimport { LinkButton } from './LinkButton';\n\nexport const QuestionCard = (props: { question: QuestionResponse }) => {\n const { question } = props;\n const styles = useStyles();\n const editQuestionRoute = useRouteRef(editQuestionRouteRef);\n const [deleteModalOpen, setDeleteModalOpen] = React.useState(false);\n const [questionEntity, setQuestionEntity] = React.useState(question);\n const handleDeleteModalOpen = () => setDeleteModalOpen(true);\n const handleDeleteModalClose = () => setDeleteModalOpen(false);\n const { t } = useTranslation();\n const onCommentAction = (q: QuestionResponse, _?: AnswerResponse) => {\n setQuestionEntity(q);\n };\n\n const highlightedAnswer = window.location.hash.slice(1) ?? undefined;\n useEffect(() => {\n if (highlightedAnswer) {\n try {\n const element = document.querySelector(`#${highlightedAnswer}`);\n if (element) {\n element.scrollIntoView();\n }\n } catch (e) {\n // NOOP\n }\n }\n }, [highlightedAnswer]);\n\n return (\n <>\n <Card\n variant=\"outlined\"\n className={`qetaQuestionCard ${styles.questionCard}`}\n >\n <CardContent>\n <div className={styles.questionCardVote}>\n <VoteButtons entity={questionEntity} />\n <FavoriteButton entity={questionEntity} />\n <LinkButton entity={questionEntity} />\n </div>\n <div className={styles.questionCardContent}>\n <Typography variant=\"body1\" gutterBottom>\n <MarkdownContent\n content={questionEntity.content}\n dialect=\"gfm\"\n className={styles.markdownContent}\n />\n </Typography>\n <Grid\n container\n item\n justifyContent=\"space-around\"\n className={styles.questionCardMetadata}\n >\n <Grid item xs={9} style={{ alignSelf: 'flex-end' }}>\n <TagsAndEntities question={questionEntity} />\n {(question.own || question.canEdit || question.canDelete) && (\n <Box className={styles.questionCardActions}>\n {(question.own || question.canDelete) && (\n <>\n <Button\n variant=\"outlined\"\n size=\"small\"\n color=\"secondary\"\n onClick={handleDeleteModalOpen}\n className={`${styles.marginRight} qetaQuestionCardDeleteBtn`}\n startIcon={<DeleteIcon />}\n >\n {t('deleteModal.deleteButton')}\n </Button>\n <DeleteModal\n open={deleteModalOpen}\n onClose={handleDeleteModalClose}\n entity={questionEntity}\n />\n </>\n )}\n {(question.own || question.canEdit) && (\n <Button\n variant=\"outlined\"\n size=\"small\"\n startIcon={<EditIcon />}\n href={editQuestionRoute({\n id: question.id.toString(10),\n })}\n className=\"qetaQuestionCardEditBtn\"\n >\n {t('questionPage.editButton')}\n </Button>\n )}\n </Box>\n )}\n </Grid>\n <Grid item xs={3} className={styles.noPadding}>\n <AuthorBox entity={questionEntity} />\n </Grid>\n </Grid>\n </div>\n </CardContent>\n </Card>\n <CommentSection\n question={questionEntity}\n onCommentDelete={onCommentAction}\n onCommentPost={onCommentAction}\n />\n </>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;AA2Ba,MAAA,YAAA,GAAe,CAAC,KAA0C,KAAA;AACrE,EAAM,MAAA,EAAE,UAAa,GAAA,KAAA,CAAA;AACrB,EAAA,MAAM,SAAS,SAAU,EAAA,CAAA;AACzB,EAAM,MAAA,iBAAA,GAAoB,YAAY,oBAAoB,CAAA,CAAA;AAC1D,EAAA,MAAM,CAAC,eAAiB,EAAA,kBAAkB,CAAI,GAAA,KAAA,CAAM,SAAS,KAAK,CAAA,CAAA;AAClE,EAAA,MAAM,CAAC,cAAgB,EAAA,iBAAiB,CAAI,GAAA,KAAA,CAAM,SAAS,QAAQ,CAAA,CAAA;AACnE,EAAM,MAAA,qBAAA,GAAwB,MAAM,kBAAA,CAAmB,IAAI,CAAA,CAAA;AAC3D,EAAM,MAAA,sBAAA,GAAyB,MAAM,kBAAA,CAAmB,KAAK,CAAA,CAAA;AAC7D,EAAM,MAAA,EAAE,CAAE,EAAA,GAAI,cAAe,EAAA,CAAA;AAC7B,EAAM,MAAA,eAAA,GAAkB,CAAC,CAAA,EAAqB,CAAuB,KAAA;AACnE,IAAA,iBAAA,CAAkB,CAAC,CAAA,CAAA;AAAA,GACrB,CAAA;AAEA,EAAA,MAAM,oBAAoB,MAAO,CAAA,QAAA,CAAS,I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QAAC,WAAA;AAAA,QAAA;AAAA,UACC,IAAM,EAAA,eAAA;AAAA,UACN,OAAS,EAAA,sBAAA;AAAA,UACT,MAAQ,EAAA,cAAA;AAAA,SAAA;AAAA,OAEZ,CAAA,EAAA,CAEA,QAAS,CAAA,GAAA,IAAO,SAAS,OACzB,qBAAA,KAAA,CAAA,aAAA;AAAA,QAAC,MAAA;AAAA,QAAA;AAAA,UACC,OAAQ,EAAA,UAAA;AAAA,UACR,IAAK,EAAA,OAAA;AAAA,UACL,SAAA,sCAAY,QAAS,EAAA,IAAA,CAAA;AAAA,UACrB,MAAM,iBAAkB,CAAA;AAAA,YACtB,EAAI,EAAA,QAAA,CAAS,EAAG,CAAA,QAAA,CAAS,EAAE,CAAA;AAAA,WAC5B,CAAA;AAAA,UACD,SAAU,EAAA,yBAAA;AAAA,SAAA;AAAA,QAET,EAAE,yBAAyB,CAAA;AAAA,OAGlC,CAEJ,CAAA;AAAA,sBACC,KAAA,CAAA,aAAA,CAAA,IAAA,EAAA,EAAK,IAAI,EAAA,IAAA,EAAC,EAAI,EAAA,CAAA,EAAG,SAAW,EAAA,MAAA,CAAO,SAClC,EAAA,kBAAA,KAAA,CAAA,aAAA,CAAC,SAAU,EAAA,EAAA,MAAA,EAAQ,gBAAgB,CACrC,CAAA;AAAA,KAEJ,CACF,CAAA;AAAA,GAEF,kBAAA,KAAA,CAAA,aAAA;AAAA,IAAC,cAAA;AAAA,IAAA;AAAA,MACC,QAAU,EAAA,cAAA;AAAA,MACV,eAAiB,EAAA,eAAA;AAAA,MACjB,aAAe,EAAA,eAAA;AAAA,KAAA;AAAA,GAEnB,CAAA,CAAA;AAEJ;;;;"}
|
|
@@ -2,7 +2,7 @@ import React, { useState, useEffect } from 'react';
|
|
|
2
2
|
import { Container, Box, Grid, Typography, FormControl, Select, Divider } from '@material-ui/core';
|
|
3
3
|
import { WarningPanel, Content, ContentHeader } from '@backstage/core-components';
|
|
4
4
|
import { useParams, useSearchParams } from 'react-router-dom';
|
|
5
|
-
import { useStyles, useQetaApi } from '../../utils/hooks.esm.js';
|
|
5
|
+
import { useStyles, useTranslation, useQetaApi } from '../../utils/hooks.esm.js';
|
|
6
6
|
import { QuestionCard } from './QuestionCard.esm.js';
|
|
7
7
|
import { AnswerForm } from './AnswerForm.esm.js';
|
|
8
8
|
import { AnswerCard } from './AnswerCard.esm.js';
|
|
@@ -16,6 +16,7 @@ import { useSignal } from '@backstage/plugin-signals-react';
|
|
|
16
16
|
const QuestionPage = () => {
|
|
17
17
|
const { id } = useParams();
|
|
18
18
|
const styles = useStyles();
|
|
19
|
+
const { t } = useTranslation();
|
|
19
20
|
const [newAnswers, setNewAnswers] = React.useState([]);
|
|
20
21
|
const [answerSort, setAnswerSort] = React.useState("default");
|
|
21
22
|
const [searchParams] = useSearchParams();
|
|
@@ -43,13 +44,13 @@ const QuestionPage = () => {
|
|
|
43
44
|
setNewAnswers(newAnswers.concat([answer]));
|
|
44
45
|
};
|
|
45
46
|
const getDescription = (q) => {
|
|
46
|
-
return /* @__PURE__ */ React.createElement("span", null, "
|
|
47
|
+
return /* @__PURE__ */ React.createElement("span", null, t("authorBox.postedAtTime"), " ", /* @__PURE__ */ React.createElement(Box, { fontWeight: "fontWeightMedium", display: "inline", sx: { mr: 2 } }, /* @__PURE__ */ React.createElement(RelativeTimeWithTooltip, { value: q.created })), q.updated && /* @__PURE__ */ React.createElement(React.Fragment, null, t("authorBox.updatedAtTime"), " ", /* @__PURE__ */ React.createElement(Box, { fontWeight: "fontWeightMedium", display: "inline", sx: { mr: 2 } }, /* @__PURE__ */ React.createElement(RelativeTimeWithTooltip, { value: q.updated }), " ", t("authorBox.updatedBy"), " ", /* @__PURE__ */ React.createElement(UpdatedByLink, { entity: q }))), /* @__PURE__ */ React.createElement(Box, { fontWeight: "fontWeightMedium", display: "inline" }, t("common.views", { count: views })));
|
|
47
48
|
};
|
|
48
49
|
if (loading) {
|
|
49
50
|
return /* @__PURE__ */ React.createElement(Skeleton, { variant: "rect", height: 200 });
|
|
50
51
|
}
|
|
51
52
|
if (error || question === void 0) {
|
|
52
|
-
return /* @__PURE__ */ React.createElement(WarningPanel, { severity: "error", title: "
|
|
53
|
+
return /* @__PURE__ */ React.createElement(WarningPanel, { severity: "error", title: t("questionPage.errorLoading") }, error?.message);
|
|
53
54
|
}
|
|
54
55
|
const sortAnswers = (a, b) => {
|
|
55
56
|
if (answerSort === "default") {
|
|
@@ -97,11 +98,13 @@ const QuestionPage = () => {
|
|
|
97
98
|
}
|
|
98
99
|
),
|
|
99
100
|
/* @__PURE__ */ React.createElement(AskQuestionButton, null)
|
|
100
|
-
), /* @__PURE__ */ React.createElement(QuestionCard, { question }), /* @__PURE__ */ React.createElement(Box, { sx: { mt: 3, mb: 2 } }, /* @__PURE__ */ React.createElement(Grid, { container: true, justifyContent: "space-between", alignItems: "center" }, /* @__PURE__ */ React.createElement(Grid, { item: true }, /* @__PURE__ */ React.createElement(Typography, { variant: "h6" },
|
|
101
|
+
), /* @__PURE__ */ React.createElement(QuestionCard, { question }), /* @__PURE__ */ React.createElement(Box, { sx: { mt: 3, mb: 2 } }, /* @__PURE__ */ React.createElement(Grid, { container: true, justifyContent: "space-between", alignItems: "center" }, /* @__PURE__ */ React.createElement(Grid, { item: true }, /* @__PURE__ */ React.createElement(Typography, { variant: "h6" }, t("common.answers", {
|
|
102
|
+
count: answersCount + newAnswers.length
|
|
103
|
+
}))), allAnswers.length > 1 && /* @__PURE__ */ React.createElement(Grid, { item: true }, /* @__PURE__ */ React.createElement(FormControl, null, /* @__PURE__ */ React.createElement(
|
|
101
104
|
Select,
|
|
102
105
|
{
|
|
103
106
|
native: true,
|
|
104
|
-
label: "
|
|
107
|
+
label: t("questionPage.sortAnswers.label"),
|
|
105
108
|
value: answerSort,
|
|
106
109
|
onChange: (val) => setAnswerSort(val.target.value),
|
|
107
110
|
inputProps: {
|
|
@@ -109,17 +112,17 @@ const QuestionPage = () => {
|
|
|
109
112
|
id: "sort-answers"
|
|
110
113
|
}
|
|
111
114
|
},
|
|
112
|
-
/* @__PURE__ */ React.createElement("option", { value: "default" }, "
|
|
113
|
-
/* @__PURE__ */ React.createElement("option", { value: "created_desc" },
|
|
114
|
-
/* @__PURE__ */ React.createElement("option", { value: "created_asc" },
|
|
115
|
-
/* @__PURE__ */ React.createElement("option", { value: "score_desc" },
|
|
116
|
-
/* @__PURE__ */ React.createElement("option", { value: "score_asc" },
|
|
117
|
-
/* @__PURE__ */ React.createElement("option", { value: "comments_desc" },
|
|
118
|
-
/* @__PURE__ */ React.createElement("option", { value: "comments_asc" },
|
|
119
|
-
/* @__PURE__ */ React.createElement("option", { value: "author_desc" },
|
|
120
|
-
/* @__PURE__ */ React.createElement("option", { value: "author_asc" },
|
|
121
|
-
/* @__PURE__ */ React.createElement("option", { value: "updated_desc" },
|
|
122
|
-
/* @__PURE__ */ React.createElement("option", { value: "updated_asc" },
|
|
115
|
+
/* @__PURE__ */ React.createElement("option", { value: "default" }, t("questionPage.sortAnswers.default")),
|
|
116
|
+
/* @__PURE__ */ React.createElement("option", { value: "created_desc" }, t("questionPage.sortAnswers.createdDesc")),
|
|
117
|
+
/* @__PURE__ */ React.createElement("option", { value: "created_asc" }, t("questionPage.sortAnswers.createdAsc")),
|
|
118
|
+
/* @__PURE__ */ React.createElement("option", { value: "score_desc" }, t("questionPage.sortAnswers.scoreDesc")),
|
|
119
|
+
/* @__PURE__ */ React.createElement("option", { value: "score_asc" }, t("questionPage.sortAnswers.scoreAsc")),
|
|
120
|
+
/* @__PURE__ */ React.createElement("option", { value: "comments_desc" }, t("questionPage.sortAnswers.commentsDesc")),
|
|
121
|
+
/* @__PURE__ */ React.createElement("option", { value: "comments_asc" }, t("questionPage.sortAnswers.commentsAsc")),
|
|
122
|
+
/* @__PURE__ */ React.createElement("option", { value: "author_desc" }, t("questionPage.sortAnswers.authorDesc")),
|
|
123
|
+
/* @__PURE__ */ React.createElement("option", { value: "author_asc" }, t("questionPage.sortAnswers.authorAsc")),
|
|
124
|
+
/* @__PURE__ */ React.createElement("option", { value: "updated_desc" }, t("questionPage.sortAnswers.updatedDesc")),
|
|
125
|
+
/* @__PURE__ */ React.createElement("option", { value: "updated_asc" }, t("questionPage.sortAnswers.updatedAsc"))
|
|
123
126
|
))))), allAnswers.sort(sortAnswers).map((a) => {
|
|
124
127
|
return /* @__PURE__ */ React.createElement(React.Fragment, { key: a.id }, /* @__PURE__ */ React.createElement(Divider, { className: styles.questionDivider }), /* @__PURE__ */ React.createElement(Box, { key: a.id, sx: { mb: 1 } }, /* @__PURE__ */ React.createElement(AnswerCard, { answer: a, question })));
|
|
125
128
|
}), /* @__PURE__ */ React.createElement(Divider, { className: styles.questionDivider }), /* @__PURE__ */ React.createElement(AnswerForm, { question, onPost: onAnswerPost })));
|