@backstage/plugin-org 0.6.25 → 0.6.26-next.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/CHANGELOG.md +27 -0
- package/alpha/package.json +1 -1
- package/dist/alpha.d.ts +1 -1
- package/dist/components/Cards/Group/GroupProfile/GroupProfileCard.esm.js +7 -8
- package/dist/components/Cards/Group/GroupProfile/GroupProfileCard.esm.js.map +1 -1
- package/dist/components/Cards/Group/MembersList/MembersListCard.esm.js +7 -9
- package/dist/components/Cards/Group/MembersList/MembersListCard.esm.js.map +1 -1
- package/dist/components/Cards/Meta/LinksGroup.esm.js +1 -4
- package/dist/components/Cards/Meta/LinksGroup.esm.js.map +1 -1
- package/dist/components/Cards/OwnershipCard/ComponentsGrid.esm.js +18 -17
- package/dist/components/Cards/OwnershipCard/ComponentsGrid.esm.js.map +1 -1
- package/dist/components/Cards/OwnershipCard/OwnershipCard.esm.js +1 -1
- package/dist/components/Cards/OwnershipCard/OwnershipCard.esm.js.map +1 -1
- package/dist/components/Cards/OwnershipCard/useGetEntities.esm.js +3 -7
- package/dist/components/Cards/OwnershipCard/useGetEntities.esm.js.map +1 -1
- package/dist/components/Cards/User/UserProfileCard/UserProfileCard.esm.js +5 -6
- package/dist/components/Cards/User/UserProfileCard/UserProfileCard.esm.js.map +1 -1
- package/dist/components/MyGroupsSidebarItem/MyGroupsSidebarItem.esm.js +3 -3
- package/dist/components/MyGroupsSidebarItem/MyGroupsSidebarItem.esm.js.map +1 -1
- package/dist/helpers/helpers.esm.js +1 -2
- package/dist/helpers/helpers.esm.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/routes.esm.js +3 -1
- package/dist/routes.esm.js.map +1 -1
- package/package.json +12 -12
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,32 @@
|
|
|
1
1
|
# @backstage/plugin-org
|
|
2
2
|
|
|
3
|
+
## 0.6.26-next.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- d8e2f53: The `catalogIndex` external route is now optional and will by default bind to the catalog index page if it is available.
|
|
8
|
+
- Updated dependencies
|
|
9
|
+
- @backstage/core-components@0.14.8-next.1
|
|
10
|
+
- @backstage/core-compat-api@0.2.6-next.1
|
|
11
|
+
- @backstage/core-plugin-api@1.9.3-next.0
|
|
12
|
+
- @backstage/frontend-plugin-api@0.6.6-next.1
|
|
13
|
+
- @backstage/plugin-catalog-react@1.12.1-next.1
|
|
14
|
+
- @backstage/catalog-model@1.5.0
|
|
15
|
+
- @backstage/plugin-catalog-common@1.0.23
|
|
16
|
+
|
|
17
|
+
## 0.6.26-next.0
|
|
18
|
+
|
|
19
|
+
### Patch Changes
|
|
20
|
+
|
|
21
|
+
- Updated dependencies
|
|
22
|
+
- @backstage/core-components@0.14.8-next.0
|
|
23
|
+
- @backstage/catalog-model@1.5.0
|
|
24
|
+
- @backstage/core-compat-api@0.2.6-next.0
|
|
25
|
+
- @backstage/core-plugin-api@1.9.2
|
|
26
|
+
- @backstage/frontend-plugin-api@0.6.6-next.0
|
|
27
|
+
- @backstage/plugin-catalog-common@1.0.23
|
|
28
|
+
- @backstage/plugin-catalog-react@1.12.1-next.0
|
|
29
|
+
|
|
3
30
|
## 0.6.25
|
|
4
31
|
|
|
5
32
|
### Patch Changes
|
package/alpha/package.json
CHANGED
package/dist/alpha.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import * as _backstage_frontend_plugin_api from '@backstage/frontend-plugin-api'
|
|
|
2
2
|
|
|
3
3
|
/** @alpha */
|
|
4
4
|
declare const _default: _backstage_frontend_plugin_api.BackstagePlugin<{}, {
|
|
5
|
-
catalogIndex: _backstage_frontend_plugin_api.ExternalRouteRef<undefined,
|
|
5
|
+
catalogIndex: _backstage_frontend_plugin_api.ExternalRouteRef<undefined, true>;
|
|
6
6
|
}>;
|
|
7
7
|
|
|
8
8
|
export { _default as default };
|
|
@@ -23,7 +23,6 @@ import { catalogEntityRefreshPermission } from '@backstage/plugin-catalog-common
|
|
|
23
23
|
|
|
24
24
|
const CardTitle = (props) => /* @__PURE__ */ React.createElement(Box, { display: "flex", alignItems: "center" }, /* @__PURE__ */ React.createElement(GroupIcon, { fontSize: "inherit" }), /* @__PURE__ */ React.createElement(Box, { ml: 1 }, props.title));
|
|
25
25
|
const GroupProfileCard = (props) => {
|
|
26
|
-
var _a, _b, _c;
|
|
27
26
|
const catalogApi = useApi(catalogApiRef);
|
|
28
27
|
const alertApi = useApi(alertApiRef);
|
|
29
28
|
const { entity: group } = useEntity();
|
|
@@ -51,11 +50,11 @@ const GroupProfileCard = (props) => {
|
|
|
51
50
|
const parentRelations = getEntityRelations(group, RELATION_CHILD_OF, {
|
|
52
51
|
kind: "group"
|
|
53
52
|
});
|
|
54
|
-
const entityLocation = annotations
|
|
55
|
-
const allowRefresh =
|
|
56
|
-
const entityMetadataEditUrl =
|
|
57
|
-
const displayName =
|
|
58
|
-
const emailHref =
|
|
53
|
+
const entityLocation = annotations?.[ANNOTATION_LOCATION];
|
|
54
|
+
const allowRefresh = entityLocation?.startsWith("url:") || entityLocation?.startsWith("file:");
|
|
55
|
+
const entityMetadataEditUrl = group.metadata.annotations?.[ANNOTATION_EDIT_URL];
|
|
56
|
+
const displayName = profile?.displayName ?? title ?? name;
|
|
57
|
+
const emailHref = profile?.email ? `mailto:${profile.email}` : "#";
|
|
59
58
|
const infoCardAction = entityMetadataEditUrl ? /* @__PURE__ */ React.createElement(
|
|
60
59
|
IconButton,
|
|
61
60
|
{
|
|
@@ -82,7 +81,7 @@ const GroupProfileCard = (props) => {
|
|
|
82
81
|
/* @__PURE__ */ React.createElement(CachedIcon, null)
|
|
83
82
|
), infoCardAction)
|
|
84
83
|
},
|
|
85
|
-
/* @__PURE__ */ React.createElement(Grid, { container: true, spacing: 3 }, /* @__PURE__ */ React.createElement(Grid, { item: true, xs: 12, sm: 2, xl: 1 }, /* @__PURE__ */ React.createElement(Avatar, { displayName, picture: profile
|
|
84
|
+
/* @__PURE__ */ React.createElement(Grid, { container: true, spacing: 3 }, /* @__PURE__ */ React.createElement(Grid, { item: true, xs: 12, sm: 2, xl: 1 }, /* @__PURE__ */ React.createElement(Avatar, { displayName, picture: profile?.picture })), /* @__PURE__ */ React.createElement(Grid, { item: true, md: 10, xl: 11 }, /* @__PURE__ */ React.createElement(List, null, profile?.email && /* @__PURE__ */ React.createElement(ListItem, null, /* @__PURE__ */ React.createElement(ListItemIcon, null, /* @__PURE__ */ React.createElement(Tooltip, { title: "Email" }, /* @__PURE__ */ React.createElement(EmailIcon, null))), /* @__PURE__ */ React.createElement(
|
|
86
85
|
ListItemText,
|
|
87
86
|
{
|
|
88
87
|
primary: /* @__PURE__ */ React.createElement(Link, { to: emailHref }, profile.email),
|
|
@@ -112,7 +111,7 @@ const GroupProfileCard = (props) => {
|
|
|
112
111
|
) : "N/A",
|
|
113
112
|
secondary: "Child Groups"
|
|
114
113
|
}
|
|
115
|
-
)),
|
|
114
|
+
)), props?.showLinks && /* @__PURE__ */ React.createElement(LinksGroup, { links }))))
|
|
116
115
|
);
|
|
117
116
|
};
|
|
118
117
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GroupProfileCard.esm.js","sources":["../../../../../src/components/Cards/Group/GroupProfile/GroupProfileCard.tsx"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n ANNOTATION_EDIT_URL,\n ANNOTATION_LOCATION,\n GroupEntity,\n RELATION_CHILD_OF,\n RELATION_PARENT_OF,\n stringifyEntityRef,\n} from '@backstage/catalog-model';\nimport {\n Avatar,\n InfoCard,\n InfoCardVariants,\n Link,\n} from '@backstage/core-components';\nimport Box from '@material-ui/core/Box';\nimport Grid from '@material-ui/core/Grid';\nimport IconButton from '@material-ui/core/IconButton';\nimport List from '@material-ui/core/List';\nimport ListItem from '@material-ui/core/ListItem';\nimport ListItemIcon from '@material-ui/core/ListItemIcon';\nimport ListItemText from '@material-ui/core/ListItemText';\nimport Tooltip from '@material-ui/core/Tooltip';\nimport {\n EntityRefLinks,\n catalogApiRef,\n getEntityRelations,\n useEntity,\n} from '@backstage/plugin-catalog-react';\nimport React, { useCallback } from 'react';\nimport { alertApiRef, useApi } from '@backstage/core-plugin-api';\n\nimport AccountTreeIcon from '@material-ui/icons/AccountTree';\nimport Alert from '@material-ui/lab/Alert';\nimport CachedIcon from '@material-ui/icons/Cached';\nimport EditIcon from '@material-ui/icons/Edit';\nimport EmailIcon from '@material-ui/icons/Email';\nimport GroupIcon from '@material-ui/icons/Group';\nimport { LinksGroup } from '../../Meta';\nimport { useEntityPermission } from '@backstage/plugin-catalog-react/alpha';\nimport { catalogEntityRefreshPermission } from '@backstage/plugin-catalog-common/alpha';\n\nconst CardTitle = (props: { title: string }) => (\n <Box display=\"flex\" alignItems=\"center\">\n <GroupIcon fontSize=\"inherit\" />\n <Box ml={1}>{props.title}</Box>\n </Box>\n);\n\n/** @public */\nexport const GroupProfileCard = (props: {\n variant?: InfoCardVariants;\n showLinks?: boolean;\n}) => {\n const catalogApi = useApi(catalogApiRef);\n const alertApi = useApi(alertApiRef);\n const { entity: group } = useEntity<GroupEntity>();\n const { allowed: canRefresh } = useEntityPermission(\n catalogEntityRefreshPermission,\n );\n\n const refreshEntity = useCallback(async () => {\n await catalogApi.refreshEntity(stringifyEntityRef(group));\n alertApi.post({\n message: 'Refresh scheduled',\n severity: 'info',\n display: 'transient',\n });\n }, [catalogApi, alertApi, group]);\n\n if (!group) {\n return <Alert severity=\"error\">Group not found</Alert>;\n }\n\n const {\n metadata: { name, description, title, annotations, links },\n spec: { profile },\n } = group;\n\n const childRelations = getEntityRelations(group, RELATION_PARENT_OF, {\n kind: 'Group',\n });\n const parentRelations = getEntityRelations(group, RELATION_CHILD_OF, {\n kind: 'group',\n });\n\n const entityLocation = annotations?.[ANNOTATION_LOCATION];\n const allowRefresh =\n entityLocation?.startsWith('url:') || entityLocation?.startsWith('file:');\n\n const entityMetadataEditUrl =\n group.metadata.annotations?.[ANNOTATION_EDIT_URL];\n\n const displayName = profile?.displayName ?? title ?? name;\n const emailHref = profile?.email ? `mailto:${profile.email}` : '#';\n const infoCardAction = entityMetadataEditUrl ? (\n <IconButton\n aria-label=\"Edit\"\n title=\"Edit Metadata\"\n component={Link}\n to={entityMetadataEditUrl}\n >\n <EditIcon />\n </IconButton>\n ) : (\n <IconButton aria-label=\"Edit\" disabled title=\"Edit Metadata\">\n <EditIcon />\n </IconButton>\n );\n\n return (\n <InfoCard\n title={<CardTitle title={displayName} />}\n subheader={description}\n variant={props.variant}\n action={\n <>\n {allowRefresh && canRefresh && (\n <IconButton\n aria-label=\"Refresh\"\n title=\"Schedule entity refresh\"\n onClick={refreshEntity}\n >\n <CachedIcon />\n </IconButton>\n )}\n {infoCardAction}\n </>\n }\n >\n <Grid container spacing={3}>\n <Grid item xs={12} sm={2} xl={1}>\n <Avatar displayName={displayName} picture={profile?.picture} />\n </Grid>\n <Grid item md={10} xl={11}>\n <List>\n {profile?.email && (\n <ListItem>\n <ListItemIcon>\n <Tooltip title=\"Email\">\n <EmailIcon />\n </Tooltip>\n </ListItemIcon>\n <ListItemText\n primary={<Link to={emailHref}>{profile.email}</Link>}\n secondary=\"Email\"\n />\n </ListItem>\n )}\n <ListItem>\n <ListItemIcon>\n <Tooltip title=\"Parent Group\">\n <AccountTreeIcon />\n </Tooltip>\n </ListItemIcon>\n <ListItemText\n primary={\n parentRelations.length ? (\n <EntityRefLinks\n entityRefs={parentRelations}\n defaultKind=\"Group\"\n />\n ) : (\n 'N/A'\n )\n }\n secondary=\"Parent Group\"\n />\n </ListItem>\n <ListItem>\n <ListItemIcon>\n <Tooltip title=\"Child Groups\">\n <GroupIcon />\n </Tooltip>\n </ListItemIcon>\n <ListItemText\n primary={\n childRelations.length ? (\n <EntityRefLinks\n entityRefs={childRelations}\n defaultKind=\"Group\"\n />\n ) : (\n 'N/A'\n )\n }\n secondary=\"Child Groups\"\n />\n </ListItem>\n {props?.showLinks && <LinksGroup links={links} />}\n </List>\n </Grid>\n </Grid>\n </InfoCard>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAyDA,MAAM,SAAA,GAAY,CAAC,KACjB,qBAAA,KAAA,CAAA,aAAA,CAAC,OAAI,OAAQ,EAAA,MAAA,EAAO,YAAW,QAC7B,EAAA,kBAAA,KAAA,CAAA,aAAA,CAAC,aAAU,QAAS,EAAA,SAAA,EAAU,mBAC7B,KAAA,CAAA,aAAA,CAAA,GAAA,EAAA,EAAI,IAAI,CAAI,EAAA,EAAA,KAAA,CAAM,KAAM,CAC3B,CAAA,CAAA;AAIW,MAAA,gBAAA,GAAmB,CAAC,KAG3B,KAAA;AApEN,EAAA,IAAA,EAAA,EAAA,EAAA,EAAA,EAAA,CAAA;AAqEE,EAAM,MAAA,UAAA,GAAa,OAAO,aAAa,CAAA,CAAA;AACvC,EAAM,MAAA,QAAA,GAAW,OAAO,WAAW,CAAA,CAAA;AACnC,EAAA,MAAM,EAAE,MAAA,EAAQ,KAAM,EAAA,GAAI,SAAuB,EAAA,CAAA;AACjD,EAAM,MAAA,EAAE,OAAS,EAAA,UAAA,EAAe,GAAA,mBAAA;AAAA,IAC9B,8BAAA;AAAA,GACF,CAAA;AAEA,EAAM,MAAA,aAAA,GAAgB,YAAY,YAAY;AAC5C,IAAA,MAAM,UAAW,CAAA,aAAA,CAAc,kBAAmB,CAAA,KAAK,CAAC,CAAA,CAAA;AACxD,IAAA,QAAA,CAAS,IAAK,CAAA;AAAA,MACZ,OAAS,EAAA,mBAAA;AAAA,MACT,QAAU,EAAA,MAA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A,aAAA;AAAA,MAAC,YAAA;AAAA,MAAA;AAAA,QACC,OAAA,EACE,gBAAgB,MACd,mBAAA,KAAA,CAAA,aAAA;AAAA,UAAC,cAAA;AAAA,UAAA;AAAA,YACC,UAAY,EAAA,eAAA;AAAA,YACZ,WAAY,EAAA,OAAA;AAAA,WAAA;AAAA,SAGd,GAAA,KAAA;AAAA,QAGJ,SAAU,EAAA,cAAA;AAAA,OAAA;AAAA,KAEd,CAAA,kBACC,KAAA,CAAA,aAAA,CAAA,QAAA,EAAA,IAAA,sCACE,YACC,EAAA,IAAA,kBAAA,KAAA,CAAA,aAAA,CAAC,OAAQ,EAAA,EAAA,KAAA,EAAM,cACb,EAAA,kBAAA,KAAA,CAAA,aAAA,CAAC,SAAU,EAAA,IAAA,CACb,CACF,CACA,kBAAA,KAAA,CAAA,aAAA;AAAA,MAAC,YAAA;AAAA,MAAA;AAAA,QACC,OAAA,EACE,eAAe,MACb,mBAAA,KAAA,CAAA,aAAA;AAAA,UAAC,cAAA;AAAA,UAAA;AAAA,YACC,UAAY,EAAA,cAAA;AAAA,YACZ,WAAY,EAAA,OAAA;AAAA,WAAA;AAAA,SAGd,GAAA,KAAA;AAAA,QAGJ,SAAU,EAAA,cAAA;AAAA,OAAA;AAAA,KAEd,IACC,KAAO,IAAA,IAAA,GAAA,KAAA,CAAA,GAAA,KAAA,CAAA,SAAA,yCAAc,UAAW,EAAA,EAAA,KAAA,EAAc,CACjD,CACF,CACF,CAAA;AAAA,GACF,CAAA;AAEJ;;;;"}
|
|
1
|
+
{"version":3,"file":"GroupProfileCard.esm.js","sources":["../../../../../src/components/Cards/Group/GroupProfile/GroupProfileCard.tsx"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n ANNOTATION_EDIT_URL,\n ANNOTATION_LOCATION,\n GroupEntity,\n RELATION_CHILD_OF,\n RELATION_PARENT_OF,\n stringifyEntityRef,\n} from '@backstage/catalog-model';\nimport {\n Avatar,\n InfoCard,\n InfoCardVariants,\n Link,\n} from '@backstage/core-components';\nimport Box from '@material-ui/core/Box';\nimport Grid from '@material-ui/core/Grid';\nimport IconButton from '@material-ui/core/IconButton';\nimport List from '@material-ui/core/List';\nimport ListItem from '@material-ui/core/ListItem';\nimport ListItemIcon from '@material-ui/core/ListItemIcon';\nimport ListItemText from '@material-ui/core/ListItemText';\nimport Tooltip from '@material-ui/core/Tooltip';\nimport {\n EntityRefLinks,\n catalogApiRef,\n getEntityRelations,\n useEntity,\n} from '@backstage/plugin-catalog-react';\nimport React, { useCallback } from 'react';\nimport { alertApiRef, useApi } from '@backstage/core-plugin-api';\n\nimport AccountTreeIcon from '@material-ui/icons/AccountTree';\nimport Alert from '@material-ui/lab/Alert';\nimport CachedIcon from '@material-ui/icons/Cached';\nimport EditIcon from '@material-ui/icons/Edit';\nimport EmailIcon from '@material-ui/icons/Email';\nimport GroupIcon from '@material-ui/icons/Group';\nimport { LinksGroup } from '../../Meta';\nimport { useEntityPermission } from '@backstage/plugin-catalog-react/alpha';\nimport { catalogEntityRefreshPermission } from '@backstage/plugin-catalog-common/alpha';\n\nconst CardTitle = (props: { title: string }) => (\n <Box display=\"flex\" alignItems=\"center\">\n <GroupIcon fontSize=\"inherit\" />\n <Box ml={1}>{props.title}</Box>\n </Box>\n);\n\n/** @public */\nexport const GroupProfileCard = (props: {\n variant?: InfoCardVariants;\n showLinks?: boolean;\n}) => {\n const catalogApi = useApi(catalogApiRef);\n const alertApi = useApi(alertApiRef);\n const { entity: group } = useEntity<GroupEntity>();\n const { allowed: canRefresh } = useEntityPermission(\n catalogEntityRefreshPermission,\n );\n\n const refreshEntity = useCallback(async () => {\n await catalogApi.refreshEntity(stringifyEntityRef(group));\n alertApi.post({\n message: 'Refresh scheduled',\n severity: 'info',\n display: 'transient',\n });\n }, [catalogApi, alertApi, group]);\n\n if (!group) {\n return <Alert severity=\"error\">Group not found</Alert>;\n }\n\n const {\n metadata: { name, description, title, annotations, links },\n spec: { profile },\n } = group;\n\n const childRelations = getEntityRelations(group, RELATION_PARENT_OF, {\n kind: 'Group',\n });\n const parentRelations = getEntityRelations(group, RELATION_CHILD_OF, {\n kind: 'group',\n });\n\n const entityLocation = annotations?.[ANNOTATION_LOCATION];\n const allowRefresh =\n entityLocation?.startsWith('url:') || entityLocation?.startsWith('file:');\n\n const entityMetadataEditUrl =\n group.metadata.annotations?.[ANNOTATION_EDIT_URL];\n\n const displayName = profile?.displayName ?? title ?? name;\n const emailHref = profile?.email ? `mailto:${profile.email}` : '#';\n const infoCardAction = entityMetadataEditUrl ? (\n <IconButton\n aria-label=\"Edit\"\n title=\"Edit Metadata\"\n component={Link}\n to={entityMetadataEditUrl}\n >\n <EditIcon />\n </IconButton>\n ) : (\n <IconButton aria-label=\"Edit\" disabled title=\"Edit Metadata\">\n <EditIcon />\n </IconButton>\n );\n\n return (\n <InfoCard\n title={<CardTitle title={displayName} />}\n subheader={description}\n variant={props.variant}\n action={\n <>\n {allowRefresh && canRefresh && (\n <IconButton\n aria-label=\"Refresh\"\n title=\"Schedule entity refresh\"\n onClick={refreshEntity}\n >\n <CachedIcon />\n </IconButton>\n )}\n {infoCardAction}\n </>\n }\n >\n <Grid container spacing={3}>\n <Grid item xs={12} sm={2} xl={1}>\n <Avatar displayName={displayName} picture={profile?.picture} />\n </Grid>\n <Grid item md={10} xl={11}>\n <List>\n {profile?.email && (\n <ListItem>\n <ListItemIcon>\n <Tooltip title=\"Email\">\n <EmailIcon />\n </Tooltip>\n </ListItemIcon>\n <ListItemText\n primary={<Link to={emailHref}>{profile.email}</Link>}\n secondary=\"Email\"\n />\n </ListItem>\n )}\n <ListItem>\n <ListItemIcon>\n <Tooltip title=\"Parent Group\">\n <AccountTreeIcon />\n </Tooltip>\n </ListItemIcon>\n <ListItemText\n primary={\n parentRelations.length ? (\n <EntityRefLinks\n entityRefs={parentRelations}\n defaultKind=\"Group\"\n />\n ) : (\n 'N/A'\n )\n }\n secondary=\"Parent Group\"\n />\n </ListItem>\n <ListItem>\n <ListItemIcon>\n <Tooltip title=\"Child Groups\">\n <GroupIcon />\n </Tooltip>\n </ListItemIcon>\n <ListItemText\n primary={\n childRelations.length ? (\n <EntityRefLinks\n entityRefs={childRelations}\n defaultKind=\"Group\"\n />\n ) : (\n 'N/A'\n )\n }\n secondary=\"Child Groups\"\n />\n </ListItem>\n {props?.showLinks && <LinksGroup links={links} />}\n </List>\n </Grid>\n </Grid>\n </InfoCard>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAyDA,MAAM,SAAA,GAAY,CAAC,KACjB,qBAAA,KAAA,CAAA,aAAA,CAAC,OAAI,OAAQ,EAAA,MAAA,EAAO,YAAW,QAC7B,EAAA,kBAAA,KAAA,CAAA,aAAA,CAAC,aAAU,QAAS,EAAA,SAAA,EAAU,mBAC7B,KAAA,CAAA,aAAA,CAAA,GAAA,EAAA,EAAI,IAAI,CAAI,EAAA,EAAA,KAAA,CAAM,KAAM,CAC3B,CAAA,CAAA;AAIW,MAAA,gBAAA,GAAmB,CAAC,KAG3B,KAAA;AACJ,EAAM,MAAA,UAAA,GAAa,OAAO,aAAa,CAAA,CAAA;AACvC,EAAM,MAAA,QAAA,GAAW,OAAO,WAAW,CAAA,CAAA;AACnC,EAAA,MAAM,EAAE,MAAA,EAAQ,KAAM,EAAA,GAAI,SAAuB,EAAA,CAAA;AACjD,EAAM,MAAA,EAAE,OAAS,EAAA,UAAA,EAAe,GAAA,mBAAA;AAAA,IAC9B,8BAAA;AAAA,GACF,CAAA;AAEA,EAAM,MAAA,aAAA,GAAgB,YAAY,YAAY;A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A,cAAA;AAAA,OAAA;AAAA,KAEd,CAAA,kBACC,KAAA,CAAA,aAAA,CAAA,QAAA,EAAA,IAAA,sCACE,YACC,EAAA,IAAA,kBAAA,KAAA,CAAA,aAAA,CAAC,OAAQ,EAAA,EAAA,KAAA,EAAM,cACb,EAAA,kBAAA,KAAA,CAAA,aAAA,CAAC,SAAU,EAAA,IAAA,CACb,CACF,CACA,kBAAA,KAAA,CAAA,aAAA;AAAA,MAAC,YAAA;AAAA,MAAA;AAAA,QACC,OAAA,EACE,eAAe,MACb,mBAAA,KAAA,CAAA,aAAA;AAAA,UAAC,cAAA;AAAA,UAAA;AAAA,YACC,UAAY,EAAA,cAAA;AAAA,YACZ,WAAY,EAAA,OAAA;AAAA,WAAA;AAAA,SAGd,GAAA,KAAA;AAAA,QAGJ,SAAU,EAAA,cAAA;AAAA,OAAA;AAAA,KAEd,GACC,KAAO,EAAA,SAAA,wCAAc,UAAW,EAAA,EAAA,KAAA,EAAc,CACjD,CACF,CACF,CAAA;AAAA,GACF,CAAA;AAEJ;;;;"}
|
|
@@ -32,13 +32,12 @@ const useStyles = makeStyles(
|
|
|
32
32
|
{ name: "MembersListCardComponent" }
|
|
33
33
|
);
|
|
34
34
|
const MemberComponent = (props) => {
|
|
35
|
-
var _a;
|
|
36
35
|
const classes = useStyles();
|
|
37
36
|
const {
|
|
38
37
|
metadata: { name: metaName, description },
|
|
39
38
|
spec: { profile }
|
|
40
39
|
} = props.member;
|
|
41
|
-
const displayName =
|
|
40
|
+
const displayName = profile?.displayName ?? metaName;
|
|
42
41
|
return /* @__PURE__ */ React.createElement(Box, { className: classes.card }, /* @__PURE__ */ React.createElement(
|
|
43
42
|
Box,
|
|
44
43
|
{
|
|
@@ -52,7 +51,7 @@ const MemberComponent = (props) => {
|
|
|
52
51
|
Avatar,
|
|
53
52
|
{
|
|
54
53
|
displayName,
|
|
55
|
-
picture: profile
|
|
54
|
+
picture: profile?.picture,
|
|
56
55
|
classes
|
|
57
56
|
}
|
|
58
57
|
),
|
|
@@ -73,7 +72,7 @@ const MemberComponent = (props) => {
|
|
|
73
72
|
title: displayName
|
|
74
73
|
}
|
|
75
74
|
)),
|
|
76
|
-
|
|
75
|
+
profile?.email && /* @__PURE__ */ React.createElement(Link, { to: `mailto:${profile.email}` }, /* @__PURE__ */ React.createElement(OverflowTooltip, { text: profile.email })),
|
|
77
76
|
description && /* @__PURE__ */ React.createElement(Typography, { variant: "subtitle2" }, description)
|
|
78
77
|
)
|
|
79
78
|
));
|
|
@@ -94,7 +93,6 @@ const useListStyles = makeStyles((theme) => ({
|
|
|
94
93
|
}
|
|
95
94
|
}));
|
|
96
95
|
const MembersListCard = (props) => {
|
|
97
|
-
var _a;
|
|
98
96
|
const {
|
|
99
97
|
memberDisplayTitle = "Members",
|
|
100
98
|
pageSize = 50,
|
|
@@ -108,7 +106,7 @@ const MembersListCard = (props) => {
|
|
|
108
106
|
spec: { profile }
|
|
109
107
|
} = groupEntity;
|
|
110
108
|
const catalogApi = useApi(catalogApiRef);
|
|
111
|
-
const displayName =
|
|
109
|
+
const displayName = profile?.displayName ?? groupName;
|
|
112
110
|
const groupNamespace = grpNamespace || DEFAULT_NAMESPACE;
|
|
113
111
|
const [page, setPage] = React.useState(1);
|
|
114
112
|
const pageChange = (_, pageIndex) => {
|
|
@@ -147,7 +145,7 @@ const MembersListCard = (props) => {
|
|
|
147
145
|
}, [catalogApi, groupEntity]);
|
|
148
146
|
const members = removeDuplicateEntitiesFrom(
|
|
149
147
|
[
|
|
150
|
-
...directMembers
|
|
148
|
+
...directMembers ?? [],
|
|
151
149
|
...descendantMembers && showAggregateMembers ? descendantMembers : []
|
|
152
150
|
].sort(
|
|
153
151
|
(a, b) => stringifyEntityRef(a).localeCompare(stringifyEntityRef(b))
|
|
@@ -158,7 +156,7 @@ const MembersListCard = (props) => {
|
|
|
158
156
|
} else if (error) {
|
|
159
157
|
return /* @__PURE__ */ React.createElement(ResponseErrorPanel, { error });
|
|
160
158
|
}
|
|
161
|
-
const nbPages = Math.ceil((
|
|
159
|
+
const nbPages = Math.ceil((members?.length || 0) / pageSize);
|
|
162
160
|
const paginationLabel = nbPages < 2 ? "" : `, page ${page} of ${nbPages}`;
|
|
163
161
|
const pagination = /* @__PURE__ */ React.createElement(
|
|
164
162
|
Pagination,
|
|
@@ -179,7 +177,7 @@ const MembersListCard = (props) => {
|
|
|
179
177
|
return /* @__PURE__ */ React.createElement(Grid, { item: true, className: classes.root }, /* @__PURE__ */ React.createElement(
|
|
180
178
|
InfoCard,
|
|
181
179
|
{
|
|
182
|
-
title: `${memberDisplayTitle} (${
|
|
180
|
+
title: `${memberDisplayTitle} (${members?.length || 0}${paginationLabel})`,
|
|
183
181
|
subheader: `of ${displayName}`,
|
|
184
182
|
...nbPages <= 1 ? {} : { actions: pagination },
|
|
185
183
|
className: classes.root,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MembersListCard.esm.js","sources":["../../../../../src/components/Cards/Group/MembersList/MembersListCard.tsx"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n DEFAULT_NAMESPACE,\n GroupEntity,\n UserEntity,\n stringifyEntityRef,\n} from '@backstage/catalog-model';\nimport { catalogApiRef, useEntity } from '@backstage/plugin-catalog-react';\nimport Box from '@material-ui/core/Box';\nimport Grid from '@material-ui/core/Grid';\nimport Switch from '@material-ui/core/Switch';\nimport Typography from '@material-ui/core/Typography';\nimport { createStyles, makeStyles, Theme } from '@material-ui/core/styles';\nimport Pagination from '@material-ui/lab/Pagination';\nimport React, { useState } from 'react';\nimport useAsync from 'react-use/esm/useAsync';\n\nimport {\n Avatar,\n InfoCard,\n Progress,\n ResponseErrorPanel,\n Link,\n OverflowTooltip,\n} from '@backstage/core-components';\nimport { useApi } from '@backstage/core-plugin-api';\nimport {\n getAllDesendantMembersForGroupEntity,\n removeDuplicateEntitiesFrom,\n} from '../../../../helpers/helpers';\nimport { EntityRefLink } from '@backstage/plugin-catalog-react';\nimport { EntityRelationAggregation } from '../../types';\n\nconst useStyles = makeStyles(\n (theme: Theme) =>\n createStyles({\n card: {\n border: `1px solid ${theme.palette.divider}`,\n boxShadow: theme.shadows[2],\n borderRadius: '4px',\n overflow: 'visible',\n position: 'relative',\n margin: theme.spacing(4, 1, 1),\n flex: '1',\n minWidth: '0px',\n },\n avatar: {\n position: 'absolute',\n top: '-2rem',\n },\n }),\n { name: 'MembersListCardComponent' },\n);\n\nconst MemberComponent = (props: { member: UserEntity }) => {\n const classes = useStyles();\n const {\n metadata: { name: metaName, description },\n spec: { profile },\n } = props.member;\n const displayName = profile?.displayName ?? metaName;\n\n return (\n <Box className={classes.card}>\n <Box\n display=\"flex\"\n flexDirection=\"column\"\n m={3}\n alignItems=\"center\"\n justifyContent=\"center\"\n >\n <Avatar\n displayName={displayName}\n picture={profile?.picture}\n classes={classes}\n />\n <Box\n pt={2}\n sx={{\n width: '100%',\n }}\n textAlign=\"center\"\n >\n <Typography variant=\"h6\">\n <EntityRefLink\n data-testid=\"user-link\"\n entityRef={props.member}\n title={displayName}\n />\n </Typography>\n {profile?.email && (\n <Link to={`mailto:${profile.email}`}>\n <OverflowTooltip text={profile.email} />\n </Link>\n )}\n {description && (\n <Typography variant=\"subtitle2\">{description}</Typography>\n )}\n </Box>\n </Box>\n </Box>\n );\n};\n\nconst useListStyles = makeStyles(theme => ({\n root: {\n height: '100%',\n },\n cardContent: {\n overflow: 'auto',\n },\n memberList: {\n display: 'grid',\n gap: theme.spacing(1.5),\n gridTemplateColumns: `repeat(auto-fit, minmax(auto, ${theme.spacing(\n 34,\n )}px))`,\n },\n}));\n\n/** @public */\nexport const MembersListCard = (props: {\n memberDisplayTitle?: string;\n pageSize?: number;\n showAggregateMembersToggle?: boolean;\n relationsType?: EntityRelationAggregation;\n}) => {\n const {\n memberDisplayTitle = 'Members',\n pageSize = 50,\n showAggregateMembersToggle,\n relationsType = 'direct',\n } = props;\n const classes = useListStyles();\n\n const { entity: groupEntity } = useEntity<GroupEntity>();\n const {\n metadata: { name: groupName, namespace: grpNamespace },\n spec: { profile },\n } = groupEntity;\n const catalogApi = useApi(catalogApiRef);\n\n const displayName = profile?.displayName ?? groupName;\n\n const groupNamespace = grpNamespace || DEFAULT_NAMESPACE;\n\n const [page, setPage] = React.useState(1);\n const pageChange = (_: React.ChangeEvent<unknown>, pageIndex: number) => {\n setPage(pageIndex);\n };\n\n const [showAggregateMembers, setShowAggregateMembers] = useState(\n relationsType === 'aggregated',\n );\n\n const { loading: loadingDescendantMembers, value: descendantMembers } =\n useAsync(async () => {\n if (!showAggregateMembers) {\n return [] as UserEntity[];\n }\n\n return await getAllDesendantMembersForGroupEntity(\n groupEntity,\n catalogApi,\n );\n }, [catalogApi, groupEntity, showAggregateMembers]);\n const {\n loading,\n error,\n value: directMembers,\n } = useAsync(async () => {\n const membersList = await catalogApi.getEntities({\n filter: {\n kind: 'User',\n 'relations.memberof': [\n stringifyEntityRef({\n kind: 'group',\n namespace: groupNamespace.toLocaleLowerCase('en-US'),\n name: groupName.toLocaleLowerCase('en-US'),\n }),\n ],\n },\n });\n\n return membersList.items as UserEntity[];\n }, [catalogApi, groupEntity]);\n\n const members = removeDuplicateEntitiesFrom(\n [\n ...(directMembers ?? []),\n ...(descendantMembers && showAggregateMembers ? descendantMembers : []),\n ].sort((a, b) =>\n stringifyEntityRef(a).localeCompare(stringifyEntityRef(b)),\n ),\n ) as UserEntity[];\n\n if (loading) {\n return <Progress />;\n } else if (error) {\n return <ResponseErrorPanel error={error} />;\n }\n\n const nbPages = Math.ceil((members?.length || 0) / pageSize);\n const paginationLabel = nbPages < 2 ? '' : `, page ${page} of ${nbPages}`;\n\n const pagination = (\n <Pagination\n count={nbPages}\n page={page}\n onChange={pageChange}\n showFirstButton\n showLastButton\n />\n );\n\n let memberList: React.JSX.Element;\n if (members && members.length > 0) {\n memberList = (\n <Box className={classes.memberList}>\n {members.slice(pageSize * (page - 1), pageSize * page).map(member => (\n <MemberComponent member={member} key={stringifyEntityRef(member)} />\n ))}\n </Box>\n );\n } else {\n memberList = (\n <Box p={2}>\n <Typography>\n This group has no {memberDisplayTitle.toLocaleLowerCase()}.\n </Typography>\n </Box>\n );\n }\n\n return (\n <Grid item className={classes.root}>\n <InfoCard\n title={`${memberDisplayTitle} (${\n members?.length || 0\n }${paginationLabel})`}\n subheader={`of ${displayName}`}\n {...(nbPages <= 1 ? {} : { actions: pagination })}\n className={classes.root}\n cardClassName={classes.cardContent}\n >\n {showAggregateMembersToggle && (\n <>\n Direct Members\n <Switch\n color=\"primary\"\n checked={showAggregateMembers}\n onChange={() => {\n setShowAggregateMembers(!showAggregateMembers);\n }}\n inputProps={{ 'aria-label': 'Users Type Switch' }}\n />\n Aggregated Members\n </>\n )}\n {showAggregateMembers && loadingDescendantMembers ? (\n <Progress />\n ) : (\n memberList\n )}\n </InfoCard>\n </Grid>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;AAgDA,MAAM,SAAY,GAAA,UAAA;AAAA,EAChB,CAAC,UACC,YAAa,CAAA;AAAA,IACX,IAAM,EAAA;AAAA,MACJ,MAAQ,EAAA,CAAA,UAAA,EAAa,KAAM,CAAA,OAAA,CAAQ,OAAO,CAAA,CAAA;AAAA,MAC1C,SAAA,EAAW,KAAM,CAAA,OAAA,CAAQ,CAAC,CAAA;AAAA,MAC1B,YAAc,EAAA,KAAA;AAAA,MACd,QAAU,EAAA,SAAA;AAAA,MACV,QAAU,EAAA,UAAA;AAAA,MACV,MAAQ,EAAA,KAAA,CAAM,OAAQ,CAAA,CAAA,EAAG,GAAG,CAAC,CAAA;AAAA,MAC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EAAA,GAC5D,CACF,CAAA,CAAA;AAAA,GAEJ;AAEA,EAAA,2CACG,IAAK,EAAA,EAAA,IAAA,EAAI,IAAC,EAAA,SAAA,EAAW,QAAQ,IAC5B,EAAA,kBAAA,KAAA,CAAA,aAAA;AAAA,IAAC,QAAA;AAAA,IAAA;AAAA,MACC,KAAA,EAAO,GAAG,kBAAkB,CAAA,EAAA,EAAA,CAC1B,mCAAS,MAAU,KAAA,CACrB,GAAG,eAAe,CAAA,CAAA,CAAA;AAAA,MAClB,SAAA,EAAW,MAAM,WAAW,CAAA,CAAA;AAAA,MAC3B,GAAI,OAAW,IAAA,CAAA,GAAI,EAAK,GAAA,EAAE,SAAS,UAAW,EAAA;AAAA,MAC/C,WAAW,OAAQ,CAAA,IAAA;AAAA,MACnB,eAAe,OAAQ,CAAA,WAAA;AAAA,KAAA;AAAA,IAEtB,0BAAA,8DACG,gBAEA,kBAAA,KAAA,CAAA,aAAA;AAAA,MAAC,MAAA;AAAA,MAAA;AAAA,QACC,KAAM,EAAA,SAAA;AAAA,QACN,OAAS,EAAA,oBAAA;AAAA,QACT,UAAU,MAAM;AACd,UAAA,uBAAA,CAAwB,CAAC,oBAAoB,CAAA,CAAA;AAAA,SAC/C;AAAA,QACA,UAAA,EAAY,EAAE,YAAA,EAAc,mBAAoB,EAAA;AAAA,OAAA;AAAA,OAChD,oBAEJ,CAAA;AAAA,IAED,oBAAwB,IAAA,wBAAA,mBACtB,KAAA,CAAA,aAAA,CAAA,QAAA,EAAA,IAAS,CAEV,GAAA,UAAA;AAAA,GAGN,CAAA,CAAA;AAEJ;;;;"}
|
|
1
|
+
{"version":3,"file":"MembersListCard.esm.js","sources":["../../../../../src/components/Cards/Group/MembersList/MembersListCard.tsx"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n DEFAULT_NAMESPACE,\n GroupEntity,\n UserEntity,\n stringifyEntityRef,\n} from '@backstage/catalog-model';\nimport { catalogApiRef, useEntity } from '@backstage/plugin-catalog-react';\nimport Box from '@material-ui/core/Box';\nimport Grid from '@material-ui/core/Grid';\nimport Switch from '@material-ui/core/Switch';\nimport Typography from '@material-ui/core/Typography';\nimport { createStyles, makeStyles, Theme } from '@material-ui/core/styles';\nimport Pagination from '@material-ui/lab/Pagination';\nimport React, { useState } from 'react';\nimport useAsync from 'react-use/esm/useAsync';\n\nimport {\n Avatar,\n InfoCard,\n Progress,\n ResponseErrorPanel,\n Link,\n OverflowTooltip,\n} from '@backstage/core-components';\nimport { useApi } from '@backstage/core-plugin-api';\nimport {\n getAllDesendantMembersForGroupEntity,\n removeDuplicateEntitiesFrom,\n} from '../../../../helpers/helpers';\nimport { EntityRefLink } from '@backstage/plugin-catalog-react';\nimport { EntityRelationAggregation } from '../../types';\n\nconst useStyles = makeStyles(\n (theme: Theme) =>\n createStyles({\n card: {\n border: `1px solid ${theme.palette.divider}`,\n boxShadow: theme.shadows[2],\n borderRadius: '4px',\n overflow: 'visible',\n position: 'relative',\n margin: theme.spacing(4, 1, 1),\n flex: '1',\n minWidth: '0px',\n },\n avatar: {\n position: 'absolute',\n top: '-2rem',\n },\n }),\n { name: 'MembersListCardComponent' },\n);\n\nconst MemberComponent = (props: { member: UserEntity }) => {\n const classes = useStyles();\n const {\n metadata: { name: metaName, description },\n spec: { profile },\n } = props.member;\n const displayName = profile?.displayName ?? metaName;\n\n return (\n <Box className={classes.card}>\n <Box\n display=\"flex\"\n flexDirection=\"column\"\n m={3}\n alignItems=\"center\"\n justifyContent=\"center\"\n >\n <Avatar\n displayName={displayName}\n picture={profile?.picture}\n classes={classes}\n />\n <Box\n pt={2}\n sx={{\n width: '100%',\n }}\n textAlign=\"center\"\n >\n <Typography variant=\"h6\">\n <EntityRefLink\n data-testid=\"user-link\"\n entityRef={props.member}\n title={displayName}\n />\n </Typography>\n {profile?.email && (\n <Link to={`mailto:${profile.email}`}>\n <OverflowTooltip text={profile.email} />\n </Link>\n )}\n {description && (\n <Typography variant=\"subtitle2\">{description}</Typography>\n )}\n </Box>\n </Box>\n </Box>\n );\n};\n\nconst useListStyles = makeStyles(theme => ({\n root: {\n height: '100%',\n },\n cardContent: {\n overflow: 'auto',\n },\n memberList: {\n display: 'grid',\n gap: theme.spacing(1.5),\n gridTemplateColumns: `repeat(auto-fit, minmax(auto, ${theme.spacing(\n 34,\n )}px))`,\n },\n}));\n\n/** @public */\nexport const MembersListCard = (props: {\n memberDisplayTitle?: string;\n pageSize?: number;\n showAggregateMembersToggle?: boolean;\n relationsType?: EntityRelationAggregation;\n}) => {\n const {\n memberDisplayTitle = 'Members',\n pageSize = 50,\n showAggregateMembersToggle,\n relationsType = 'direct',\n } = props;\n const classes = useListStyles();\n\n const { entity: groupEntity } = useEntity<GroupEntity>();\n const {\n metadata: { name: groupName, namespace: grpNamespace },\n spec: { profile },\n } = groupEntity;\n const catalogApi = useApi(catalogApiRef);\n\n const displayName = profile?.displayName ?? groupName;\n\n const groupNamespace = grpNamespace || DEFAULT_NAMESPACE;\n\n const [page, setPage] = React.useState(1);\n const pageChange = (_: React.ChangeEvent<unknown>, pageIndex: number) => {\n setPage(pageIndex);\n };\n\n const [showAggregateMembers, setShowAggregateMembers] = useState(\n relationsType === 'aggregated',\n );\n\n const { loading: loadingDescendantMembers, value: descendantMembers } =\n useAsync(async () => {\n if (!showAggregateMembers) {\n return [] as UserEntity[];\n }\n\n return await getAllDesendantMembersForGroupEntity(\n groupEntity,\n catalogApi,\n );\n }, [catalogApi, groupEntity, showAggregateMembers]);\n const {\n loading,\n error,\n value: directMembers,\n } = useAsync(async () => {\n const membersList = await catalogApi.getEntities({\n filter: {\n kind: 'User',\n 'relations.memberof': [\n stringifyEntityRef({\n kind: 'group',\n namespace: groupNamespace.toLocaleLowerCase('en-US'),\n name: groupName.toLocaleLowerCase('en-US'),\n }),\n ],\n },\n });\n\n return membersList.items as UserEntity[];\n }, [catalogApi, groupEntity]);\n\n const members = removeDuplicateEntitiesFrom(\n [\n ...(directMembers ?? []),\n ...(descendantMembers && showAggregateMembers ? descendantMembers : []),\n ].sort((a, b) =>\n stringifyEntityRef(a).localeCompare(stringifyEntityRef(b)),\n ),\n ) as UserEntity[];\n\n if (loading) {\n return <Progress />;\n } else if (error) {\n return <ResponseErrorPanel error={error} />;\n }\n\n const nbPages = Math.ceil((members?.length || 0) / pageSize);\n const paginationLabel = nbPages < 2 ? '' : `, page ${page} of ${nbPages}`;\n\n const pagination = (\n <Pagination\n count={nbPages}\n page={page}\n onChange={pageChange}\n showFirstButton\n showLastButton\n />\n );\n\n let memberList: React.JSX.Element;\n if (members && members.length > 0) {\n memberList = (\n <Box className={classes.memberList}>\n {members.slice(pageSize * (page - 1), pageSize * page).map(member => (\n <MemberComponent member={member} key={stringifyEntityRef(member)} />\n ))}\n </Box>\n );\n } else {\n memberList = (\n <Box p={2}>\n <Typography>\n This group has no {memberDisplayTitle.toLocaleLowerCase()}.\n </Typography>\n </Box>\n );\n }\n\n return (\n <Grid item className={classes.root}>\n <InfoCard\n title={`${memberDisplayTitle} (${\n members?.length || 0\n }${paginationLabel})`}\n subheader={`of ${displayName}`}\n {...(nbPages <= 1 ? {} : { actions: pagination })}\n className={classes.root}\n cardClassName={classes.cardContent}\n >\n {showAggregateMembersToggle && (\n <>\n Direct Members\n <Switch\n color=\"primary\"\n checked={showAggregateMembers}\n onChange={() => {\n setShowAggregateMembers(!showAggregateMembers);\n }}\n inputProps={{ 'aria-label': 'Users Type Switch' }}\n />\n Aggregated Members\n </>\n )}\n {showAggregateMembers && loadingDescendantMembers ? (\n <Progress />\n ) : (\n memberList\n )}\n </InfoCard>\n </Grid>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CAAC,UAAW,EAAA,IAAA,EAAA,oBAAA,EACS,kBAAmB,CAAA,iBAAA,EAAoB,EAAA,GAC5D,CACF,CAAA,CAAA;AAAA,GAEJ;AAEA,EAAA,2CACG,IAAK,EAAA,EAAA,IAAA,EAAI,IAAC,EAAA,SAAA,EAAW,QAAQ,IAC5B,EAAA,kBAAA,KAAA,CAAA,aAAA;AAAA,IAAC,QAAA;AAAA,IAAA;AAAA,MACC,KAAA,EAAO,GAAG,kBAAkB,CAAA,EAAA,EAC1B,SAAS,MAAU,IAAA,CACrB,GAAG,eAAe,CAAA,CAAA,CAAA;AAAA,MAClB,SAAA,EAAW,MAAM,WAAW,CAAA,CAAA;AAAA,MAC3B,GAAI,OAAW,IAAA,CAAA,GAAI,EAAK,GAAA,EAAE,SAAS,UAAW,EAAA;AAAA,MAC/C,WAAW,OAAQ,CAAA,IAAA;AAAA,MACnB,eAAe,OAAQ,CAAA,WAAA;AAAA,KAAA;AAAA,IAEtB,0BAAA,8DACG,gBAEA,kBAAA,KAAA,CAAA,aAAA;AAAA,MAAC,MAAA;AAAA,MAAA;AAAA,QACC,KAAM,EAAA,SAAA;AAAA,QACN,OAAS,EAAA,oBAAA;AAAA,QACT,UAAU,MAAM;AACd,UAAA,uBAAA,CAAwB,CAAC,oBAAoB,CAAA,CAAA;AAAA,SAC/C;AAAA,QACA,UAAA,EAAY,EAAE,YAAA,EAAc,mBAAoB,EAAA;AAAA,OAAA;AAAA,OAChD,oBAEJ,CAAA;AAAA,IAED,oBAAwB,IAAA,wBAAA,mBACtB,KAAA,CAAA,aAAA,CAAA,QAAA,EAAA,IAAS,CAEV,GAAA,UAAA;AAAA,GAGN,CAAA,CAAA;AAEJ;;;;"}
|
|
@@ -14,10 +14,7 @@ const WebLink = ({
|
|
|
14
14
|
}) => /* @__PURE__ */ React.createElement(ListItem, { key: href }, /* @__PURE__ */ React.createElement(ListItemIcon, null, Icon ? /* @__PURE__ */ React.createElement(Icon, null) : /* @__PURE__ */ React.createElement(LanguageIcon, null)), /* @__PURE__ */ React.createElement(ListItemText, null, /* @__PURE__ */ React.createElement(Link, { to: href }, text)));
|
|
15
15
|
const LinksGroup = ({ links }) => {
|
|
16
16
|
const app = useApp();
|
|
17
|
-
const iconResolver = (key) =>
|
|
18
|
-
var _a;
|
|
19
|
-
return key ? (_a = app.getSystemIcon(key)) != null ? _a : LanguageIcon : LanguageIcon;
|
|
20
|
-
};
|
|
17
|
+
const iconResolver = (key) => key ? app.getSystemIcon(key) ?? LanguageIcon : LanguageIcon;
|
|
21
18
|
if (links === void 0) {
|
|
22
19
|
return null;
|
|
23
20
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LinksGroup.esm.js","sources":["../../../../src/components/Cards/Meta/LinksGroup.tsx"],"sourcesContent":["/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { EntityLink } from '@backstage/catalog-model';\nimport { IconComponent, useApp } from '@backstage/core-plugin-api';\nimport LanguageIcon from '@material-ui/icons/Language';\nimport ListItem from '@material-ui/core/ListItem';\nimport ListItemIcon from '@material-ui/core/ListItemIcon';\nimport ListItemText from '@material-ui/core/ListItemText';\nimport Divider from '@material-ui/core/Divider';\nimport React from 'react';\nimport { Link } from '@backstage/core-components';\n\nconst WebLink = ({\n href,\n Icon,\n text,\n}: {\n href: string;\n text?: string;\n Icon?: IconComponent;\n}) => (\n <ListItem key={href}>\n <ListItemIcon>{Icon ? <Icon /> : <LanguageIcon />}</ListItemIcon>\n <ListItemText>\n <Link to={href}>{text}</Link>\n </ListItemText>\n </ListItem>\n);\n\nexport const LinksGroup = ({ links }: { links?: EntityLink[] }) => {\n const app = useApp();\n const iconResolver = (key?: string): IconComponent =>\n key ? app.getSystemIcon(key) ?? LanguageIcon : LanguageIcon;\n\n if (links === undefined) {\n return null;\n }\n\n return (\n <>\n <Divider />\n {links.map(link => {\n return (\n <WebLink\n key={link.url}\n href={link.url}\n text={link.title}\n Icon={iconResolver(link.icon)}\n />\n );\n })}\n </>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;AAyBA,MAAM,UAAU,CAAC;AAAA,EACf,IAAA;AAAA,EACA,IAAA;AAAA,EACA,IAAA;AACF,CAKE,qBAAA,KAAA,CAAA,aAAA,CAAC,YAAS,GAAK,EAAA,IAAA,EAAA,sCACZ,YAAc,EAAA,IAAA,EAAA,IAAA,mBAAQ,KAAA,CAAA,aAAA,CAAA,IAAA,EAAA,IAAK,CAAK,mBAAA,KAAA,CAAA,aAAA,CAAC,kBAAa,CAAG,CAAA,sCACjD,YACC,EAAA,IAAA,kBAAA,KAAA,CAAA,aAAA,CAAC,QAAK,EAAI,EAAA,IAAA,EAAA,EAAO,IAAK,CACxB,CACF,CAAA,CAAA;AAGK,MAAM,UAAa,GAAA,CAAC,EAAE,KAAA,EAAsC,KAAA;AACjE,EAAA,MAAM,MAAM,MAAO,EAAA,CAAA;AACnB,EAAM,MAAA,YAAA,GAAe,CAAC,
|
|
1
|
+
{"version":3,"file":"LinksGroup.esm.js","sources":["../../../../src/components/Cards/Meta/LinksGroup.tsx"],"sourcesContent":["/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { EntityLink } from '@backstage/catalog-model';\nimport { IconComponent, useApp } from '@backstage/core-plugin-api';\nimport LanguageIcon from '@material-ui/icons/Language';\nimport ListItem from '@material-ui/core/ListItem';\nimport ListItemIcon from '@material-ui/core/ListItemIcon';\nimport ListItemText from '@material-ui/core/ListItemText';\nimport Divider from '@material-ui/core/Divider';\nimport React from 'react';\nimport { Link } from '@backstage/core-components';\n\nconst WebLink = ({\n href,\n Icon,\n text,\n}: {\n href: string;\n text?: string;\n Icon?: IconComponent;\n}) => (\n <ListItem key={href}>\n <ListItemIcon>{Icon ? <Icon /> : <LanguageIcon />}</ListItemIcon>\n <ListItemText>\n <Link to={href}>{text}</Link>\n </ListItemText>\n </ListItem>\n);\n\nexport const LinksGroup = ({ links }: { links?: EntityLink[] }) => {\n const app = useApp();\n const iconResolver = (key?: string): IconComponent =>\n key ? app.getSystemIcon(key) ?? LanguageIcon : LanguageIcon;\n\n if (links === undefined) {\n return null;\n }\n\n return (\n <>\n <Divider />\n {links.map(link => {\n return (\n <WebLink\n key={link.url}\n href={link.url}\n text={link.title}\n Icon={iconResolver(link.icon)}\n />\n );\n })}\n </>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;AAyBA,MAAM,UAAU,CAAC;AAAA,EACf,IAAA;AAAA,EACA,IAAA;AAAA,EACA,IAAA;AACF,CAKE,qBAAA,KAAA,CAAA,aAAA,CAAC,YAAS,GAAK,EAAA,IAAA,EAAA,sCACZ,YAAc,EAAA,IAAA,EAAA,IAAA,mBAAQ,KAAA,CAAA,aAAA,CAAA,IAAA,EAAA,IAAK,CAAK,mBAAA,KAAA,CAAA,aAAA,CAAC,kBAAa,CAAG,CAAA,sCACjD,YACC,EAAA,IAAA,kBAAA,KAAA,CAAA,aAAA,CAAC,QAAK,EAAI,EAAA,IAAA,EAAA,EAAO,IAAK,CACxB,CACF,CAAA,CAAA;AAGK,MAAM,UAAa,GAAA,CAAC,EAAE,KAAA,EAAsC,KAAA;AACjE,EAAA,MAAM,MAAM,MAAO,EAAA,CAAA;AACnB,EAAM,MAAA,YAAA,GAAe,CAAC,GACpB,KAAA,GAAA,GAAM,IAAI,aAAc,CAAA,GAAG,KAAK,YAAe,GAAA,YAAA,CAAA;AAEjD,EAAA,IAAI,UAAU,KAAW,CAAA,EAAA;AACvB,IAAO,OAAA,IAAA,CAAA;AAAA,GACT;AAEA,EAAA,iFAEK,KAAA,CAAA,aAAA,CAAA,OAAA,EAAA,IAAQ,CACR,EAAA,KAAA,CAAM,IAAI,CAAQ,IAAA,KAAA;AACjB,IACE,uBAAA,KAAA,CAAA,aAAA;AAAA,MAAC,OAAA;AAAA,MAAA;AAAA,QACC,KAAK,IAAK,CAAA,GAAA;AAAA,QACV,MAAM,IAAK,CAAA,GAAA;AAAA,QACX,MAAM,IAAK,CAAA,KAAA;AAAA,QACX,IAAA,EAAM,YAAa,CAAA,IAAA,CAAK,IAAI,CAAA;AAAA,OAAA;AAAA,KAC9B,CAAA;AAAA,GAEH,CACH,CAAA,CAAA;AAEJ;;;;"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Progress, ResponseErrorPanel,
|
|
1
|
+
import { Progress, ResponseErrorPanel, OverflowTooltip, Link } from '@backstage/core-components';
|
|
2
2
|
import { useRouteRef } from '@backstage/core-plugin-api';
|
|
3
3
|
import Box from '@material-ui/core/Box';
|
|
4
4
|
import Grid from '@material-ui/core/Grid';
|
|
@@ -40,10 +40,10 @@ const EntityCountTile = ({
|
|
|
40
40
|
kind,
|
|
41
41
|
url
|
|
42
42
|
}) => {
|
|
43
|
-
const classes = useStyles({ type: type
|
|
44
|
-
const rawTitle = type
|
|
43
|
+
const classes = useStyles({ type: type ?? kind });
|
|
44
|
+
const rawTitle = type ?? kind;
|
|
45
45
|
const isLongText = rawTitle.length > 10;
|
|
46
|
-
|
|
46
|
+
const tile = /* @__PURE__ */ React.createElement(
|
|
47
47
|
Box,
|
|
48
48
|
{
|
|
49
49
|
className: `${classes.card} ${classes.entityTypeBox}`,
|
|
@@ -66,7 +66,11 @@ const EntityCountTile = ({
|
|
|
66
66
|
)
|
|
67
67
|
)),
|
|
68
68
|
type && /* @__PURE__ */ React.createElement(Typography, { variant: "subtitle1" }, kind)
|
|
69
|
-
)
|
|
69
|
+
);
|
|
70
|
+
if (url) {
|
|
71
|
+
return /* @__PURE__ */ React.createElement(Link, { to: url, variant: "body2" }, tile);
|
|
72
|
+
}
|
|
73
|
+
return tile;
|
|
70
74
|
};
|
|
71
75
|
const ComponentsGrid = ({
|
|
72
76
|
className,
|
|
@@ -87,18 +91,15 @@ const ComponentsGrid = ({
|
|
|
87
91
|
} else if (error) {
|
|
88
92
|
return /* @__PURE__ */ React.createElement(ResponseErrorPanel, { error });
|
|
89
93
|
}
|
|
90
|
-
return /* @__PURE__ */ React.createElement(Grid, { container: true, className }, componentsWithCounters
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
}
|
|
100
|
-
));
|
|
101
|
-
}));
|
|
94
|
+
return /* @__PURE__ */ React.createElement(Grid, { container: true, className }, componentsWithCounters?.map((c) => /* @__PURE__ */ React.createElement(Grid, { item: true, xs: 6, md: 6, lg: 4, key: c.type ?? c.kind }, /* @__PURE__ */ React.createElement(
|
|
95
|
+
EntityCountTile,
|
|
96
|
+
{
|
|
97
|
+
counter: c.counter,
|
|
98
|
+
kind: c.kind,
|
|
99
|
+
type: c.type,
|
|
100
|
+
url: catalogLink && `${catalogLink()}/?${c.queryParams}`
|
|
101
|
+
}
|
|
102
|
+
))));
|
|
102
103
|
};
|
|
103
104
|
|
|
104
105
|
export { ComponentsGrid };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ComponentsGrid.esm.js","sources":["../../../../src/components/Cards/OwnershipCard/ComponentsGrid.tsx"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Entity } from '@backstage/catalog-model';\nimport {\n Link,\n OverflowTooltip,\n Progress,\n ResponseErrorPanel,\n} from '@backstage/core-components';\nimport { useRouteRef } from '@backstage/core-plugin-api';\nimport Box from '@material-ui/core/Box';\nimport Grid from '@material-ui/core/Grid';\nimport Typography from '@material-ui/core/Typography';\nimport { createStyles, makeStyles } from '@material-ui/core/styles';\nimport React from 'react';\nimport pluralize from 'pluralize';\nimport { catalogIndexRouteRef } from '../../../routes';\nimport { useGetEntities } from './useGetEntities';\nimport { EntityRelationAggregation } from '../types';\n\nconst useStyles = makeStyles(theme =>\n createStyles({\n card: {\n border: `1px solid ${theme.palette.divider}`,\n boxShadow: theme.shadows[2],\n borderRadius: '4px',\n padding: theme.spacing(2),\n transition: `${theme.transitions.duration.standard}ms`,\n '&:hover': {\n boxShadow: theme.shadows[4],\n },\n height: '100%',\n },\n bold: {\n fontWeight: theme.typography.fontWeightBold,\n },\n smallFont: {\n fontSize: theme.typography.body2.fontSize,\n },\n entityTypeBox: {\n background: (props: { type: string }) =>\n theme.getPageTheme({ themeId: props.type }).backgroundImage,\n color: (props: { type: string }) =>\n theme.getPageTheme({ themeId: props.type }).fontColor,\n },\n }),\n);\n\nconst EntityCountTile = ({\n counter,\n type,\n kind,\n url,\n}: {\n counter: number;\n type?: string;\n kind: string;\n url
|
|
1
|
+
{"version":3,"file":"ComponentsGrid.esm.js","sources":["../../../../src/components/Cards/OwnershipCard/ComponentsGrid.tsx"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Entity } from '@backstage/catalog-model';\nimport {\n Link,\n OverflowTooltip,\n Progress,\n ResponseErrorPanel,\n} from '@backstage/core-components';\nimport { useRouteRef } from '@backstage/core-plugin-api';\nimport Box from '@material-ui/core/Box';\nimport Grid from '@material-ui/core/Grid';\nimport Typography from '@material-ui/core/Typography';\nimport { createStyles, makeStyles } from '@material-ui/core/styles';\nimport React from 'react';\nimport pluralize from 'pluralize';\nimport { catalogIndexRouteRef } from '../../../routes';\nimport { useGetEntities } from './useGetEntities';\nimport { EntityRelationAggregation } from '../types';\n\nconst useStyles = makeStyles(theme =>\n createStyles({\n card: {\n border: `1px solid ${theme.palette.divider}`,\n boxShadow: theme.shadows[2],\n borderRadius: '4px',\n padding: theme.spacing(2),\n transition: `${theme.transitions.duration.standard}ms`,\n '&:hover': {\n boxShadow: theme.shadows[4],\n },\n height: '100%',\n },\n bold: {\n fontWeight: theme.typography.fontWeightBold,\n },\n smallFont: {\n fontSize: theme.typography.body2.fontSize,\n },\n entityTypeBox: {\n background: (props: { type: string }) =>\n theme.getPageTheme({ themeId: props.type }).backgroundImage,\n color: (props: { type: string }) =>\n theme.getPageTheme({ themeId: props.type }).fontColor,\n },\n }),\n);\n\nconst EntityCountTile = ({\n counter,\n type,\n kind,\n url,\n}: {\n counter: number;\n type?: string;\n kind: string;\n url?: string;\n}) => {\n const classes = useStyles({ type: type ?? kind });\n\n const rawTitle = type ?? kind;\n const isLongText = rawTitle.length > 10;\n\n const tile = (\n <Box\n className={`${classes.card} ${classes.entityTypeBox}`}\n display=\"flex\"\n flexDirection=\"column\"\n alignItems=\"center\"\n >\n <Typography className={classes.bold} variant=\"h6\">\n {counter}\n </Typography>\n <Box sx={{ width: '100%', textAlign: 'center' }}>\n <Typography\n className={`${classes.bold} ${isLongText && classes.smallFont}`}\n variant=\"h6\"\n >\n <OverflowTooltip\n text={pluralize(rawTitle.toLocaleUpperCase('en-US'), counter)}\n />\n </Typography>\n </Box>\n {type && <Typography variant=\"subtitle1\">{kind}</Typography>}\n </Box>\n );\n\n if (url) {\n return (\n <Link to={url} variant=\"body2\">\n {tile}\n </Link>\n );\n }\n return tile;\n};\n\nexport const ComponentsGrid = ({\n className,\n entity,\n relationsType,\n entityFilterKind,\n entityLimit = 6,\n}: {\n className?: string;\n entity: Entity;\n relationsType: EntityRelationAggregation;\n entityFilterKind?: string[];\n entityLimit?: number;\n}) => {\n const catalogLink = useRouteRef(catalogIndexRouteRef);\n const { componentsWithCounters, loading, error } = useGetEntities(\n entity,\n relationsType,\n entityFilterKind,\n entityLimit,\n );\n\n if (loading) {\n return <Progress />;\n } else if (error) {\n return <ResponseErrorPanel error={error} />;\n }\n\n return (\n <Grid container className={className}>\n {componentsWithCounters?.map(c => (\n <Grid item xs={6} md={6} lg={4} key={c.type ?? c.kind}>\n <EntityCountTile\n counter={c.counter}\n kind={c.kind}\n type={c.type}\n url={catalogLink && `${catalogLink()}/?${c.queryParams}`}\n />\n </Grid>\n ))}\n </Grid>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;AAkCA,MAAM,SAAY,GAAA,UAAA;AAAA,EAAW,WAC3B,YAAa,CAAA;AAAA,IACX,IAAM,EAAA;AAAA,MACJ,MAAQ,EAAA,CAAA,UAAA,EAAa,KAAM,CAAA,OAAA,CAAQ,OAAO,CAAA,CAAA;AAAA,MAC1C,SAAA,EAAW,KAAM,CAAA,OAAA,CAAQ,CAAC,CAAA;AAAA,MAC1B,YAAc,EAAA,KAAA;AAAA,MACd,OAAA,EAAS,KAAM,CAAA,OAAA,CAAQ,CAAC,CAAA;AAAA,MACxB,UAAY,EAAA,CAAA,EAAG,KAAM,CAAA,WAAA,CAAY,SAAS,QAAQ,CAAA,EAAA,CAAA;AAAA,MACl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,EAAA,IAAI,OAAS,EAAA;AACX,IAAA,2CAAQ,QAAS,EAAA,IAAA,CAAA,CAAA;AAAA,aACR,KAAO,EAAA;AAChB,IAAO,uBAAA,KAAA,CAAA,aAAA,CAAC,sBAAmB,KAAc,EAAA,CAAA,CAAA;AAAA,GAC3C;AAEA,EACE,uBAAA,KAAA,CAAA,aAAA,CAAC,QAAK,SAAS,EAAA,IAAA,EAAC,aACb,sBAAwB,EAAA,GAAA,CAAI,CAC3B,CAAA,qBAAA,KAAA,CAAA,aAAA,CAAC,IAAK,EAAA,EAAA,IAAA,EAAI,MAAC,EAAI,EAAA,CAAA,EAAG,IAAI,CAAG,EAAA,EAAA,EAAI,GAAG,GAAK,EAAA,CAAA,CAAE,IAAQ,IAAA,CAAA,CAAE,IAC/C,EAAA,kBAAA,KAAA,CAAA,aAAA;AAAA,IAAC,eAAA;AAAA,IAAA;AAAA,MACC,SAAS,CAAE,CAAA,OAAA;AAAA,MACX,MAAM,CAAE,CAAA,IAAA;AAAA,MACR,MAAM,CAAE,CAAA,IAAA;AAAA,MACR,KAAK,WAAe,IAAA,CAAA,EAAG,aAAa,CAAA,EAAA,EAAK,EAAE,WAAW,CAAA,CAAA;AAAA,KAAA;AAAA,GAE1D,CACD,CACH,CAAA,CAAA;AAEJ;;;;"}
|
|
@@ -57,7 +57,7 @@ const OwnershipCard = (props) => {
|
|
|
57
57
|
const { entity } = useEntity();
|
|
58
58
|
const defaultRelationsType = entity.kind === "User" ? "aggregated" : "direct";
|
|
59
59
|
const [getRelationsType, setRelationsType] = useState(
|
|
60
|
-
relationsType
|
|
60
|
+
relationsType ?? defaultRelationsType
|
|
61
61
|
);
|
|
62
62
|
useEffect(() => {
|
|
63
63
|
if (!relationsType) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OwnershipCard.esm.js","sources":["../../../../src/components/Cards/OwnershipCard/OwnershipCard.tsx"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { InfoCard, InfoCardVariants } from '@backstage/core-components';\nimport { useEntity } from '@backstage/plugin-catalog-react';\nimport List from '@material-ui/core/List';\nimport ListItem from '@material-ui/core/ListItem';\nimport ListItemSecondaryAction from '@material-ui/core/ListItemSecondaryAction';\nimport ListItemText from '@material-ui/core/ListItemText';\nimport Switch from '@material-ui/core/Switch';\nimport Tooltip from '@material-ui/core/Tooltip';\nimport { makeStyles } from '@material-ui/core/styles';\nimport React, { useEffect, useState } from 'react';\nimport { ComponentsGrid } from './ComponentsGrid';\nimport { EntityRelationAggregation } from '../types';\n\nconst useStyles = makeStyles(theme => ({\n card: {\n maxHeight: '100%',\n },\n cardContent: {\n display: 'flex',\n flexDirection: 'column',\n overflow: 'hidden',\n },\n list: {\n [theme.breakpoints.down('xs')]: {\n padding: `0 0 12px`,\n },\n },\n listItemText: {\n [theme.breakpoints.down('xs')]: {\n paddingRight: 0,\n paddingLeft: 0,\n },\n },\n listItemSecondaryAction: {\n [theme.breakpoints.down('xs')]: {\n width: '100%',\n top: 'auto',\n right: 'auto',\n position: 'relative',\n transform: 'unset',\n },\n },\n grid: {\n overflowY: 'auto',\n marginTop: 0,\n },\n}));\n\n/** @public */\nexport const OwnershipCard = (props: {\n variant?: InfoCardVariants;\n entityFilterKind?: string[];\n hideRelationsToggle?: boolean;\n relationsType?: EntityRelationAggregation;\n entityLimit?: number;\n}) => {\n const {\n variant,\n entityFilterKind,\n hideRelationsToggle,\n relationsType,\n entityLimit = 6,\n } = props;\n const relationsToggle =\n hideRelationsToggle === undefined ? false : hideRelationsToggle;\n const classes = useStyles();\n const { entity } = useEntity();\n\n const defaultRelationsType = entity.kind === 'User' ? 'aggregated' : 'direct';\n const [getRelationsType, setRelationsType] = useState(\n relationsType ?? defaultRelationsType,\n );\n\n useEffect(() => {\n if (!relationsType) {\n setRelationsType(defaultRelationsType);\n }\n }, [setRelationsType, defaultRelationsType, relationsType]);\n\n return (\n <InfoCard\n title=\"Ownership\"\n variant={variant}\n className={classes.card}\n cardClassName={classes.cardContent}\n >\n {!relationsToggle && (\n <List dense>\n <ListItem className={classes.list}>\n <ListItemText className={classes.listItemText} />\n <ListItemSecondaryAction\n className={classes.listItemSecondaryAction}\n >\n Direct Relations\n <Tooltip\n placement=\"top\"\n arrow\n title={`${\n getRelationsType === 'direct' ? 'Direct' : 'Aggregated'\n } Relations`}\n >\n <Switch\n color=\"primary\"\n checked={getRelationsType !== 'direct'}\n onChange={() => {\n const updatedRelationsType =\n getRelationsType === 'direct' ? 'aggregated' : 'direct';\n setRelationsType(updatedRelationsType);\n }}\n name=\"pin\"\n inputProps={{ 'aria-label': 'Ownership Type Switch' }}\n />\n </Tooltip>\n Aggregated Relations\n </ListItemSecondaryAction>\n </ListItem>\n </List>\n )}\n <ComponentsGrid\n className={classes.grid}\n entity={entity}\n entityLimit={entityLimit}\n relationsType={getRelationsType}\n entityFilterKind={entityFilterKind}\n />\n </InfoCard>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;AA6BA,MAAM,SAAA,GAAY,WAAW,CAAU,KAAA,MAAA;AAAA,EACrC,IAAM,EAAA;AAAA,IACJ,SAAW,EAAA,MAAA;AAAA,GACb;AAAA,EACA,WAAa,EAAA;AAAA,IACX,OAAS,EAAA,MAAA;AAAA,IACT,aAAe,EAAA,QAAA;AAAA,IACf,QAAU,EAAA,QAAA;AAAA,GACZ;AAAA,EACA,IAAM,EAAA;AAAA,IACJ,CAAC,KAAM,CAAA,WAAA,CAAY,IAAK,CAAA,IAAI,CAAC,GAAG;AAAA,MAC9B,OAAS,EAAA,CAAA,QAAA,CAAA;A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Card.tsx"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { InfoCard, InfoCardVariants } from '@backstage/core-components';\nimport { useEntity } from '@backstage/plugin-catalog-react';\nimport List from '@material-ui/core/List';\nimport ListItem from '@material-ui/core/ListItem';\nimport ListItemSecondaryAction from '@material-ui/core/ListItemSecondaryAction';\nimport ListItemText from '@material-ui/core/ListItemText';\nimport Switch from '@material-ui/core/Switch';\nimport Tooltip from '@material-ui/core/Tooltip';\nimport { makeStyles } from '@material-ui/core/styles';\nimport React, { useEffect, useState } from 'react';\nimport { ComponentsGrid } from './ComponentsGrid';\nimport { EntityRelationAggregation } from '../types';\n\nconst useStyles = makeStyles(theme => ({\n card: {\n maxHeight: '100%',\n },\n cardContent: {\n display: 'flex',\n flexDirection: 'column',\n overflow: 'hidden',\n },\n list: {\n [theme.breakpoints.down('xs')]: {\n padding: `0 0 12px`,\n },\n },\n listItemText: {\n [theme.breakpoints.down('xs')]: {\n paddingRight: 0,\n paddingLeft: 0,\n },\n },\n listItemSecondaryAction: {\n [theme.breakpoints.down('xs')]: {\n width: '100%',\n top: 'auto',\n right: 'auto',\n position: 'relative',\n transform: 'unset',\n },\n },\n grid: {\n overflowY: 'auto',\n marginTop: 0,\n },\n}));\n\n/** @public */\nexport const OwnershipCard = (props: {\n variant?: InfoCardVariants;\n entityFilterKind?: string[];\n hideRelationsToggle?: boolean;\n relationsType?: EntityRelationAggregation;\n entityLimit?: number;\n}) => {\n const {\n variant,\n entityFilterKind,\n hideRelationsToggle,\n relationsType,\n entityLimit = 6,\n } = props;\n const relationsToggle =\n hideRelationsToggle === undefined ? false : hideRelationsToggle;\n const classes = useStyles();\n const { entity } = useEntity();\n\n const defaultRelationsType = entity.kind === 'User' ? 'aggregated' : 'direct';\n const [getRelationsType, setRelationsType] = useState(\n relationsType ?? defaultRelationsType,\n );\n\n useEffect(() => {\n if (!relationsType) {\n setRelationsType(defaultRelationsType);\n }\n }, [setRelationsType, defaultRelationsType, relationsType]);\n\n return (\n <InfoCard\n title=\"Ownership\"\n variant={variant}\n className={classes.card}\n cardClassName={classes.cardContent}\n >\n {!relationsToggle && (\n <List dense>\n <ListItem className={classes.list}>\n <ListItemText className={classes.listItemText} />\n <ListItemSecondaryAction\n className={classes.listItemSecondaryAction}\n >\n Direct Relations\n <Tooltip\n placement=\"top\"\n arrow\n title={`${\n getRelationsType === 'direct' ? 'Direct' : 'Aggregated'\n } Relations`}\n >\n <Switch\n color=\"primary\"\n checked={getRelationsType !== 'direct'}\n onChange={() => {\n const updatedRelationsType =\n getRelationsType === 'direct' ? 'aggregated' : 'direct';\n setRelationsType(updatedRelationsType);\n }}\n name=\"pin\"\n inputProps={{ 'aria-label': 'Ownership Type Switch' }}\n />\n </Tooltip>\n Aggregated Relations\n </ListItemSecondaryAction>\n </ListItem>\n </List>\n )}\n <ComponentsGrid\n className={classes.grid}\n entity={entity}\n entityLimit={entityLimit}\n relationsType={getRelationsType}\n entityFilterKind={entityFilterKind}\n />\n </InfoCard>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;AA6BA,MAAM,SAAA,GAAY,WAAW,CAAU,KAAA,MAAA;AAAA,EACrC,IAAM,EAAA;AAAA,IACJ,SAAW,EAAA,MAAA;AAAA,GACb;AAAA,EACA,WAAa,EAAA;AAAA,IACX,OAAS,EAAA,MAAA;AAAA,IACT,aAAe,EAAA,QAAA;AAAA,IACf,QAAU,EAAA,QAAA;AAAA,GACZ;AAAA,EACA,IAAM,EAAA;AAAA,IACJ,CAAC,KAAM,CAAA,WAAA,CAAY,IAAK,CAAA,I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CAAA;AACjD,cAAA,gBAAA,CAAiB,oBAAoB,CAAA,CAAA;AAAA,aACvC;AAAA,YACA,IAAK,EAAA,KAAA;AAAA,YACL,UAAA,EAAY,EAAE,YAAA,EAAc,uBAAwB,EAAA;AAAA,WAAA;AAAA,SACtD;AAAA,OACF;AAAA,MAAU,sBAAA;AAAA,KAGd,CACF,CAAA;AAAA,oBAEF,KAAA,CAAA,aAAA;AAAA,MAAC,cAAA;AAAA,MAAA;AAAA,QACC,WAAW,OAAQ,CAAA,IAAA;AAAA,QACnB,MAAA;AAAA,QACA,WAAA;AAAA,QACA,aAAe,EAAA,gBAAA;AAAA,QACf,gBAAA;AAAA,OAAA;AAAA,KACF;AAAA,GACF,CAAA;AAEJ;;;;"}
|
|
@@ -95,7 +95,7 @@ const getOwnedEntitiesByOwners = (owners, kinds, catalogApi) => catalogApi.getEn
|
|
|
95
95
|
});
|
|
96
96
|
function useGetEntities(entity, relations, entityFilterKind, entityLimit = 6) {
|
|
97
97
|
const catalogApi = useApi(catalogApiRef);
|
|
98
|
-
const kinds = entityFilterKind
|
|
98
|
+
const kinds = entityFilterKind ?? ["Component", "API", "System"];
|
|
99
99
|
const {
|
|
100
100
|
loading,
|
|
101
101
|
error,
|
|
@@ -109,19 +109,15 @@ function useGetEntities(entity, relations, entityFilterKind, entityLimit = 6) {
|
|
|
109
109
|
);
|
|
110
110
|
const counts = ownedEntitiesList.items.reduce(
|
|
111
111
|
(acc, ownedEntity) => {
|
|
112
|
-
var _a, _b;
|
|
113
112
|
const match = acc.find(
|
|
114
|
-
(x) =>
|
|
115
|
-
var _a2;
|
|
116
|
-
return x.kind === ownedEntity.kind && x.type === ((_a2 = ownedEntity.spec) == null ? void 0 : _a2.type);
|
|
117
|
-
}
|
|
113
|
+
(x) => x.kind === ownedEntity.kind && x.type === ownedEntity.spec?.type
|
|
118
114
|
);
|
|
119
115
|
if (match) {
|
|
120
116
|
match.count += 1;
|
|
121
117
|
} else {
|
|
122
118
|
acc.push({
|
|
123
119
|
kind: ownedEntity.kind,
|
|
124
|
-
type:
|
|
120
|
+
type: ownedEntity.spec?.type?.toString(),
|
|
125
121
|
count: 1
|
|
126
122
|
});
|
|
127
123
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useGetEntities.esm.js","sources":["../../../../src/components/Cards/OwnershipCard/useGetEntities.ts"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n Entity,\n parseEntityRef,\n RELATION_MEMBER_OF,\n RELATION_PARENT_OF,\n stringifyEntityRef,\n} from '@backstage/catalog-model';\nimport {\n CatalogApi,\n catalogApiRef,\n getEntityRelations,\n humanizeEntityRef,\n} from '@backstage/plugin-catalog-react';\nimport limiterFactory from 'p-limit';\nimport { useApi } from '@backstage/core-plugin-api';\nimport useAsync from 'react-use/esm/useAsync';\nimport qs from 'qs';\nimport { EntityRelationAggregation } from '../types';\nimport { uniq } from 'lodash';\n\nconst limiter = limiterFactory(5);\n\ntype EntityTypeProps = {\n kind: string;\n type?: string;\n count: number;\n};\n\nconst getQueryParams = (\n ownersEntityRef: string[],\n selectedEntity: EntityTypeProps,\n): string => {\n const { kind, type } = selectedEntity;\n const owners = ownersEntityRef.map(owner =>\n humanizeEntityRef(parseEntityRef(owner), { defaultKind: 'group' }),\n );\n const filters = {\n kind: kind.toLocaleLowerCase('en-US'),\n type,\n owners,\n user: 'all',\n };\n return qs.stringify({ filters }, { arrayFormat: 'repeat' });\n};\n\nconst getMemberOfEntityRefs = (owner: Entity): string[] => {\n const parentGroups = getEntityRelations(owner, RELATION_MEMBER_OF, {\n kind: 'Group',\n });\n\n const ownerGroupsNames = parentGroups.map(({ kind, namespace, name }) =>\n stringifyEntityRef({\n kind,\n namespace,\n name,\n }),\n );\n\n return [...ownerGroupsNames, stringifyEntityRef(owner)];\n};\n\nconst isEntity = (entity: Entity | undefined): entity is Entity =>\n entity !== undefined;\n\nconst getChildOwnershipEntityRefs = async (\n entity: Entity,\n catalogApi: CatalogApi,\n alreadyRetrievedParentRefs: string[] = [],\n): Promise<string[]> => {\n const childGroups = getEntityRelations(entity, RELATION_PARENT_OF, {\n kind: 'Group',\n });\n\n const hasChildGroups = childGroups.length > 0;\n\n const entityRef = stringifyEntityRef(entity);\n if (hasChildGroups) {\n const entityRefs = childGroups.map(r => stringifyEntityRef(r));\n const childGroupResponse = await limiter(() =>\n catalogApi.getEntitiesByRefs({\n fields: ['kind', 'metadata.namespace', 'metadata.name', 'relations'],\n entityRefs,\n }),\n );\n const childGroupEntities = childGroupResponse.items.filter(isEntity);\n\n const unknownChildren = childGroupEntities.filter(\n childGroupEntity =>\n !alreadyRetrievedParentRefs.includes(\n stringifyEntityRef(childGroupEntity),\n ),\n );\n const childrenRefs = (\n await Promise.all(\n unknownChildren.map(childGroupEntity =>\n getChildOwnershipEntityRefs(childGroupEntity, catalogApi, [\n ...alreadyRetrievedParentRefs,\n entityRef,\n ]),\n ),\n )\n ).flatMap(aggregated => aggregated);\n\n return uniq([...childrenRefs, entityRef]);\n }\n\n return [entityRef];\n};\n\nconst getOwners = async (\n entity: Entity,\n relations: EntityRelationAggregation,\n catalogApi: CatalogApi,\n): Promise<string[]> => {\n const isGroup = entity.kind === 'Group';\n const isAggregated = relations === 'aggregated';\n const isUserEntity = entity.kind === 'User';\n\n if (isAggregated && isGroup) {\n return getChildOwnershipEntityRefs(entity, catalogApi);\n }\n\n if (isAggregated && isUserEntity) {\n return getMemberOfEntityRefs(entity);\n }\n\n return [stringifyEntityRef(entity)];\n};\n\nconst getOwnedEntitiesByOwners = (\n owners: string[],\n kinds: string[],\n catalogApi: CatalogApi,\n) =>\n catalogApi.getEntities({\n filter: [\n {\n kind: kinds,\n 'relations.ownedBy': owners,\n },\n ],\n fields: [\n 'kind',\n 'metadata.name',\n 'metadata.namespace',\n 'spec.type',\n 'relations',\n ],\n });\n\nexport function useGetEntities(\n entity: Entity,\n relations: EntityRelationAggregation,\n entityFilterKind?: string[],\n entityLimit = 6,\n): {\n componentsWithCounters:\n | {\n counter: number;\n type: string;\n kind: string;\n queryParams: string;\n }[]\n | undefined;\n loading: boolean;\n error?: Error;\n} {\n const catalogApi = useApi(catalogApiRef);\n const kinds = entityFilterKind ?? ['Component', 'API', 'System'];\n\n const {\n loading,\n error,\n value: componentsWithCounters,\n } = useAsync(async () => {\n const owners = await getOwners(entity, relations, catalogApi);\n\n const ownedEntitiesList = await getOwnedEntitiesByOwners(\n owners,\n kinds,\n catalogApi,\n );\n\n const counts = ownedEntitiesList.items.reduce(\n (acc: EntityTypeProps[], ownedEntity) => {\n const match = acc.find(\n x => x.kind === ownedEntity.kind && x.type === ownedEntity.spec?.type,\n );\n if (match) {\n match.count += 1;\n } else {\n acc.push({\n kind: ownedEntity.kind,\n type: ownedEntity.spec?.type?.toString(),\n count: 1,\n });\n }\n return acc;\n },\n [],\n );\n\n // Return top N (entityLimit) entities to be displayed in ownership boxes\n const topN = counts.sort((a, b) => b.count - a.count).slice(0, entityLimit);\n\n return topN.map(topOwnedEntity => ({\n counter: topOwnedEntity.count,\n type: topOwnedEntity.type,\n kind: topOwnedEntity.kind,\n queryParams: getQueryParams(owners, topOwnedEntity),\n })) as Array<{\n counter: number;\n type: string;\n kind: string;\n queryParams: string;\n }>;\n }, [catalogApi, entity, relations]);\n\n return {\n componentsWithCounters,\n loading,\n error,\n };\n}\n"],"names":["_a"],"mappings":";;;;;;;;AAoCA,MAAM,OAAA,GAAU,eAAe,CAAC,CAAA,CAAA;AAQhC,MAAM,cAAA,GAAiB,CACrB,eAAA,EACA,cACW,KAAA;AACX,EAAM,MAAA,E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AAW,CAAA,CAAA;AAE1E,IAAO,OAAA,IAAA,CAAK,IAAI,CAAmB,cAAA,MAAA;AAAA,MACjC,SAAS,cAAe,CAAA,KAAA;AAAA,MACxB,MAAM,cAAe,CAAA,IAAA;AAAA,MACrB,MAAM,cAAe,CAAA,IAAA;AAAA,MACrB,WAAA,EAAa,cAAe,CAAA,MAAA,EAAQ,cAAc,CAAA;AAAA,KAClD,CAAA,CAAA,CAAA;AAAA,GAMD,EAAA,CAAC,UAAY,EAAA,MAAA,EAAQ,SAAS,CAAC,CAAA,CAAA;AAElC,EAAO,OAAA;AAAA,IACL,sBAAA;AAAA,IACA,OAAA;AAAA,IACA,KAAA;AAAA,GACF,CAAA;AACF;;;;"}
|
|
1
|
+
{"version":3,"file":"useGetEntities.esm.js","sources":["../../../../src/components/Cards/OwnershipCard/useGetEntities.ts"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n Entity,\n parseEntityRef,\n RELATION_MEMBER_OF,\n RELATION_PARENT_OF,\n stringifyEntityRef,\n} from '@backstage/catalog-model';\nimport {\n CatalogApi,\n catalogApiRef,\n getEntityRelations,\n humanizeEntityRef,\n} from '@backstage/plugin-catalog-react';\nimport limiterFactory from 'p-limit';\nimport { useApi } from '@backstage/core-plugin-api';\nimport useAsync from 'react-use/esm/useAsync';\nimport qs from 'qs';\nimport { EntityRelationAggregation } from '../types';\nimport { uniq } from 'lodash';\n\nconst limiter = limiterFactory(5);\n\ntype EntityTypeProps = {\n kind: string;\n type?: string;\n count: number;\n};\n\nconst getQueryParams = (\n ownersEntityRef: string[],\n selectedEntity: EntityTypeProps,\n): string => {\n const { kind, type } = selectedEntity;\n const owners = ownersEntityRef.map(owner =>\n humanizeEntityRef(parseEntityRef(owner), { defaultKind: 'group' }),\n );\n const filters = {\n kind: kind.toLocaleLowerCase('en-US'),\n type,\n owners,\n user: 'all',\n };\n return qs.stringify({ filters }, { arrayFormat: 'repeat' });\n};\n\nconst getMemberOfEntityRefs = (owner: Entity): string[] => {\n const parentGroups = getEntityRelations(owner, RELATION_MEMBER_OF, {\n kind: 'Group',\n });\n\n const ownerGroupsNames = parentGroups.map(({ kind, namespace, name }) =>\n stringifyEntityRef({\n kind,\n namespace,\n name,\n }),\n );\n\n return [...ownerGroupsNames, stringifyEntityRef(owner)];\n};\n\nconst isEntity = (entity: Entity | undefined): entity is Entity =>\n entity !== undefined;\n\nconst getChildOwnershipEntityRefs = async (\n entity: Entity,\n catalogApi: CatalogApi,\n alreadyRetrievedParentRefs: string[] = [],\n): Promise<string[]> => {\n const childGroups = getEntityRelations(entity, RELATION_PARENT_OF, {\n kind: 'Group',\n });\n\n const hasChildGroups = childGroups.length > 0;\n\n const entityRef = stringifyEntityRef(entity);\n if (hasChildGroups) {\n const entityRefs = childGroups.map(r => stringifyEntityRef(r));\n const childGroupResponse = await limiter(() =>\n catalogApi.getEntitiesByRefs({\n fields: ['kind', 'metadata.namespace', 'metadata.name', 'relations'],\n entityRefs,\n }),\n );\n const childGroupEntities = childGroupResponse.items.filter(isEntity);\n\n const unknownChildren = childGroupEntities.filter(\n childGroupEntity =>\n !alreadyRetrievedParentRefs.includes(\n stringifyEntityRef(childGroupEntity),\n ),\n );\n const childrenRefs = (\n await Promise.all(\n unknownChildren.map(childGroupEntity =>\n getChildOwnershipEntityRefs(childGroupEntity, catalogApi, [\n ...alreadyRetrievedParentRefs,\n entityRef,\n ]),\n ),\n )\n ).flatMap(aggregated => aggregated);\n\n return uniq([...childrenRefs, entityRef]);\n }\n\n return [entityRef];\n};\n\nconst getOwners = async (\n entity: Entity,\n relations: EntityRelationAggregation,\n catalogApi: CatalogApi,\n): Promise<string[]> => {\n const isGroup = entity.kind === 'Group';\n const isAggregated = relations === 'aggregated';\n const isUserEntity = entity.kind === 'User';\n\n if (isAggregated && isGroup) {\n return getChildOwnershipEntityRefs(entity, catalogApi);\n }\n\n if (isAggregated && isUserEntity) {\n return getMemberOfEntityRefs(entity);\n }\n\n return [stringifyEntityRef(entity)];\n};\n\nconst getOwnedEntitiesByOwners = (\n owners: string[],\n kinds: string[],\n catalogApi: CatalogApi,\n) =>\n catalogApi.getEntities({\n filter: [\n {\n kind: kinds,\n 'relations.ownedBy': owners,\n },\n ],\n fields: [\n 'kind',\n 'metadata.name',\n 'metadata.namespace',\n 'spec.type',\n 'relations',\n ],\n });\n\nexport function useGetEntities(\n entity: Entity,\n relations: EntityRelationAggregation,\n entityFilterKind?: string[],\n entityLimit = 6,\n): {\n componentsWithCounters:\n | {\n counter: number;\n type: string;\n kind: string;\n queryParams: string;\n }[]\n | undefined;\n loading: boolean;\n error?: Error;\n} {\n const catalogApi = useApi(catalogApiRef);\n const kinds = entityFilterKind ?? ['Component', 'API', 'System'];\n\n const {\n loading,\n error,\n value: componentsWithCounters,\n } = useAsync(async () => {\n const owners = await getOwners(entity, relations, catalogApi);\n\n const ownedEntitiesList = await getOwnedEntitiesByOwners(\n owners,\n kinds,\n catalogApi,\n );\n\n const counts = ownedEntitiesList.items.reduce(\n (acc: EntityTypeProps[], ownedEntity) => {\n const match = acc.find(\n x => x.kind === ownedEntity.kind && x.type === ownedEntity.spec?.type,\n );\n if (match) {\n match.count += 1;\n } else {\n acc.push({\n kind: ownedEntity.kind,\n type: ownedEntity.spec?.type?.toString(),\n count: 1,\n });\n }\n return acc;\n },\n [],\n );\n\n // Return top N (entityLimit) entities to be displayed in ownership boxes\n const topN = counts.sort((a, b) => b.count - a.count).slice(0, entityLimit);\n\n return topN.map(topOwnedEntity => ({\n counter: topOwnedEntity.count,\n type: topOwnedEntity.type,\n kind: topOwnedEntity.kind,\n queryParams: getQueryParams(owners, topOwnedEntity),\n })) as Array<{\n counter: number;\n type: string;\n kind: string;\n queryParams: string;\n }>;\n }, [catalogApi, entity, relations]);\n\n return {\n componentsWithCounters,\n loading,\n error,\n };\n}\n"],"names":[],"mappings":";;;;;;;;AAoCA,MAAM,OAAA,GAAU,eAAe,CAAC,CAAA,CAAA;AAQhC,MAAM,cAAA,GAAiB,CACrB,eAAA,EACA,cACW,KAAA;AACX,EAAM,MAAA,EAAE,IAAM,EAAA,IAAA,EAAS,GAAA,cAAA,CAAA;AACvB,EAAA,MAAM,SAAS,eAAgB,CAAA,GAAA;AAAA,IAAI,CAAA,KAAA,KACjC,kBAAkB,cAAe,CAAA,KAAK,GAAG,EAAE,WAAA,EAAa,SAAS,CAAA;AAAA,GACnE,CAAA;AACA,EAAA,MAAM,OAAU,GAAA;AAAA,IACd,IAAA,EAAM,IAAK,CAAA,iBAAA,CAAkB,OAAO,CAAA;AAAA,IACpC,IAAA;AAAA,IACA,MAAA;AAAA,IACA,IAAM,EAAA,KAAA;AAAA,GACR,CAAA;AACA,EAAO,OAAA,EAAA,CAAG,UAAU,EAAE,OAAA,IAAW,EAAE,WAAA,EAAa,UAAU,CAAA,CAAA;AAC5D,CAAA,CAAA;AAEA,MAAM,qBAAA,GAAwB,CAAC,KAA4B,KAAA;AACzD,EAAM,MAAA,YAAA,GAAe,kBAAmB,CAAA,KAAA,EAAO,kBAAoB,EAAA;AAAA,IACjE,IAAM,EAAA,OAAA;AAAA,GACP,CAAA,CAAA;AAED,EAAA,MAAM,mBAAmB,YAAa,CAAA,GAAA;AAAA,IAAI,CAAC,EAAE,IAAA,EAAM,SAAW,EAAA,IAAA,OAC5D,kBAAmB,CAAA;AAAA,MACjB,IAAA;AAAA,MACA,SAAA;AAAA,MACA,IAAA;AAAA,KACD,CAAA;AAAA,GACH,CAAA;AAEA,EAAA,OAAO,CAAC,GAAG,gBAAkB,EAAA,kBAAA,CAAmB,KAAK,CAAC,CAAA,CAAA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,CAAK,IAAI,CAAmB,cAAA,MAAA;AAAA,MACjC,SAAS,cAAe,CAAA,KAAA;AAAA,MACxB,MAAM,cAAe,CAAA,IAAA;AAAA,MACrB,MAAM,cAAe,CAAA,IAAA;AAAA,MACrB,WAAA,EAAa,cAAe,CAAA,MAAA,EAAQ,cAAc,CAAA;AAAA,KAClD,CAAA,CAAA,CAAA;AAAA,GAMD,EAAA,CAAC,UAAY,EAAA,MAAA,EAAQ,SAAS,CAAC,CAAA,CAAA;AAElC,EAAO,OAAA;AAAA,IACL,sBAAA;AAAA,IACA,OAAA;AAAA,IACA,KAAA;AAAA,GACF,CAAA;AACF;;;;"}
|
|
@@ -19,18 +19,17 @@ import React from 'react';
|
|
|
19
19
|
|
|
20
20
|
const CardTitle = (props) => props.title ? /* @__PURE__ */ React.createElement(Box, { display: "flex", alignItems: "center" }, /* @__PURE__ */ React.createElement(PersonIcon, { fontSize: "inherit" }), /* @__PURE__ */ React.createElement(Box, { ml: 1 }, props.title)) : null;
|
|
21
21
|
const UserProfileCard = (props) => {
|
|
22
|
-
var _a, _b;
|
|
23
22
|
const { entity: user } = useEntity();
|
|
24
23
|
if (!user) {
|
|
25
24
|
return /* @__PURE__ */ React.createElement(Alert, { severity: "error" }, "User not found");
|
|
26
25
|
}
|
|
27
|
-
const entityMetadataEditUrl =
|
|
26
|
+
const entityMetadataEditUrl = user.metadata.annotations?.[ANNOTATION_EDIT_URL];
|
|
28
27
|
const {
|
|
29
28
|
metadata: { name: metaName, description, links },
|
|
30
29
|
spec: { profile }
|
|
31
30
|
} = user;
|
|
32
|
-
const displayName =
|
|
33
|
-
const emailHref =
|
|
31
|
+
const displayName = profile?.displayName ?? metaName;
|
|
32
|
+
const emailHref = profile?.email ? `mailto:${profile.email}` : void 0;
|
|
34
33
|
const memberOfRelations = getEntityRelations(user, RELATION_MEMBER_OF, {
|
|
35
34
|
kind: "Group"
|
|
36
35
|
});
|
|
@@ -51,13 +50,13 @@ const UserProfileCard = (props) => {
|
|
|
51
50
|
/* @__PURE__ */ React.createElement(EditIcon, null)
|
|
52
51
|
))
|
|
53
52
|
},
|
|
54
|
-
/* @__PURE__ */ React.createElement(Grid, { container: true, spacing: 3, alignItems: "flex-start" }, /* @__PURE__ */ React.createElement(Grid, { item: true, xs: 12, sm: 2, xl: 1 }, /* @__PURE__ */ React.createElement(Avatar, { displayName, picture: profile
|
|
53
|
+
/* @__PURE__ */ React.createElement(Grid, { container: true, spacing: 3, alignItems: "flex-start" }, /* @__PURE__ */ React.createElement(Grid, { item: true, xs: 12, sm: 2, xl: 1 }, /* @__PURE__ */ React.createElement(Avatar, { displayName, picture: profile?.picture })), /* @__PURE__ */ React.createElement(Grid, { item: true, md: 10, xl: 11 }, /* @__PURE__ */ React.createElement(List, null, profile?.email && /* @__PURE__ */ React.createElement(ListItem, null, /* @__PURE__ */ React.createElement(ListItemIcon, null, /* @__PURE__ */ React.createElement(Tooltip, { title: "Email" }, /* @__PURE__ */ React.createElement(EmailIcon, null))), /* @__PURE__ */ React.createElement(ListItemText, null, /* @__PURE__ */ React.createElement(Link, { to: emailHref ?? "" }, profile.email))), /* @__PURE__ */ React.createElement(ListItem, null, /* @__PURE__ */ React.createElement(ListItemIcon, null, /* @__PURE__ */ React.createElement(Tooltip, { title: "Member of" }, /* @__PURE__ */ React.createElement(GroupIcon, null))), /* @__PURE__ */ React.createElement(ListItemText, null, /* @__PURE__ */ React.createElement(
|
|
55
54
|
EntityRefLinks,
|
|
56
55
|
{
|
|
57
56
|
entityRefs: memberOfRelations,
|
|
58
57
|
defaultKind: "Group"
|
|
59
58
|
}
|
|
60
|
-
))),
|
|
59
|
+
))), props?.showLinks && /* @__PURE__ */ React.createElement(LinksGroup, { links }))))
|
|
61
60
|
);
|
|
62
61
|
};
|
|
63
62
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UserProfileCard.esm.js","sources":["../../../../../src/components/Cards/User/UserProfileCard/UserProfileCard.tsx"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n ANNOTATION_EDIT_URL,\n RELATION_MEMBER_OF,\n UserEntity,\n} from '@backstage/catalog-model';\nimport {\n Avatar,\n InfoCard,\n InfoCardVariants,\n Link,\n} from '@backstage/core-components';\nimport Box from '@material-ui/core/Box';\nimport Grid from '@material-ui/core/Grid';\nimport IconButton from '@material-ui/core/IconButton';\nimport List from '@material-ui/core/List';\nimport ListItem from '@material-ui/core/ListItem';\nimport ListItemIcon from '@material-ui/core/ListItemIcon';\nimport ListItemText from '@material-ui/core/ListItemText';\nimport Tooltip from '@material-ui/core/Tooltip';\nimport {\n EntityRefLinks,\n getEntityRelations,\n useEntity,\n} from '@backstage/plugin-catalog-react';\n\nimport Alert from '@material-ui/lab/Alert';\nimport EditIcon from '@material-ui/icons/Edit';\nimport EmailIcon from '@material-ui/icons/Email';\nimport GroupIcon from '@material-ui/icons/Group';\nimport { LinksGroup } from '../../Meta';\nimport PersonIcon from '@material-ui/icons/Person';\nimport React from 'react';\n\nconst CardTitle = (props: { title?: string }) =>\n props.title ? (\n <Box display=\"flex\" alignItems=\"center\">\n <PersonIcon fontSize=\"inherit\" />\n <Box ml={1}>{props.title}</Box>\n </Box>\n ) : null;\n\n/** @public */\nexport const UserProfileCard = (props: {\n variant?: InfoCardVariants;\n showLinks?: boolean;\n}) => {\n const { entity: user } = useEntity<UserEntity>();\n if (!user) {\n return <Alert severity=\"error\">User not found</Alert>;\n }\n\n const entityMetadataEditUrl =\n user.metadata.annotations?.[ANNOTATION_EDIT_URL];\n\n const {\n metadata: { name: metaName, description, links },\n spec: { profile },\n } = user;\n const displayName = profile?.displayName ?? metaName;\n const emailHref = profile?.email ? `mailto:${profile.email}` : undefined;\n const memberOfRelations = getEntityRelations(user, RELATION_MEMBER_OF, {\n kind: 'Group',\n });\n\n return (\n <InfoCard\n title={<CardTitle title={displayName} />}\n subheader={description}\n variant={props.variant}\n action={\n <>\n {entityMetadataEditUrl && (\n <IconButton\n aria-label=\"Edit\"\n title=\"Edit Metadata\"\n component={Link}\n to={entityMetadataEditUrl}\n >\n <EditIcon />\n </IconButton>\n )}\n </>\n }\n >\n <Grid container spacing={3} alignItems=\"flex-start\">\n <Grid item xs={12} sm={2} xl={1}>\n <Avatar displayName={displayName} picture={profile?.picture} />\n </Grid>\n\n <Grid item md={10} xl={11}>\n <List>\n {profile?.email && (\n <ListItem>\n <ListItemIcon>\n <Tooltip title=\"Email\">\n <EmailIcon />\n </Tooltip>\n </ListItemIcon>\n <ListItemText>\n <Link to={emailHref ?? ''}>{profile.email}</Link>\n </ListItemText>\n </ListItem>\n )}\n\n <ListItem>\n <ListItemIcon>\n <Tooltip title=\"Member of\">\n <GroupIcon />\n </Tooltip>\n </ListItemIcon>\n <ListItemText>\n <EntityRefLinks\n entityRefs={memberOfRelations}\n defaultKind=\"Group\"\n />\n </ListItemText>\n </ListItem>\n\n {props?.showLinks && <LinksGroup links={links} />}\n </List>\n </Grid>\n </Grid>\n </InfoCard>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;AAiDA,MAAM,SAAA,GAAY,CAAC,KACjB,KAAA,KAAA,CAAM,wBACH,KAAA,CAAA,aAAA,CAAA,GAAA,EAAA,EAAI,OAAQ,EAAA,MAAA,EAAO,UAAW,EAAA,QAAA,EAAA,sCAC5B,UAAW,EAAA,EAAA,QAAA,EAAS,SAAU,EAAA,CAAA,kBAC9B,KAAA,CAAA,aAAA,CAAA,GAAA,EAAA,EAAI,IAAI,CAAI,EAAA,EAAA,KAAA,CAAM,KAAM,CAC3B,CACE,GAAA,IAAA,CAAA;AAGO,MAAA,eAAA,GAAkB,CAAC,KAG1B,KAAA;
|
|
1
|
+
{"version":3,"file":"UserProfileCard.esm.js","sources":["../../../../../src/components/Cards/User/UserProfileCard/UserProfileCard.tsx"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n ANNOTATION_EDIT_URL,\n RELATION_MEMBER_OF,\n UserEntity,\n} from '@backstage/catalog-model';\nimport {\n Avatar,\n InfoCard,\n InfoCardVariants,\n Link,\n} from '@backstage/core-components';\nimport Box from '@material-ui/core/Box';\nimport Grid from '@material-ui/core/Grid';\nimport IconButton from '@material-ui/core/IconButton';\nimport List from '@material-ui/core/List';\nimport ListItem from '@material-ui/core/ListItem';\nimport ListItemIcon from '@material-ui/core/ListItemIcon';\nimport ListItemText from '@material-ui/core/ListItemText';\nimport Tooltip from '@material-ui/core/Tooltip';\nimport {\n EntityRefLinks,\n getEntityRelations,\n useEntity,\n} from '@backstage/plugin-catalog-react';\n\nimport Alert from '@material-ui/lab/Alert';\nimport EditIcon from '@material-ui/icons/Edit';\nimport EmailIcon from '@material-ui/icons/Email';\nimport GroupIcon from '@material-ui/icons/Group';\nimport { LinksGroup } from '../../Meta';\nimport PersonIcon from '@material-ui/icons/Person';\nimport React from 'react';\n\nconst CardTitle = (props: { title?: string }) =>\n props.title ? (\n <Box display=\"flex\" alignItems=\"center\">\n <PersonIcon fontSize=\"inherit\" />\n <Box ml={1}>{props.title}</Box>\n </Box>\n ) : null;\n\n/** @public */\nexport const UserProfileCard = (props: {\n variant?: InfoCardVariants;\n showLinks?: boolean;\n}) => {\n const { entity: user } = useEntity<UserEntity>();\n if (!user) {\n return <Alert severity=\"error\">User not found</Alert>;\n }\n\n const entityMetadataEditUrl =\n user.metadata.annotations?.[ANNOTATION_EDIT_URL];\n\n const {\n metadata: { name: metaName, description, links },\n spec: { profile },\n } = user;\n const displayName = profile?.displayName ?? metaName;\n const emailHref = profile?.email ? `mailto:${profile.email}` : undefined;\n const memberOfRelations = getEntityRelations(user, RELATION_MEMBER_OF, {\n kind: 'Group',\n });\n\n return (\n <InfoCard\n title={<CardTitle title={displayName} />}\n subheader={description}\n variant={props.variant}\n action={\n <>\n {entityMetadataEditUrl && (\n <IconButton\n aria-label=\"Edit\"\n title=\"Edit Metadata\"\n component={Link}\n to={entityMetadataEditUrl}\n >\n <EditIcon />\n </IconButton>\n )}\n </>\n }\n >\n <Grid container spacing={3} alignItems=\"flex-start\">\n <Grid item xs={12} sm={2} xl={1}>\n <Avatar displayName={displayName} picture={profile?.picture} />\n </Grid>\n\n <Grid item md={10} xl={11}>\n <List>\n {profile?.email && (\n <ListItem>\n <ListItemIcon>\n <Tooltip title=\"Email\">\n <EmailIcon />\n </Tooltip>\n </ListItemIcon>\n <ListItemText>\n <Link to={emailHref ?? ''}>{profile.email}</Link>\n </ListItemText>\n </ListItem>\n )}\n\n <ListItem>\n <ListItemIcon>\n <Tooltip title=\"Member of\">\n <GroupIcon />\n </Tooltip>\n </ListItemIcon>\n <ListItemText>\n <EntityRefLinks\n entityRefs={memberOfRelations}\n defaultKind=\"Group\"\n />\n </ListItemText>\n </ListItem>\n\n {props?.showLinks && <LinksGroup links={links} />}\n </List>\n </Grid>\n </Grid>\n </InfoCard>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;AAiDA,MAAM,SAAA,GAAY,CAAC,KACjB,KAAA,KAAA,CAAM,wBACH,KAAA,CAAA,aAAA,CAAA,GAAA,EAAA,EAAI,OAAQ,EAAA,MAAA,EAAO,UAAW,EAAA,QAAA,EAAA,sCAC5B,UAAW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KAAA,CAAA,aAAA,CAAC,OAAQ,EAAA,EAAA,KAAA,EAAM,+BACZ,KAAA,CAAA,aAAA,CAAA,SAAA,EAAA,IAAU,CACb,CACF,CAAA,sCACC,YACC,EAAA,IAAA,kBAAA,KAAA,CAAA,aAAA;AAAA,MAAC,cAAA;AAAA,MAAA;AAAA,QACC,UAAY,EAAA,iBAAA;AAAA,QACZ,WAAY,EAAA,OAAA;AAAA,OAAA;AAAA,KAEhB,CACF,CAAA,EAEC,KAAO,EAAA,SAAA,wCAAc,UAAW,EAAA,EAAA,KAAA,EAAc,CACjD,CACF,CACF,CAAA;AAAA,GACF,CAAA;AAEJ;;;;"}
|
|
@@ -17,14 +17,14 @@ const MyGroupsSidebarItem = (props) => {
|
|
|
17
17
|
{
|
|
18
18
|
kind: "group",
|
|
19
19
|
"relations.hasMember": profile.userEntityRef,
|
|
20
|
-
...filter
|
|
20
|
+
...filter ?? {}
|
|
21
21
|
}
|
|
22
22
|
],
|
|
23
23
|
fields: ["metadata", "kind"]
|
|
24
24
|
});
|
|
25
25
|
return response.items;
|
|
26
26
|
}, []);
|
|
27
|
-
if (!
|
|
27
|
+
if (!groups?.length) {
|
|
28
28
|
return null;
|
|
29
29
|
}
|
|
30
30
|
if (groups.length === 1) {
|
|
@@ -38,7 +38,7 @@ const MyGroupsSidebarItem = (props) => {
|
|
|
38
38
|
}
|
|
39
39
|
);
|
|
40
40
|
}
|
|
41
|
-
return /* @__PURE__ */ React.createElement(SidebarItem, { icon, text: pluralTitle }, /* @__PURE__ */ React.createElement(SidebarSubmenu, { title: pluralTitle }, groups
|
|
41
|
+
return /* @__PURE__ */ React.createElement(SidebarItem, { icon, text: pluralTitle }, /* @__PURE__ */ React.createElement(SidebarSubmenu, { title: pluralTitle }, groups?.map(function groupsMap(group) {
|
|
42
42
|
return /* @__PURE__ */ React.createElement(
|
|
43
43
|
SidebarSubmenuItem,
|
|
44
44
|
{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MyGroupsSidebarItem.esm.js","sources":["../../../src/components/MyGroupsSidebarItem/MyGroupsSidebarItem.tsx"],"sourcesContent":["/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React from 'react';\nimport {\n DEFAULT_NAMESPACE,\n stringifyEntityRef,\n} from '@backstage/catalog-model';\nimport {\n SidebarItem,\n SidebarSubmenu,\n SidebarSubmenuItem,\n} from '@backstage/core-components';\nimport {\n IconComponent,\n identityApiRef,\n useApi,\n useRouteRef,\n} from '@backstage/core-plugin-api';\nimport useAsync from 'react-use/esm/useAsync';\nimport {\n catalogApiRef,\n CatalogApi,\n entityRouteRef,\n} from '@backstage/plugin-catalog-react';\nimport { getCompoundEntityRef } from '@backstage/catalog-model';\n\n/**\n * MyGroupsSidebarItem can be added to your sidebar providing quick access to groups the logged in user is a member of\n *\n * @public\n */\nexport const MyGroupsSidebarItem = (props: {\n singularTitle: string;\n pluralTitle: string;\n icon: IconComponent;\n filter?: Record<string, string | symbol | (string | symbol)[]>;\n}) => {\n const { singularTitle, pluralTitle, icon, filter } = props;\n\n const identityApi = useApi(identityApiRef);\n const catalogApi: CatalogApi = useApi(catalogApiRef);\n const catalogEntityRoute = useRouteRef(entityRouteRef);\n\n const { value: groups } = useAsync(async () => {\n const profile = await identityApi.getBackstageIdentity();\n\n const response = await catalogApi.getEntities({\n filter: [\n {\n kind: 'group',\n 'relations.hasMember': profile.userEntityRef,\n ...(filter ?? {}),\n },\n ],\n fields: ['metadata', 'kind'],\n });\n\n return response.items;\n }, []);\n\n // Not a member of any groups\n if (!groups?.length) {\n return null;\n }\n\n // Only member of one group\n if (groups.length === 1) {\n const group = groups[0];\n return (\n <SidebarItem\n text={singularTitle}\n to={catalogEntityRoute(getCompoundEntityRef(group))}\n icon={icon}\n />\n );\n }\n\n // Member of more than one group\n return (\n <SidebarItem icon={icon} text={pluralTitle}>\n <SidebarSubmenu title={pluralTitle}>\n {groups?.map(function groupsMap(group) {\n return (\n <SidebarSubmenuItem\n title={group.metadata.title || group.metadata.name}\n subtitle={\n group.metadata.namespace !== DEFAULT_NAMESPACE\n ? group.metadata.namespace\n : undefined\n }\n to={catalogEntityRoute(getCompoundEntityRef(group))}\n icon={icon}\n key={stringifyEntityRef(group)}\n />\n );\n })}\n </SidebarSubmenu>\n </SidebarItem>\n );\n};\n"],"names":[],"mappings":";;;;;;;AA6Ca,MAAA,mBAAA,GAAsB,CAAC,KAK9B,KAAA;AACJ,EAAA,MAAM,EAAE,aAAA,EAAe,WAAa,EAAA,IAAA,EAAM,QAAW,GAAA,KAAA,CAAA;AAErD,EAAM,MAAA,WAAA,GAAc,OAAO,cAAc,CAAA,CAAA;AACzC,EAAM,MAAA,UAAA,GAAyB,OAAO,aAAa,CAAA,CAAA;AACnD,EAAM,MAAA,kBAAA,GAAqB,YAAY,cAAc,CAAA,CAAA;AAErD,EAAA,MAAM,EAAE,KAAA,EAAO,MAAO,EAAA,GAAI,SAAS,YAAY;AAC7C,IAAM,MAAA,OAAA,GAAU,MAAM,WAAA,CAAY,oBAAqB,EAAA,CAAA;AAEvD,IAAM,MAAA,QAAA,GAAW,MAAM,UAAA,CAAW,WAAY,CAAA;AAAA,MAC5C,MAAQ,EAAA;AAAA,QACN;AAAA,UACE,IAAM,EAAA,OAAA;AAAA,UACN,uBAAuB,OAAQ,CAAA,aAAA;AAAA,UAC/B,GAAI,
|
|
1
|
+
{"version":3,"file":"MyGroupsSidebarItem.esm.js","sources":["../../../src/components/MyGroupsSidebarItem/MyGroupsSidebarItem.tsx"],"sourcesContent":["/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React from 'react';\nimport {\n DEFAULT_NAMESPACE,\n stringifyEntityRef,\n} from '@backstage/catalog-model';\nimport {\n SidebarItem,\n SidebarSubmenu,\n SidebarSubmenuItem,\n} from '@backstage/core-components';\nimport {\n IconComponent,\n identityApiRef,\n useApi,\n useRouteRef,\n} from '@backstage/core-plugin-api';\nimport useAsync from 'react-use/esm/useAsync';\nimport {\n catalogApiRef,\n CatalogApi,\n entityRouteRef,\n} from '@backstage/plugin-catalog-react';\nimport { getCompoundEntityRef } from '@backstage/catalog-model';\n\n/**\n * MyGroupsSidebarItem can be added to your sidebar providing quick access to groups the logged in user is a member of\n *\n * @public\n */\nexport const MyGroupsSidebarItem = (props: {\n singularTitle: string;\n pluralTitle: string;\n icon: IconComponent;\n filter?: Record<string, string | symbol | (string | symbol)[]>;\n}) => {\n const { singularTitle, pluralTitle, icon, filter } = props;\n\n const identityApi = useApi(identityApiRef);\n const catalogApi: CatalogApi = useApi(catalogApiRef);\n const catalogEntityRoute = useRouteRef(entityRouteRef);\n\n const { value: groups } = useAsync(async () => {\n const profile = await identityApi.getBackstageIdentity();\n\n const response = await catalogApi.getEntities({\n filter: [\n {\n kind: 'group',\n 'relations.hasMember': profile.userEntityRef,\n ...(filter ?? {}),\n },\n ],\n fields: ['metadata', 'kind'],\n });\n\n return response.items;\n }, []);\n\n // Not a member of any groups\n if (!groups?.length) {\n return null;\n }\n\n // Only member of one group\n if (groups.length === 1) {\n const group = groups[0];\n return (\n <SidebarItem\n text={singularTitle}\n to={catalogEntityRoute(getCompoundEntityRef(group))}\n icon={icon}\n />\n );\n }\n\n // Member of more than one group\n return (\n <SidebarItem icon={icon} text={pluralTitle}>\n <SidebarSubmenu title={pluralTitle}>\n {groups?.map(function groupsMap(group) {\n return (\n <SidebarSubmenuItem\n title={group.metadata.title || group.metadata.name}\n subtitle={\n group.metadata.namespace !== DEFAULT_NAMESPACE\n ? group.metadata.namespace\n : undefined\n }\n to={catalogEntityRoute(getCompoundEntityRef(group))}\n icon={icon}\n key={stringifyEntityRef(group)}\n />\n );\n })}\n </SidebarSubmenu>\n </SidebarItem>\n );\n};\n"],"names":[],"mappings":";;;;;;;AA6Ca,MAAA,mBAAA,GAAsB,CAAC,KAK9B,KAAA;AACJ,EAAA,MAAM,EAAE,aAAA,EAAe,WAAa,EAAA,IAAA,EAAM,QAAW,GAAA,KAAA,CAAA;AAErD,EAAM,MAAA,WAAA,GAAc,OAAO,cAAc,CAAA,CAAA;AACzC,EAAM,MAAA,UAAA,GAAyB,OAAO,aAAa,CAAA,CAAA;AACnD,EAAM,MAAA,kBAAA,GAAqB,YAAY,cAAc,CAAA,CAAA;AAErD,EAAA,MAAM,EAAE,KAAA,EAAO,MAAO,EAAA,GAAI,SAAS,YAAY;AAC7C,IAAM,MAAA,OAAA,GAAU,MAAM,WAAA,CAAY,oBAAqB,EAAA,CAAA;AAEvD,IAAM,MAAA,QAAA,GAAW,MAAM,UAAA,CAAW,WAAY,CAAA;AAAA,MAC5C,MAAQ,EAAA;AAAA,QACN;AAAA,UACE,IAAM,EAAA,OAAA;AAAA,UACN,uBAAuB,OAAQ,CAAA,aAAA;AAAA,UAC/B,GAAI,UAAU,EAAC;AAAA,SACjB;AAAA,OACF;AAAA,MACA,MAAA,EAAQ,CAAC,UAAA,EAAY,MAAM,CAAA;AAAA,KAC5B,CAAA,CAAA;AAED,IAAA,OAAO,QAAS,CAAA,KAAA,CAAA;AAAA,GAClB,EAAG,EAAE,CAAA,CAAA;AAGL,EAAI,IAAA,CAAC,QAAQ,MAAQ,EAAA;AACnB,IAAO,OAAA,IAAA,CAAA;AAAA,GACT;AAGA,EAAI,IAAA,MAAA,CAAO,WAAW,CAAG,EAAA;AACvB,IAAM,MAAA,KAAA,GAAQ,OAAO,CAAC,CAAA,CAAA;AACtB,IACE,uBAAA,KAAA,CAAA,aAAA;AAAA,MAAC,WAAA;AAAA,MAAA;AAAA,QACC,IAAM,EAAA,aAAA;AAAA,QACN,EAAI,EAAA,kBAAA,CAAmB,oBAAqB,CAAA,KAAK,CAAC,CAAA;AAAA,QAClD,IAAA;AAAA,OAAA;AAAA,KACF,CAAA;AAAA,GAEJ;AAGA,EAAA,uBACG,KAAA,CAAA,aAAA,CAAA,WAAA,EAAA,EAAY,IAAY,EAAA,IAAA,EAAM,WAC7B,EAAA,kBAAA,KAAA,CAAA,aAAA,CAAC,cAAe,EAAA,EAAA,KAAA,EAAO,WACpB,EAAA,EAAA,MAAA,EAAQ,GAAI,CAAA,SAAS,UAAU,KAAO,EAAA;AACrC,IACE,uBAAA,KAAA,CAAA,aAAA;AAAA,MAAC,kBAAA;AAAA,MAAA;AAAA,QACC,KAAO,EAAA,KAAA,CAAM,QAAS,CAAA,KAAA,IAAS,MAAM,QAAS,CAAA,IAAA;AAAA,QAC9C,UACE,KAAM,CAAA,QAAA,CAAS,cAAc,iBACzB,GAAA,KAAA,CAAM,SAAS,SACf,GAAA,KAAA,CAAA;AAAA,QAEN,EAAI,EAAA,kBAAA,CAAmB,oBAAqB,CAAA,KAAK,CAAC,CAAA;AAAA,QAClD,IAAA;AAAA,QACA,GAAA,EAAK,mBAAmB,KAAK,CAAA;AAAA,OAAA;AAAA,KAC/B,CAAA;AAAA,GAEH,CACH,CACF,CAAA,CAAA;AAEJ;;;;"}
|
|
@@ -17,11 +17,10 @@ const getMembersFromGroups = async (groups, catalogApi) => {
|
|
|
17
17
|
return membersList.items;
|
|
18
18
|
};
|
|
19
19
|
const getDescendantGroupsFromGroup = async (group, catalogApi) => {
|
|
20
|
-
var _a;
|
|
21
20
|
const alreadyQueuedOrExpandedGroupNames = /* @__PURE__ */ new Map();
|
|
22
21
|
const groupRef = {
|
|
23
22
|
kind: group.kind,
|
|
24
|
-
namespace:
|
|
23
|
+
namespace: group.metadata.namespace ?? DEFAULT_NAMESPACE,
|
|
25
24
|
name: group.metadata.name
|
|
26
25
|
};
|
|
27
26
|
const groupQueue = [groupRef];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.esm.js","sources":["../../src/helpers/helpers.ts"],"sourcesContent":["/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n CompoundEntityRef,\n DEFAULT_NAMESPACE,\n Entity,\n GroupEntity,\n RELATION_PARENT_OF,\n stringifyEntityRef,\n UserEntity,\n} from '@backstage/catalog-model';\nimport {\n CatalogApi,\n getEntityRelations,\n} from '@backstage/plugin-catalog-react';\n\nexport const getMembersFromGroups = async (\n groups: CompoundEntityRef[],\n catalogApi: CatalogApi,\n) => {\n const membersList =\n groups.length === 0\n ? { items: [] }\n : await catalogApi.getEntities({\n filter: {\n kind: 'User',\n 'relations.memberof': groups.map(group =>\n stringifyEntityRef({\n kind: 'group',\n namespace: group.namespace.toLocaleLowerCase('en-US'),\n name: group.name.toLocaleLowerCase('en-US'),\n }),\n ),\n },\n });\n\n return membersList.items as UserEntity[];\n};\n\nexport const getDescendantGroupsFromGroup = async (\n group: GroupEntity,\n catalogApi: CatalogApi,\n) => {\n const alreadyQueuedOrExpandedGroupNames = new Map<string, boolean>();\n const groupRef: CompoundEntityRef = {\n kind: group.kind,\n namespace: group.metadata.namespace ?? DEFAULT_NAMESPACE,\n name: group.metadata.name,\n };\n\n const groupQueue = [groupRef];\n const resultantGroupRefs: CompoundEntityRef[] = [];\n\n // Continue expanding groups until there are no more\n while (groupQueue.length > 0) {\n const activeGroupRef = groupQueue.shift() as CompoundEntityRef;\n const activeGroup = await catalogApi.getEntityByRef(activeGroupRef);\n alreadyQueuedOrExpandedGroupNames.set(\n stringifyEntityRef(activeGroupRef),\n true,\n );\n\n const childGroups = getEntityRelations(activeGroup, RELATION_PARENT_OF, {\n kind: 'Group',\n }).filter(\n currentGroup =>\n !alreadyQueuedOrExpandedGroupNames.has(\n stringifyEntityRef(currentGroup),\n ),\n );\n childGroups.forEach(childGroup =>\n alreadyQueuedOrExpandedGroupNames.set(\n stringifyEntityRef(childGroup),\n true,\n ),\n );\n\n groupQueue.push(...childGroups);\n resultantGroupRefs.push(...childGroups);\n }\n\n return resultantGroupRefs;\n};\n\nexport const getAllDesendantMembersForGroupEntity = async (\n groupEntity: GroupEntity,\n catalogApi: CatalogApi,\n) =>\n getMembersFromGroups(\n await getDescendantGroupsFromGroup(groupEntity, catalogApi),\n catalogApi,\n );\n\nexport const removeDuplicateEntitiesFrom = (entityArray: Entity[]) => {\n const seenEntities = new Map<string, boolean>();\n\n return entityArray.filter(entity => {\n const stringifiedEntity = stringifyEntityRef(entity);\n const isDuplicate = seenEntities.has(stringifiedEntity);\n\n seenEntities.set(stringifiedEntity, true);\n return !isDuplicate;\n });\n};\n"],"names":[],"mappings":";;;AA8Ba,MAAA,oBAAA,GAAuB,OAClC,MAAA,EACA,UACG,KAAA;AACH,EAAM,MAAA,WAAA,GACJ,MAAO,CAAA,MAAA,KAAW,CACd,GAAA,EAAE,KAAO,EAAA,EAAG,EAAA,GACZ,MAAM,UAAA,CAAW,WAAY,CAAA;AAAA,IAC3B,MAAQ,EAAA;AAAA,MACN,IAAM,EAAA,MAAA;AAAA,MACN,sBAAsB,MAAO,CAAA,GAAA;AAAA,QAAI,WAC/B,kBAAmB,CAAA;AAAA,UACjB,IAAM,EAAA,OAAA;AAAA,UACN,SAAW,EAAA,KAAA,CAAM,SAAU,CAAA,iBAAA,CAAkB,OAAO,CAAA;AAAA,UACpD,IAAM,EAAA,KAAA,CAAM,IAAK,CAAA,iBAAA,CAAkB,OAAO,CAAA;AAAA,SAC3C,CAAA;AAAA,OACH;AAAA,KACF;AAAA,GACD,CAAA,CAAA;AAEP,EAAA,OAAO,WAAY,CAAA,KAAA,CAAA;AACrB,EAAA;AAEa,MAAA,4BAAA,GAA+B,OAC1C,KAAA,EACA,UACG,KAAA;
|
|
1
|
+
{"version":3,"file":"helpers.esm.js","sources":["../../src/helpers/helpers.ts"],"sourcesContent":["/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n CompoundEntityRef,\n DEFAULT_NAMESPACE,\n Entity,\n GroupEntity,\n RELATION_PARENT_OF,\n stringifyEntityRef,\n UserEntity,\n} from '@backstage/catalog-model';\nimport {\n CatalogApi,\n getEntityRelations,\n} from '@backstage/plugin-catalog-react';\n\nexport const getMembersFromGroups = async (\n groups: CompoundEntityRef[],\n catalogApi: CatalogApi,\n) => {\n const membersList =\n groups.length === 0\n ? { items: [] }\n : await catalogApi.getEntities({\n filter: {\n kind: 'User',\n 'relations.memberof': groups.map(group =>\n stringifyEntityRef({\n kind: 'group',\n namespace: group.namespace.toLocaleLowerCase('en-US'),\n name: group.name.toLocaleLowerCase('en-US'),\n }),\n ),\n },\n });\n\n return membersList.items as UserEntity[];\n};\n\nexport const getDescendantGroupsFromGroup = async (\n group: GroupEntity,\n catalogApi: CatalogApi,\n) => {\n const alreadyQueuedOrExpandedGroupNames = new Map<string, boolean>();\n const groupRef: CompoundEntityRef = {\n kind: group.kind,\n namespace: group.metadata.namespace ?? DEFAULT_NAMESPACE,\n name: group.metadata.name,\n };\n\n const groupQueue = [groupRef];\n const resultantGroupRefs: CompoundEntityRef[] = [];\n\n // Continue expanding groups until there are no more\n while (groupQueue.length > 0) {\n const activeGroupRef = groupQueue.shift() as CompoundEntityRef;\n const activeGroup = await catalogApi.getEntityByRef(activeGroupRef);\n alreadyQueuedOrExpandedGroupNames.set(\n stringifyEntityRef(activeGroupRef),\n true,\n );\n\n const childGroups = getEntityRelations(activeGroup, RELATION_PARENT_OF, {\n kind: 'Group',\n }).filter(\n currentGroup =>\n !alreadyQueuedOrExpandedGroupNames.has(\n stringifyEntityRef(currentGroup),\n ),\n );\n childGroups.forEach(childGroup =>\n alreadyQueuedOrExpandedGroupNames.set(\n stringifyEntityRef(childGroup),\n true,\n ),\n );\n\n groupQueue.push(...childGroups);\n resultantGroupRefs.push(...childGroups);\n }\n\n return resultantGroupRefs;\n};\n\nexport const getAllDesendantMembersForGroupEntity = async (\n groupEntity: GroupEntity,\n catalogApi: CatalogApi,\n) =>\n getMembersFromGroups(\n await getDescendantGroupsFromGroup(groupEntity, catalogApi),\n catalogApi,\n );\n\nexport const removeDuplicateEntitiesFrom = (entityArray: Entity[]) => {\n const seenEntities = new Map<string, boolean>();\n\n return entityArray.filter(entity => {\n const stringifiedEntity = stringifyEntityRef(entity);\n const isDuplicate = seenEntities.has(stringifiedEntity);\n\n seenEntities.set(stringifiedEntity, true);\n return !isDuplicate;\n });\n};\n"],"names":[],"mappings":";;;AA8Ba,MAAA,oBAAA,GAAuB,OAClC,MAAA,EACA,UACG,KAAA;AACH,EAAM,MAAA,WAAA,GACJ,MAAO,CAAA,MAAA,KAAW,CACd,GAAA,EAAE,KAAO,EAAA,EAAG,EAAA,GACZ,MAAM,UAAA,CAAW,WAAY,CAAA;AAAA,IAC3B,MAAQ,EAAA;AAAA,MACN,IAAM,EAAA,MAAA;AAAA,MACN,sBAA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C,mBAAmB,YAAY,CAAA;AAAA,OACjC;AAAA,KACJ,CAAA;AACA,IAAY,WAAA,CAAA,OAAA;AAAA,MAAQ,gBAClB,iCAAkC,CAAA,GAAA;AAAA,QAChC,mBAAmB,UAAU,CAAA;AAAA,QAC7B,IAAA;AAAA,OACF;AAAA,KACF,CAAA;AAEA,IAAW,UAAA,CAAA,IAAA,CAAK,GAAG,WAAW,CAAA,CAAA;AAC9B,IAAmB,kBAAA,CAAA,IAAA,CAAK,GAAG,WAAW,CAAA,CAAA;AAAA,GACxC;AAEA,EAAO,OAAA,kBAAA,CAAA;AACT,EAAA;AAEa,MAAA,oCAAA,GAAuC,OAClD,WAAA,EACA,UAEA,KAAA,oBAAA;AAAA,EACE,MAAM,4BAA6B,CAAA,WAAA,EAAa,UAAU,CAAA;AAAA,EAC1D,UAAA;AACF,EAAA;AAEW,MAAA,2BAAA,GAA8B,CAAC,WAA0B,KAAA;AACpE,EAAM,MAAA,YAAA,uBAAmB,GAAqB,EAAA,CAAA;AAE9C,EAAO,OAAA,WAAA,CAAY,OAAO,CAAU,MAAA,KAAA;AAClC,IAAM,MAAA,iBAAA,GAAoB,mBAAmB,MAAM,CAAA,CAAA;AACnD,IAAM,MAAA,WAAA,GAAc,YAAa,CAAA,GAAA,CAAI,iBAAiB,CAAA,CAAA;AAEtD,IAAa,YAAA,CAAA,GAAA,CAAI,mBAAmB,IAAI,CAAA,CAAA;AACxC,IAAA,OAAO,CAAC,WAAA,CAAA;AAAA,GACT,CAAA,CAAA;AACH;;;;"}
|
package/dist/index.d.ts
CHANGED
|
@@ -52,7 +52,7 @@ declare const MyGroupsSidebarItem: (props: {
|
|
|
52
52
|
|
|
53
53
|
/** @public */
|
|
54
54
|
declare const orgPlugin: _backstage_core_plugin_api.BackstagePlugin<{}, {
|
|
55
|
-
catalogIndex: _backstage_core_plugin_api.ExternalRouteRef<undefined,
|
|
55
|
+
catalogIndex: _backstage_core_plugin_api.ExternalRouteRef<undefined, true>;
|
|
56
56
|
}>;
|
|
57
57
|
/** @public */
|
|
58
58
|
declare const EntityGroupProfileCard: (props: {
|
package/dist/routes.esm.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { createExternalRouteRef } from '@backstage/core-plugin-api';
|
|
2
2
|
|
|
3
3
|
const catalogIndexRouteRef = createExternalRouteRef({
|
|
4
|
-
id: "catalog-index"
|
|
4
|
+
id: "catalog-index",
|
|
5
|
+
optional: true,
|
|
6
|
+
defaultTarget: "catalog.catalogIndex"
|
|
5
7
|
});
|
|
6
8
|
|
|
7
9
|
export { catalogIndexRouteRef };
|
package/dist/routes.esm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"routes.esm.js","sources":["../src/routes.ts"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { createExternalRouteRef } from '@backstage/core-plugin-api';\n\nexport const catalogIndexRouteRef = createExternalRouteRef({\n id: 'catalog-index',\n});\n"],"names":[],"mappings":";;AAkBO,MAAM,uBAAuB,sBAAuB,CAAA;AAAA,EACzD,EAAI,EAAA,eAAA;
|
|
1
|
+
{"version":3,"file":"routes.esm.js","sources":["../src/routes.ts"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { createExternalRouteRef } from '@backstage/core-plugin-api';\n\nexport const catalogIndexRouteRef = createExternalRouteRef({\n id: 'catalog-index',\n optional: true,\n defaultTarget: 'catalog.catalogIndex',\n});\n"],"names":[],"mappings":";;AAkBO,MAAM,uBAAuB,sBAAuB,CAAA;AAAA,EACzD,EAAI,EAAA,eAAA;AAAA,EACJ,QAAU,EAAA,IAAA;AAAA,EACV,aAAe,EAAA,sBAAA;AACjB,CAAC;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backstage/plugin-org",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.26-next.1",
|
|
4
4
|
"description": "A Backstage plugin that helps you create entity pages for your organization",
|
|
5
5
|
"backstage": {
|
|
6
6
|
"role": "frontend-plugin"
|
|
@@ -46,12 +46,12 @@
|
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
48
|
"@backstage/catalog-model": "^1.5.0",
|
|
49
|
-
"@backstage/core-compat-api": "^0.2.
|
|
50
|
-
"@backstage/core-components": "^0.14.
|
|
51
|
-
"@backstage/core-plugin-api": "^1.9.
|
|
52
|
-
"@backstage/frontend-plugin-api": "^0.6.
|
|
49
|
+
"@backstage/core-compat-api": "^0.2.6-next.1",
|
|
50
|
+
"@backstage/core-components": "^0.14.8-next.1",
|
|
51
|
+
"@backstage/core-plugin-api": "^1.9.3-next.0",
|
|
52
|
+
"@backstage/frontend-plugin-api": "^0.6.6-next.1",
|
|
53
53
|
"@backstage/plugin-catalog-common": "^1.0.23",
|
|
54
|
-
"@backstage/plugin-catalog-react": "^1.12.
|
|
54
|
+
"@backstage/plugin-catalog-react": "^1.12.1-next.1",
|
|
55
55
|
"@material-ui/core": "^4.12.2",
|
|
56
56
|
"@material-ui/icons": "^4.9.1",
|
|
57
57
|
"@material-ui/lab": "4.0.0-alpha.61",
|
|
@@ -64,13 +64,13 @@
|
|
|
64
64
|
},
|
|
65
65
|
"devDependencies": {
|
|
66
66
|
"@backstage/catalog-client": "^1.6.5",
|
|
67
|
-
"@backstage/cli": "^0.26.
|
|
68
|
-
"@backstage/core-app-api": "^1.12.
|
|
69
|
-
"@backstage/dev-utils": "^1.0.
|
|
70
|
-
"@backstage/plugin-catalog": "^1.
|
|
67
|
+
"@backstage/cli": "^0.26.7-next.2",
|
|
68
|
+
"@backstage/core-app-api": "^1.12.6-next.0",
|
|
69
|
+
"@backstage/dev-utils": "^1.0.33-next.1",
|
|
70
|
+
"@backstage/plugin-catalog": "^1.21.0-next.2",
|
|
71
71
|
"@backstage/plugin-permission-common": "^0.7.13",
|
|
72
|
-
"@backstage/plugin-permission-react": "^0.4.
|
|
73
|
-
"@backstage/test-utils": "^1.5.
|
|
72
|
+
"@backstage/plugin-permission-react": "^0.4.23-next.0",
|
|
73
|
+
"@backstage/test-utils": "^1.5.6-next.1",
|
|
74
74
|
"@backstage/types": "^1.1.1",
|
|
75
75
|
"@testing-library/dom": "^10.0.0",
|
|
76
76
|
"@testing-library/jest-dom": "^6.0.0",
|