@backstage/plugin-catalog-react 0.0.0-nightly-20230105022800 → 0.0.0-nightly-20230107022546

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 CHANGED
@@ -1,23 +1,24 @@
1
1
  # @backstage/plugin-catalog-react
2
2
 
3
- ## 0.0.0-nightly-20230105022800
3
+ ## 0.0.0-nightly-20230107022546
4
4
 
5
5
  ### Patch Changes
6
6
 
7
7
  - 37426f6f5e: Fixed bug in `EntityTagPicker` that filtered on unavailable tags for the selected kind.
8
+ - 516b2039b6: Add a reusable pop over `EntityPeekAheadPopover` component. It shows more details about the associated entity. See the playbook here https://backstage.io/storybook/?path=/story/catalog-entitypeekaheadpopover--default
8
9
  - Updated dependencies
9
- - @backstage/catalog-model@0.0.0-nightly-20230105022800
10
- - @backstage/catalog-client@0.0.0-nightly-20230105022800
11
- - @backstage/core-components@0.0.0-nightly-20230105022800
12
- - @backstage/core-plugin-api@0.0.0-nightly-20230105022800
10
+ - @backstage/catalog-model@0.0.0-nightly-20230107022546
11
+ - @backstage/catalog-client@0.0.0-nightly-20230107022546
12
+ - @backstage/core-components@0.0.0-nightly-20230107022546
13
+ - @backstage/plugin-permission-react@0.0.0-nightly-20230107022546
14
+ - @backstage/core-plugin-api@0.0.0-nightly-20230107022546
13
15
  - @backstage/errors@1.1.4
14
- - @backstage/integration@0.0.0-nightly-20230105022800
16
+ - @backstage/integration@0.0.0-nightly-20230107022546
15
17
  - @backstage/theme@0.2.16
16
18
  - @backstage/types@1.0.2
17
19
  - @backstage/version-bridge@1.0.3
18
- - @backstage/plugin-catalog-common@0.0.0-nightly-20230105022800
19
- - @backstage/plugin-permission-common@0.0.0-nightly-20230105022800
20
- - @backstage/plugin-permission-react@0.0.0-nightly-20230105022800
20
+ - @backstage/plugin-catalog-common@0.0.0-nightly-20230107022546
21
+ - @backstage/plugin-permission-common@0.0.0-nightly-20230107022546
21
22
 
22
23
  ## 1.2.4-next.1
23
24
 
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backstage/plugin-catalog-react",
3
- "version": "0.0.0-nightly-20230105022800",
3
+ "version": "0.0.0-nightly-20230107022546",
4
4
  "main": "../dist/index.esm.js",
5
5
  "types": "../dist/index.alpha.d.ts"
6
6
  }
