@backstage/plugin-catalog-react 1.1.4-next.1 → 1.1.4

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,5 +1,43 @@
1
1
  # @backstage/plugin-catalog-react
2
2
 
3
+ ## 1.1.4
4
+
5
+ ### Patch Changes
6
+
7
+ - 817f3196f6: Updated React Router dependencies to be peer dependencies.
8
+ - f6033d1121: humanizeEntityRef function can now be forced to include default namespace
9
+ - c86741a052: Support showing counts in option labels of the `EntityTagPicker`. You can enable this by adding the `showCounts` property
10
+ - 7d47def9c4: Removed dependency on `@types/jest`.
11
+ - a6d551fad9: Properly handle free-text entity filtering in the case of empty tag arrays
12
+ - ef9ab322de: Minor API signatures cleanup
13
+ - Updated dependencies
14
+ - @backstage/core-components@0.11.1
15
+ - @backstage/core-plugin-api@1.0.6
16
+ - @backstage/plugin-permission-react@0.4.5
17
+ - @backstage/integration@1.3.1
18
+ - @backstage/catalog-client@1.1.0
19
+ - @backstage/catalog-model@1.1.1
20
+ - @backstage/errors@1.1.1
21
+ - @backstage/plugin-permission-common@0.6.4
22
+ - @backstage/plugin-catalog-common@1.0.6
23
+
24
+ ## 1.1.4-next.2
25
+
26
+ ### Patch Changes
27
+
28
+ - f6033d1121: humanizeEntityRef function can now be forced to include default namespace
29
+ - c86741a052: Support showing counts in option labels of the `EntityTagPicker`. You can enable this by adding the `showCounts` property
30
+ - 7d47def9c4: Removed dependency on `@types/jest`.
31
+ - Updated dependencies
32
+ - @backstage/catalog-client@1.1.0-next.2
33
+ - @backstage/catalog-model@1.1.1-next.0
34
+ - @backstage/core-components@0.11.1-next.3
35
+ - @backstage/core-plugin-api@1.0.6-next.3
36
+ - @backstage/errors@1.1.1-next.0
37
+ - @backstage/integration@1.3.1-next.2
38
+ - @backstage/plugin-permission-common@0.6.4-next.2
39
+ - @backstage/plugin-permission-react@0.4.5-next.2
40
+
3
41
  ## 1.1.4-next.1
4
42
 
5
43
  ### Patch Changes
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backstage/plugin-catalog-react",
3
- "version": "1.1.4-next.1",
3
+ "version": "1.1.4",
4
4
  "main": "../dist/index.esm.js",
5
5
  "types": "../dist/index.alpha.d.ts"
6
6
  }
@@ -431,7 +431,12 @@ export declare class EntityTagFilter implements EntityFilter {
431
431
  }
432
432
 
433
433
  /** @public */
434
- export declare const EntityTagPicker: () => JSX.Element | null;
434
+ export declare const EntityTagPicker: (props: EntityTagPickerProps) => JSX.Element | null;
435
+
436
+ /** @public */
437
+ export declare type EntityTagPickerProps = {
438
+ showCounts?: boolean;
439
+ };
435
440
 
436
441
  /**
437
442
  * Filters entities where the text matches spec, title or tags.
@@ -493,9 +498,14 @@ export declare function getEntityRelations(entity: Entity | undefined, relationT
493
498
  /** @public */
494
499
  export declare function getEntitySourceLocation(entity: Entity, scmIntegrationsApi: ScmIntegrationRegistry): EntitySourceLocation | undefined;
495
500
 
496
- /** @public */
501
+ /**
502
+ * @param defaultNamespace - if set to false then namespace is never omitted,
503
+ * if set to string which matches namespace of entity then omitted
504
+ *
505
+ * @public */
497
506
  export declare function humanizeEntityRef(entityRef: Entity | CompoundEntityRef, opts?: {
498
507
  defaultKind?: string;
508
+ defaultNamespace?: string | false;
499
509
  }): string;
500
510
 
501
511
  /**
@@ -431,7 +431,12 @@ export declare class EntityTagFilter implements EntityFilter {
431
431
  }
432
432
 
433
433
  /** @public */
434
- export declare const EntityTagPicker: () => JSX.Element | null;
434
+ export declare const EntityTagPicker: (props: EntityTagPickerProps) => JSX.Element | null;
435
+
436
+ /** @public */
437
+ export declare type EntityTagPickerProps = {
438
+ showCounts?: boolean;
439
+ };
435
440
 
436
441
  /**
437
442
  * Filters entities where the text matches spec, title or tags.
@@ -493,9 +498,14 @@ export declare function getEntityRelations(entity: Entity | undefined, relationT
493
498
  /** @public */
494
499
  export declare function getEntitySourceLocation(entity: Entity, scmIntegrationsApi: ScmIntegrationRegistry): EntitySourceLocation | undefined;
495
500
 
496
- /** @public */
501
+ /**
502
+ * @param defaultNamespace - if set to false then namespace is never omitted,
503
+ * if set to string which matches namespace of entity then omitted
504
+ *
505
+ * @public */
497
506
  export declare function humanizeEntityRef(entityRef: Entity | CompoundEntityRef, opts?: {
498
507
  defaultKind?: string;
508
+ defaultNamespace?: string | false;
499
509
  }): string;
