@backstage/plugin-org 0.6.24 → 0.6.25-next.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +13 -0
- package/alpha/package.json +1 -1
- package/dist/alpha.esm.js +5 -6
- package/dist/alpha.esm.js.map +1 -1
- package/dist/{esm/GroupProfileCard-BlBaoRJ2.esm.js → components/Cards/Group/GroupProfile/GroupProfileCard.esm.js} +2 -4
- package/dist/{esm/GroupProfileCard-BlBaoRJ2.esm.js.map → components/Cards/Group/GroupProfile/GroupProfileCard.esm.js.map} +1 -1
- package/dist/{esm/MembersListCard-DB1VdRYu.esm.js → components/Cards/Group/MembersList/MembersListCard.esm.js} +4 -67
- package/dist/components/Cards/Group/MembersList/MembersListCard.esm.js.map +1 -0
- package/dist/{esm/LinksGroup-BGqEsmrO.esm.js → components/Cards/Meta/LinksGroup.esm.js} +2 -2
- package/dist/components/Cards/Meta/LinksGroup.esm.js.map +1 -0
- package/dist/components/Cards/OwnershipCard/ComponentsGrid.esm.js +105 -0
- package/dist/components/Cards/OwnershipCard/ComponentsGrid.esm.js.map +1 -0
- package/dist/components/Cards/OwnershipCard/OwnershipCard.esm.js +118 -0
- package/dist/components/Cards/OwnershipCard/OwnershipCard.esm.js.map +1 -0
- package/dist/components/Cards/OwnershipCard/useGetEntities.esm.js +148 -0
- package/dist/components/Cards/OwnershipCard/useGetEntities.esm.js.map +1 -0
- package/dist/{esm/UserProfileCard-DDOjuS1z.esm.js → components/Cards/User/UserProfileCard/UserProfileCard.esm.js} +2 -5
- package/dist/{esm/UserProfileCard-DDOjuS1z.esm.js.map → components/Cards/User/UserProfileCard/UserProfileCard.esm.js.map} +1 -1
- package/dist/components/MyGroupsSidebarItem/MyGroupsSidebarItem.esm.js +56 -0
- package/dist/components/MyGroupsSidebarItem/MyGroupsSidebarItem.esm.js.map +1 -0
- package/dist/components/index.esm.js +6 -0
- package/dist/components/index.esm.js.map +1 -0
- package/dist/helpers/helpers.esm.js +69 -0
- package/dist/helpers/helpers.esm.js.map +1 -0
- package/dist/index.esm.js +6 -128
- package/dist/index.esm.js.map +1 -1
- package/dist/plugin.esm.js +44 -0
- package/dist/plugin.esm.js.map +1 -0
- package/dist/{esm/routes-B-Sa5Rrg.esm.js → routes.esm.js} +2 -2
- package/dist/routes.esm.js.map +1 -0
- package/package.json +12 -12
- package/dist/esm/LinksGroup-BGqEsmrO.esm.js.map +0 -1
- package/dist/esm/MembersListCard-DB1VdRYu.esm.js.map +0 -1
- package/dist/esm/OwnershipCard-DUaYCP-K.esm.js +0 -358
- package/dist/esm/OwnershipCard-DUaYCP-K.esm.js.map +0 -1
- package/dist/esm/index-BuXsbtgm.esm.js +0 -42
- package/dist/esm/index-BuXsbtgm.esm.js.map +0 -1
- package/dist/esm/routes-B-Sa5Rrg.esm.js.map +0 -1
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import { parseEntityRef, stringifyEntityRef, RELATION_MEMBER_OF, RELATION_PARENT_OF } from '@backstage/catalog-model';
|
|
2
|
+
import { catalogApiRef, humanizeEntityRef, getEntityRelations } from '@backstage/plugin-catalog-react';
|
|
3
|
+
import limiterFactory from 'p-limit';
|
|
4
|
+
import { useApi } from '@backstage/core-plugin-api';
|
|
5
|
+
import useAsync from 'react-use/esm/useAsync';
|
|
6
|
+
import qs from 'qs';
|
|
7
|
+
import { uniq } from 'lodash';
|
|
8
|
+
|
|
9
|
+
const limiter = limiterFactory(10);
|
|
10
|
+
const getQueryParams = (ownersEntityRef, selectedEntity) => {
|
|
11
|
+
const { kind, type } = selectedEntity;
|
|
12
|
+
const owners = ownersEntityRef.map(
|
|
13
|
+
(owner) => humanizeEntityRef(parseEntityRef(owner), { defaultKind: "group" })
|
|
14
|
+
);
|
|
15
|
+
const filters = {
|
|
16
|
+
kind: kind.toLocaleLowerCase("en-US"),
|
|
17
|
+
type,
|
|
18
|
+
owners,
|
|
19
|
+
user: "all"
|
|
20
|
+
};
|
|
21
|
+
return qs.stringify({ filters }, { arrayFormat: "repeat" });
|
|
22
|
+
};
|
|
23
|
+
const getMemberOfEntityRefs = (owner) => {
|
|
24
|
+
const parentGroups = getEntityRelations(owner, RELATION_MEMBER_OF, {
|
|
25
|
+
kind: "Group"
|
|
26
|
+
});
|
|
27
|
+
const ownerGroupsNames = parentGroups.map(
|
|
28
|
+
({ kind, namespace, name }) => stringifyEntityRef({
|
|
29
|
+
kind,
|
|
30
|
+
namespace,
|
|
31
|
+
name
|
|
32
|
+
})
|
|
33
|
+
);
|
|
34
|
+
return [...ownerGroupsNames, stringifyEntityRef(owner)];
|
|
35
|
+
};
|
|
36
|
+
const isEntity = (entity) => entity !== void 0;
|
|
37
|
+
const getChildOwnershipEntityRefs = async (entity, catalogApi, alreadyRetrievedParentRefs = []) => {
|
|
38
|
+
const childGroups = getEntityRelations(entity, RELATION_PARENT_OF, {
|
|
39
|
+
kind: "Group"
|
|
40
|
+
});
|
|
41
|
+
const hasChildGroups = childGroups.length > 0;
|
|
42
|
+
const entityRef = stringifyEntityRef(entity);
|
|
43
|
+
if (hasChildGroups) {
|
|
44
|
+
const entityRefs = childGroups.map((r) => stringifyEntityRef(r));
|
|
45
|
+
const childGroupResponse = await catalogApi.getEntitiesByRefs({
|
|
46
|
+
fields: ["kind", "metadata.namespace", "metadata.name", "relations"],
|
|
47
|
+
entityRefs
|
|
48
|
+
});
|
|
49
|
+
const childGroupEntities = childGroupResponse.items.filter(isEntity);
|
|
50
|
+
const unknownChildren = childGroupEntities.filter(
|
|
51
|
+
(childGroupEntity) => !alreadyRetrievedParentRefs.includes(
|
|
52
|
+
stringifyEntityRef(childGroupEntity)
|
|
53
|
+
)
|
|
54
|
+
);
|
|
55
|
+
const childrenRefs = (await Promise.all(
|
|
56
|
+
unknownChildren.map(
|
|
57
|
+
(childGroupEntity) => limiter(
|
|
58
|
+
() => getChildOwnershipEntityRefs(childGroupEntity, catalogApi, [
|
|
59
|
+
...alreadyRetrievedParentRefs,
|
|
60
|
+
entityRef
|
|
61
|
+
])
|
|
62
|
+
)
|
|
63
|
+
)
|
|
64
|
+
)).flatMap((aggregated) => aggregated);
|
|
65
|
+
return uniq([...childrenRefs, entityRef]);
|
|
66
|
+
}
|
|
67
|
+
return [entityRef];
|
|
68
|
+
};
|
|
69
|
+
const getOwners = async (entity, relations, catalogApi) => {
|
|
70
|
+
const isGroup = entity.kind === "Group";
|
|
71
|
+
const isAggregated = relations === "aggregated";
|
|
72
|
+
const isUserEntity = entity.kind === "User";
|
|
73
|
+
if (isAggregated && isGroup) {
|
|
74
|
+
return getChildOwnershipEntityRefs(entity, catalogApi);
|
|
75
|
+
}
|
|
76
|
+
if (isAggregated && isUserEntity) {
|
|
77
|
+
return getMemberOfEntityRefs(entity);
|
|
78
|
+
}
|
|
79
|
+
return [stringifyEntityRef(entity)];
|
|
80
|
+
};
|
|
81
|
+
const getOwnedEntitiesByOwners = (owners, kinds, catalogApi) => catalogApi.getEntities({
|
|
82
|
+
filter: [
|
|
83
|
+
{
|
|
84
|
+
kind: kinds,
|
|
85
|
+
"relations.ownedBy": owners
|
|
86
|
+
}
|
|
87
|
+
],
|
|
88
|
+
fields: [
|
|
89
|
+
"kind",
|
|
90
|
+
"metadata.name",
|
|
91
|
+
"metadata.namespace",
|
|
92
|
+
"spec.type",
|
|
93
|
+
"relations"
|
|
94
|
+
]
|
|
95
|
+
});
|
|
96
|
+
function useGetEntities(entity, relations, entityFilterKind, entityLimit = 6) {
|
|
97
|
+
const catalogApi = useApi(catalogApiRef);
|
|
98
|
+
const kinds = entityFilterKind != null ? entityFilterKind : ["Component", "API", "System"];
|
|
99
|
+
const {
|
|
100
|
+
loading,
|
|
101
|
+
error,
|
|
102
|
+
value: componentsWithCounters
|
|
103
|
+
} = useAsync(async () => {
|
|
104
|
+
const owners = await getOwners(entity, relations, catalogApi);
|
|
105
|
+
const ownedEntitiesList = await getOwnedEntitiesByOwners(
|
|
106
|
+
owners,
|
|
107
|
+
kinds,
|
|
108
|
+
catalogApi
|
|
109
|
+
);
|
|
110
|
+
const counts = ownedEntitiesList.items.reduce(
|
|
111
|
+
(acc, ownedEntity) => {
|
|
112
|
+
var _a, _b;
|
|
113
|
+
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
|
+
}
|
|
118
|
+
);
|
|
119
|
+
if (match) {
|
|
120
|
+
match.count += 1;
|
|
121
|
+
} else {
|
|
122
|
+
acc.push({
|
|
123
|
+
kind: ownedEntity.kind,
|
|
124
|
+
type: (_b = (_a = ownedEntity.spec) == null ? void 0 : _a.type) == null ? void 0 : _b.toString(),
|
|
125
|
+
count: 1
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
return acc;
|
|
129
|
+
},
|
|
130
|
+
[]
|
|
131
|
+
);
|
|
132
|
+
const topN = counts.sort((a, b) => b.count - a.count).slice(0, entityLimit);
|
|
133
|
+
return topN.map((topOwnedEntity) => ({
|
|
134
|
+
counter: topOwnedEntity.count,
|
|
135
|
+
type: topOwnedEntity.type,
|
|
136
|
+
kind: topOwnedEntity.kind,
|
|
137
|
+
queryParams: getQueryParams(owners, topOwnedEntity)
|
|
138
|
+
}));
|
|
139
|
+
}, [catalogApi, entity, relations]);
|
|
140
|
+
return {
|
|
141
|
+
componentsWithCounters,
|
|
142
|
+
loading,
|
|
143
|
+
error
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
export { useGetEntities };
|
|
148
|
+
//# sourceMappingURL=useGetEntities.esm.js.map
|
|
@@ -0,0 +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(10);\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 catalogApi.getEntitiesByRefs({\n fields: ['kind', 'metadata.namespace', 'metadata.name', 'relations'],\n entityRefs,\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 limiter(() =>\n getChildOwnershipEntityRefs(childGroupEntity, catalogApi, [\n ...alreadyRetrievedParentRefs,\n entityRef,\n ]),\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,EAAE,CAAA,CAAA;AAQjC,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,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A,CAAA;AAElC,EAAO,OAAA;AAAA,IACL,sBAAA;AAAA,IACA,OAAA;AAAA,IACA,KAAA;AAAA,GACF,CAAA;AACF;;;;"}
|
|
@@ -13,12 +13,9 @@ import Alert from '@material-ui/lab/Alert';
|
|
|
13
13
|
import EditIcon from '@material-ui/icons/Edit';
|
|
14
14
|
import EmailIcon from '@material-ui/icons/Email';
|
|
15
15
|
import GroupIcon from '@material-ui/icons/Group';
|
|
16
|
-
import {
|
|
16
|
+
import { LinksGroup } from '../../Meta/LinksGroup.esm.js';
|
|
17
17
|
import PersonIcon from '@material-ui/icons/Person';
|
|
18
18
|
import React from 'react';
|
|
19
|
-
import '@backstage/core-plugin-api';
|
|
20
|
-
import '@material-ui/icons/Language';
|
|
21
|
-
import '@material-ui/core/Divider';
|
|
22
19
|
|
|
23
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;
|
|
24
21
|
const UserProfileCard = (props) => {
|
|
@@ -65,4 +62,4 @@ const UserProfileCard = (props) => {
|
|
|
65
62
|
};
|
|
66
63
|
|
|
67
64
|
export { UserProfileCard };
|
|
68
|
-
//# sourceMappingURL=UserProfileCard
|
|
65
|
+
//# sourceMappingURL=UserProfileCard.esm.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UserProfileCard
|
|
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;AA7DN,EAAA,IAAA,EAAA,EAAA,EAAA,CAAA;AA8DE,EAAA,MAAM,EAAE,MAAA,EAAQ,IAAK,EAAA,GAAI,SAAsB,EAAA,CAAA;AAC/C,EAAA,IAAI,CAAC,I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A,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,EAAA,CAEC,KAAO,IAAA,IAAA,GAAA,KAAA,CAAA,GAAA,KAAA,CAAA,SAAA,yCAAc,UAAW,EAAA,EAAA,KAAA,EAAc,CACjD,CACF,CACF,CAAA;AAAA,GACF,CAAA;AAEJ;;;;"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { getCompoundEntityRef, DEFAULT_NAMESPACE, stringifyEntityRef } from '@backstage/catalog-model';
|
|
3
|
+
import { SidebarItem, SidebarSubmenu, SidebarSubmenuItem } from '@backstage/core-components';
|
|
4
|
+
import { useApi, identityApiRef, useRouteRef } from '@backstage/core-plugin-api';
|
|
5
|
+
import useAsync from 'react-use/esm/useAsync';
|
|
6
|
+
import { catalogApiRef, entityRouteRef } from '@backstage/plugin-catalog-react';
|
|
7
|
+
|
|
8
|
+
const MyGroupsSidebarItem = (props) => {
|
|
9
|
+
const { singularTitle, pluralTitle, icon, filter } = props;
|
|
10
|
+
const identityApi = useApi(identityApiRef);
|
|
11
|
+
const catalogApi = useApi(catalogApiRef);
|
|
12
|
+
const catalogEntityRoute = useRouteRef(entityRouteRef);
|
|
13
|
+
const { value: groups } = useAsync(async () => {
|
|
14
|
+
const profile = await identityApi.getBackstageIdentity();
|
|
15
|
+
const response = await catalogApi.getEntities({
|
|
16
|
+
filter: [
|
|
17
|
+
{
|
|
18
|
+
kind: "group",
|
|
19
|
+
"relations.hasMember": profile.userEntityRef,
|
|
20
|
+
...filter != null ? filter : {}
|
|
21
|
+
}
|
|
22
|
+
],
|
|
23
|
+
fields: ["metadata", "kind"]
|
|
24
|
+
});
|
|
25
|
+
return response.items;
|
|
26
|
+
}, []);
|
|
27
|
+
if (!(groups == null ? void 0 : groups.length)) {
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
if (groups.length === 1) {
|
|
31
|
+
const group = groups[0];
|
|
32
|
+
return /* @__PURE__ */ React.createElement(
|
|
33
|
+
SidebarItem,
|
|
34
|
+
{
|
|
35
|
+
text: singularTitle,
|
|
36
|
+
to: catalogEntityRoute(getCompoundEntityRef(group)),
|
|
37
|
+
icon
|
|
38
|
+
}
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
return /* @__PURE__ */ React.createElement(SidebarItem, { icon, text: pluralTitle }, /* @__PURE__ */ React.createElement(SidebarSubmenu, { title: pluralTitle }, groups == null ? void 0 : groups.map(function groupsMap(group) {
|
|
42
|
+
return /* @__PURE__ */ React.createElement(
|
|
43
|
+
SidebarSubmenuItem,
|
|
44
|
+
{
|
|
45
|
+
title: group.metadata.title || group.metadata.name,
|
|
46
|
+
subtitle: group.metadata.namespace !== DEFAULT_NAMESPACE ? group.metadata.namespace : void 0,
|
|
47
|
+
to: catalogEntityRoute(getCompoundEntityRef(group)),
|
|
48
|
+
icon,
|
|
49
|
+
key: stringifyEntityRef(group)
|
|
50
|
+
}
|
|
51
|
+
);
|
|
52
|
+
})));
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
export { MyGroupsSidebarItem };
|
|
56
|
+
//# sourceMappingURL=MyGroupsSidebarItem.esm.js.map
|
|
@@ -0,0 +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,0BAAU,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,EAAC,iCAAQ,MAAQ,CAAA,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,IAAA,IAAA,GAAA,KAAA,CAAA,GAAA,MAAA,CAAQ,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,IAGN,CACF,CAAA,CAAA;AAEJ;;;;"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { MembersListCard } from './Cards/Group/MembersList/MembersListCard.esm.js';
|
|
2
|
+
export { GroupProfileCard } from './Cards/Group/GroupProfile/GroupProfileCard.esm.js';
|
|
3
|
+
export { UserProfileCard } from './Cards/User/UserProfileCard/UserProfileCard.esm.js';
|
|
4
|
+
export { OwnershipCard } from './Cards/OwnershipCard/OwnershipCard.esm.js';
|
|
5
|
+
export { MyGroupsSidebarItem } from './MyGroupsSidebarItem/MyGroupsSidebarItem.esm.js';
|
|
6
|
+
//# sourceMappingURL=index.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { stringifyEntityRef, DEFAULT_NAMESPACE, RELATION_PARENT_OF } from '@backstage/catalog-model';
|
|
2
|
+
import { getEntityRelations } from '@backstage/plugin-catalog-react';
|
|
3
|
+
|
|
4
|
+
const getMembersFromGroups = async (groups, catalogApi) => {
|
|
5
|
+
const membersList = groups.length === 0 ? { items: [] } : await catalogApi.getEntities({
|
|
6
|
+
filter: {
|
|
7
|
+
kind: "User",
|
|
8
|
+
"relations.memberof": groups.map(
|
|
9
|
+
(group) => stringifyEntityRef({
|
|
10
|
+
kind: "group",
|
|
11
|
+
namespace: group.namespace.toLocaleLowerCase("en-US"),
|
|
12
|
+
name: group.name.toLocaleLowerCase("en-US")
|
|
13
|
+
})
|
|
14
|
+
)
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
return membersList.items;
|
|
18
|
+
};
|
|
19
|
+
const getDescendantGroupsFromGroup = async (group, catalogApi) => {
|
|
20
|
+
var _a;
|
|
21
|
+
const alreadyQueuedOrExpandedGroupNames = /* @__PURE__ */ new Map();
|
|
22
|
+
const groupRef = {
|
|
23
|
+
kind: group.kind,
|
|
24
|
+
namespace: (_a = group.metadata.namespace) != null ? _a : DEFAULT_NAMESPACE,
|
|
25
|
+
name: group.metadata.name
|
|
26
|
+
};
|
|
27
|
+
const groupQueue = [groupRef];
|
|
28
|
+
const resultantGroupRefs = [];
|
|
29
|
+
while (groupQueue.length > 0) {
|
|
30
|
+
const activeGroupRef = groupQueue.shift();
|
|
31
|
+
const activeGroup = await catalogApi.getEntityByRef(activeGroupRef);
|
|
32
|
+
alreadyQueuedOrExpandedGroupNames.set(
|
|
33
|
+
stringifyEntityRef(activeGroupRef),
|
|
34
|
+
true
|
|
35
|
+
);
|
|
36
|
+
const childGroups = getEntityRelations(activeGroup, RELATION_PARENT_OF, {
|
|
37
|
+
kind: "Group"
|
|
38
|
+
}).filter(
|
|
39
|
+
(currentGroup) => !alreadyQueuedOrExpandedGroupNames.has(
|
|
40
|
+
stringifyEntityRef(currentGroup)
|
|
41
|
+
)
|
|
42
|
+
);
|
|
43
|
+
childGroups.forEach(
|
|
44
|
+
(childGroup) => alreadyQueuedOrExpandedGroupNames.set(
|
|
45
|
+
stringifyEntityRef(childGroup),
|
|
46
|
+
true
|
|
47
|
+
)
|
|
48
|
+
);
|
|
49
|
+
groupQueue.push(...childGroups);
|
|
50
|
+
resultantGroupRefs.push(...childGroups);
|
|
51
|
+
}
|
|
52
|
+
return resultantGroupRefs;
|
|
53
|
+
};
|
|
54
|
+
const getAllDesendantMembersForGroupEntity = async (groupEntity, catalogApi) => getMembersFromGroups(
|
|
55
|
+
await getDescendantGroupsFromGroup(groupEntity, catalogApi),
|
|
56
|
+
catalogApi
|
|
57
|
+
);
|
|
58
|
+
const removeDuplicateEntitiesFrom = (entityArray) => {
|
|
59
|
+
const seenEntities = /* @__PURE__ */ new Map();
|
|
60
|
+
return entityArray.filter((entity) => {
|
|
61
|
+
const stringifiedEntity = stringifyEntityRef(entity);
|
|
62
|
+
const isDuplicate = seenEntities.has(stringifiedEntity);
|
|
63
|
+
seenEntities.set(stringifiedEntity, true);
|
|
64
|
+
return !isDuplicate;
|
|
65
|
+
});
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
export { getAllDesendantMembersForGroupEntity, getDescendantGroupsFromGroup, getMembersFromGroups, removeDuplicateEntitiesFrom };
|
|
69
|
+
//# sourceMappingURL=helpers.esm.js.map
|
|
@@ -0,0 +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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AA,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.esm.js
CHANGED
|
@@ -1,129 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export {
|
|
4
|
-
export {
|
|
5
|
-
export {
|
|
6
|
-
export {
|
|
7
|
-
import React from 'react';
|
|
8
|
-
import { getCompoundEntityRef, DEFAULT_NAMESPACE, stringifyEntityRef } from '@backstage/catalog-model';
|
|
9
|
-
import { SidebarItem, SidebarSubmenu, SidebarSubmenuItem } from '@backstage/core-components';
|
|
10
|
-
import useAsync from 'react-use/esm/useAsync';
|
|
11
|
-
import { catalogApiRef, entityRouteRef } from '@backstage/plugin-catalog-react';
|
|
12
|
-
import '@material-ui/core/Box';
|
|
13
|
-
import '@material-ui/core/Grid';
|
|
14
|
-
import '@material-ui/core/Switch';
|
|
15
|
-
import '@material-ui/core/Typography';
|
|
16
|
-
import '@material-ui/core/styles';
|
|
17
|
-
import '@material-ui/lab/Pagination';
|
|
18
|
-
import '@material-ui/core/IconButton';
|
|
19
|
-
import '@material-ui/core/List';
|
|
20
|
-
import '@material-ui/core/ListItem';
|
|
21
|
-
import '@material-ui/core/ListItemIcon';
|
|
22
|
-
import '@material-ui/core/ListItemText';
|
|
23
|
-
import '@material-ui/core/Tooltip';
|
|
24
|
-
import '@material-ui/icons/AccountTree';
|
|
25
|
-
import '@material-ui/lab/Alert';
|
|
26
|
-
import '@material-ui/icons/Cached';
|
|
27
|
-
import '@material-ui/icons/Edit';
|
|
28
|
-
import '@material-ui/icons/Email';
|
|
29
|
-
import '@material-ui/icons/Group';
|
|
30
|
-
import './esm/LinksGroup-BGqEsmrO.esm.js';
|
|
31
|
-
import '@material-ui/icons/Language';
|
|
32
|
-
import '@material-ui/core/Divider';
|
|
33
|
-
import '@backstage/plugin-catalog-react/alpha';
|
|
34
|
-
import '@backstage/plugin-catalog-common/alpha';
|
|
35
|
-
import '@material-ui/icons/Person';
|
|
36
|
-
import '@material-ui/core/ListItemSecondaryAction';
|
|
37
|
-
import 'pluralize';
|
|
38
|
-
import 'p-limit';
|
|
39
|
-
import 'qs';
|
|
40
|
-
import 'lodash';
|
|
41
|
-
|
|
42
|
-
const orgPlugin = createPlugin({
|
|
43
|
-
id: "org",
|
|
44
|
-
externalRoutes: {
|
|
45
|
-
catalogIndex: catalogIndexRouteRef
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
const EntityGroupProfileCard = orgPlugin.provide(
|
|
49
|
-
createComponentExtension({
|
|
50
|
-
name: "EntityGroupProfileCard",
|
|
51
|
-
component: {
|
|
52
|
-
lazy: () => import('./esm/index-BuXsbtgm.esm.js').then((m) => m.GroupProfileCard)
|
|
53
|
-
}
|
|
54
|
-
})
|
|
55
|
-
);
|
|
56
|
-
const EntityMembersListCard = orgPlugin.provide(
|
|
57
|
-
createComponentExtension({
|
|
58
|
-
name: "EntityMembersListCard",
|
|
59
|
-
component: {
|
|
60
|
-
lazy: () => import('./esm/index-BuXsbtgm.esm.js').then((m) => m.MembersListCard)
|
|
61
|
-
}
|
|
62
|
-
})
|
|
63
|
-
);
|
|
64
|
-
const EntityOwnershipCard = orgPlugin.provide(
|
|
65
|
-
createComponentExtension({
|
|
66
|
-
name: "EntityOwnershipCard",
|
|
67
|
-
component: {
|
|
68
|
-
lazy: () => import('./esm/index-BuXsbtgm.esm.js').then((m) => m.OwnershipCard)
|
|
69
|
-
}
|
|
70
|
-
})
|
|
71
|
-
);
|
|
72
|
-
const EntityUserProfileCard = orgPlugin.provide(
|
|
73
|
-
createComponentExtension({
|
|
74
|
-
name: "EntityUserProfileCard",
|
|
75
|
-
component: {
|
|
76
|
-
lazy: () => import('./esm/index-BuXsbtgm.esm.js').then((m) => m.UserProfileCard)
|
|
77
|
-
}
|
|
78
|
-
})
|
|
79
|
-
);
|
|
80
|
-
|
|
81
|
-
const MyGroupsSidebarItem = (props) => {
|
|
82
|
-
const { singularTitle, pluralTitle, icon, filter } = props;
|
|
83
|
-
const identityApi = useApi(identityApiRef);
|
|
84
|
-
const catalogApi = useApi(catalogApiRef);
|
|
85
|
-
const catalogEntityRoute = useRouteRef(entityRouteRef);
|
|
86
|
-
const { value: groups } = useAsync(async () => {
|
|
87
|
-
const profile = await identityApi.getBackstageIdentity();
|
|
88
|
-
const response = await catalogApi.getEntities({
|
|
89
|
-
filter: [
|
|
90
|
-
{
|
|
91
|
-
kind: "group",
|
|
92
|
-
"relations.hasMember": profile.userEntityRef,
|
|
93
|
-
...filter != null ? filter : {}
|
|
94
|
-
}
|
|
95
|
-
],
|
|
96
|
-
fields: ["metadata", "kind"]
|
|
97
|
-
});
|
|
98
|
-
return response.items;
|
|
99
|
-
}, []);
|
|
100
|
-
if (!(groups == null ? void 0 : groups.length)) {
|
|
101
|
-
return null;
|
|
102
|
-
}
|
|
103
|
-
if (groups.length === 1) {
|
|
104
|
-
const group = groups[0];
|
|
105
|
-
return /* @__PURE__ */ React.createElement(
|
|
106
|
-
SidebarItem,
|
|
107
|
-
{
|
|
108
|
-
text: singularTitle,
|
|
109
|
-
to: catalogEntityRoute(getCompoundEntityRef(group)),
|
|
110
|
-
icon
|
|
111
|
-
}
|
|
112
|
-
);
|
|
113
|
-
}
|
|
114
|
-
return /* @__PURE__ */ React.createElement(SidebarItem, { icon, text: pluralTitle }, /* @__PURE__ */ React.createElement(SidebarSubmenu, { title: pluralTitle }, groups == null ? void 0 : groups.map(function groupsMap(group) {
|
|
115
|
-
return /* @__PURE__ */ React.createElement(
|
|
116
|
-
SidebarSubmenuItem,
|
|
117
|
-
{
|
|
118
|
-
title: group.metadata.title || group.metadata.name,
|
|
119
|
-
subtitle: group.metadata.namespace !== DEFAULT_NAMESPACE ? group.metadata.namespace : void 0,
|
|
120
|
-
to: catalogEntityRoute(getCompoundEntityRef(group)),
|
|
121
|
-
icon,
|
|
122
|
-
key: stringifyEntityRef(group)
|
|
123
|
-
}
|
|
124
|
-
);
|
|
125
|
-
})));
|
|
126
|
-
};
|
|
127
|
-
|
|
128
|
-
export { EntityGroupProfileCard, EntityMembersListCard, EntityOwnershipCard, EntityUserProfileCard, MyGroupsSidebarItem, orgPlugin, orgPlugin as plugin };
|
|
1
|
+
export { EntityGroupProfileCard, EntityMembersListCard, EntityOwnershipCard, EntityUserProfileCard, orgPlugin, orgPlugin as plugin } from './plugin.esm.js';
|
|
2
|
+
export { MembersListCard } from './components/Cards/Group/MembersList/MembersListCard.esm.js';
|
|
3
|
+
export { GroupProfileCard } from './components/Cards/Group/GroupProfile/GroupProfileCard.esm.js';
|
|
4
|
+
export { UserProfileCard } from './components/Cards/User/UserProfileCard/UserProfileCard.esm.js';
|
|
5
|
+
export { OwnershipCard } from './components/Cards/OwnershipCard/OwnershipCard.esm.js';
|
|
6
|
+
export { MyGroupsSidebarItem } from './components/MyGroupsSidebarItem/MyGroupsSidebarItem.esm.js';
|
|
129
7
|
//# sourceMappingURL=index.esm.js.map
|
package/dist/index.esm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.esm.js","sources":[
|
|
1
|
+
{"version":3,"file":"index.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { createPlugin, createComponentExtension } from '@backstage/core-plugin-api';
|
|
2
|
+
import { catalogIndexRouteRef } from './routes.esm.js';
|
|
3
|
+
|
|
4
|
+
const orgPlugin = createPlugin({
|
|
5
|
+
id: "org",
|
|
6
|
+
externalRoutes: {
|
|
7
|
+
catalogIndex: catalogIndexRouteRef
|
|
8
|
+
}
|
|
9
|
+
});
|
|
10
|
+
const EntityGroupProfileCard = orgPlugin.provide(
|
|
11
|
+
createComponentExtension({
|
|
12
|
+
name: "EntityGroupProfileCard",
|
|
13
|
+
component: {
|
|
14
|
+
lazy: () => import('./components/index.esm.js').then((m) => m.GroupProfileCard)
|
|
15
|
+
}
|
|
16
|
+
})
|
|
17
|
+
);
|
|
18
|
+
const EntityMembersListCard = orgPlugin.provide(
|
|
19
|
+
createComponentExtension({
|
|
20
|
+
name: "EntityMembersListCard",
|
|
21
|
+
component: {
|
|
22
|
+
lazy: () => import('./components/index.esm.js').then((m) => m.MembersListCard)
|
|
23
|
+
}
|
|
24
|
+
})
|
|
25
|
+
);
|
|
26
|
+
const EntityOwnershipCard = orgPlugin.provide(
|
|
27
|
+
createComponentExtension({
|
|
28
|
+
name: "EntityOwnershipCard",
|
|
29
|
+
component: {
|
|
30
|
+
lazy: () => import('./components/index.esm.js').then((m) => m.OwnershipCard)
|
|
31
|
+
}
|
|
32
|
+
})
|
|
33
|
+
);
|
|
34
|
+
const EntityUserProfileCard = orgPlugin.provide(
|
|
35
|
+
createComponentExtension({
|
|
36
|
+
name: "EntityUserProfileCard",
|
|
37
|
+
component: {
|
|
38
|
+
lazy: () => import('./components/index.esm.js').then((m) => m.UserProfileCard)
|
|
39
|
+
}
|
|
40
|
+
})
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
export { EntityGroupProfileCard, EntityMembersListCard, EntityOwnershipCard, EntityUserProfileCard, orgPlugin };
|
|
44
|
+
//# sourceMappingURL=plugin.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.esm.js","sources":["../src/plugin.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 */\nimport {\n createComponentExtension,\n createPlugin,\n} from '@backstage/core-plugin-api';\nimport { catalogIndexRouteRef } from './routes';\n\n/** @public */\nexport const orgPlugin = createPlugin({\n id: 'org',\n externalRoutes: {\n catalogIndex: catalogIndexRouteRef,\n },\n});\n\n/** @public */\nexport const EntityGroupProfileCard = orgPlugin.provide(\n createComponentExtension({\n name: 'EntityGroupProfileCard',\n component: {\n lazy: () => import('./components').then(m => m.GroupProfileCard),\n },\n }),\n);\n\n/** @public */\nexport const EntityMembersListCard = orgPlugin.provide(\n createComponentExtension({\n name: 'EntityMembersListCard',\n component: {\n lazy: () => import('./components').then(m => m.MembersListCard),\n },\n }),\n);\n\n/** @public */\nexport const EntityOwnershipCard = orgPlugin.provide(\n createComponentExtension({\n name: 'EntityOwnershipCard',\n component: {\n lazy: () => import('./components').then(m => m.OwnershipCard),\n },\n }),\n);\n\n/** @public */\nexport const EntityUserProfileCard = orgPlugin.provide(\n createComponentExtension({\n name: 'EntityUserProfileCard',\n component: {\n lazy: () => import('./components').then(m => m.UserProfileCard),\n },\n }),\n);\n"],"names":[],"mappings":";;;AAsBO,MAAM,YAAY,YAAa,CAAA;AAAA,EACpC,EAAI,EAAA,KAAA;AAAA,EACJ,cAAgB,EAAA;AAAA,IACd,YAAc,EAAA,oBAAA;AAAA,GAChB;AACF,CAAC,EAAA;AAGM,MAAM,yBAAyB,SAAU,CAAA,OAAA;AAAA,EAC9C,wBAAyB,CAAA;AAAA,IACvB,IAAM,EAAA,wBAAA;AAAA,IACN,SAAW,EAAA;AAAA,MACT,IAAA,EAAM,MAAM,OAAO,2BAAc,EAAE,IAAK,CAAA,CAAA,CAAA,KAAK,EAAE,gBAAgB,CAAA;AAAA,KACjE;AAAA,GACD,CAAA;AACH,EAAA;AAGO,MAAM,wBAAwB,SAAU,CAAA,OAAA;AAAA,EAC7C,wBAAyB,CAAA;AAAA,IACvB,IAAM,EAAA,uBAAA;AAAA,IACN,SAAW,EAAA;AAAA,MACT,IAAA,EAAM,MAAM,OAAO,2BAAc,EAAE,IAAK,CAAA,CAAA,CAAA,KAAK,EAAE,eAAe,CAAA;AAAA,KAChE;AAAA,GACD,CAAA;AACH,EAAA;AAGO,MAAM,sBAAsB,SAAU,CAAA,OAAA;AAAA,EAC3C,wBAAyB,CAAA;AAAA,IACvB,IAAM,EAAA,qBAAA;AAAA,IACN,SAAW,EAAA;AAAA,MACT,IAAA,EAAM,MAAM,OAAO,2BAAc,EAAE,IAAK,CAAA,CAAA,CAAA,KAAK,EAAE,aAAa,CAAA;AAAA,KAC9D;AAAA,GACD,CAAA;AACH,EAAA;AAGO,MAAM,wBAAwB,SAAU,CAAA,OAAA;AAAA,EAC7C,wBAAyB,CAAA;AAAA,IACvB,IAAM,EAAA,uBAAA;AAAA,IACN,SAAW,EAAA;AAAA,MACT,IAAA,EAAM,MAAM,OAAO,2BAAc,EAAE,IAAK,CAAA,CAAA,CAAA,KAAK,EAAE,eAAe,CAAA;AAAA,KAChE;AAAA,GACD,CAAA;AACH;;;;"}
|
|
@@ -0,0 +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;AACN,CAAC;;;;"}
|