@backstage/plugin-catalog-react 1.1.4-next.0 → 1.1.4-next.2

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,33 @@
1
1
  # @backstage/plugin-catalog-react
2
2
 
3
+ ## 1.1.4-next.2
4
+
5
+ ### Patch Changes
6
+
7
+ - f6033d1121: humanizeEntityRef function can now be forced to include default namespace
8
+ - c86741a052: Support showing counts in option labels of the `EntityTagPicker`. You can enable this by adding the `showCounts` property
9
+ - 7d47def9c4: Removed dependency on `@types/jest`.
10
+ - Updated dependencies
11
+ - @backstage/catalog-client@1.1.0-next.2
12
+ - @backstage/catalog-model@1.1.1-next.0
13
+ - @backstage/core-components@0.11.1-next.3
14
+ - @backstage/core-plugin-api@1.0.6-next.3
15
+ - @backstage/errors@1.1.1-next.0
16
+ - @backstage/integration@1.3.1-next.2
17
+ - @backstage/plugin-permission-common@0.6.4-next.2
18
+ - @backstage/plugin-permission-react@0.4.5-next.2
19
+
20
+ ## 1.1.4-next.1
21
+
22
+ ### Patch Changes
23
+
24
+ - 817f3196f6: Updated React Router dependencies to be peer dependencies.
25
+ - a6d551fad9: Properly handle free-text entity filtering in the case of empty tag arrays
26
+ - Updated dependencies
27
+ - @backstage/core-components@0.11.1-next.1
28
+ - @backstage/core-plugin-api@1.0.6-next.1
29
+ - @backstage/plugin-permission-react@0.4.5-next.1
30
+
3
31
  ## 1.1.4-next.0
4
32
 
5
33
  ### Patch Changes
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backstage/plugin-catalog-react",
3
- "version": "1.1.4-next.0",
3
+ "version": "1.1.4-next.2",
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.
@@ -441,6 +446,7 @@ export declare class EntityTextFilter implements EntityFilter {
441
446
  readonly value: string;
442
447
  constructor(value: string);
443
448
  filterEntity(entity: Entity): boolean;
449
+ private toUpperArray;
444
450
  }
445
451
 
446
452
  /**
@@ -492,9 +498,14 @@ export declare function getEntityRelations(entity: Entity | undefined, relationT
492
498
  /** @public */
493
499
  export declare function getEntitySourceLocation(entity: Entity, scmIntegrationsApi: ScmIntegrationRegistry): EntitySourceLocation | undefined;
494
500
 
495
- /** @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 */
496
506
  export declare function humanizeEntityRef(entityRef: Entity | CompoundEntityRef, opts?: {
497
507
  defaultKind?: string;
508
+ defaultNamespace?: string | false;
498
509
  }): string;
499
510
 
500
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.
@@ -441,6 +446,7 @@ export declare class EntityTextFilter implements EntityFilter {
441
446
  readonly value: string;
442
447
  constructor(value: string);
443
448
  filterEntity(entity: Entity): boolean;
449
+ private toUpperArray;
444
450
  }
445
451
 
446
452
  /**
@@ -492,9 +498,14 @@ export declare function getEntityRelations(entity: Entity | undefined, relationT
492
498
  /** @public */
493
499
  export declare function getEntitySourceLocation(entity: Entity, scmIntegrationsApi: ScmIntegrationRegistry): EntitySourceLocation | undefined;
494
500
 
495
- /** @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 */
496
506
  export declare function humanizeEntityRef(entityRef: Entity | CompoundEntityRef, opts?: {
497
507
  defaultKind?: string;
508
+ defaultNamespace?: string | false;
498
509
  }): string;
499
510
 
500
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.
@@ -441,6 +446,7 @@ export declare class EntityTextFilter implements EntityFilter {
441
446
  readonly value: string;
442
447
  constructor(value: string);
443
448
  filterEntity(entity: Entity): boolean;
449
+ private toUpperArray;
444
450
  }
445
451
 
446
452
  /**
@@ -492,9 +498,14 @@ export declare function getEntityRelations(entity: Entity | undefined, relationT
492
498
  /** @public */
493
499
  export declare function getEntitySourceLocation(entity: Entity, scmIntegrationsApi: ScmIntegrationRegistry): EntitySourceLocation | undefined;
494
500
 
