@drodil/backstage-plugin-qeta-react 3.54.0 → 3.55.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/AuthorBox/AuthorBox.esm.js +0 -1
- package/dist/components/AuthorBox/AuthorBox.esm.js.map +1 -1
- package/dist/components/Badges/BadgeChip.esm.js +23 -4
- package/dist/components/Badges/BadgeChip.esm.js.map +1 -1
- package/dist/components/Badges/UserBadges.esm.js +3 -3
- package/dist/components/Badges/UserBadges.esm.js.map +1 -1
- package/dist/components/CollectionForm/CollectionForm.esm.js +99 -6
- package/dist/components/CollectionForm/CollectionForm.esm.js.map +1 -1
- package/dist/components/CollectionsContainer/CollectionsGridItem.esm.js +8 -1
- package/dist/components/CollectionsContainer/CollectionsGridItem.esm.js.map +1 -1
- package/dist/components/FollowedLists/FollowedCollectionsList.esm.js +1 -1
- package/dist/components/FollowedLists/FollowedCollectionsList.esm.js.map +1 -1
- package/dist/components/FollowedLists/FollowedEntitiesList.esm.js +1 -1
- package/dist/components/FollowedLists/FollowedEntitiesList.esm.js.map +1 -1
- package/dist/components/FollowedLists/FollowedTagsList.esm.js +1 -1
- package/dist/components/FollowedLists/FollowedTagsList.esm.js.map +1 -1
- package/dist/components/FollowedLists/FollowedUsersList.esm.js +1 -1
- package/dist/components/FollowedLists/FollowedUsersList.esm.js.map +1 -1
- package/dist/components/HeaderImageInput/HeaderImageInput.esm.js +1 -1
- package/dist/components/HeaderImageInput/HeaderImageInput.esm.js.map +1 -1
- package/dist/components/PostForm/TagInput.esm.js +4 -3
- package/dist/components/PostForm/TagInput.esm.js.map +1 -1
- package/dist/components/PostsContainer/PostsGridItem.esm.js +51 -38
- package/dist/components/PostsContainer/PostsGridItem.esm.js.map +1 -1
- package/dist/components/TagsAndEntities/TagChip.esm.js +2 -2
- package/dist/components/TagsAndEntities/TagChip.esm.js.map +1 -1
- package/dist/components/TagsAndEntities/TagsAndEntities.esm.js +30 -4
- package/dist/components/TagsAndEntities/TagsAndEntities.esm.js.map +1 -1
- package/dist/components/Utility/RightList.esm.js +39 -3
- package/dist/components/Utility/RightList.esm.js.map +1 -1
- package/dist/hooks/useEntityAuthor.esm.js +35 -26
- package/dist/hooks/useEntityAuthor.esm.js.map +1 -1
- package/dist/index.d.ts +8 -0
- package/dist/translation.esm.js +18 -2
- package/dist/translation.esm.js.map +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TagChip.esm.js","sources":["../../../src/components/TagsAndEntities/TagChip.tsx"],"sourcesContent":["import { CSSProperties, useEffect, useState } from 'react';\nimport { useApi, useRouteRef } from '@backstage/core-plugin-api';\nimport { tagRouteRef } from '../../routes';\nimport { qetaApiRef } from '../../api';\nimport { TagResponse } from '@drodil/backstage-plugin-qeta-common';\nimport { MarkdownRenderer } from '../MarkdownRenderer/MarkdownRenderer';\nimport { useTagsFollow } from '../../hooks';\nimport { Link } from 'react-router-dom';\nimport {\n Box,\n Button,\n Chip,\n Grid,\n Tooltip,\n Typography,\n} from '@material-ui/core';\nimport VisibilityOff from '@material-ui/icons/VisibilityOff';\nimport Visibility from '@material-ui/icons/Visibility';\nimport LoyaltyOutlined from '@material-ui/icons/LoyaltyOutlined';\nimport { useTranslationRef } from '@backstage/core-plugin-api/alpha';\nimport { qetaTranslationRef } from '../../translation.ts';\nimport { useTooltipStyles } from '../../hooks/useTooltipStyles';\n\nconst cache: Map<string, TagResponse> = new Map();\n\nconst TagTooltip = (props: { tag: string }) => {\n const { tag } = props;\n const qetaApi = useApi(qetaApiRef);\n const { t } = useTranslationRef(qetaTranslationRef);\n const tags = useTagsFollow();\n const [resp, setResp] = useState<undefined | TagResponse>();\n\n useEffect(() => {\n if (cache.has(tag)) {\n setResp(cache.get(tag));\n return;\n }\n\n qetaApi.getTag(tag).then(res => {\n if (res) {\n cache.set(tag, res);\n setResp(res);\n } else {\n setResp({\n id: 0,\n tag,\n postsCount: 0,\n questionsCount: 0,\n articlesCount: 0,\n linksCount: 0,\n followerCount: 0,\n description: t('tagChip.nonExistingTag'),\n });\n }\n });\n }, [qetaApi, tag, t]);\n\n if (!resp) {\n return null;\n }\n\n return (\n <Grid container style={{ padding: '0.5em' }} spacing={1}>\n <Grid item xs={12}>\n <Box style={{ display: 'flex', alignItems: 'center' }}>\n <LoyaltyOutlined fontSize=\"small\" />\n <Typography\n variant=\"subtitle1\"\n style={{\n textOverflow: 'ellipsis',\n overflow: 'hidden',\n whiteSpace: 'nowrap',\n }}\n >\n {tag}\n </Typography>\n </Box>\n {resp.id > 0 && (\n <Typography variant=\"subtitle2\">\n {t('common.posts', { count: resp.postsCount, itemType: 'post' })}\n {' · '}\n {t('common.followers', { count: resp.followerCount })}\n </Typography>\n )}\n </Grid>\n {resp.description && (\n <Grid item xs={12}>\n <MarkdownRenderer content={resp.description} />\n </Grid>\n )}\n {!tags.loading && resp.id !== 0 && (\n <Grid item xs={12}>\n <Button\n size=\"small\"\n variant=\"outlined\"\n color={tags.isFollowingTag(tag) ? 'secondary' : 'primary'}\n onClick={() => {\n if (tags.isFollowingTag(tag)) {\n tags.unfollowTag(tag);\n } else {\n tags.followTag(tag);\n }\n }}\n startIcon={\n tags.isFollowingTag(tag) ? <VisibilityOff /> : <Visibility />\n }\n >\n {tags.isFollowingTag(tag)\n ? t('tagButton.unfollow')\n : t('tagButton.follow')}\n </Button>\n </Grid>\n )}\n </Grid>\n );\n};\n\nexport const TagChip = (props: {\n tag: string;\n style?: CSSProperties;\n useHref?: boolean;\n}) => {\n const tagRoute = useRouteRef(tagRouteRef);\n const { tag } = props;\n const classes = useTooltipStyles();\n const href = tagRoute({ tag });\n\n return (\n <Tooltip\n arrow\n title={<TagTooltip tag={tag} />}\n enterDelay={400}\n interactive\n classes={{\n tooltip: classes.tooltip,\n arrow: classes.tooltipArrow,\n }}\n >\n <Chip\n label={tag}\n size=\"small\"\n className=\"qetaTagChip\"\n component={props.useHref ? 'a' : Link}\n style={props.style}\n to={props.useHref ? undefined : href}\n href={props.useHref ? href : undefined}\n target={props.useHref ? '_blank' : undefined}\n onClick={(e: React.MouseEvent) => {\n e.stopPropagation();\n }}\n clickable\n />\n </Tooltip>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuBA,MAAM,KAAA,uBAAsC,GAAI,EAAA;AAEhD,MAAM,UAAA,GAAa,CAAC,KAA2B,KAAA;AAC7C,EAAM,MAAA,EAAE,KAAQ,GAAA,KAAA;AAChB,EAAM,MAAA,OAAA,GAAU,OAAO,UAAU,CAAA;AACjC,EAAA,MAAM,EAAE,CAAA,EAAM,GAAA,iBAAA,CAAkB,kBAAkB,CAAA;AAClD,EAAA,MAAM,OAAO,aAAc,EAAA;AAC3B,EAAA,MAAM,CAAC,IAAA,EAAM,OAAO,CAAA,GAAI,QAAkC,EAAA;AAE1D,EAAA,SAAA,CAAU,MAAM;AACd,IAAI,IAAA,KAAA,CAAM,GAAI,CAAA,GAAG,CAAG,EAAA;AAClB,MAAQ,OAAA,CAAA,KAAA,CAAM,GAAI,CAAA,GAAG,CAAC,CAAA;AACtB,MAAA;AAAA;AAGF,IAAA,OAAA,CAAQ,MAAO,CAAA,GAAG,CAAE,CAAA,IAAA,CAAK,CAAO,GAAA,KAAA;AAC9B,MAAA,IAAI,GAAK,EAAA;AACP,QAAM,KAAA,CAAA,GAAA,CAAI,KAAK,GAAG,CAAA;AAClB,QAAA,OAAA,CAAQ,GAAG,CAAA;AAAA,OACN,MAAA;AACL,QAAQ,OAAA,CAAA;AAAA,UACN,EAAI,EAAA,CAAA;AAAA,UACJ,GAAA;AAAA,UACA,UAAY,EAAA,CAAA;AAAA,UACZ,cAAgB,EAAA,CAAA;AAAA,UAChB,aAAe,EAAA,CAAA;AAAA,UACf,UAAY,EAAA,CAAA;AAAA,UACZ,aAAe,EAAA,CAAA;AAAA,UACf,WAAA,EAAa,EAAE,wBAAwB;AAAA,SACxC,CAAA;AAAA;AACH,KACD,CAAA;AAAA,GACA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,EAAA,EACb,QAAC,kBAAA,GAAA,CAAA,gBAAA,EAAA,EAAiB,OAAS,EAAA,IAAA,CAAK,aAAa,CAC/C,EAAA,CAAA;AAAA,IAED,CAAC,IAAK,CAAA,OAAA,IAAW,IAAK,CAAA,EAAA,KAAO,CAC5B,oBAAA,GAAA,CAAC,IAAK,EAAA,EAAA,IAAA,EAAI,IAAC,EAAA,EAAA,EAAI,EACb,EAAA,QAAA,kBAAA,GAAA;AAAA,MAAC,MAAA;AAAA,MAAA;AAAA,QACC,IAAK,EAAA,OAAA;AAAA,QACL,OAAQ,EAAA,UAAA;AAAA,QACR,KAAO,EAAA,IAAA,CAAK,cAAe,CAAA,GAAG,IAAI,WAAc,GAAA,SAAA;AAAA,QAChD,SAAS,MAAM;AACb,UAAI,IAAA,IAAA,CAAK,cAAe,CAAA,GAAG,CAAG,EAAA;AAC5B,YAAA,IAAA,CAAK,YAAY,GAAG,CAAA;AAAA,WACf,MAAA;AACL,YAAA,IAAA,CAAK,UAAU,GAAG,CAAA;AAAA;AACpB,SACF;AAAA,QACA,SAAA,EACE,KAAK,cAAe,CAAA,GAAG,oBAAK,GAAA,CAAA,aAAA,EAAA,EAAc,CAAK,mBAAA,GAAA,CAAC,UAAW,EAAA,EAAA,CAAA;AAAA,QAG5D,QAAA,EAAA,IAAA,CAAK,eAAe,GAAG,CAAA,GACpB,EAAE,oBAAoB,CAAA,GACtB,EAAE,kBAAkB;AAAA;AAAA,KAE5B,EAAA;AAAA,GAEJ,EAAA,CAAA;AAEJ,CAAA;AAEa,MAAA,OAAA,GAAU,CAAC,
|
|
1
|
+
{"version":3,"file":"TagChip.esm.js","sources":["../../../src/components/TagsAndEntities/TagChip.tsx"],"sourcesContent":["import { CSSProperties, useEffect, useState } from 'react';\nimport { useApi, useRouteRef } from '@backstage/core-plugin-api';\nimport { tagRouteRef } from '../../routes';\nimport { qetaApiRef } from '../../api';\nimport { TagResponse } from '@drodil/backstage-plugin-qeta-common';\nimport { MarkdownRenderer } from '../MarkdownRenderer/MarkdownRenderer';\nimport { useTagsFollow } from '../../hooks';\nimport { Link } from 'react-router-dom';\nimport {\n Box,\n Button,\n Chip,\n Grid,\n Tooltip,\n Typography,\n} from '@material-ui/core';\nimport VisibilityOff from '@material-ui/icons/VisibilityOff';\nimport Visibility from '@material-ui/icons/Visibility';\nimport LoyaltyOutlined from '@material-ui/icons/LoyaltyOutlined';\nimport { useTranslationRef } from '@backstage/core-plugin-api/alpha';\nimport { qetaTranslationRef } from '../../translation.ts';\nimport { useTooltipStyles } from '../../hooks/useTooltipStyles';\n\nconst cache: Map<string, TagResponse> = new Map();\n\nconst TagTooltip = (props: { tag: string }) => {\n const { tag } = props;\n const qetaApi = useApi(qetaApiRef);\n const { t } = useTranslationRef(qetaTranslationRef);\n const tags = useTagsFollow();\n const [resp, setResp] = useState<undefined | TagResponse>();\n\n useEffect(() => {\n if (cache.has(tag)) {\n setResp(cache.get(tag));\n return;\n }\n\n qetaApi.getTag(tag).then(res => {\n if (res) {\n cache.set(tag, res);\n setResp(res);\n } else {\n setResp({\n id: 0,\n tag,\n postsCount: 0,\n questionsCount: 0,\n articlesCount: 0,\n linksCount: 0,\n followerCount: 0,\n description: t('tagChip.nonExistingTag'),\n });\n }\n });\n }, [qetaApi, tag, t]);\n\n if (!resp) {\n return null;\n }\n\n return (\n <Grid container style={{ padding: '0.5em' }} spacing={1}>\n <Grid item xs={12}>\n <Box style={{ display: 'flex', alignItems: 'center' }}>\n <LoyaltyOutlined fontSize=\"small\" />\n <Typography\n variant=\"subtitle1\"\n style={{\n textOverflow: 'ellipsis',\n overflow: 'hidden',\n whiteSpace: 'nowrap',\n }}\n >\n {tag}\n </Typography>\n </Box>\n {resp.id > 0 && (\n <Typography variant=\"subtitle2\">\n {t('common.posts', { count: resp.postsCount, itemType: 'post' })}\n {' · '}\n {t('common.followers', { count: resp.followerCount })}\n </Typography>\n )}\n </Grid>\n {resp.description && (\n <Grid item xs={12}>\n <MarkdownRenderer content={resp.description} />\n </Grid>\n )}\n {!tags.loading && resp.id !== 0 && (\n <Grid item xs={12}>\n <Button\n size=\"small\"\n variant=\"outlined\"\n color={tags.isFollowingTag(tag) ? 'secondary' : 'primary'}\n onClick={() => {\n if (tags.isFollowingTag(tag)) {\n tags.unfollowTag(tag);\n } else {\n tags.followTag(tag);\n }\n }}\n startIcon={\n tags.isFollowingTag(tag) ? <VisibilityOff /> : <Visibility />\n }\n >\n {tags.isFollowingTag(tag)\n ? t('tagButton.unfollow')\n : t('tagButton.follow')}\n </Button>\n </Grid>\n )}\n </Grid>\n );\n};\n\nexport const TagChip = (props: {\n tag: string;\n style?: CSSProperties;\n useHref?: boolean;\n tooltip?: React.ReactElement;\n}) => {\n const tagRoute = useRouteRef(tagRouteRef);\n const { tag, tooltip } = props;\n const classes = useTooltipStyles();\n const href = tagRoute({ tag });\n\n return (\n <Tooltip\n arrow\n title={tooltip ? tooltip : <TagTooltip tag={tag} />}\n enterDelay={400}\n interactive\n classes={{\n tooltip: classes.tooltip,\n arrow: classes.tooltipArrow,\n }}\n >\n <Chip\n label={tag}\n size=\"small\"\n className=\"qetaTagChip\"\n component={props.useHref ? 'a' : Link}\n style={props.style}\n to={props.useHref ? undefined : href}\n href={props.useHref ? href : undefined}\n target={props.useHref ? '_blank' : undefined}\n onClick={(e: React.MouseEvent) => {\n e.stopPropagation();\n }}\n clickable\n />\n </Tooltip>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuBA,MAAM,KAAA,uBAAsC,GAAI,EAAA;AAEhD,MAAM,UAAA,GAAa,CAAC,KAA2B,KAAA;AAC7C,EAAM,MAAA,EAAE,KAAQ,GAAA,KAAA;AAChB,EAAM,MAAA,OAAA,GAAU,OAAO,UAAU,CAAA;AACjC,EAAA,MAAM,EAAE,CAAA,EAAM,GAAA,iBAAA,CAAkB,kBAAkB,CAAA;AAClD,EAAA,MAAM,OAAO,aAAc,EAAA;AAC3B,EAAA,MAAM,CAAC,IAAA,EAAM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AAU,GAAM,GAAA,IAAA;AAAA,UACjC,OAAO,KAAM,CAAA,KAAA;AAAA,UACb,EAAA,EAAI,KAAM,CAAA,OAAA,GAAU,KAAY,CAAA,GAAA,IAAA;AAAA,UAChC,IAAA,EAAM,KAAM,CAAA,OAAA,GAAU,IAAO,GAAA,KAAA,CAAA;AAAA,UAC7B,MAAA,EAAQ,KAAM,CAAA,OAAA,GAAU,QAAW,GAAA,KAAA,CAAA;AAAA,UACnC,OAAA,EAAS,CAAC,CAAwB,KAAA;AAChC,YAAA,CAAA,CAAE,eAAgB,EAAA;AAAA,WACpB;AAAA,UACA,SAAS,EAAA;AAAA;AAAA;AACX;AAAA,GACF;AAEJ;;;;"}
|
|
@@ -1,15 +1,41 @@
|
|
|
1
1
|
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
2
2
|
import { EntityChip } from './EntityChip.esm.js';
|
|
3
3
|
import { TagChip } from './TagChip.esm.js';
|
|
4
|
+
import { Chip } from '@material-ui/core';
|
|
5
|
+
import { useTranslationRef } from '@backstage/core-plugin-api/alpha';
|
|
6
|
+
import { qetaTranslationRef } from '../../translation.esm.js';
|
|
4
7
|
|
|
5
8
|
const TagsAndEntities = (props) => {
|
|
6
|
-
const { entity } = props;
|
|
7
|
-
|
|
9
|
+
const { entity, tagsLimit, entitiesLimit } = props;
|
|
10
|
+
const { t } = useTranslationRef(qetaTranslationRef);
|
|
11
|
+
let tags = "postTags" in entity ? entity.postTags : entity.tags;
|
|
12
|
+
let entities = "postEntities" in entity ? entity.postEntities : entity.entities;
|
|
13
|
+
if ((!tags || tags.length === 0) && (!entities || entities.length === 0)) {
|
|
8
14
|
return null;
|
|
9
15
|
}
|
|
16
|
+
let tagsCount = 0;
|
|
17
|
+
if (tags && tagsLimit && tags.length > tagsLimit) {
|
|
18
|
+
tagsCount = tags.length - tagsLimit;
|
|
19
|
+
tags = tags.slice(0, tagsLimit);
|
|
20
|
+
}
|
|
21
|
+
let entitiesCount = 0;
|
|
22
|
+
if (entities && entitiesLimit && entities.length > entitiesLimit) {
|
|
23
|
+
entitiesCount = entities.length - entitiesLimit;
|
|
24
|
+
entities = entities.slice(0, entitiesLimit);
|
|
25
|
+
}
|
|
26
|
+
const moreCount = tagsCount + entitiesCount;
|
|
10
27
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
11
|
-
|
|
12
|
-
|
|
28
|
+
tags && tags.map((tag) => /* @__PURE__ */ jsx(TagChip, { tag }, tag)),
|
|
29
|
+
entities && entities.map((component) => /* @__PURE__ */ jsx(EntityChip, { entity: component }, component)),
|
|
30
|
+
moreCount > 0 && /* @__PURE__ */ jsx(
|
|
31
|
+
Chip,
|
|
32
|
+
{
|
|
33
|
+
label: t("common.more", { count: moreCount }),
|
|
34
|
+
size: "small",
|
|
35
|
+
variant: "outlined",
|
|
36
|
+
color: "primary"
|
|
37
|
+
}
|
|
38
|
+
)
|
|
13
39
|
] });
|
|
14
40
|
};
|
|
15
41
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TagsAndEntities.esm.js","sources":["../../../src/components/TagsAndEntities/TagsAndEntities.tsx"],"sourcesContent":["import {\n CollectionResponse,\n PostResponse,\n} from '@drodil/backstage-plugin-qeta-common';\nimport { EntityChip } from './EntityChip';\nimport { TagChip } from './TagChip';\n\nexport const TagsAndEntities = (props: {\n entity: PostResponse | CollectionResponse;\n}) => {\n const { entity } = props;\n
|
|
1
|
+
{"version":3,"file":"TagsAndEntities.esm.js","sources":["../../../src/components/TagsAndEntities/TagsAndEntities.tsx"],"sourcesContent":["import {\n CollectionResponse,\n PostResponse,\n} from '@drodil/backstage-plugin-qeta-common';\nimport { EntityChip } from './EntityChip';\nimport { TagChip } from './TagChip';\nimport { Chip } from '@material-ui/core';\nimport { useTranslationRef } from '@backstage/core-plugin-api/alpha';\nimport { qetaTranslationRef } from '../../translation';\n\nexport const TagsAndEntities = (props: {\n entity: PostResponse | CollectionResponse;\n tagsLimit?: number;\n entitiesLimit?: number;\n}) => {\n const { entity, tagsLimit, entitiesLimit } = props;\n const { t } = useTranslationRef(qetaTranslationRef);\n\n let tags = 'postTags' in entity ? entity.postTags : entity.tags;\n let entities =\n 'postEntities' in entity ? entity.postEntities : entity.entities;\n\n if ((!tags || tags.length === 0) && (!entities || entities.length === 0)) {\n return null;\n }\n\n let tagsCount = 0;\n if (tags && tagsLimit && tags.length > tagsLimit) {\n tagsCount = tags.length - tagsLimit;\n tags = tags.slice(0, tagsLimit);\n }\n\n let entitiesCount = 0;\n if (entities && entitiesLimit && entities.length > entitiesLimit) {\n entitiesCount = entities.length - entitiesLimit;\n entities = entities.slice(0, entitiesLimit);\n }\n const moreCount = tagsCount + entitiesCount;\n\n return (\n <>\n {tags && tags.map(tag => <TagChip key={tag} tag={tag} />)}\n {entities &&\n entities.map(component => (\n <EntityChip entity={component} key={component} />\n ))}\n {moreCount > 0 && (\n <Chip\n label={t('common.more', { count: moreCount } as any)}\n size=\"small\"\n variant=\"outlined\"\n color=\"primary\"\n />\n )}\n </>\n );\n};\n"],"names":[],"mappings":";;;;;;;AAUa,MAAA,eAAA,GAAkB,CAAC,KAI1B,KAAA;AACJ,EAAA,MAAM,EAAE,MAAA,EAAQ,SAAW,EAAA,aAAA,EAAkB,GAAA,KAAA;AAC7C,EAAA,MAAM,EAAE,CAAA,EAAM,GAAA,iBAAA,CAAkB,kBAAkB,CAAA;AAElD,EAAA,IAAI,IAAO,GAAA,UAAA,IAAc,MAAS,GAAA,MAAA,CAAO,WAAW,MAAO,CAAA,IAAA;AAC3D,EAAA,IAAI,QACF,GAAA,cAAA,IAAkB,MAAS,GAAA,MAAA,CAAO,eAAe,MAAO,CAAA,QAAA;AAE1D,EAAK,IAAA,CAAA,CAAC,QAAQ,IAAK,CAAA,MAAA,KAAW,OAAO,CAAC,QAAA,IAAY,QAAS,CAAA,MAAA,KAAW,CAAI,CAAA,EAAA;AACxE,IAAO,OAAA,IAAA;AAAA;AAGT,EAAA,IAAI,SAAY,GAAA,CAAA;AAChB,EAAA,IAAI,IAAQ,IAAA,SAAA,IAAa,IAAK,CAAA,MAAA,GAAS,SAAW,EAAA;AAChD,IAAA,SAAA,GAAY,KAAK,MAAS,GAAA,SAAA;AAC1B,IAAO,IAAA,GAAA,IAAA,CAAK,KAAM,CAAA,CAAA,EAAG,SAAS,CAAA;AAAA;AAGhC,EAAA,IAAI,aAAgB,GAAA,CAAA;AACpB,EAAA,IAAI,QAAY,IAAA,aAAA,IAAiB,QAAS,CAAA,MAAA,GAAS,aAAe,EAAA;AAChE,IAAA,aAAA,GAAgB,SAAS,MAAS,GAAA,aAAA;AAClC,IAAW,QAAA,GAAA,QAAA,CAAS,KAAM,CAAA,CAAA,EAAG,aAAa,CAAA;AAAA;AAE5C,EAAA,MAAM,YAAY,SAAY,GAAA,aAAA;AAE9B,EAAA,uBAEK,IAAA,CAAA,QAAA,EAAA,EAAA,QAAA,EAAA;AAAA,IAAA,IAAA,IAAQ,KAAK,GAAI,CAAA,CAAA,GAAA,yBAAQ,OAAkB,EAAA,EAAA,GAAA,EAAA,EAAL,GAAe,CAAE,CAAA;AAAA,IACvD,QAAA,IACC,SAAS,GAAI,CAAA,CAAA,SAAA,yBACV,UAAW,EAAA,EAAA,MAAA,EAAQ,SAAgB,EAAA,EAAA,SAAW,CAChD,CAAA;AAAA,IACF,YAAY,CACX,oBAAA,GAAA;AAAA,MAAC,IAAA;AAAA,MAAA;AAAA,QACC,OAAO,CAAE,CAAA,aAAA,EAAe,EAAE,KAAA,EAAO,WAAkB,CAAA;AAAA,QACnD,IAAK,EAAA,OAAA;AAAA,QACL,OAAQ,EAAA,UAAA;AAAA,QACR,KAAM,EAAA;AAAA;AAAA;AACR,GAEJ,EAAA,CAAA;AAEJ;;;;"}
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
2
|
-
import {
|
|
2
|
+
import { useState, useMemo, Children } from 'react';
|
|
3
|
+
import { makeStyles, Box, List, ListSubheader, Button } from '@material-ui/core';
|
|
4
|
+
import { useTranslationRef } from '@backstage/core-plugin-api/alpha';
|
|
5
|
+
import { qetaTranslationRef } from '../../translation.esm.js';
|
|
6
|
+
import ExpandMoreIcon from '@material-ui/icons/ExpandMore';
|
|
7
|
+
import ExpandLessIcon from '@material-ui/icons/ExpandLess';
|
|
3
8
|
|
|
4
9
|
const useStyles = makeStyles((theme) => ({
|
|
5
10
|
container: {
|
|
@@ -19,6 +24,13 @@ const useStyles = makeStyles((theme) => ({
|
|
|
19
24
|
paddingLeft: theme.spacing(1),
|
|
20
25
|
paddingRight: theme.spacing(1)
|
|
21
26
|
}
|
|
27
|
+
},
|
|
28
|
+
showMoreButton: {
|
|
29
|
+
marginLeft: theme.spacing(1),
|
|
30
|
+
alignItems: "center",
|
|
31
|
+
display: "flex",
|
|
32
|
+
justifyContent: "center",
|
|
33
|
+
fontSize: "0.8rem"
|
|
22
34
|
}
|
|
23
35
|
}));
|
|
24
36
|
const RightListContainer = (props) => {
|
|
@@ -27,7 +39,18 @@ const RightListContainer = (props) => {
|
|
|
27
39
|
};
|
|
28
40
|
const RightList = (props) => {
|
|
29
41
|
const styles = useStyles();
|
|
30
|
-
|
|
42
|
+
const { t } = useTranslationRef(qetaTranslationRef);
|
|
43
|
+
const [expanded, setExpanded] = useState(false);
|
|
44
|
+
const arrayChildren = useMemo(() => {
|
|
45
|
+
const children = Children.toArray(props.children);
|
|
46
|
+
if (props.randomize && props.limit && children.length > props.limit) {
|
|
47
|
+
return children.sort(() => 0.5 - Math.random());
|
|
48
|
+
}
|
|
49
|
+
return children;
|
|
50
|
+
}, [props.children, props.randomize, props.limit]);
|
|
51
|
+
const showButton = props.limit && arrayChildren.length > props.limit;
|
|
52
|
+
const displayChildren = showButton && !expanded ? arrayChildren.slice(0, props.limit) : arrayChildren;
|
|
53
|
+
return /* @__PURE__ */ jsxs(
|
|
31
54
|
List,
|
|
32
55
|
{
|
|
33
56
|
component: "nav",
|
|
@@ -47,7 +70,20 @@ const RightList = (props) => {
|
|
|
47
70
|
]
|
|
48
71
|
}
|
|
49
72
|
),
|
|
50
|
-
children:
|
|
73
|
+
children: [
|
|
74
|
+
displayChildren,
|
|
75
|
+
showButton && /* @__PURE__ */ jsx(
|
|
76
|
+
Button,
|
|
77
|
+
{
|
|
78
|
+
onClick: () => setExpanded(!expanded),
|
|
79
|
+
color: "primary",
|
|
80
|
+
size: "small",
|
|
81
|
+
className: styles.showMoreButton,
|
|
82
|
+
endIcon: expanded ? /* @__PURE__ */ jsx(ExpandLessIcon, {}) : /* @__PURE__ */ jsx(ExpandMoreIcon, {}),
|
|
83
|
+
children: expanded ? t("common.showLess") : t("common.showMore")
|
|
84
|
+
}
|
|
85
|
+
)
|
|
86
|
+
]
|
|
51
87
|
}
|
|
52
88
|
);
|
|
53
89
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RightList.esm.js","sources":["../../../src/components/Utility/RightList.tsx"],"sourcesContent":["import { ReactNode } from 'react';\nimport {
|
|
1
|
+
{"version":3,"file":"RightList.esm.js","sources":["../../../src/components/Utility/RightList.tsx"],"sourcesContent":["import { ReactNode, useState, Children, useMemo } from 'react';\nimport {\n Box,\n Button,\n List,\n ListSubheader,\n makeStyles,\n} from '@material-ui/core';\nimport { useTranslationRef } from '@backstage/core-plugin-api/alpha';\nimport { qetaTranslationRef } from '../../translation';\nimport ExpandMore from '@material-ui/icons/ExpandMore';\nimport ExpandLess from '@material-ui/icons/ExpandLess';\n\nconst useStyles = makeStyles(theme => ({\n container: {\n width: '100%',\n marginBottom: '1em',\n },\n subheader: {\n color: theme.palette.text.hint,\n padding: '0px 0px 0.5rem 0.5rem',\n whiteSpace: 'nowrap',\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n lineHeight: 1.5,\n },\n list: {\n '& li': {\n paddingLeft: theme.spacing(1),\n paddingRight: theme.spacing(1),\n },\n },\n showMoreButton: {\n marginLeft: theme.spacing(1),\n alignItems: 'center',\n display: 'flex',\n justifyContent: 'center',\n fontSize: '0.8rem',\n },\n}));\n\nexport const RightListContainer = (props: { children: ReactNode }) => {\n const styles = useStyles();\n return (\n <Box display={{ md: 'none', lg: 'block' }} className={styles.container}>\n {props.children}\n </Box>\n );\n};\n\nexport const RightList = (props: {\n children: ReactNode;\n title?: string;\n icon?: ReactNode;\n limit?: number;\n randomize?: boolean;\n}) => {\n const styles = useStyles();\n const { t } = useTranslationRef(qetaTranslationRef);\n const [expanded, setExpanded] = useState(false);\n const arrayChildren = useMemo(() => {\n const children = Children.toArray(props.children);\n if (props.randomize && props.limit && children.length > props.limit) {\n return children.sort(() => 0.5 - Math.random());\n }\n return children;\n }, [props.children, props.randomize, props.limit]);\n const showButton = props.limit && arrayChildren.length > props.limit;\n const displayChildren =\n showButton && !expanded\n ? arrayChildren.slice(0, props.limit)\n : arrayChildren;\n\n return (\n <List\n component=\"nav\"\n aria-labelledby=\"nested-list-subheader\"\n className={styles.list}\n subheader={\n <ListSubheader\n disableSticky\n component=\"div\"\n id=\"nested-list-subheader\"\n color=\"primary\"\n className={styles.subheader}\n >\n {props.title}\n {props.icon}\n </ListSubheader>\n }\n >\n {displayChildren}\n {showButton && (\n <Button\n onClick={() => setExpanded(!expanded)}\n color=\"primary\"\n size=\"small\"\n className={styles.showMoreButton}\n endIcon={expanded ? <ExpandLess /> : <ExpandMore />}\n >\n {expanded ? t('common.showLess') : t('common.showMore')}\n </Button>\n )}\n </List>\n );\n};\n"],"names":["ExpandLess","ExpandMore"],"mappings":";;;;;;;;AAaA,MAAM,SAAA,GAAY,WAAW,CAAU,KAAA,MAAA;AAAA,EACrC,SAAW,EAAA;AAAA,IACT,KAAO,EAAA,MAAA;AAAA,IACP,YAAc,EAAA;AAAA,GAChB;AAAA,EACA,SAAW,EAAA;AAAA,IACT,KAAA,EAAO,KAAM,CAAA,OAAA,CAAQ,IAAK,CAAA,IAAA;AAAA,IAC1B,OAAS,EAAA,uBAAA;AAAA,IACT,UAAY,EAAA,QAAA;AAAA,IACZ,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,EAAA,QAAA,GAAA,CAAA,CAAE,iBAAiB,CAAA,GAAI,EAAE,iBAAiB;AAAA;AAAA;AACxD;AAAA;AAAA,GAEJ;AAEJ;;;;"}
|
|
@@ -7,32 +7,41 @@ import { useTranslationRef } from '@backstage/core-plugin-api/alpha';
|
|
|
7
7
|
import { qetaTranslationRef } from '../translation.esm.js';
|
|
8
8
|
|
|
9
9
|
const userCache = /* @__PURE__ */ new Map();
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
"kind",
|
|
15
|
-
"metadata.name",
|
|
16
|
-
"metadata.namespace",
|
|
17
|
-
"spec.profile.displayName",
|
|
18
|
-
"spec.profile.picture"
|
|
19
|
-
],
|
|
20
|
-
entityRefs
|
|
21
|
-
});
|
|
22
|
-
entityRefs.forEach((entityRef, index) => {
|
|
23
|
-
userCache.set(entityRef, items[index]);
|
|
24
|
-
});
|
|
25
|
-
return items;
|
|
26
|
-
},
|
|
27
|
-
{
|
|
28
|
-
name: "EntityAuthorLoader",
|
|
29
|
-
cacheMap: /* @__PURE__ */ new Map(),
|
|
30
|
-
maxBatchSize: 100,
|
|
31
|
-
batchScheduleFn: (callback) => {
|
|
32
|
-
setTimeout(callback, 50);
|
|
33
|
-
}
|
|
10
|
+
let userLoader;
|
|
11
|
+
const getEntityAuthorLoader = (catalogApi) => {
|
|
12
|
+
if (userLoader) {
|
|
13
|
+
return userLoader;
|
|
34
14
|
}
|
|
35
|
-
|
|
15
|
+
userLoader = new DataLoader(
|
|
16
|
+
async (entityRefs) => {
|
|
17
|
+
const { items } = await catalogApi.getEntitiesByRefs({
|
|
18
|
+
fields: [
|
|
19
|
+
"kind",
|
|
20
|
+
"metadata.name",
|
|
21
|
+
"metadata.namespace",
|
|
22
|
+
"spec.profile.displayName",
|
|
23
|
+
"spec.profile.picture"
|
|
24
|
+
],
|
|
25
|
+
entityRefs
|
|
26
|
+
});
|
|
27
|
+
entityRefs.forEach((entityRef, index) => {
|
|
28
|
+
if (items[index]) {
|
|
29
|
+
userCache.set(entityRef, items[index]);
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
return items;
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
name: "EntityAuthorLoader",
|
|
36
|
+
cacheMap: /* @__PURE__ */ new Map(),
|
|
37
|
+
maxBatchSize: 100,
|
|
38
|
+
batchScheduleFn: (callback) => {
|
|
39
|
+
setTimeout(callback, 50);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
);
|
|
43
|
+
return userLoader;
|
|
44
|
+
};
|
|
36
45
|
const useUserInfo = (entityRef, anonymous) => {
|
|
37
46
|
const catalogApi = useApi(catalogApiRef);
|
|
38
47
|
const identityApi = useApi(identityApiRef);
|
|
@@ -58,7 +67,7 @@ const useUserInfo = (entityRef, anonymous) => {
|
|
|
58
67
|
setUser(userCache.get(ref));
|
|
59
68
|
return;
|
|
60
69
|
}
|
|
61
|
-
|
|
70
|
+
getEntityAuthorLoader(catalogApi).load(ref).then((data) => {
|
|
62
71
|
if (data) {
|
|
63
72
|
setUser(data);
|
|
64
73
|
} else {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useEntityAuthor.esm.js","sources":["../../src/hooks/useEntityAuthor.ts"],"sourcesContent":["import {\n parseEntityRef,\n stringifyEntityRef,\n UserEntity,\n} from '@backstage/catalog-model';\nimport { CatalogApi } from '@backstage/catalog-client';\nimport DataLoader from 'dataloader';\nimport { identityApiRef, useApi } from '@backstage/core-plugin-api';\nimport {\n catalogApiRef,\n useEntityPresentation,\n} from '@backstage/plugin-catalog-react';\nimport { useEffect, useState } from 'react';\nimport {\n AnswerResponse,\n CollectionResponse,\n PostResponse,\n UserResponse,\n} from '@drodil/backstage-plugin-qeta-common';\nimport { useTranslationRef } from '@backstage/core-plugin-api/alpha';\nimport { qetaTranslationRef } from '../translation.ts';\n\nconst userCache: Map<string, UserEntity> = new Map();\nconst
|
|
1
|
+
{"version":3,"file":"useEntityAuthor.esm.js","sources":["../../src/hooks/useEntityAuthor.ts"],"sourcesContent":["import {\n parseEntityRef,\n stringifyEntityRef,\n UserEntity,\n} from '@backstage/catalog-model';\nimport { CatalogApi } from '@backstage/catalog-client';\nimport DataLoader from 'dataloader';\nimport { identityApiRef, useApi } from '@backstage/core-plugin-api';\nimport {\n catalogApiRef,\n useEntityPresentation,\n} from '@backstage/plugin-catalog-react';\nimport { useEffect, useState } from 'react';\nimport {\n AnswerResponse,\n CollectionResponse,\n PostResponse,\n UserResponse,\n} from '@drodil/backstage-plugin-qeta-common';\nimport { useTranslationRef } from '@backstage/core-plugin-api/alpha';\nimport { qetaTranslationRef } from '../translation.ts';\n\nconst userCache: Map<string, UserEntity> = new Map();\nlet userLoader: DataLoader<string, UserEntity | null> | undefined;\n\nconst getEntityAuthorLoader = (catalogApi: CatalogApi) => {\n if (userLoader) {\n return userLoader;\n }\n userLoader = new DataLoader<string, UserEntity | null>(\n async (entityRefs: readonly string[]) => {\n const { items } = await catalogApi.getEntitiesByRefs({\n fields: [\n 'kind',\n 'metadata.name',\n 'metadata.namespace',\n 'spec.profile.displayName',\n 'spec.profile.picture',\n ],\n entityRefs: entityRefs as string[],\n });\n\n entityRefs.forEach((entityRef, index) => {\n if (items[index]) {\n userCache.set(entityRef, items[index] as UserEntity);\n }\n });\n return items as (UserEntity | null)[];\n },\n {\n name: 'EntityAuthorLoader',\n cacheMap: new Map(),\n maxBatchSize: 100,\n batchScheduleFn: callback => {\n setTimeout(callback, 50);\n },\n },\n );\n return userLoader;\n};\n\nexport const useUserInfo = (entityRef: string, anonymous?: boolean) => {\n const catalogApi = useApi(catalogApiRef);\n const identityApi = useApi(identityApiRef);\n const { t } = useTranslationRef(qetaTranslationRef);\n const [name, setName] = useState<string>('');\n const [isCurrentUser, setIsCurrentUser] = useState<boolean>(false);\n const [user, setUser] = useState<UserEntity | null>(null);\n const [initials, setInitials] = useState<string | null>(null);\n const [currentUser, setCurrentUser] = useState<string | null>(null);\n const ref = stringifyEntityRef(\n parseEntityRef(entityRef, { defaultKind: 'user' }),\n );\n\n const {\n primaryTitle: userName,\n secondaryTitle,\n Icon,\n } = useEntityPresentation(ref, { defaultKind: 'user' });\n\n useEffect(() => {\n if (anonymous) {\n return;\n }\n\n if (userCache.get(ref)) {\n setUser(userCache.get(ref) as UserEntity);\n return;\n }\n\n getEntityAuthorLoader(catalogApi)\n .load(ref)\n .then(data => {\n if (data) {\n setUser(data);\n } else {\n setUser(null);\n }\n })\n .catch(() => {\n setUser(null);\n });\n }, [catalogApi, ref, anonymous]);\n\n useEffect(() => {\n identityApi.getBackstageIdentity().then(res => {\n setCurrentUser(res.userEntityRef ?? 'user:default/guest');\n });\n }, [identityApi]);\n\n useEffect(() => {\n let displayName = userName;\n if (currentUser) {\n const currentUserRef = parseEntityRef(currentUser, {\n defaultKind: 'user',\n });\n const userRef = parseEntityRef(ref, { defaultKind: 'user' });\n if (\n currentUserRef.name === userRef.name &&\n currentUserRef.namespace === userRef.namespace\n ) {\n setIsCurrentUser(true);\n displayName = `${t('userLink.you')}${\n anonymous\n ? ` (${t('userLink.anonymous').toLocaleLowerCase('en-US')})`\n : ''\n }`;\n } else if (anonymous) {\n displayName = t('userLink.anonymous');\n }\n } else if (anonymous) {\n displayName = t('userLink.anonymous');\n }\n setName(displayName);\n }, [ref, anonymous, currentUser, userName, t]);\n\n useEffect(() => {\n const init = (name ?? '')\n .replace(/[^a-zA-Z]/g, '')\n .split(' ')\n .map(p => p[0])\n .join('')\n .substring(0, 2)\n .toUpperCase();\n setInitials(init);\n }, [name]);\n\n return { name, initials, user, secondaryTitle, Icon, isCurrentUser };\n};\n\nexport const useEntityAuthor = (\n entity: PostResponse | AnswerResponse | CollectionResponse | UserResponse,\n) => {\n const anonymous = 'anonymous' in entity ? entity.anonymous ?? false : false;\n const author =\n // eslint-disable-next-line no-nested-ternary\n 'author' in entity\n ? entity.author\n : 'userRef' in entity\n ? entity.userRef\n : entity.owner;\n return useUserInfo(author, anonymous);\n};\n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AE,EACP,SAAU,CAAA,CAAA,EAAG,CAAC,CAAA,CACd,WAAY,EAAA;AACf,IAAA,WAAA,CAAY,IAAI,CAAA;AAAA,GAClB,EAAG,CAAC,IAAI,CAAC,CAAA;AAET,EAAA,OAAO,EAAE,IAAM,EAAA,QAAA,EAAU,IAAM,EAAA,cAAA,EAAgB,MAAM,aAAc,EAAA;AACrE;AAEa,MAAA,eAAA,GAAkB,CAC7B,MACG,KAAA;AACH,EAAA,MAAM,SAAY,GAAA,WAAA,IAAe,MAAS,GAAA,MAAA,CAAO,aAAa,KAAQ,GAAA,KAAA;AACtE,EAAM,MAAA,MAAA;AAAA;AAAA,IAEJ,QAAA,IAAY,SACR,MAAO,CAAA,MAAA,GACP,aAAa,MACb,GAAA,MAAA,CAAO,UACP,MAAO,CAAA;AAAA,GAAA;AACb,EAAO,OAAA,WAAA,CAAY,QAAQ,SAAS,CAAA;AACtC;;;;"}
|
package/dist/index.d.ts
CHANGED
|
@@ -881,6 +881,9 @@ declare const qetaTranslationRef: _backstage_frontend_plugin_api.TranslationRef<
|
|
|
881
881
|
readonly "common.followersLabel_one": "follower";
|
|
882
882
|
readonly "common.followersLabel_other": "followers";
|
|
883
883
|
readonly "common.unsaved_changes": "You have unsaved changes. Are you sure you want to leave?";
|
|
884
|
+
readonly "common.more": "+{{count}} more";
|
|
885
|
+
readonly "common.showMore": "Show more";
|
|
886
|
+
readonly "common.showLess": "Show less";
|
|
884
887
|
readonly "markdownEditor.write": "Write";
|
|
885
888
|
readonly "markdownEditor.preview": "Preview";
|
|
886
889
|
readonly "markdownEditor.uploadingImage": "Uploading image...";
|
|
@@ -916,6 +919,11 @@ declare const qetaTranslationRef: _backstage_frontend_plugin_api.TranslationRef<
|
|
|
916
919
|
readonly "collectionForm.descriptionInput.markdownHelp": "Markdown help";
|
|
917
920
|
readonly "collectionForm.submit.existingCollection": "Save";
|
|
918
921
|
readonly "collectionForm.submit.newCollection": "Create Collection";
|
|
922
|
+
readonly "collectionForm.automaticRules.title": "Automatic collection rules";
|
|
923
|
+
readonly "collectionForm.automaticRules.description": "You can optionally define tags, entities and users that will automatically add matching posts to this collection. Posts that match ANY of the defined tags OR entities will be automatically added.";
|
|
924
|
+
readonly "collectionForm.automaticEntitiesInput.label": "Automatic Entities";
|
|
925
|
+
readonly "collectionForm.automaticTagsInput.label": "Automatic Tags";
|
|
926
|
+
readonly "collectionForm.automaticUsersInput.label": "Automatic Users";
|
|
919
927
|
readonly "postForm.errorLoading": "Could not load {{type}}";
|
|
920
928
|
readonly "postForm.uploadHeaderImage": "Upload header image";
|
|
921
929
|
readonly "postForm.errorPosting": "Could not post {{type}}";
|
package/dist/translation.esm.js
CHANGED
|
@@ -89,7 +89,10 @@ const qetaTranslationRef = createTranslationRef({
|
|
|
89
89
|
unsaved_changes: "You have unsaved changes. Are you sure you want to leave?",
|
|
90
90
|
loading: "Loading...",
|
|
91
91
|
draft: "Draft",
|
|
92
|
-
deleted: "Deleted"
|
|
92
|
+
deleted: "Deleted",
|
|
93
|
+
more: "+{{count}} more",
|
|
94
|
+
showMore: "Show more",
|
|
95
|
+
showLess: "Show less"
|
|
93
96
|
},
|
|
94
97
|
markdownEditor: {
|
|
95
98
|
write: "Write",
|
|
@@ -148,7 +151,20 @@ const qetaTranslationRef = createTranslationRef({
|
|
|
148
151
|
submitting: "Creating...",
|
|
149
152
|
tips_1: "Choose a clear and descriptive title that reflects the collection's purpose",
|
|
150
153
|
tips_2: "Provide a detailed description of what topics or questions the collection will contain",
|
|
151
|
-
tips_3: "Use markdown formatting to describe your collection with headings, lists, and links"
|
|
154
|
+
tips_3: "Use markdown formatting to describe your collection with headings, lists, and links",
|
|
155
|
+
automaticRules: {
|
|
156
|
+
title: "Automatic collection rules",
|
|
157
|
+
description: "You can optionally define tags, entities and users that will automatically add matching posts to this collection. Posts that match ANY of the defined tags OR entities will be automatically added."
|
|
158
|
+
},
|
|
159
|
+
automaticEntitiesInput: {
|
|
160
|
+
label: "Automatic Entities"
|
|
161
|
+
},
|
|
162
|
+
automaticTagsInput: {
|
|
163
|
+
label: "Automatic Tags"
|
|
164
|
+
},
|
|
165
|
+
automaticUsersInput: {
|
|
166
|
+
label: "Automatic Users"
|
|
167
|
+
}
|
|
152
168
|
},
|
|
153
169
|
postForm: {
|
|
154
170
|
errorPosting: "Could not post {{type}}",
|