@backstage/plugin-org 0.6.20-next.1 → 0.6.20-next.3

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.
@@ -0,0 +1,325 @@
1
+ import { Progress, ResponseErrorPanel, Link, OverflowTooltip, InfoCard } from '@backstage/core-components';
2
+ import { catalogApiRef, humanizeEntityRef, getEntityRelations, useEntity } from '@backstage/plugin-catalog-react';
3
+ import { makeStyles, createStyles, Grid, Box, Typography, List, ListItem, ListItemText, ListItemSecondaryAction, Tooltip, Switch } from '@material-ui/core';
4
+ import React, { useState, useEffect } from 'react';
5
+ import { useApi, useRouteRef } from '@backstage/core-plugin-api';
6
+ import pluralize from 'pluralize';
7
+ import { c as catalogIndexRouteRef } from './routes-e3daad75.esm.js';
8
+ import { parseEntityRef, stringifyEntityRef, RELATION_MEMBER_OF, RELATION_PARENT_OF } from '@backstage/catalog-model';
9
+ import limiterFactory from 'p-limit';
10
+ import useAsync from 'react-use/lib/useAsync';
11
+ import qs from 'qs';
12
+ import { uniq } from 'lodash';
13
+
14
+ const limiter = limiterFactory(10);
15
+ const getQueryParams = (ownersEntityRef, selectedEntity) => {
16
+ const { kind, type } = selectedEntity;
17
+ const owners = ownersEntityRef.map(
18
+ (owner) => humanizeEntityRef(parseEntityRef(owner), { defaultKind: "group" })
19
+ );
20
+ const filters = {
21
+ kind: kind.toLocaleLowerCase("en-US"),
22
+ type,
23
+ owners,
24
+ user: "all"
25
+ };
26
+ return qs.stringify({ filters }, { arrayFormat: "repeat" });
27
+ };
28
+ const getMemberOfEntityRefs = (owner) => {
29
+ const parentGroups = getEntityRelations(owner, RELATION_MEMBER_OF, {
30
+ kind: "Group"
31
+ });
32
+ const ownerGroupsNames = parentGroups.map(
33
+ ({ kind, namespace, name }) => stringifyEntityRef({
34
+ kind,
35
+ namespace,
36
+ name
37
+ })
38
+ );
39
+ return [...ownerGroupsNames, stringifyEntityRef(owner)];
40
+ };
41
+ const isEntity = (entity) => entity !== void 0;
42
+ const getChildOwnershipEntityRefs = async (entity, catalogApi, alreadyRetrievedParentRefs = []) => {
43
+ const childGroups = getEntityRelations(entity, RELATION_PARENT_OF, {
44
+ kind: "Group"
45
+ });
46
+ const hasChildGroups = childGroups.length > 0;
47
+ const entityRef = stringifyEntityRef(entity);
48
+ if (hasChildGroups) {
49
+ const entityRefs = childGroups.map((r) => stringifyEntityRef(r));
50
+ const childGroupResponse = await catalogApi.getEntitiesByRefs({
51
+ fields: ["kind", "metadata.namespace", "metadata.name", "relations"],
52
+ entityRefs
53
+ });
54
+ const childGroupEntities = childGroupResponse.items.filter(isEntity);
55
+ const unknownChildren = childGroupEntities.filter(
56
+ (childGroupEntity) => !alreadyRetrievedParentRefs.includes(
57
+ stringifyEntityRef(childGroupEntity)
58
+ )
59
+ );
60
+ const childrenRefs = (await Promise.all(
61
+ unknownChildren.map(
62
+ (childGroupEntity) => limiter(
63
+ () => getChildOwnershipEntityRefs(childGroupEntity, catalogApi, [
64
+ ...alreadyRetrievedParentRefs,
65
+ entityRef
66
+ ])
67
+ )
68
+ )
69
+ )).flatMap((aggregated) => aggregated);
70
+ return uniq([...childrenRefs, entityRef]);
71
+ }
72
+ return [entityRef];
73
+ };
74
+ const getOwners = async (entity, relations, catalogApi) => {
75
+ const isGroup = entity.kind === "Group";
76
+ const isAggregated = relations === "aggregated";
77
+ const isUserEntity = entity.kind === "User";
78
+ if (isAggregated && isGroup) {
79
+ return getChildOwnershipEntityRefs(entity, catalogApi);
80
+ }
81
+ if (isAggregated && isUserEntity) {
82
+ return getMemberOfEntityRefs(entity);
83
+ }
84
+ return [stringifyEntityRef(entity)];
85
+ };
86
+ const getOwnedEntitiesByOwners = (owners, kinds, catalogApi) => catalogApi.getEntities({
87
+ filter: [
88
+ {
89
+ kind: kinds,
90
+ "relations.ownedBy": owners
91
+ }
92
+ ],
93
+ fields: [
94
+ "kind",
95
+ "metadata.name",
96
+ "metadata.namespace",
97
+ "spec.type",
98
+ "relations"
99
+ ]
100
+ });
101
+ function useGetEntities(entity, relations, entityFilterKind, entityLimit = 6) {
102
+ const catalogApi = useApi(catalogApiRef);
103
+ const kinds = entityFilterKind != null ? entityFilterKind : ["Component", "API", "System"];
104
+ const {
105
+ loading,
106
+ error,
107
+ value: componentsWithCounters
108
+ } = useAsync(async () => {
109
+ const owners = await getOwners(entity, relations, catalogApi);
110
+ const ownedEntitiesList = await getOwnedEntitiesByOwners(
111
+ owners,
112
+ kinds,
113
+ catalogApi
114
+ );
115
+ const counts = ownedEntitiesList.items.reduce(
116
+ (acc, ownedEntity) => {
117
+ var _a, _b;
118
+ const match = acc.find(
119
+ (x) => {
120
+ var _a2;
121
+ return x.kind === ownedEntity.kind && x.type === ((_a2 = ownedEntity.spec) == null ? void 0 : _a2.type);
122
+ }
123
+ );
124
+ if (match) {
125
+ match.count += 1;
126
+ } else {
127
+ acc.push({
128
+ kind: ownedEntity.kind,
129
+ type: (_b = (_a = ownedEntity.spec) == null ? void 0 : _a.type) == null ? void 0 : _b.toString(),
130
+ count: 1
131
+ });
132
+ }
133
+ return acc;
134
+ },
135
+ []
136
+ );
137
+ const topN = counts.sort((a, b) => b.count - a.count).slice(0, entityLimit);
138
+ return topN.map((topOwnedEntity) => ({
139
+ counter: topOwnedEntity.count,
140
+ type: topOwnedEntity.type,
141
+ kind: topOwnedEntity.kind,
142
+ queryParams: getQueryParams(owners, topOwnedEntity)
143
+ }));
144
+ }, [catalogApi, entity, relations]);
145
+ return {
146
+ componentsWithCounters,
147
+ loading,
148
+ error
149
+ };
150
+ }
151
+
152
+ const useStyles$1 = makeStyles(
153
+ (theme) => createStyles({
154
+ card: {
155
+ border: `1px solid ${theme.palette.divider}`,
156
+ boxShadow: theme.shadows[2],
157
+ borderRadius: "4px",
158
+ padding: theme.spacing(2),
159
+ transition: `${theme.transitions.duration.standard}ms`,
160
+ "&:hover": {
161
+ boxShadow: theme.shadows[4]
162
+ },
163
+ height: "100%"
164
+ },
165
+ bold: {
166
+ fontWeight: theme.typography.fontWeightBold
167
+ },
168
+ smallFont: {
169
+ fontSize: theme.typography.body2.fontSize
170
+ },
171
+ entityTypeBox: {
172
+ background: (props) => theme.getPageTheme({ themeId: props.type }).backgroundImage,
173
+ color: (props) => theme.getPageTheme({ themeId: props.type }).fontColor
174
+ }
175
+ })
176
+ );
177
+ const EntityCountTile = ({
178
+ counter,
179
+ type,
180
+ kind,
181
+ url
182
+ }) => {
183
+ const classes = useStyles$1({ type: type != null ? type : kind });
184
+ const rawTitle = type != null ? type : kind;
185
+ const isLongText = rawTitle.length > 10;
186
+ return /* @__PURE__ */ React.createElement(Link, { to: url, variant: "body2" }, /* @__PURE__ */ React.createElement(
187
+ Box,
188
+ {
189
+ className: `${classes.card} ${classes.entityTypeBox}`,
190
+ display: "flex",
191
+ flexDirection: "column",
192
+ alignItems: "center"
193
+ },
194
+ /* @__PURE__ */ React.createElement(Typography, { className: classes.bold, variant: "h6" }, counter),
195
+ /* @__PURE__ */ React.createElement(Box, { sx: { width: "100%", textAlign: "center" } }, /* @__PURE__ */ React.createElement(
196
+ Typography,
197
+ {
198
+ className: `${classes.bold} ${isLongText && classes.smallFont}`,
199
+ variant: "h6"
200
+ },
201
+ /* @__PURE__ */ React.createElement(
202
+ OverflowTooltip,
203
+ {
204
+ text: pluralize(rawTitle.toLocaleUpperCase("en-US"), counter)
205
+ }
206
+ )
207
+ )),
208
+ type && /* @__PURE__ */ React.createElement(Typography, { variant: "subtitle1" }, kind)
209
+ ));
210
+ };
211
+ const ComponentsGrid = ({
212
+ entity,
213
+ relationsType,
214
+ entityFilterKind,
215
+ entityLimit = 6
216
+ }) => {
217
+ const catalogLink = useRouteRef(catalogIndexRouteRef);
218
+ const { componentsWithCounters, loading, error } = useGetEntities(
219
+ entity,
220
+ relationsType,
221
+ entityFilterKind,
222
+ entityLimit
223
+ );
224
+ if (loading) {
225
+ return /* @__PURE__ */ React.createElement(Progress, null);
226
+ } else if (error) {
227
+ return /* @__PURE__ */ React.createElement(ResponseErrorPanel, { error });
228
+ }
229
+ return /* @__PURE__ */ React.createElement(Grid, { container: true }, componentsWithCounters == null ? void 0 : componentsWithCounters.map((c) => {
230
+ var _a;
231
+ return /* @__PURE__ */ React.createElement(Grid, { item: true, xs: 6, md: 6, lg: 4, key: (_a = c.type) != null ? _a : c.kind }, /* @__PURE__ */ React.createElement(
232
+ EntityCountTile,
233
+ {
234
+ counter: c.counter,
235
+ kind: c.kind,
236
+ type: c.type,
237
+ url: `${catalogLink()}/?${c.queryParams}`
238
+ }
239
+ ));
240
+ }));
241
+ };
242
+
243
+ const useStyles = makeStyles((theme) => ({
244
+ list: {
245
+ [theme.breakpoints.down("xs")]: {
246
+ padding: `0 0 12px`
247
+ }
248
+ },
249
+ listItemText: {
250
+ [theme.breakpoints.down("xs")]: {
251
+ paddingRight: 0,
252
+ paddingLeft: 0
253
+ }
254
+ },
255
+ listItemSecondaryAction: {
256
+ [theme.breakpoints.down("xs")]: {
257
+ width: "100%",
258
+ top: "auto",
259
+ right: "auto",
260
+ position: "relative",
261
+ transform: "unset"
262
+ }
263
+ }
264
+ }));
265
+ const OwnershipCard = (props) => {
266
+ const {
267
+ variant,
268
+ entityFilterKind,
269
+ hideRelationsToggle,
270
+ relationsType,
271
+ entityLimit = 6
272
+ } = props;
273
+ const relationsToggle = hideRelationsToggle === void 0 ? false : hideRelationsToggle;
274
+ const classes = useStyles();
275
+ const { entity } = useEntity();
276
+ const defaultRelationsType = entity.kind === "User" ? "aggregated" : "direct";
277
+ const [getRelationsType, setRelationsType] = useState(
278
+ relationsType != null ? relationsType : defaultRelationsType
279
+ );
280
+ useEffect(() => {
281
+ if (!relationsType) {
282
+ setRelationsType(defaultRelationsType);
283
+ }
284
+ }, [setRelationsType, defaultRelationsType, relationsType]);
285
+ return /* @__PURE__ */ React.createElement(InfoCard, { title: "Ownership", variant }, !relationsToggle && /* @__PURE__ */ React.createElement(List, { dense: true }, /* @__PURE__ */ React.createElement(ListItem, { className: classes.list }, /* @__PURE__ */ React.createElement(ListItemText, { className: classes.listItemText }), /* @__PURE__ */ React.createElement(
286
+ ListItemSecondaryAction,
287
+ {
288
+ className: classes.listItemSecondaryAction
289
+ },
290
+ "Direct Relations",
291
+ /* @__PURE__ */ React.createElement(
292
+ Tooltip,
293
+ {
294
+ placement: "top",
295
+ arrow: true,
296
+ title: `${getRelationsType === "direct" ? "Direct" : "Aggregated"} Relations`
297
+ },
298
+ /* @__PURE__ */ React.createElement(
299
+ Switch,
300
+ {
301
+ color: "primary",
302
+ checked: getRelationsType !== "direct",
303
+ onChange: () => {
304
+ const updatedRelationsType = getRelationsType === "direct" ? "aggregated" : "direct";
305
+ setRelationsType(updatedRelationsType);
306
+ },
307
+ name: "pin",
308
+ inputProps: { "aria-label": "Ownership Type Switch" }
309
+ }
310
+ )
311
+ ),
312
+ "Aggregated Relations"
313
+ ))), /* @__PURE__ */ React.createElement(
314
+ ComponentsGrid,
315
+ {
316
+ entity,
317
+ entityLimit,
318
+ relationsType: getRelationsType,
319
+ entityFilterKind
320
+ }
321
+ ));
322
+ };
323
+
324
+ export { OwnershipCard };
325
+ //# sourceMappingURL=OwnershipCard-9f8835e6.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OwnershipCard-9f8835e6.esm.js","sources":["../../src/components/Cards/OwnershipCard/useGetEntities.ts","../../src/components/Cards/OwnershipCard/ComponentsGrid.tsx","../../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 {\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/lib/useAsync';\nimport qs from 'qs';\nimport { EntityRelationAggregation as EntityRelationsAggregation } 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: EntityRelationsAggregation,\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: EntityRelationsAggregation,\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","/*\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 {\n Box,\n createStyles,\n Grid,\n makeStyles,\n Typography,\n} from '@material-ui/core';\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 return (\n <Link to={url} variant=\"body2\">\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 </Link>\n );\n};\n\nexport const ComponentsGrid = ({\n entity,\n relationsType,\n entityFilterKind,\n entityLimit = 6,\n}: {\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>\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()}/?${c.queryParams}`}\n />\n </Grid>\n ))}\n </Grid>\n );\n};\n","/*\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 {\n List,\n ListItem,\n ListItemSecondaryAction,\n ListItemText,\n makeStyles,\n Switch,\n Tooltip,\n} from '@material-ui/core';\nimport React, { useEffect, useState } from 'react';\nimport { ComponentsGrid } from './ComponentsGrid';\nimport { EntityRelationAggregation } from './types';\n\nconst useStyles = makeStyles(theme => ({\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}));\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 title=\"Ownership\" variant={variant}>\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 entity={entity}\n entityLimit={entityLimit}\n relationsType={getRelationsType}\n entityFilterKind={entityFilterKind}\n />\n </InfoCard>\n );\n};\n"],"names":["_a","useStyles"],"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,KAAA;AAAA,GACR,CAAA;AACA,EAAO,OAAA,EAAA,CAAG,UAAU,EA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AA,GAAW,YAAe,GAAA,QAAA,CAAA;AACjD,YAAA,gBAAA,CAAiB,oBAAoB,CAAA,CAAA;AAAA,WACvC;AAAA,UACA,IAAK,EAAA,KAAA;AAAA,UACL,UAAA,EAAY,EAAE,YAAA,EAAc,uBAAwB,EAAA;AAAA,SAAA;AAAA,OACtD;AAAA,KACF;AAAA,IAAU,sBAAA;AAAA,GAGd,CACF,CAEF,kBAAA,KAAA,CAAA,aAAA;AAAA,IAAC,cAAA;AAAA,IAAA;AAAA,MACC,MAAA;AAAA,MACA,WAAA;AAAA,MACA,aAAe,EAAA,gBAAA;AAAA,MACf,gBAAA;AAAA,KAAA;AAAA,GAEJ,CAAA,CAAA;AAEJ;;;;"}
@@ -0,0 +1,60 @@
1
+ import { ANNOTATION_EDIT_URL, RELATION_MEMBER_OF } from '@backstage/catalog-model';
2
+ import { InfoCard, Link, Avatar } from '@backstage/core-components';
3
+ import { IconButton, Grid, List, ListItem, ListItemIcon, Tooltip, ListItemText, Box } from '@material-ui/core';
4
+ import { useEntity, getEntityRelations, EntityRefLinks } from '@backstage/plugin-catalog-react';
5
+ import Alert from '@material-ui/lab/Alert';
6
+ import EditIcon from '@material-ui/icons/Edit';
7
+ import EmailIcon from '@material-ui/icons/Email';
8
+ import GroupIcon from '@material-ui/icons/Group';
9
+ import { L as LinksGroup } from './LinksGroup-9fefd100.esm.js';
10
+ import PersonIcon from '@material-ui/icons/Person';
11
+ import React from 'react';
12
+ import '@backstage/core-plugin-api';
13
+ import '@material-ui/icons/Language';
14
+
15
+ 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;
16
+ const UserProfileCard = (props) => {
17
+ var _a, _b;
18
+ const { entity: user } = useEntity();
19
+ if (!user) {
20
+ return /* @__PURE__ */ React.createElement(Alert, { severity: "error" }, "User not found");
21
+ }
22
+ const entityMetadataEditUrl = (_a = user.metadata.annotations) == null ? void 0 : _a[ANNOTATION_EDIT_URL];
23
+ const {
24
+ metadata: { name: metaName, description, links },
25
+ spec: { profile }
26
+ } = user;
27
+ const displayName = (_b = profile == null ? void 0 : profile.displayName) != null ? _b : metaName;
28
+ const emailHref = (profile == null ? void 0 : profile.email) ? `mailto:${profile.email}` : void 0;
29
+ const memberOfRelations = getEntityRelations(user, RELATION_MEMBER_OF, {
30
+ kind: "Group"
31
+ });
32
+ return /* @__PURE__ */ React.createElement(
33
+ InfoCard,
34
+ {
35
+ title: /* @__PURE__ */ React.createElement(CardTitle, { title: displayName }),
36
+ subheader: description,
37
+ variant: props.variant,
38
+ action: /* @__PURE__ */ React.createElement(React.Fragment, null, entityMetadataEditUrl && /* @__PURE__ */ React.createElement(
39
+ IconButton,
40
+ {
41
+ "aria-label": "Edit",
42
+ title: "Edit Metadata",
43
+ component: Link,
44
+ to: entityMetadataEditUrl
45
+ },
46
+ /* @__PURE__ */ React.createElement(EditIcon, null)
47
+ ))
48
+ },
49
+ /* @__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 == null ? void 0 : profile.picture })), /* @__PURE__ */ React.createElement(Grid, { item: true, md: 10, xl: 11 }, /* @__PURE__ */ React.createElement(List, null, (profile == null ? void 0 : 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 != null ? 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(
50
+ EntityRefLinks,
51
+ {
52
+ entityRefs: memberOfRelations,
53
+ defaultKind: "Group"
54
+ }
55
+ ))), (props == null ? void 0 : props.showLinks) && /* @__PURE__ */ React.createElement(LinksGroup, { links }))))
56
+ );
57
+ };
58
+
59
+ export { UserProfileCard };
60
+ //# sourceMappingURL=UserProfileCard-d467b6e5.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"UserProfileCard-d467b6e5.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 {\n Box,\n Grid,\n IconButton,\n List,\n ListItem,\n ListItemIcon,\n ListItemText,\n Tooltip,\n} from '@material-ui/core';\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":";;;;;;;;;;;;;;AAmDA,MAAM,SAAA,GAA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GAAA,OAAA,CAAA,KAAA,qBACP,KAAA,CAAA,aAAA,CAAA,QAAA,EAAA,IAAA,sCACE,YACC,EAAA,IAAA,kBAAA,KAAA,CAAA,aAAA,CAAC,OAAQ,EAAA,EAAA,KAAA,EAAM,2BACZ,KAAA,CAAA,aAAA,CAAA,SAAA,EAAA,IAAU,CACb,CACF,mBACC,KAAA,CAAA,aAAA,CAAA,YAAA,EAAA,IAAA,kBACE,KAAA,CAAA,aAAA,CAAA,IAAA,EAAA,EAAK,IAAI,SAAa,IAAA,IAAA,GAAA,SAAA,GAAA,EAAA,EAAA,EAAK,OAAQ,CAAA,KAAM,CAC5C,CACF,CAAA,kBAGD,KAAA,CAAA,aAAA,CAAA,QAAA,EAAA,IAAA,sCACE,YACC,EAAA,IAAA,kBAAA,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,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;;;;"}
@@ -1,5 +1,8 @@
1
- export { GroupProfileCard, MembersListCard, MyGroupsSidebarItem, OwnershipCard, UserProfileCard } from '../index.esm.js';
2
- import '@backstage/core-plugin-api';
1
+ export { MembersListCard } from './MembersListCard-cb148b44.esm.js';
2
+ export { GroupProfileCard } from './GroupProfileCard-d9207fd9.esm.js';
3
+ export { UserProfileCard } from './UserProfileCard-d467b6e5.esm.js';
4
+ export { OwnershipCard } from './OwnershipCard-9f8835e6.esm.js';
5
+ export { MyGroupsSidebarItem } from '../index.esm.js';
3
6
  import '@backstage/catalog-model';