495
- /** @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 */
496
506
  export declare function humanizeEntityRef(entityRef: Entity | CompoundEntityRef, opts?: {
497
507
  defaultKind?: string;
508
+ defaultNamespace?: string | false;
498
509
  }): string;
499
510
 
500
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");
@@ -474,9 +481,21 @@ class EntityTextFilter {
474
481
  this.value = value;
475
482
  }
476
483
  filterEntity(entity) {
477
- var _a;
478
- const upperCaseValue = this.value.toLocaleUpperCase("en-US");
479
- return entity.metadata.name.toLocaleUpperCase("en-US").includes(upperCaseValue) || `${entity.metadata.title}`.toLocaleUpperCase("en-US").includes(upperCaseValue) || ((_a = entity.metadata.tags) == null ? void 0 : _a.join("").toLocaleUpperCase("en-US").indexOf(upperCaseValue)) !== -1;
484
+ const words = this.toUpperArray(this.value.split(/\s/));
485
+ const exactMatch = this.toUpperArray([entity.metadata.tags]);
486
+ const partialMatch = this.toUpperArray([
487
+ entity.metadata.name,
488
+ entity.metadata.title
489
+ ]);
490
+ for (const word of words) {
491
+ if (exactMatch.every((m) => m !== word) && partialMatch.every((m) => !m.includes(word))) {
492
+ return false;
493
+ }
494
+ }
495
+ return true;
496
+ }
497
+ toUpperArray(value) {
498
+ return value.flat().filter((m) => Boolean(m)).map((m) => m.toLocaleUpperCase("en-US"));
480
499
  }
481
500
  }
482
501
  class EntityOwnerFilter {
@@ -1189,7 +1208,7 @@ const icon$1 = /* @__PURE__ */ React.createElement(CheckBoxOutlineBlankIcon, {
1189
1208
  const checkedIcon$1 = /* @__PURE__ */ React.createElement(CheckBoxIcon, {
1190
1209
  fontSize: "small"
1191
1210
  });
1192
- const EntityTagPicker = () => {
1211
+ const EntityTagPicker = (props) => {
1193
1212
  var _a, _b;
1194
1213
  const classes = useStyles$8();
1195
1214
  const {
@@ -1205,7 +1224,9 @@ const EntityTagPicker = () => {
1205
1224
  facets: [facet],
1206
1225
  filter: (_a2 = filters.kind) == null ? void 0 : _a2.getCatalogFilters()
1207
1226
  });
1208
- return facets[facet].map(({ value }) => value);
1227
+ return Object.fromEntries(
1228
+ facets[facet].map(({ value, count }) => [value, count])
1229
+ );
1209
1230
  }, [filters.kind]);
1210
1231
  const queryParamTags = useMemo(
1211
1232
  () => [tagsParameter].flat().filter(Boolean),
@@ -1224,7 +1245,7 @@ const EntityTagPicker = () => {
1224
1245
  tags: selectedTags.length ? new EntityTagFilter(selectedTags) : void 0
1225
1246
  });
1226
1247
  }, [selectedTags, updateFilters]);
1227
- if (!(availableTags == null ? void 0 : availableTags.length))
1248
+ if (!Object.keys(availableTags != null ? availableTags : {}).length)
1228
1249
  return null;
1229
1250
  return /* @__PURE__ */ React.createElement(Box, {
1230
1251
  pb: 1,
@@ -1234,7 +1255,7 @@ const EntityTagPicker = () => {
1234
1255
  component: "label"
1235
1256
  }, "Tags", /* @__PURE__ */ React.createElement(Autocomplete, {
1236
1257
  multiple: true,
1237
- options: availableTags,
1258
+ options: Object.keys(availableTags != null ? availableTags : {}),
1238
1259
  value: selectedTags,
1239
1260
  onChange: (_, value) => setSelectedTags(value),
1240
1261
  renderOption: (option, { selected }) => /* @__PURE__ */ React.createElement(FormControlLabel, {
@@ -1243,7 +1264,7 @@ const EntityTagPicker = () => {
1243
1264
  checkedIcon: checkedIcon$1,
1244
1265
  checked: selected
1245
1266
  }),
1246
- label: option
1267
+ label: props.showCounts ? `${option} (${availableTags == null ? void 0 : availableTags[option]})` : option
1247
1268
  }),
1248
1269
  size: "small",
1249
1270
  popupIcon: /* @__PURE__ */ React.createElement(ExpandMoreIcon, {