500
510
 
501
511
  /**
package/dist/index.d.ts CHANGED
@@ -431,7 +431,12 @@ export declare class EntityTagFilter implements EntityFilter {
431
431
  }
432
432
 
433
433
  /** @public */
434
- export declare const EntityTagPicker: () => JSX.Element | null;
434
+ export declare const EntityTagPicker: (props: EntityTagPickerProps) => JSX.Element | null;
435
+
436
+ /** @public */
437
+ export declare type EntityTagPickerProps = {
438
+ showCounts?: boolean;
439
+ };
435
440
 
436
441
  /**
437
442
  * Filters entities where the text matches spec, title or tags.
@@ -493,9 +498,14 @@ export declare function getEntityRelations(entity: Entity | undefined, relationT
493
498
  /** @public */
494
499
  export declare function getEntitySourceLocation(entity: Entity, scmIntegrationsApi: ScmIntegrationRegistry): EntitySourceLocation | undefined;
495
500
 
496
- /** @public */
501
+ /**
502
+ * @param defaultNamespace - if set to false then namespace is never omitted,
503
+ * if set to string which matches namespace of entity then omitted
504
+ *
505
+ * @public */
497
506
  export declare function humanizeEntityRef(entityRef: Entity | CompoundEntityRef, opts?: {
498
507
  defaultKind?: string;
508
+ defaultNamespace?: string | false;
499
509
  }): string;
500
510
 
501
511
  /**
package/dist/index.esm.js CHANGED
@@ -371,7 +371,14 @@ function humanizeEntityRef(entityRef, opts) {
371
371
  namespace = entityRef.namespace;
372
372
  name = entityRef.name;
373
373
  }
374
- if (namespace === DEFAULT_NAMESPACE) {
374
+ if (namespace === void 0 || namespace === "") {
375
+ namespace = DEFAULT_NAMESPACE;
376
+ }
377
+ if ((opts == null ? void 0 : opts.defaultNamespace) !== void 0) {
378
+ if ((opts == null ? void 0 : opts.defaultNamespace) === namespace) {
379
+ namespace = void 0;
380
+ }
381
+ } else if (namespace === DEFAULT_NAMESPACE) {
375
382
  namespace = void 0;
376
383
  }
377
384
  kind = kind.toLocaleLowerCase("en-US");
@@ -1201,7 +1208,7 @@ const icon$1 = /* @__PURE__ */ React.createElement(CheckBoxOutlineBlankIcon, {
1201
1208
  const checkedIcon$1 = /* @__PURE__ */ React.createElement(CheckBoxIcon, {
1202
1209
  fontSize: "small"
1203
1210
  });
1204
- const EntityTagPicker = () => {
1211
+ const EntityTagPicker = (props) => {
1205
1212
  var _a, _b;
1206
1213
  const classes = useStyles$8();
1207
1214
  const {
@@ -1217,7 +1224,9 @@ const EntityTagPicker = () => {
1217
1224
  facets: [facet],
1218
1225
  filter: (_a2 = filters.kind) == null ? void 0 : _a2.getCatalogFilters()
1219
1226
  });
1220
- return facets[facet].map(({ value }) => value);
1227
+ return Object.fromEntries(
1228
+ facets[facet].map(({ value, count }) => [value, count])
1229
+ );
1221
1230
  }, [filters.kind]);
1222
1231
  const queryParamTags = useMemo(
1223
1232
  () => [tagsParameter].flat().filter(Boolean),
@@ -1236,7 +1245,7 @@ const EntityTagPicker = () => {
1236
1245
  tags: selectedTags.length ? new EntityTagFilter(selectedTags) : void 0
1237
1246
  });
1238
1247
  }, [selectedTags, updateFilters]);
1239
- if (!(availableTags == null ? void 0 : availableTags.length))
1248
+ if (!Object.keys(availableTags != null ? availableTags : {}).length)
1240
1249
  return null;
1241
1250
  return /* @__PURE__ */ React.createElement(Box, {
1242
1251
  pb: 1,
@@ -1246,7 +1255,7 @@ const EntityTagPicker = () => {
1246
1255
  component: "label"
1247
1256
  }, "Tags", /* @__PURE__ */ React.createElement(Autocomplete, {
1248
1257
  multiple: true,
1249
- options: availableTags,
1258
+ options: Object.keys(availableTags != null ? availableTags : {}),
1250
1259
  value: selectedTags,
1251
1260
  onChange: (_, value) => setSelectedTags(value),
1252
1261
  renderOption: (option, { selected }) => /* @__PURE__ */ React.createElement(FormControlLabel, {
@@ -1255,7 +1264,7 @@ const EntityTagPicker = () => {
1255
1264
  checkedIcon: checkedIcon$1,
1256
1265
  checked: selected
1257
1266
  }),
1258
- label: option
1267
+ label: props.showCounts ? `${option} (${availableTags == null ? void 0 : availableTags[option]})` : option
1259
1268
  }),
1260
1269
  size: "small",
1261
1270
  popupIcon: /* @__PURE__ */ React.createElement(ExpandMoreIcon, {