@@ -286,6 +286,23 @@ export declare class EntityOwnerFilter implements EntityFilter {
286
286
  /** @public */
287
287
  export declare const EntityOwnerPicker: () => JSX.Element | null;
288
288
 
289
+ /**
290
+ * Shows an entity popover on hover of a component.
291
+ *
292
+ * @public
293
+ */
294
+ export declare const EntityPeekAheadPopover: (props: EntityPeekAheadPopoverProps) => JSX.Element;
295
+
296
+ /**
297
+ * Properties for an entity popover on hover of a component.
298
+ *
299
+ * @public
300
+ */
301
+ export declare type EntityPeekAheadPopoverProps = PropsWithChildren<{
302
+ entityRef: string;
303
+ delayTime?: number;
304
+ }>;
305
+
289
306
  /** @public */
290
307
  export declare const EntityProcessingStatusPicker: () => JSX.Element;
291
308
 
@@ -286,6 +286,23 @@ export declare class EntityOwnerFilter implements EntityFilter {
286
286
  /** @public */
287
287
  export declare const EntityOwnerPicker: () => JSX.Element | null;
288
288
 
289
+ /**
290
+ * Shows an entity popover on hover of a component.
291
+ *
292
+ * @public
293
+ */
294
+ export declare const EntityPeekAheadPopover: (props: EntityPeekAheadPopoverProps) => JSX.Element;
295
+
296
+ /**
297
+ * Properties for an entity popover on hover of a component.
298
+ *
299
+ * @public
300
+ */
301
+ export declare type EntityPeekAheadPopoverProps = PropsWithChildren<{
302
+ entityRef: string;
303
+ delayTime?: number;
304
+ }>;
305
+
289
306
  /** @public */
290
307
  export declare const EntityProcessingStatusPicker: () => JSX.Element;
291
308
 
package/dist/index.d.ts CHANGED
@@ -286,6 +286,23 @@ export declare class EntityOwnerFilter implements EntityFilter {
286
286
  /** @public */
287
287
  export declare const EntityOwnerPicker: () => JSX.Element | null;
288
288
 
289
+ /**
290
+ * Shows an entity popover on hover of a component.
291
+ *
292
+ * @public
293
+ */
294
+ export declare const EntityPeekAheadPopover: (props: EntityPeekAheadPopoverProps) => JSX.Element;
295
+
296
+ /**
297
+ * Properties for an entity popover on hover of a component.
298
+ *
299
+ * @public
300
+ */
301
+ export declare type EntityPeekAheadPopoverProps = PropsWithChildren<{
302
+ entityRef: string;
303
+ delayTime?: number;
304
+ }>;
305
+
289
306
  /** @public */
290
307
  export declare const EntityProcessingStatusPicker: () => JSX.Element;
291
308
 
package/dist/index.esm.js CHANGED
@@ -1,14 +1,14 @@
1
1
  export { CATALOG_FILTER_EXISTS } from '@backstage/catalog-client';
2
- import { createApiRef, createRouteRef, useRouteRef, useApi, AnalyticsContext, identityApiRef, alertApiRef, useApp, configApiRef } from '@backstage/core-plugin-api';
2
+ import { createApiRef, createRouteRef, useRouteRef, useApi, AnalyticsContext, identityApiRef, alertApiRef, useApiHolder, useApp, configApiRef } from '@backstage/core-plugin-api';
3
3
  import ObservableImpl from 'zen-observable';
4
4
  import React, { useState, forwardRef, createContext, useMemo, useCallback, useContext, useEffect, useRef, useLayoutEffect, Fragment } from 'react';
5
- import { Grid, useMediaQuery, useTheme, Button, Drawer, Box, Typography, Tooltip, makeStyles, FormControlLabel, Checkbox, TextField, Toolbar, FormControl, Input, InputAdornment, IconButton, withStyles, DialogContentText, ListItemText as ListItemText$1, ListSubheader as ListSubheader$1, Card, CardContent, ListItem, ListItemIcon, List, Dialog, DialogTitle, DialogContent, Tabs, Tab, DialogActions, Divider, MenuItem, ListItemSecondaryAction } from '@material-ui/core';
5
+ import { Grid, useMediaQuery, useTheme, Button, Drawer, Box, Typography, Tooltip, makeStyles, FormControlLabel, Checkbox, TextField, IconButton, Card, CardContent, Chip, CardActions, Toolbar, FormControl, Input, InputAdornment, withStyles, DialogContentText, ListItemText as ListItemText$1, ListSubheader as ListSubheader$1, ListItem, ListItemIcon, List, Dialog, DialogTitle, DialogContent, Tabs, Tab, DialogActions, Divider, MenuItem, ListItemSecondaryAction } from '@material-ui/core';
6
6
  import FilterListIcon from '@material-ui/icons/FilterList';
7
- import { Link, Progress, ErrorPanel, Select, OverflowTooltip, Table, ResponseErrorPanel, DependencyGraph, DependencyGraphTypes, CodeSnippet } from '@backstage/core-components';
8
- import { DEFAULT_NAMESPACE, parseEntityRef, ANNOTATION_SOURCE_LOCATION, parseLocationRef, RELATION_MEMBER_OF, getCompoundEntityRef, stringifyEntityRef, RELATION_OWNED_BY, RELATION_PART_OF, ANNOTATION_LOCATION, ANNOTATION_ORIGIN_LOCATION } from '@backstage/catalog-model';
7
+ import { Link, Progress, ErrorPanel, Select, ResponseErrorPanel, OverflowTooltip, Table, DependencyGraph, DependencyGraphTypes, CodeSnippet } from '@backstage/core-components';
8
+ import { DEFAULT_NAMESPACE, parseEntityRef, ANNOTATION_SOURCE_LOCATION, parseLocationRef, RELATION_MEMBER_OF, getCompoundEntityRef, stringifyEntityRef, RELATION_OWNED_BY, isUserEntity, isGroupEntity, RELATION_PART_OF, ANNOTATION_LOCATION, ANNOTATION_ORIGIN_LOCATION } from '@backstage/catalog-model';
9
9
  import { getOrCreateGlobalSingleton, createVersionedContext, createVersionedValueMap, useVersionedContext } from '@backstage/version-bridge';
10
10
  import useAsync from 'react-use/lib/useAsync';
11
- import { compact, isEqual, groupBy, chunk } from 'lodash';
11
+ import { compact, isEqual, groupBy, chunk, debounce } from 'lodash';
12
12
  import qs from 'qs';
13
13
  import { useLocation, useNavigate } from 'react-router-dom';
14
14
  import useAsyncFn from 'react-use/lib/useAsyncFn';
@@ -22,6 +22,10 @@ import CheckBoxIcon from '@material-ui/icons/CheckBox';
22
22
  import CheckBoxOutlineBlankIcon from '@material-ui/icons/CheckBoxOutlineBlank';
23
23
  import ExpandMoreIcon from '@material-ui/icons/ExpandMore';
24
24
  import { Autocomplete, Alert } from '@material-ui/lab';
25
+ import HoverPopover from 'material-ui-popup-state/HoverPopover';
26
+ import { usePopupState, bindHover, bindPopover } from 'material-ui-popup-state/hooks';
27
+ import InfoIcon from '@material-ui/icons/Info';
28
+ import EmailIcon from '@material-ui/icons/Email';
25
29
  import Clear from '@material-ui/icons/Clear';
26
30
  import Search from '@material-ui/icons/Search';
27
31
  import Star from '@material-ui/icons/Star';
@@ -960,7 +964,7 @@ const EntityKindPicker = (props) => {
960
964
  ));
961
965
  };
962
966
 
963
- const useStyles$c = makeStyles(
967
+ const useStyles$d = makeStyles(
964
968
  {
965
969
  input: {}
966
970
  },
@@ -972,7 +976,7 @@ const icon$3 = /* @__PURE__ */ React.createElement(CheckBoxOutlineBlankIcon, { f
972
976
  const checkedIcon$3 = /* @__PURE__ */ React.createElement(CheckBoxIcon, { fontSize: "small" });
973
977
  const EntityLifecyclePicker = () => {
974
978
  var _a, _b;
975
- const classes = useStyles$c();
979
+ const classes = useStyles$d();
976
980
  const {
977
981
  updateFilters,
978
982
  backendEntities,
@@ -1044,7 +1048,7 @@ const EntityLifecyclePicker = () => {
1044
1048
  )));
1045
1049
  };
1046
1050
 
1047
- const useStyles$b = makeStyles(
1051
+ const useStyles$c = makeStyles(
1048
1052
  {
1049
1053
  input: {}
1050
1054
  },
@@ -1056,7 +1060,7 @@ const icon$2 = /* @__PURE__ */ React.createElement(CheckBoxOutlineBlankIcon, { f
1056
1060
  const checkedIcon$2 = /* @__PURE__ */ React.createElement(CheckBoxIcon, { fontSize: "small" });
1057
1061
  const EntityOwnerPicker = () => {
1058
1062
  var _a, _b;
1059
- const classes = useStyles$b();
1063
+ const classes = useStyles$c();
1060
1064
  const {
1061
1065
  updateFilters,
1062
1066
  backendEntities,
@@ -1129,6 +1133,133 @@ const EntityOwnerPicker = () => {
1129
1133
  )));
1130
1134
  };
1131
1135
 
1136
+ const EntityCardActions = ({ entity }) => {
1137
+ const entityRoute = useRouteRef(entityRouteRef);
1138
+ return /* @__PURE__ */ React.createElement(
1139
+ IconButton,
1140
+ {
1141
+ component: Link,
1142
+ "aria-label": "Show",
1143
+ title: "Show details",
1144
+ to: entityRoute({
1145
+ name: entity.metadata.name,
1146
+ namespace: entity.metadata.namespace || "default",
1147
+ kind: entity.kind.toLocaleLowerCase("en-US")
1148
+ })
1149
+ },
1150
+ /* @__PURE__ */ React.createElement(InfoIcon, null)
1151
+ );
1152
+ };
1153
+
1154
+ const EmailCardAction = ({ email }) => {
1155
+ return /* @__PURE__ */ React.createElement(
1156
+ IconButton,
1157
+ {
1158
+ component: Link,
1159
+ "aria-label": "Email",
1160
+ title: `Email ${email}`,
1161
+ to: `mailto:${email}`,
1162
+ target: "_blank"
1163
+ },
1164
+ /* @__PURE__ */ React.createElement(EmailIcon, null)
1165
+ );
1166
+ };
1167
+
1168
+ const GroupCardActions = ({ entity }) => {
1169
+ var _a;
1170
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, ((_a = entity.spec.profile) == null ? void 0 : _a.email) && /* @__PURE__ */ React.createElement(EmailCardAction, { email: entity.spec.profile.email }));
1171
+ };
1172
+
1173
+ const UserCardActions = ({ entity }) => {
1174
+ var _a;
1175
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, ((_a = entity.spec.profile) == null ? void 0 : _a.email) && /* @__PURE__ */ React.createElement(EmailCardAction, { email: entity.spec.profile.email }));
1176
+ };
1177
+
1178
+ const useStyles$b = makeStyles(() => {
1179
+ return {
1180
+ trigger: {
1181
+ display: "inline-block"
1182
+ },
1183
+ popoverPaper: {
1184
+ width: "30em"
1185
+ },
1186
+ descriptionTypography: {
1187
+ overflow: "hidden",
1188
+ textOverflow: "ellipsis",
1189
+ display: "-webkit-box",
1190
+ WebkitLineClamp: 2,
1191
+ WebkitBoxOrient: "vertical"
1192
+ }
1193
+ };
1194
+ });
1195
+ const maxTagChips = 4;
1196
+ const EntityPeekAheadPopover = (props) => {
1197
+ var _a, _b, _c;
1198
+ const { entityRef, children, delayTime = 500 } = props;
1199
+ const classes = useStyles$b();
1200
+ const apiHolder = useApiHolder();
1201
+ const popupState = usePopupState({
1202
+ variant: "popover",
1203
+ popupId: "entity-peek-ahead"
1204
+ });
1205
+ const compoundEntityRef = parseEntityRef(entityRef);
1206
+ const [isHovered, setIsHovered] = useState(false);
1207
+ const debouncedHandleMouseEnter = debounce(
1208
+ () => setIsHovered(true),
1209
+ delayTime
1210
+ );
1211
+ const [{ loading, error, value: entity }, load] = useAsyncFn(async () => {
1212
+ const catalogApi = apiHolder.get(catalogApiRef);
1213
+ if (catalogApi) {
1214
+ const retrievedEntity = await catalogApi.getEntityByRef(
1215
+ compoundEntityRef
1216
+ );
1217
+ if (!retrievedEntity) {
1218
+ throw new Error(`${compoundEntityRef.name} was not found`);
1219
+ }
1220
+ return retrievedEntity;
1221
+ }
1222
+ return void 0;
1223
+ }, [apiHolder, compoundEntityRef]);
1224
+ const handleOnMouseLeave = () => {
1225
+ setIsHovered(false);
1226
+ debouncedHandleMouseEnter.cancel();
1227
+ };
1228
+ useEffect(() => {
1229
+ if (popupState.isOpen && !entity && !error && !loading) {
1230
+ load();
1231
+ }
1232
+ }, [popupState.isOpen, load, entity, error, loading]);
1233
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("span", { onMouseEnter: debouncedHandleMouseEnter }, /* @__PURE__ */ React.createElement("span", { "data-testid": "trigger", ...bindHover(popupState) }, children)), isHovered && /* @__PURE__ */ React.createElement(
1234
+ HoverPopover,
1235
+ {
1236
+ PaperProps: {
1237
+ className: classes.popoverPaper
1238
+ },
1239
+ ...bindPopover(popupState),
1240
+ anchorOrigin: {
1241
+ vertical: "bottom",
1242
+ horizontal: "center"
1243
+ },
1244
+ transformOrigin: {
1245
+ vertical: "top",
1246
+ horizontal: "center"
1247
+ },
1248
+ onMouseLeave: handleOnMouseLeave
1249
+ },
1250
+ /* @__PURE__ */ React.createElement(React.Fragment, null, error && /* @__PURE__ */ React.createElement(ResponseErrorPanel, { error }), /* @__PURE__ */ React.createElement(Card, null, loading && /* @__PURE__ */ React.createElement(Progress, null), /* @__PURE__ */ React.createElement(CardContent, null, entity && /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(Typography, { color: "textSecondary" }, compoundEntityRef.namespace), /* @__PURE__ */ React.createElement(Typography, { variant: "h5", component: "div" }, compoundEntityRef.name), /* @__PURE__ */ React.createElement(Typography, { color: "textSecondary" }, entity.kind), /* @__PURE__ */ React.createElement(
1251
+ Typography,
1252
+ {
1253
+ className: classes.descriptionTypography,
1254
+ paragraph: true
1255
+ },
1256
+ entity.metadata.description
1257
+ ), /* @__PURE__ */ React.createElement(Typography, null, (_a = entity.spec) == null ? void 0 : _a.type), /* @__PURE__ */ React.createElement(Box, { marginTop: "0.5em" }, (entity.metadata.tags || []).slice(0, maxTagChips).map((tag) => {
1258
+ return /* @__PURE__ */ React.createElement(Chip, { key: tag, size: "small", label: tag });
1259
+ }), ((_b = entity.metadata.tags) == null ? void 0 : _b.length) && ((_c = entity.metadata.tags) == null ? void 0 : _c.length) > maxTagChips && /* @__PURE__ */ React.createElement(Tooltip, { title: "Drill into the entity to see all of the tags." }, /* @__PURE__ */ React.createElement(Chip, { key: "other-tags", size: "small", label: "..." }))))), !error && /* @__PURE__ */ React.createElement(CardActions, null, entity && /* @__PURE__ */ React.createElement(React.Fragment, null, isUserEntity(entity) && /* @__PURE__ */ React.createElement(UserCardActions, { entity }), isGroupEntity(entity) && /* @__PURE__ */ React.createElement(GroupCardActions, { entity }), /* @__PURE__ */ React.createElement(EntityCardActions, { entity })))))
1260
+ ));
1261
+ };
1262
+
1132
1263
  const useStyles$a = makeStyles(
1133
1264
  (_theme) => ({
1134
1265
  searchToolbar: {
@@ -2453,5 +2584,5 @@ const MockEntityListContextProvider = ({
2453
2584
  return /* @__PURE__ */ React.createElement(EntityListContext.Provider, { value: resolvedValue }, children);
2454
2585
  };
2455
2586
 
2456
- export { AsyncEntityProvider, CatalogFilterLayout, EntityErrorFilter, EntityKindFilter, EntityKindPicker, EntityLifecycleFilter, EntityLifecyclePicker, EntityListContext, EntityListProvider, EntityOrphanFilter, EntityOwnerFilter, EntityOwnerPicker, EntityProcessingStatusPicker, EntityProvider, EntityRefLink, EntityRefLinks, EntitySearchBar, EntityTable, EntityTagFilter, EntityTagPicker, EntityTextFilter, EntityTypeFilter, EntityTypePicker, FavoriteEntity, InspectEntityDialog, MockEntityListContextProvider, MockStarredEntitiesApi, UnregisterEntityDialog, UserListFilter, UserListPicker, catalogApiRef, columnFactories, entityRouteParams, entityRouteRef, getEntityRelations, getEntitySourceLocation, humanizeEntityRef, isOwnerOf, starredEntitiesApiRef, useAsyncEntity, useEntity, useEntityList, useEntityOwnership, useEntityPermission, useEntityTypeFilter, useRelatedEntities, useStarredEntities, useStarredEntity };
2587
+ export { AsyncEntityProvider, CatalogFilterLayout, EntityErrorFilter, EntityKindFilter, EntityKindPicker, EntityLifecycleFilter, EntityLifecyclePicker, EntityListContext, EntityListProvider, EntityOrphanFilter, EntityOwnerFilter, EntityOwnerPicker, EntityPeekAheadPopover, EntityProcessingStatusPicker, EntityProvider, EntityRefLink, EntityRefLinks, EntitySearchBar, EntityTable, EntityTagFilter, EntityTagPicker, EntityTextFilter, EntityTypeFilter, EntityTypePicker, FavoriteEntity, InspectEntityDialog, MockEntityListContextProvider, MockStarredEntitiesApi, UnregisterEntityDialog, UserListFilter, UserListPicker, catalogApiRef, columnFactories, entityRouteParams, entityRouteRef, getEntityRelations, getEntitySourceLocation, humanizeEntityRef, isOwnerOf, starredEntitiesApiRef, useAsyncEntity, useEntity, useEntityList, useEntityOwnership, useEntityPermission, useEntityTypeFilter, useRelatedEntities, useStarredEntities, useStarredEntity };
2457
2588
  //# sourceMappingURL=index.esm.js.map