4
7
  import '@backstage/plugin-catalog-react';
5
8
  import '@material-ui/core';
@@ -7,18 +10,21 @@ import '@material-ui/lab/Pagination';
7
10
  import 'react';
8
11
  import 'react-use/lib/useAsync';
9
12
  import '@backstage/core-components';
13
+ import '@backstage/core-plugin-api';
10
14
  import '@material-ui/icons/AccountTree';
11
15
  import '@material-ui/lab/Alert';
12
16
  import '@material-ui/icons/Cached';
13
17
  import '@material-ui/icons/Edit';
14
18
  import '@material-ui/icons/Email';
15
19
  import '@material-ui/icons/Group';
20
+ import './LinksGroup-9fefd100.esm.js';
16
21
  import '@material-ui/icons/Language';
17
22
  import '@backstage/plugin-catalog-react/alpha';
18
23
  import '@backstage/plugin-catalog-common/alpha';
19
24
  import '@material-ui/icons/Person';
20
25
  import 'pluralize';
26
+ import './routes-e3daad75.esm.js';
21
27
  import 'p-limit';
22
28
  import 'qs';
23
29
  import 'lodash';
24
- //# sourceMappingURL=index-9172d7e6.esm.js.map
30
+ //# sourceMappingURL=index-ad2d9b29.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-ad2d9b29.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -0,0 +1,8 @@
1
+ import { createExternalRouteRef } from '@backstage/core-plugin-api';
2
+
3
+ const catalogIndexRouteRef = createExternalRouteRef({
4
+ id: "catalog-index"
5
+ });
6
+
7
+ export { catalogIndexRouteRef as c };
8
+ //# sourceMappingURL=routes-e3daad75.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"routes-e3daad75.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;;;;"}