@drodil/backstage-plugin-qeta-react 3.7.2 → 3.9.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 +2 -2
- package/dist/components/AIAnswerCard/AIAnswerCard.esm.js.map +1 -1
- package/dist/components/AnswerCard/AnswerCard.esm.js +63 -53
- package/dist/components/AnswerCard/AnswerCard.esm.js.map +1 -1
- package/dist/components/AnswersContainer/AnswersContainer.esm.js +21 -17
- package/dist/components/AnswersContainer/AnswersContainer.esm.js.map +1 -1
- package/dist/components/CollectionsGrid/CollectionsGrid.esm.js +36 -10
- package/dist/components/CollectionsGrid/CollectionsGrid.esm.js.map +1 -1
- package/dist/components/CollectionsGrid/CollectionsGridContent.esm.js +9 -7
- package/dist/components/CollectionsGrid/CollectionsGridContent.esm.js.map +1 -1
- package/dist/components/EntitiesGrid/EntitiesGrid.esm.js +1 -5
- package/dist/components/EntitiesGrid/EntitiesGrid.esm.js.map +1 -1
- package/dist/components/EntitiesGrid/EntitiesGridContent.esm.js +12 -4
- package/dist/components/EntitiesGrid/EntitiesGridContent.esm.js.map +1 -1
- package/dist/components/FilterPanel/FilterPanel.esm.js +233 -180
- package/dist/components/FilterPanel/FilterPanel.esm.js.map +1 -1
- package/dist/components/HomePageCards/PostsCard.esm.js +7 -5
- package/dist/components/HomePageCards/PostsCard.esm.js.map +1 -1
- package/dist/components/LoadingGrid/LoadingGrid.esm.js +18 -0
- package/dist/components/LoadingGrid/LoadingGrid.esm.js.map +1 -0
- package/dist/components/PostForm/EntitiesInput.esm.js +64 -41
- package/dist/components/PostForm/EntitiesInput.esm.js.map +1 -1
- package/dist/components/PostForm/PostForm.esm.js +17 -4
- package/dist/components/PostForm/PostForm.esm.js.map +1 -1
- package/dist/components/PostForm/TagInput.esm.js +65 -45
- package/dist/components/PostForm/TagInput.esm.js.map +1 -1
- package/dist/components/PostsContainer/PostList.esm.js +10 -6
- package/dist/components/PostsContainer/PostList.esm.js.map +1 -1
- package/dist/components/PostsContainer/PostsContainer.esm.js +8 -1
- package/dist/components/PostsContainer/PostsContainer.esm.js.map +1 -1
- package/dist/components/PostsGrid/PostsGrid.esm.js +16 -4
- package/dist/components/PostsGrid/PostsGrid.esm.js.map +1 -1
- package/dist/components/PostsGrid/PostsGridContent.esm.js +20 -6
- package/dist/components/PostsGrid/PostsGridContent.esm.js.map +1 -1
- package/dist/components/PostsGrid/PostsGridItem.esm.js +33 -5
- package/dist/components/PostsGrid/PostsGridItem.esm.js.map +1 -1
- package/dist/components/QuestionCard/QuestionCard.esm.js +49 -39
- package/dist/components/QuestionCard/QuestionCard.esm.js.map +1 -1
- package/dist/components/TagsGrid/TagsGrid.esm.js +1 -5
- package/dist/components/TagsGrid/TagsGrid.esm.js.map +1 -1
- package/dist/components/TagsGrid/TagsGridContent.esm.js +12 -4
- package/dist/components/TagsGrid/TagsGridContent.esm.js.map +1 -1
- package/dist/components/TemplateList/TemplateForm.esm.js +11 -4
- package/dist/components/TemplateList/TemplateForm.esm.js.map +1 -1
- package/dist/components/UsersGrid/UsersGrid.esm.js +1 -5
- package/dist/components/UsersGrid/UsersGrid.esm.js.map +1 -1
- package/dist/components/UsersGrid/UsersGridContent.esm.js +14 -6
- package/dist/components/UsersGrid/UsersGridContent.esm.js.map +1 -1
- package/dist/hooks/useAI.esm.js +9 -0
- package/dist/hooks/useAI.esm.js.map +1 -1
- package/dist/hooks/usePaginatedPosts.esm.js +40 -26
- package/dist/hooks/usePaginatedPosts.esm.js.map +1 -1
- package/dist/hooks/useStyles.esm.js +2 -1
- package/dist/hooks/useStyles.esm.js.map +1 -1
- package/dist/index.d.ts +56 -29
- package/dist/translation.esm.js +29 -0
- package/dist/translation.esm.js.map +1 -1
- package/package.json +2 -2
|
@@ -9,7 +9,6 @@ import 'react-use/lib/useAsync';
|
|
|
9
9
|
import useDebounce from 'react-use/lib/useDebounce';
|
|
10
10
|
import { QetaPagination } from '../QetaPagination/QetaPagination.esm.js';
|
|
11
11
|
import { EntitiesGridContent } from './EntitiesGridContent.esm.js';
|
|
12
|
-
import { NoEntitiesCard } from './NoEntitiesCard.esm.js';
|
|
13
12
|
|
|
14
13
|
const EntitiesGrid = () => {
|
|
15
14
|
const [page, setPage] = React.useState(1);
|
|
@@ -51,9 +50,6 @@ const EntitiesGrid = () => {
|
|
|
51
50
|
setPageCount(Math.ceil(response.total / entitiesPerPage));
|
|
52
51
|
}
|
|
53
52
|
}, [response, entitiesPerPage]);
|
|
54
|
-
if (!response?.entities || response.entities.length === 0) {
|
|
55
|
-
return /* @__PURE__ */ React.createElement(NoEntitiesCard, null);
|
|
56
|
-
}
|
|
57
53
|
return /* @__PURE__ */ React.createElement(Grid, { container: true, className: "qetaEntitiesContainer" }, /* @__PURE__ */ React.createElement(Grid, { item: true, xs: 12 }, /* @__PURE__ */ React.createElement(
|
|
58
54
|
TextField,
|
|
59
55
|
{
|
|
@@ -72,7 +68,7 @@ const EntitiesGrid = () => {
|
|
|
72
68
|
loading,
|
|
73
69
|
error
|
|
74
70
|
}
|
|
75
|
-
), /* @__PURE__ */ React.createElement(
|
|
71
|
+
), response && response?.total > 0 && /* @__PURE__ */ React.createElement(
|
|
76
72
|
QetaPagination,
|
|
77
73
|
{
|
|
78
74
|
pageSize: entitiesPerPage,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EntitiesGrid.esm.js","sources":["../../../src/components/EntitiesGrid/EntitiesGrid.tsx"],"sourcesContent":["import { Grid, IconButton, TextField } from '@material-ui/core';\nimport React, { useEffect } from 'react';\nimport { useQetaApi, useTranslation } from '../../hooks';\nimport useDebounce from 'react-use/lib/useDebounce';\nimport { QetaPagination } from '../QetaPagination/QetaPagination';\nimport { EntitiesGridContent } from './EntitiesGridContent';\
|
|
1
|
+
{"version":3,"file":"EntitiesGrid.esm.js","sources":["../../../src/components/EntitiesGrid/EntitiesGrid.tsx"],"sourcesContent":["import { Grid, IconButton, TextField } from '@material-ui/core';\nimport React, { useEffect } from 'react';\nimport { useQetaApi, useTranslation } from '../../hooks';\nimport useDebounce from 'react-use/lib/useDebounce';\nimport { QetaPagination } from '../QetaPagination/QetaPagination';\nimport { EntitiesGridContent } from './EntitiesGridContent';\n\ntype EntityFilters = {\n order: 'asc' | 'desc';\n orderBy?: 'entityRef';\n searchQuery: string;\n};\n\nexport const EntitiesGrid = () => {\n const [page, setPage] = React.useState(1);\n const [pageCount, setPageCount] = React.useState(1);\n const [entitiesPerPage, setEntitiesPerPage] = React.useState(25);\n const [searchQuery, setSearchQuery] = React.useState('');\n const [filters, setFilters] = React.useState<EntityFilters>({\n order: 'desc',\n searchQuery: '',\n });\n const { t } = useTranslation();\n\n const {\n value: response,\n loading,\n error,\n } = useQetaApi(\n api =>\n api.getEntities({\n limit: entitiesPerPage,\n offset: (page - 1) * entitiesPerPage,\n ...filters,\n }),\n [entitiesPerPage, page, filters],\n );\n\n const onSearchQueryChange = (val: string) => {\n setPage(1);\n setSearchQuery(val);\n };\n\n useDebounce(\n () => {\n if (filters.searchQuery !== searchQuery) {\n setFilters({ ...filters, searchQuery: searchQuery });\n }\n },\n 400,\n [searchQuery],\n );\n\n useEffect(() => {\n if (response) {\n setPageCount(Math.ceil(response.total / entitiesPerPage));\n }\n }, [response, entitiesPerPage]);\n\n return (\n <Grid container className=\"qetaEntitiesContainer\">\n <Grid item xs={12}>\n <TextField\n id=\"search-bar\"\n className=\"text qetaEntitiesContainerSearchInput\"\n onChange={(\n event: React.ChangeEvent<HTMLTextAreaElement | HTMLInputElement>,\n ) => onSearchQueryChange(event.target.value)}\n label={t('entitiesPage.search.label')}\n variant=\"outlined\"\n placeholder={t('entitiesPage.search.placeholder')}\n size=\"small\"\n />\n <IconButton type=\"submit\" aria-label=\"search\" />\n </Grid>\n <EntitiesGridContent\n response={response}\n loading={loading}\n error={error}\n />\n {response && response?.total > 0 && (\n <QetaPagination\n pageSize={entitiesPerPage}\n handlePageChange={(_e, p) => setPage(p)}\n hand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;AAAA,GAED,EAAA,QAAA,IAAY,QAAU,EAAA,KAAA,GAAQ,CAC7B,oBAAA,KAAA,CAAA,aAAA;AAAA,IAAC,cAAA;AAAA,IAAA;AAAA,MACC,QAAU,EAAA,eAAA;AAAA,MACV,gBAAkB,EAAA,CAAC,EAAI,EAAA,CAAA,KAAM,QAAQ,CAAC,CAAA;AAAA,MACtC,sBAAsB,CAAK,CAAA,KAAA,kBAAA,CAAmB,OAAO,CAAE,CAAA,MAAA,CAAO,KAAK,CAAC,CAAA;AAAA,MACpE,IAAA;AAAA,MACA,SAAA;AAAA,KAAA;AAAA,GAGN,CAAA,CAAA;AAEJ;;;;"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Grid, Typography } from '@material-ui/core';
|
|
2
2
|
import React, { useState, useEffect } from 'react';
|
|
3
|
-
import {
|
|
3
|
+
import { WarningPanel } from '@backstage/core-components';
|
|
4
4
|
import '@backstage/core-plugin-api';
|
|
5
5
|
import '../../api.esm.js';
|
|
6
6
|
import 'react-use';
|
|
@@ -8,22 +8,30 @@ import { useTranslation } from '../../hooks/useTranslation.esm.js';
|
|
|
8
8
|
import '../../hooks/useStyles.esm.js';
|
|
9
9
|
import 'react-use/lib/useAsync';
|
|
10
10
|
import { EntitiesGridItem } from './EntitiesGridItem.esm.js';
|
|
11
|
+
import { NoEntitiesCard } from './NoEntitiesCard.esm.js';
|
|
12
|
+
import { LoadingGrid } from '../LoadingGrid/LoadingGrid.esm.js';
|
|
11
13
|
|
|
12
14
|
const EntitiesGridContent = (props) => {
|
|
13
15
|
const { response, loading, error } = props;
|
|
14
16
|
const { t } = useTranslation();
|
|
15
17
|
const [initialLoad, setInitialLoad] = useState(true);
|
|
16
18
|
useEffect(() => {
|
|
17
|
-
if (!
|
|
19
|
+
if (!loading) {
|
|
18
20
|
setInitialLoad(false);
|
|
19
21
|
}
|
|
20
22
|
}, [initialLoad, loading]);
|
|
21
|
-
if (loading
|
|
22
|
-
|
|
23
|
+
if (loading) {
|
|
24
|
+
if (initialLoad) {
|
|
25
|
+
return /* @__PURE__ */ React.createElement(LoadingGrid, null);
|
|
26
|
+
}
|
|
27
|
+
return null;
|
|
23
28
|
}
|
|
24
29
|
if (error || response === void 0) {
|
|
25
30
|
return /* @__PURE__ */ React.createElement(WarningPanel, { severity: "error", title: t("entitiesPage.errorLoading") }, error?.message);
|
|
26
31
|
}
|
|
32
|
+
if (!response?.entities || response.entities.length === 0) {
|
|
33
|
+
return /* @__PURE__ */ React.createElement(NoEntitiesCard, null);
|
|
34
|
+
}
|
|
27
35
|
return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(Grid, { item: true, xs: 12 }, /* @__PURE__ */ React.createElement(Typography, { variant: "h6", className: "qetaEntitiesContainerTitle" }, t("entitiesPage.entities", { count: response.total }))), /* @__PURE__ */ React.createElement(Grid, { container: true, item: true, xs: 12, alignItems: "stretch" }, response?.entities.map((entity) => /* @__PURE__ */ React.createElement(EntitiesGridItem, { entity, key: entity.entityRef }))));
|
|
28
36
|
};
|
|
29
37
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EntitiesGridContent.esm.js","sources":["../../../src/components/EntitiesGrid/EntitiesGridContent.tsx"],"sourcesContent":["import { Grid, Typography } from '@material-ui/core';\nimport React, { useEffect, useState } from 'react';\nimport { EntitiesResponse } from '@drodil/backstage-plugin-qeta-common';\nimport {
|
|
1
|
+
{"version":3,"file":"EntitiesGridContent.esm.js","sources":["../../../src/components/EntitiesGrid/EntitiesGridContent.tsx"],"sourcesContent":["import { Grid, Typography } from '@material-ui/core';\nimport React, { useEffect, useState } from 'react';\nimport { EntitiesResponse } from '@drodil/backstage-plugin-qeta-common';\nimport { WarningPanel } from '@backstage/core-components';\nimport { useTranslation } from '../../hooks';\nimport { EntitiesGridItem } from './EntitiesGridItem';\nimport { NoEntitiesCard } from './NoEntitiesCard';\nimport { LoadingGrid } from '../LoadingGrid/LoadingGrid';\n\nexport const EntitiesGridContent = (props: {\n loading: boolean;\n error: any;\n response?: EntitiesResponse;\n}) => {\n const { response, loading, error } = props;\n const { t } = useTranslation();\n const [initialLoad, setInitialLoad] = useState(true);\n useEffect(() => {\n if (!loading) {\n setInitialLoad(false);\n }\n }, [initialLoad, loading]);\n\n if (loading) {\n if (initialLoad) {\n return <LoadingGrid />;\n }\n return null;\n }\n\n if (error || response === undefined) {\n return (\n <WarningPanel severity=\"error\" title={t('entitiesPage.errorLoading')}>\n {error?.message}\n </WarningPanel>\n );\n }\n\n if (!response?.entities || response.entities.length === 0) {\n return <NoEntitiesCard />;\n }\n\n return (\n <>\n <Grid item xs={12}>\n <Typography variant=\"h6\" className=\"qetaEntitiesContainerTitle\">\n {t('entitiesPage.entities', { count: response.total })}\n </Typography>\n </Grid>\n <Grid container item xs={12} alignItems=\"stretch\">\n {response?.entities.map(entity => (\n <EntitiesGridItem entity={entity} key={entity.entityRef} />\n ))}\n </Grid>\n </>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;AASa,MAAA,mBAAA,GAAsB,CAAC,KAI9B,KAAA;AACJ,EAAA,MAAM,EAAE,QAAA,EAAU,OAAS,EAAA,KAAA,EAAU,GAAA,KAAA,CAAA;AACrC,EAAM,MAAA,EAAE,CAAE,EAAA,GAAI,cAAe,EAAA,CAAA;AAC7B,EAAA,MAAM,CAAC,WAAA,EAAa,cAAc,CAAA,GAAI,SAAS,IAAI,CAAA,CAAA;AACnD,EAAA,SAAA,CAAU,MAAM;AACd,IAAA,IAAI,CAAC,OAAS,EAAA;AACZ,MAAA,cAAA,CAAe,KAAK,CAAA,CAAA;AAAA,KACtB;AAAA,GACC,EAAA,CAAC,WAAa,EAAA,OAAO,CAAC,CAAA,CAAA;AAEzB,EAAA,IAAI,OAAS,EAAA;AACX,IAAA,IAAI,WAAa,EAAA;AACf,MAAA,2CAAQ,WAAY,EAAA,IAAA,CAAA,CAAA;AAAA,KACtB;AACA,IAAO,OAAA,IAAA,CAAA;AAAA,GACT;AAEA,EAAI,IAAA,KAAA,IAAS,aAAa,KAAW,CAAA,EAAA;AACnC,IACE,uBAAA,KAAA,CAAA,aAAA,CAAC,gBAAa,QAAS,EAAA,OAAA,EAAQ,OAAO,CAAE,CAAA,2BAA2B,CAChE,EAAA,EAAA,KAAA,EAAO,OACV,CAAA,CAAA;AAAA,GAEJ;AAEA,EAAA,IAAI,CAAC,QAAU,EAAA,QAAA,IAAY,QAAS,CAAA,QAAA,CAAS,WAAW,CAAG,EAAA;AACzD,IAAA,2CAAQ,cAAe,EAAA,IAAA,CAAA,CAAA;AAAA,GACzB;AAEA,EACE,uBAAA,KAAA,CAAA,aAAA,CAAA,KAAA,CAAA,QAAA,EAAA,IAAA,sCACG,IAAK,EAAA,EAAA,IAAA,EAAI,MAAC,EAAI,EAAA,EAAA,EAAA,sCACZ,UAAW,EAAA,EAAA,OAAA,EAAQ,MAAK,SAAU,EAAA,4BAAA,EAAA,EAChC,EAAE,uBAAyB,EAAA,EAAE,OAAO,QAAS,CAAA,KAAA,EAAO,CACvD,CACF,mBACC,KAAA,CAAA,aAAA,CAAA,IAAA,EAAA,EAAK,WAAS,IAAC,EAAA,IAAA,EAAI,MAAC,EAAI,EAAA,EAAA,EAAI,YAAW,SACrC,EAAA,EAAA,QAAA,EAAU,SAAS,GAAI,CAAA,CAAA,MAAA,yCACrB,gBAAiB,EAAA,EAAA,MAAA,EAAgB,KAAK,MAAO,CAAA,SAAA,EAAW,CAC1D,CACH,CACF,CAAA,CAAA;AAEJ;;;;"}
|
|
@@ -1,16 +1,18 @@
|
|
|
1
|
-
import React
|
|
2
|
-
import { Box, Grid, FormGroup, FormControlLabel, Checkbox, FormControl,
|
|
3
|
-
import { Autocomplete } from '@material-ui/lab';
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Box, Grid, FormGroup, FormLabel, FormControlLabel, Checkbox, FormControl, RadioGroup, Divider, Tooltip, IconButton, Radio } from '@material-ui/core';
|
|
4
3
|
import { stringifyEntityRef } from '@backstage/catalog-model';
|
|
5
|
-
import { useApi } from '@backstage/core-plugin-api';
|
|
6
|
-
import { catalogApiRef } from '@backstage/plugin-catalog-react';
|
|
7
|
-
import { getEntityTitle } from '../../utils/utils.esm.js';
|
|
8
4
|
import { DateRangeFilter } from './DateRangeFilter.esm.js';
|
|
9
|
-
import {
|
|
5
|
+
import { useApi, identityApiRef } from '@backstage/core-plugin-api';
|
|
10
6
|
import '../../api.esm.js';
|
|
7
|
+
import 'react-use';
|
|
11
8
|
import { useTranslation } from '../../hooks/useTranslation.esm.js';
|
|
12
9
|
import { useStyles } from '../../hooks/useStyles.esm.js';
|
|
13
10
|
import 'react-use/lib/useAsync';
|
|
11
|
+
import { EntitiesInput } from '../PostForm/EntitiesInput.esm.js';
|
|
12
|
+
import { TagInput } from '../PostForm/TagInput.esm.js';
|
|
13
|
+
import { useStarredEntities, catalogApiRef } from '@backstage/plugin-catalog-react';
|
|
14
|
+
import FiberManualRecordIcon from '@material-ui/icons/FiberManualRecord';
|
|
15
|
+
import AdjustIcon from '@material-ui/icons/Adjust';
|
|
14
16
|
|
|
15
17
|
const radioSelect = (value, label) => {
|
|
16
18
|
return /* @__PURE__ */ React.createElement(
|
|
@@ -28,214 +30,265 @@ const filterKeys = [
|
|
|
28
30
|
"noAnswers",
|
|
29
31
|
"noCorrectAnswer",
|
|
30
32
|
"noVotes",
|
|
31
|
-
"entity",
|
|
32
33
|
"tags",
|
|
33
34
|
"dateRange"
|
|
34
35
|
];
|
|
36
|
+
function isPostFilters(filters) {
|
|
37
|
+
return filters.noAnswers !== void 0;
|
|
38
|
+
}
|
|
39
|
+
function isAnswerFilters(filters) {
|
|
40
|
+
return filters.noVotes !== void 0 && filters.noAnswers === void 0;
|
|
41
|
+
}
|
|
42
|
+
function isCollectionFilters(filters) {
|
|
43
|
+
return filters.noAnswers === void 0;
|
|
44
|
+
}
|
|
35
45
|
const FilterPanel = (props) => {
|
|
36
46
|
const {
|
|
37
47
|
onChange,
|
|
38
48
|
filters,
|
|
39
49
|
showEntityFilter = true,
|
|
40
50
|
showTagFilter = true,
|
|
41
|
-
answerFilters = false,
|
|
42
51
|
type
|
|
43
52
|
} = props;
|
|
44
53
|
const styles = useStyles();
|
|
45
|
-
const { value: refs } = useQetaApi((api) => api.getEntities(), []);
|
|
46
|
-
const { value: tags } = useQetaApi((api) => api.getTags(), []);
|
|
47
|
-
const catalogApi = useApi(catalogApiRef);
|
|
48
54
|
const { t } = useTranslation();
|
|
49
|
-
const [
|
|
50
|
-
|
|
51
|
-
const [availableTags, setAvailableTags] = React.useState(
|
|
52
|
-
null
|
|
55
|
+
const [entities, setEntities] = React.useState(
|
|
56
|
+
void 0
|
|
53
57
|
);
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
useEffect(() => {
|
|
64
|
-
const entityRefs = [];
|
|
65
|
-
if (filters.entity && !Array.isArray(filters.entity)) {
|
|
66
|
-
entityRefs.push(filters.entity);
|
|
58
|
+
const [starredEntities, setStarredEntities] = React.useState(false);
|
|
59
|
+
const [ownedEntities, setOwnedEntities] = React.useState(false);
|
|
60
|
+
const starredEntitiesApi = useStarredEntities();
|
|
61
|
+
const catalogApi = useApi(catalogApiRef);
|
|
62
|
+
const identityApi = useApi(identityApiRef);
|
|
63
|
+
const handleChange = (event) => {
|
|
64
|
+
let value = event.target.value;
|
|
65
|
+
if (event.target.type === "checkbox") {
|
|
66
|
+
value = event.target.checked ? "true" : "false";
|
|
67
67
|
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
68
|
+
onChange({ key: event.target.name, value });
|
|
69
|
+
};
|
|
70
|
+
const handleStarredEntities = (checked) => {
|
|
71
|
+
setStarredEntities(checked);
|
|
72
|
+
setEntities([]);
|
|
73
|
+
if (checked) {
|
|
74
|
+
onChange({
|
|
75
|
+
key: "entities",
|
|
76
|
+
value: [...starredEntitiesApi.starredEntities]
|
|
73
77
|
});
|
|
78
|
+
} else {
|
|
79
|
+
onChange({ key: "entities", value: [] });
|
|
74
80
|
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
81
|
+
};
|
|
82
|
+
const handleOwnedEntities = (checked) => {
|
|
83
|
+
setOwnedEntities(checked);
|
|
84
|
+
setEntities([]);
|
|
85
|
+
if (checked) {
|
|
86
|
+
identityApi.getBackstageIdentity().then((identity) => {
|
|
87
|
+
catalogApi.getEntities({
|
|
88
|
+
filter: {
|
|
89
|
+
"spec.owner": identity.ownershipEntityRefs
|
|
90
|
+
},
|
|
91
|
+
fields: ["kind", "metadata.name", "metadata.namespace"]
|
|
92
|
+
}).then((data) => {
|
|
93
|
+
const entityRefs = data.items.map((e) => stringifyEntityRef(e));
|
|
94
|
+
onChange([
|
|
95
|
+
{ key: "entities", value: entityRefs },
|
|
96
|
+
{ key: "entitiesRelation", value: "or" }
|
|
97
|
+
]);
|
|
98
|
+
});
|
|
87
99
|
});
|
|
88
|
-
}
|
|
89
|
-
}, [filters.entity, catalogApi, refs]);
|
|
90
|
-
useEffect(() => {
|
|
91
|
-
if (filters.entity && availableEntities) {
|
|
92
|
-
const value = availableEntities.find(
|
|
93
|
-
(e) => stringifyEntityRef(e) === filters.entity
|
|
94
|
-
);
|
|
95
|
-
setSelectedEntity(value);
|
|
96
|
-
if (!value) {
|
|
97
|
-
onChange("entity", "");
|
|
98
|
-
}
|
|
99
100
|
} else {
|
|
100
|
-
|
|
101
|
+
onChange([
|
|
102
|
+
{ key: "entities", value: [] },
|
|
103
|
+
{ key: "entitiesRelation", value: "and" }
|
|
104
|
+
]);
|
|
101
105
|
}
|
|
102
|
-
}, [availableEntities, filters.entity, onChange]);
|
|
103
|
-
const handleChange = (event) => {
|
|
104
|
-
let value = event.target.value;
|
|
105
|
-
if (event.target.type === "checkbox") {
|
|
106
|
-
value = event.target.checked ? "true" : "false";
|
|
107
|
-
}
|
|
108
|
-
onChange(event.target.name, value);
|
|
109
106
|
};
|
|
110
|
-
|
|
111
|
-
|
|
107
|
+
const postFilters = isPostFilters(filters);
|
|
108
|
+
const answerFilters = isAnswerFilters(filters);
|
|
109
|
+
const collectionFilters = isCollectionFilters(filters);
|
|
110
|
+
return /* @__PURE__ */ React.createElement(Box, { className: `qetaFilterPanel ${styles.filterPanel}` }, /* @__PURE__ */ React.createElement(
|
|
111
|
+
Grid,
|
|
112
112
|
{
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
113
|
+
container: true,
|
|
114
|
+
spacing: 4,
|
|
115
|
+
alignItems: "stretch",
|
|
116
|
+
justifyContent: "space-evenly"
|
|
117
|
+
},
|
|
118
|
+
(postFilters || answerFilters) && /* @__PURE__ */ React.createElement(Grid, { item: true }, /* @__PURE__ */ React.createElement(FormGroup, null, /* @__PURE__ */ React.createElement(FormLabel, { id: "qeta-filter-quick" }, t("filterPanel.quickFilters.label")), postFilters && type !== "article" && /* @__PURE__ */ React.createElement(
|
|
119
|
+
FormControlLabel,
|
|
120
|
+
{
|
|
121
|
+
control: /* @__PURE__ */ React.createElement(
|
|
122
|
+
Checkbox,
|
|
123
|
+
{
|
|
124
|
+
size: "small",
|
|
125
|
+
name: "noAnswers",
|
|
126
|
+
onChange: handleChange,
|
|
127
|
+
checked: filters.noAnswers === "true"
|
|
128
|
+
}
|
|
129
|
+
),
|
|
130
|
+
label: t("filterPanel.noAnswers.label")
|
|
131
|
+
}
|
|
132
|
+
), (postFilters || answerFilters) && type !== "article" && /* @__PURE__ */ React.createElement(
|
|
133
|
+
FormControlLabel,
|
|
134
|
+
{
|
|
135
|
+
control: /* @__PURE__ */ React.createElement(
|
|
136
|
+
Checkbox,
|
|
137
|
+
{
|
|
138
|
+
size: "small",
|
|
139
|
+
name: "noCorrectAnswer",
|
|
140
|
+
checked: filters.noCorrectAnswer === "true",
|
|
141
|
+
onChange: handleChange
|
|
142
|
+
}
|
|
143
|
+
),
|
|
144
|
+
label: t("filterPanel.noCorrectAnswers.label")
|
|
145
|
+
}
|
|
146
|
+
), (postFilters || answerFilters) && /* @__PURE__ */ React.createElement(
|
|
147
|
+
FormControlLabel,
|
|
148
|
+
{
|
|
149
|
+
control: /* @__PURE__ */ React.createElement(
|
|
150
|
+
Checkbox,
|
|
151
|
+
{
|
|
152
|
+
size: "small",
|
|
153
|
+
name: "noVotes",
|
|
154
|
+
checked: filters.noVotes === "true",
|
|
155
|
+
onChange: handleChange
|
|
156
|
+
}
|
|
157
|
+
),
|
|
158
|
+
label: t("filterPanel.noVotes.label")
|
|
159
|
+
}
|
|
160
|
+
), starredEntitiesApi.starredEntities.size > 0 && /* @__PURE__ */ React.createElement(
|
|
161
|
+
FormControlLabel,
|
|
162
|
+
{
|
|
163
|
+
control: /* @__PURE__ */ React.createElement(
|
|
164
|
+
Checkbox,
|
|
165
|
+
{
|
|
166
|
+
size: "small",
|
|
167
|
+
name: "starredEntities",
|
|
168
|
+
onChange: (e) => handleStarredEntities(e.target.checked),
|
|
169
|
+
checked: starredEntities
|
|
170
|
+
}
|
|
171
|
+
),
|
|
172
|
+
label: t("filterPanel.starredEntities.label")
|
|
173
|
+
}
|
|
174
|
+
), /* @__PURE__ */ React.createElement(
|
|
175
|
+
FormControlLabel,
|
|
176
|
+
{
|
|
177
|
+
control: /* @__PURE__ */ React.createElement(
|
|
178
|
+
Checkbox,
|
|
179
|
+
{
|
|
180
|
+
size: "small",
|
|
181
|
+
name: "ownedEntities",
|
|
182
|
+
onChange: (e) => handleOwnedEntities(e.target.checked),
|
|
183
|
+
checked: ownedEntities
|
|
184
|
+
}
|
|
185
|
+
),
|
|
186
|
+
label: t("filterPanel.ownedEntities.label")
|
|
187
|
+
}
|
|
188
|
+
))),
|
|
189
|
+
/* @__PURE__ */ React.createElement(Grid, { item: true }, /* @__PURE__ */ React.createElement(FormControl, null, /* @__PURE__ */ React.createElement(FormLabel, { id: "qeta-filter-order-by" }, t("filterPanel.orderBy.label")), /* @__PURE__ */ React.createElement(
|
|
190
|
+
RadioGroup,
|
|
191
|
+
{
|
|
192
|
+
"aria-labelledby": "qeta-filter-order-by",
|
|
193
|
+
name: "orderBy",
|
|
194
|
+
value: filters.orderBy,
|
|
195
|
+
onChange: handleChange,
|
|
196
|
+
style: {
|
|
197
|
+
display: "grid",
|
|
198
|
+
gridTemplateColumns: "1fr 1fr",
|
|
199
|
+
gap: "0 1rem"
|
|
120
200
|
}
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
201
|
+
},
|
|
202
|
+
postFilters && filters.collectionId !== void 0 && radioSelect("rank", t("filterPanel.orderBy.rank")),
|
|
203
|
+
radioSelect("created", t("filterPanel.orderBy.created")),
|
|
204
|
+
(postFilters || collectionFilters) && radioSelect("title", t("filterPanel.orderBy.title")),
|
|
205
|
+
postFilters && radioSelect("views", t("filterPanel.orderBy.views")),
|
|
206
|
+
(postFilters || answerFilters) && radioSelect("score", t("filterPanel.orderBy.score")),
|
|
207
|
+
postFilters && radioSelect("trend", t("filterPanel.orderBy.trend")),
|
|
208
|
+
postFilters && type !== "article" && radioSelect("answersCount", t("filterPanel.orderBy.answers")),
|
|
209
|
+
(postFilters || answerFilters) && radioSelect("updated", t("filterPanel.orderBy.updated"))
|
|
210
|
+
))),
|
|
211
|
+
/* @__PURE__ */ React.createElement(Grid, { item: true }, /* @__PURE__ */ React.createElement(FormControl, null, /* @__PURE__ */ React.createElement(FormLabel, { id: "qeta-filter-order" }, t("filterPanel.order.label")), /* @__PURE__ */ React.createElement(
|
|
212
|
+
RadioGroup,
|
|
213
|
+
{
|
|
214
|
+
"aria-labelledby": "qeta-filter-order",
|
|
215
|
+
name: "order",
|
|
216
|
+
value: filters.order,
|
|
217
|
+
onChange: handleChange
|
|
218
|
+
},
|
|
219
|
+
radioSelect("desc", t("filterPanel.order.desc")),
|
|
220
|
+
radioSelect("asc", t("filterPanel.order.asc"))
|
|
221
|
+
)))
|
|
222
|
+
), /* @__PURE__ */ React.createElement(Box, { marginY: "24px" }, /* @__PURE__ */ React.createElement(Divider, null)), /* @__PURE__ */ React.createElement(Grid, { container: true, alignItems: "stretch", justifyContent: "space-evenly" }, /* @__PURE__ */ React.createElement(Grid, { item: true }, /* @__PURE__ */ React.createElement(
|
|
223
|
+
DateRangeFilter,
|
|
126
224
|
{
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
{
|
|
130
|
-
size: "small",
|
|
131
|
-
name: "noCorrectAnswer",
|
|
132
|
-
checked: filters.noCorrectAnswer === "true",
|
|
133
|
-
onChange: handleChange
|
|
134
|
-
}
|
|
135
|
-
),
|
|
136
|
-
label: t("filterPanel.noCorrectAnswers.label")
|
|
225
|
+
value: filters.dateRange,
|
|
226
|
+
onChange: (e) => onChange({ key: "dateRange", value: e })
|
|
137
227
|
}
|
|
138
|
-
), /* @__PURE__ */ React.createElement(
|
|
139
|
-
|
|
228
|
+
)), showEntityFilter && /* @__PURE__ */ React.createElement(Grid, { item: true }, /* @__PURE__ */ React.createElement(Grid, { container: true, alignItems: "center" }, /* @__PURE__ */ React.createElement(Grid, { item: true }, /* @__PURE__ */ React.createElement(
|
|
229
|
+
EntitiesInput,
|
|
140
230
|
{
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
231
|
+
disabled: starredEntities || ownedEntities,
|
|
232
|
+
style: { minWidth: "200px" },
|
|
233
|
+
onChange: (newEntities) => {
|
|
234
|
+
const entityRefs = (newEntities ?? []).map(
|
|
235
|
+
(e) => stringifyEntityRef(e)
|
|
236
|
+
);
|
|
237
|
+
handleChange({
|
|
238
|
+
target: { name: "entities", value: entityRefs }
|
|
239
|
+
});
|
|
240
|
+
setEntities(newEntities);
|
|
241
|
+
},
|
|
242
|
+
value: entities,
|
|
243
|
+
useOnlyUsedEntities: true,
|
|
244
|
+
hideHelpText: true
|
|
151
245
|
}
|
|
152
|
-
))
|
|
153
|
-
|
|
246
|
+
)), filters.entities && filters.entities?.length > 1 && /* @__PURE__ */ React.createElement(Grid, { item: true }, /* @__PURE__ */ React.createElement(
|
|
247
|
+
Tooltip,
|
|
154
248
|
{
|
|
155
|
-
"
|
|
156
|
-
name: "orderBy",
|
|
157
|
-
value: filters.orderBy,
|
|
158
|
-
onChange: handleChange
|
|
249
|
+
title: filters.entitiesRelation === "or" ? t("filterPanel.toggleEntityRelation.and") : t("filterPanel.toggleEntityRelation.or")
|
|
159
250
|
},
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
"aria-labelledby": "qeta-filter-order",
|
|
169
|
-
name: "order",
|
|
170
|
-
value: filters.order,
|
|
171
|
-
onChange: handleChange
|
|
172
|
-
},
|
|
173
|
-
radioSelect("desc", t("filterPanel.order.desc")),
|
|
174
|
-
radioSelect("asc", t("filterPanel.order.asc"))
|
|
175
|
-
))), (availableEntities && availableEntities.length > 0 || availableTags && availableTags.length > 0) && (showEntityFilter || showTagFilter) && /* @__PURE__ */ React.createElement(Grid, { item: true, md: 4, xs: 8 }, /* @__PURE__ */ React.createElement(FormLabel, { id: "qeta-filter-entity" }, t("filterPanel.filters.label")), showEntityFilter && availableEntities && availableEntities.length > 0 && /* @__PURE__ */ React.createElement(
|
|
176
|
-
Autocomplete,
|
|
177
|
-
{
|
|
178
|
-
multiple: false,
|
|
179
|
-
className: "qetaEntityFilter",
|
|
180
|
-
value: selectedEntity ?? null,
|
|
181
|
-
id: "entities-select",
|
|
182
|
-
options: availableEntities,
|
|
183
|
-
getOptionLabel: getEntityTitle,
|
|
184
|
-
getOptionSelected: (o, v) => {
|
|
185
|
-
if (!o || !v) {
|
|
186
|
-
return false;
|
|
187
|
-
}
|
|
188
|
-
return stringifyEntityRef(o) === stringifyEntityRef(v);
|
|
189
|
-
},
|
|
190
|
-
onChange: (_e, newValue) => {
|
|
191
|
-
handleChange({
|
|
192
|
-
target: {
|
|
193
|
-
name: "entity",
|
|
194
|
-
value: newValue ? stringifyEntityRef(newValue) : ""
|
|
251
|
+
/* @__PURE__ */ React.createElement(
|
|
252
|
+
IconButton,
|
|
253
|
+
{
|
|
254
|
+
onClick: () => {
|
|
255
|
+
if (filters.entitiesRelation === "or") {
|
|
256
|
+
onChange({ key: "entitiesRelation", value: "and" });
|
|
257
|
+
} else {
|
|
258
|
+
onChange({ key: "entitiesRelation", value: "or" });
|
|
195
259
|
}
|
|
196
|
-
});
|
|
197
|
-
},
|
|
198
|
-
renderInput: (params) => /* @__PURE__ */ React.createElement(
|
|
199
|
-
TextField,
|
|
200
|
-
{
|
|
201
|
-
...params,
|
|
202
|
-
variant: "outlined",
|
|
203
|
-
margin: "normal",
|
|
204
|
-
label: t("filterPanel.filters.entity.label"),
|
|
205
|
-
placeholder: t(
|
|
206
|
-
"filterPanel.filters.entity.placeholder"
|
|
207
|
-
)
|
|
208
260
|
}
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
261
|
+
},
|
|
262
|
+
filters.entitiesRelation === "or" ? /* @__PURE__ */ React.createElement(AdjustIcon, null) : /* @__PURE__ */ React.createElement(FiberManualRecordIcon, null)
|
|
263
|
+
)
|
|
264
|
+
)))), showTagFilter && /* @__PURE__ */ React.createElement(Grid, { item: true }, /* @__PURE__ */ React.createElement(Grid, { container: true, alignItems: "center" }, /* @__PURE__ */ React.createElement(Grid, { item: true }, /* @__PURE__ */ React.createElement(
|
|
265
|
+
TagInput,
|
|
213
266
|
{
|
|
214
|
-
|
|
215
|
-
|
|
267
|
+
style: { minWidth: "200px" },
|
|
268
|
+
onChange: (newTags) => onChange({ key: "tags", value: newTags }),
|
|
216
269
|
value: filters.tags,
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
270
|
+
hideHelpText: true,
|
|
271
|
+
allowCreate: false
|
|
272
|
+
}
|
|
273
|
+
)), filters.tags && filters.tags?.length > 1 && /* @__PURE__ */ React.createElement(Grid, { item: true }, /* @__PURE__ */ React.createElement(
|
|
274
|
+
Tooltip,
|
|
275
|
+
{
|
|
276
|
+
title: filters.tagsRelation === "or" ? t("filterPanel.toggleTagRelation.and") : t("filterPanel.toggleTagRelation.or")
|
|
277
|
+
},
|
|
278
|
+
/* @__PURE__ */ React.createElement(
|
|
279
|
+
IconButton,
|
|
280
|
+
{
|
|
281
|
+
onClick: () => {
|
|
282
|
+
if (filters.tagsRelation === "or") {
|
|
283
|
+
onChange({ key: "tagsRelation", value: "and" });
|
|
284
|
+
} else {
|
|
285
|
+
onChange({ key: "tagsRelation", value: "or" });
|
|
224
286
|
}
|
|
225
|
-
});
|
|
226
|
-
},
|
|
227
|
-
renderInput: (params) => /* @__PURE__ */ React.createElement(
|
|
228
|
-
TextField,
|
|
229
|
-
{
|
|
230
|
-
...params,
|
|
231
|
-
variant: "outlined",
|
|
232
|
-
margin: "normal",
|
|
233
|
-
label: t("filterPanel.filters.tag.label"),
|
|
234
|
-
placeholder: t("filterPanel.filters.tag.placeholder")
|
|
235
287
|
}
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
288
|
+
},
|
|
289
|
+
filters.tagsRelation === "or" ? /* @__PURE__ */ React.createElement(AdjustIcon, null) : /* @__PURE__ */ React.createElement(FiberManualRecordIcon, null)
|
|
290
|
+
)
|
|
291
|
+
))))));
|
|
239
292
|
};
|
|
240
293
|
|
|
241
294
|
export { FilterPanel, filterKeys };
|